aboutsummaryrefslogtreecommitdiff
path: root/sys/dev/tpm
diff options
context:
space:
mode:
authorMarcin Wojtas <mw@FreeBSD.org>2019-04-26 01:29:00 +0000
committerMarcin Wojtas <mw@FreeBSD.org>2019-04-26 01:29:00 +0000
commit90305687f89599101693552724ebb3ee0cf48d3c (patch)
tree359ce60d0b788d1543f98c1b7000272231c6d2f9 /sys/dev/tpm
parent32866af6371ccebfe2468efdc9ebe5bf2908f2cf (diff)
Notes
Diffstat (limited to 'sys/dev/tpm')
-rw-r--r--sys/dev/tpm/tpm20.h6
-rw-r--r--sys/dev/tpm/tpm_crb.c23
-rw-r--r--sys/dev/tpm/tpm_tis.c23
3 files changed, 24 insertions, 28 deletions
diff --git a/sys/dev/tpm/tpm20.h b/sys/dev/tpm/tpm20.h
index b478f3d0eb22..619b101d2fee 100644
--- a/sys/dev/tpm/tpm20.h
+++ b/sys/dev/tpm/tpm20.h
@@ -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;
diff --git a/sys/dev/tpm/tpm_crb.c b/sys/dev/tpm/tpm_crb.c
index d824965b3b92..3643c00f4a36 100644
--- a/sys/dev/tpm/tpm_crb.c
+++ b/sys/dev/tpm/tpm_crb.c
@@ -104,26 +104,21 @@ char *tpmcrb_ids[] = {"MSFT0101", NULL};
static int
tpmcrb_acpi_probe(device_t dev)
{
- struct resource *res;
- int rid = 0;
- uint32_t caps;
+ int err = 0;
+ ACPI_TABLE_TPM23 *tbl;
+ ACPI_STATUS status;
if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmcrb_ids) == NULL)
return (ENXIO);
- /* 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
diff --git a/sys/dev/tpm/tpm_tis.c b/sys/dev/tpm/tpm_tis.c
index 9677fc5b9019..a4fa9ee809ad 100644
--- a/sys/dev/tpm/tpm_tis.c
+++ b/sys/dev/tpm/tpm_tis.c
@@ -100,25 +100,20 @@ char *tpmtis_ids[] = {"MSFT0101", NULL};
static int
tpmtis_acpi_probe(device_t dev)
{
- struct resource *res;
- int rid = 0;
- uint32_t caps;
+ int err = 0;
+ ACPI_TABLE_TPM23 *tbl;
+ ACPI_STATUS status;
if (ACPI_ID_PROBE(device_get_parent(dev), dev, tpmtis_ids) == NULL)
return (ENXIO);
-
- /* 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