1
0
mirror of https://git.FreeBSD.org/src.git synced 2025-01-03 12:35:02 +00:00

Use ACPI TPM2 table to probe tpmtis and tpmcrb device.

Differential Revision: https://reviews.freebsd.org/D18937
This commit is contained in:
Takanori Watanabe 2019-01-25 16:16:10 +00:00
parent 77102fd6a2
commit 877fc2e350
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=343438
4 changed files with 38 additions and 31 deletions

View File

@ -93,6 +93,12 @@ __FBSDID("$FreeBSD$");
#define TPM_CDEV_NAME "tpm0"
#define TPM_CDEV_PERM_FLAG 0600
#define TPM2_START_METHOD_ACPI 2
#define TPM2_START_METHOD_TIS 6
#define TPM2_START_METHOD_CRB 7
#define TPM2_START_METHOD_CRB_ACPI 8
struct tpm_sc {
device_t dev;

View File

@ -104,27 +104,20 @@ char *tpmcrb_ids[] = {"MSFT0101", NULL};
static int
tpmcrb_acpi_probe(device_t dev)
{
struct resource *res;
int err, rid = 0;
uint32_t caps;
int err;
ACPI_TABLE_TPM23 *tbl;
ACPI_STATUS status;
err = ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids, NULL);
if (err > 0)
return (err);
/* Check if device is in CRB mode */
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
if (res == NULL)
return (ENXIO);
caps = bus_read_4(res, TPM_CRB_INTF_ID);
bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
if ((caps & TPM_CRB_INTF_ID_TYPE) != TPM_CRB_INTF_ID_TYPE_CRB)
return (ENXIO);
/*Find TPM2 Header*/
status = AcpiGetTable(ACPI_SIG_TPM2, 1, (ACPI_TABLE_HEADER **) &tbl);
if(ACPI_FAILURE(status) ||
tbl->StartMethod != TPM2_START_METHOD_CRB)
err = ENXIO;
device_set_desc(dev, "Trusted Platform Module 2.0, CRB mode");
return (BUS_PROBE_DEFAULT);
return (err);
}
static ACPI_STATUS

View File

@ -100,26 +100,21 @@ char *tpmtis_ids[] = {"MSFT0101", NULL};
static int
tpmtis_acpi_probe(device_t dev)
{
struct resource *res;
int err, rid = 0;
uint32_t caps;
int err;
ACPI_TABLE_TPM23 *tbl;
ACPI_STATUS status;
err = ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids, NULL);
if (err > 0)
return (err);
/* Check if device is in TPM 2.0 TIS mode */
res = bus_alloc_resource_any(dev, SYS_RES_MEMORY, &rid, RF_ACTIVE);
if (res == NULL)
return (ENXIO);
caps = bus_read_4(res, TPM_INTF_CAPS);
bus_release_resource(dev, SYS_RES_MEMORY, rid, res);
if ((caps & TPM_INTF_CAPS_VERSION) != TPM_INTF_CAPS_TPM20)
return (ENXIO);
/*Find TPM2 Header*/
status = AcpiGetTable(ACPI_SIG_TPM2, 1, (ACPI_TABLE_HEADER **) &tbl);
if(ACPI_FAILURE(status) ||
tbl->StartMethod != TPM2_START_METHOD_TIS)
err = ENXIO;
device_set_desc(dev, "Trusted Platform Module 2.0, FIFO mode");
return (BUS_PROBE_DEFAULT);
return (err);
}
static int

View File

@ -970,7 +970,18 @@ acpi_handle_tcpa(ACPI_TABLE_HEADER *sdp)
printf(END_COMMENT);
}
static void acpi_handle_tpm2(ACPI_TABLE_HEADER *sdp)
{
ACPI_TABLE_TPM2 *tpm2;
printf (BEGIN_COMMENT);
acpi_print_sdt(sdp);
tpm2 = (ACPI_TABLE_TPM2 *) sdp;
printf ("\t\tControlArea=%lx\n", tpm2->ControlAddress);
printf ("\t\tStartMethod=%x\n", tpm2->StartMethod);
printf (END_COMMENT);
}
static const char *
devscope_type2str(int type)
{
@ -1769,6 +1780,8 @@ acpi_handle_rsdt(ACPI_TABLE_HEADER *rsdp)
acpi_handle_wddt(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_LPIT, 4))
acpi_handle_lpit(sdp);
else if (!memcmp(sdp->Signature, ACPI_SIG_TPM2, 4))
acpi_handle_tpm2(sdp);
else {
printf(BEGIN_COMMENT);
acpi_print_sdt(sdp);