Skip to contentSkip to conversation

Add support for TCG ACPI table 'TCPA'

PATCH New Stefan Berger 1 participant 1 message Nov 16, 2006

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 Add support for TCG ACPI table 'TCPA'

This patch add support for a TCG ACPI table called 'TCPA' to the existing ACPI tables. The size of the logging table is set to 10kb for now - it should be 64kb.
The ACPI table is generated if the probing for the TIS interface succeeds.
I cleaned up the ACPI signatures in acpi2_0.h to be more readable.

The specification for the layout of these ACPI tables can be found here:

https://www.trustedcomputinggroup.org/groups/server/TCG_ACPIGeneralSpecification_1-00_1-00_FINAL.pdf

Extensions to the Bochs BIOS that use these ACPI extensions will follow.

xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c +92 -31
Index: root/xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c
===================================================================
@@ -26,6 +26,8 @@
 
 static int acpi_rsdt_add_entry_pointer(unsigned char *acpi_start,
                                        unsigned char *entry);
+static int acpi_xsdt_add_entry_pointer(unsigned char *acpi_start,
+                                       unsigned char *entry);
 static unsigned char *acpi_xsdt_add_entry(unsigned char *acpi_start,
                                           unsigned char **freemem,
                                           unsigned char *limit,
@@ -52,27 +54,60 @@ static int acpi_tpm_tis_probe(unsigned c
                               unsigned char **freemem,
                               unsigned char *limit)
 {
-	int success = 1; /* not successful means 'out of memory' */
-	unsigned char *addr;
-	/* check TPM_DID, TPM_VID, TPM_RID in ioemu/hw/tpm_tis.c */
-	uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
-
-	/* probe for TIS interface ... */
-	if (memcmp((char *)(0xFED40000 + 0xF00),
-	           tis_did_vid_rid,
-	           sizeof(tis_did_vid_rid)) == 0) {
-		puts("TIS is available\n");
-		addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
-		                           AmlCode_TPM, sizeof(AmlCode_TPM));
-		if (addr == NULL)
-			success = 0;
-		else {
-			/* legacy systems need an RSDT entry */
-			acpi_rsdt_add_entry_pointer(acpi_start,
-			                            addr);
-		}
-	}
-	return success;
+    int success = 1; /* not successful means 'out of memory' */
+    unsigned char *addr;
+    /* check TPM_DID, TPM_VID, TPM_RID in ioemu/hw/tpm_tis.c */
+    uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
+    static const ACPI_2_0_TCPA_CLIENT Tcpa = {
+        {
+            ACPI_2_0_TCPA_SIGNATURE,
+            sizeof (ACPI_2_0_TCPA_CLIENT),
+            ACPI_2_0_TCPA_REVISION,
+            0,
+            {'I', 'B', 'M', ' ', ' ', ' '},
+            ASCII64(' ', ' ', ' ', ' ', ' ', 'x', 'e', 'n'),
+            1,
+            ASCII32('I', 'B', 'M', ' '),
+            1,
+        },
+        0,
+        0,
+        0
+    };
+
+    /* probe for TIS interface ... */
+    if (memcmp((char *)(0xFED40000 + 0xF00),
+               tis_did_vid_rid,
+               sizeof(tis_did_vid_rid)) == 0) {
+        puts("TIS is available\n");
+        addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
+                                   AmlCode_TPM, sizeof(AmlCode_TPM));
+        if (addr == NULL)
+            success = 0;
+        else {
+            /* legacy systems need an RSDT entry */
+            acpi_rsdt_add_entry_pointer(acpi_start,
+                                        addr);
+            /* add ACPI TCPA table */
+            addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
+                                       (unsigned char *)&Tcpa,
+                                       sizeof(Tcpa) +
+                                       ACPI_2_0_TCPA_LAML_SIZE);
+            if (addr) {
+                ACPI_2_0_TCPA_CLIENT *tcpa = (ACPI_2_0_TCPA_CLIENT *)addr;
+                tcpa->LASA = (uint64_t)(unsigned long)(addr + sizeof(Tcpa));
+                tcpa->LAML = ACPI_2_0_TCPA_LAML_SIZE,
+                memset((char *)(unsigned long)tcpa->LASA,
+                       0x0,
+                       tcpa->LAML);
+                set_checksum(tcpa,
+                             FIELD_OFFSET(struct acpi_header, checksum),
+                             tcpa->header.length);
+                acpi_rsdt_add_entry_pointer(acpi_start, addr);
+            }
+        }
+    }
+    return success;
 }
 
 
@@ -129,7 +164,7 @@ static int acpi_rsdt_add_entry_pointer(u
     }
 
     if (found) {
-        rsdt->entry[i] = (uint64_t)(long)entry;
+        rsdt->entry[i] = (uint64_t)(unsigned long)entry;
         rsdt->header.length =
             sizeof(struct acpi_header) +
             (i + 1) * sizeof(uint64_t);
@@ -163,6 +198,38 @@ struct acpi_20_xsdt *acpi_xsdt_get(unsig
 }
 
 /*
+ * Add an entry to the XSDT table given the pointer to the entry.
+ */
+static int acpi_xsdt_add_entry_pointer(unsigned char *acpi_start,
+                                       unsigned char *entry)
+{
+    struct acpi_20_xsdt *xsdt = acpi_xsdt_get(acpi_start);
+    int found = 0;
+    int i = 0;
+
+    /* get empty slot in the XSDT table */
+    while (i < ACPI_MAX_NUM_TABLES) {
+        if (xsdt->entry[i] == 0) {
+            found = 1;
+            break;
+        }
+        i++;
+    }
+
+    if (found) {
+        xsdt->entry[i] = (uint64_t)(unsigned long)entry;
+        xsdt->header.length =
+            sizeof(struct acpi_header) +
+            (i + 1) * sizeof(uint64_t);
+        set_checksum(xsdt,
+                     FIELD_OFFSET(struct acpi_header, checksum),
+                     xsdt->header.length);
+    }
+
+    return found;
+}
+
+/*
    add an entry to the xdst table entry pointers
    copy the given ssdt data to the current available memory at
    freemem, if it does not exceed the limit
@@ -177,7 +244,7 @@ static unsigned char *acpi_xsdt_add_entr
     int found = 0, i = 0;
     unsigned char *addr = NULL;
 
-    /* get empty slot in the Xsdt table */
+    /* check for empty slot in the Xsdt table */
     while (i < ACPI_MAX_NUM_TABLES) {
         if (xsdt->entry[i] == 0) {
             found = 1;
@@ -192,15 +259,9 @@ static unsigned char *acpi_xsdt_add_entr
             puts("Copying SSDT entry!\n");
             addr = *freemem;
             memcpy(addr, table, table_size);
-            xsdt->entry[i] = (uint64_t)(long)addr;
             *freemem += table_size;
-            /* update the XSDT table */
-            xsdt->header.length =
-                sizeof(struct acpi_header) +
-                (i + 1) * sizeof(uint64_t);
-            set_checksum(xsdt,
-                         FIELD_OFFSET(struct acpi_header, checksum),
-                         xsdt->header.length);
+
+            acpi_xsdt_add_entry_pointer(acpi_start, addr);
         }
     }
     return addr;
xen-unstable.hg/tools/firmware/hvmloader/acpi/acpi2_0.h +31 -7
Index: root/xen-unstable.hg/tools/firmware/hvmloader/acpi/acpi2_0.h
===================================================================
@@ -34,6 +34,13 @@ typedef   signed long int64_t;
 
 #include <xen/xen.h>
 
+#define ASCII32(a,b,c,d)     (((a) <<  0) | ((b) <<  8) | \
+                              ((c) << 16) | ((d) << 24)  )
+#define ASCII64(a,b,c,d,e,f,g,h)                              \
+                       (((uint64_t)ASCII32(a,b,c,d)) << 0  |  \
+                        ((uint64_t)ASCII32(e,f,g,h)) << 32   )
+
+
 #pragma pack (1)
 
 /*
@@ -52,7 +59,7 @@ struct acpi_header {
 };
 
 #define ACPI_OEM_ID             {'I','N','T','E','L',' '}
-#define ACPI_OEM_TABLE_ID       0x544244   /* "TBD" */
+#define ACPI_OEM_TABLE_ID       ASCII32(' ','T','B','D') // "TBD"
 #define ACPI_OEM_REVISION       0x00000002
 #define ACPI_CREATOR_ID         0x00       /* TBD */
 #define ACPI_CREATOR_REVISION   0x00000002
@@ -128,6 +135,20 @@ struct acpi_20_xsdt {
 #define ACPI_2_0_XSDT_REVISION 0x01
 
 /*
+ * TCG Hardware Interface Table (TCPA)
+ */
+
+typedef struct _ACPI_2_0_TCPA_CLIENT {
+		struct acpi_header header;
+		uint16_t PlatformClass;
+		uint32_t LAML;
+		uint64_t LASA;
+} ACPI_2_0_TCPA_CLIENT;
+
+#define ACPI_2_0_TCPA_REVISION 0x02
+#define ACPI_2_0_TCPA_LAML_SIZE (10*1024)
+
+/*
  * Fixed ACPI Description Table Structure (FADT).
  */
 struct acpi_20_fadt {
@@ -297,12 +318,15 @@ struct acpi_20_madt {
 /*
  * Table Signatures.
  */
-#define ACPI_2_0_RSDP_SIGNATURE 0x2052545020445352LL /* "RSD PTR " */
-#define ACPI_2_0_FACS_SIGNATURE 0x53434146 /* "FACS" */
-#define ACPI_2_0_FADT_SIGNATURE 0x50434146 /* "FADT" */
-#define ACPI_2_0_MADT_SIGNATURE 0x43495041 /* "APIC" */
-#define ACPI_2_0_RSDT_SIGNATURE 0x54445352 /* "RSDT" */
-#define ACPI_2_0_XSDT_SIGNATURE 0x54445358 /* "XSDT" */
+#define ACPI_2_0_RSDP_SIGNATURE ASCII64('R','S','D',' ','P','T','R',' ')
+                                        /* "RSD PTR " */
+#define ACPI_2_0_FACS_SIGNATURE ASCII32('F','A','C','S') /* "FACS" */
+#define ACPI_2_0_FADT_SIGNATURE ASCII32('F','A','C','P')
+                                        /* "FACP" is signature for FADT */
+#define ACPI_2_0_MADT_SIGNATURE ASCII32('A','P','I','C') /* "APIC" */
+#define ACPI_2_0_RSDT_SIGNATURE ASCII32('R','S','D','T') /* "RSDT" */
+#define ACPI_2_0_XSDT_SIGNATURE ASCII32('X','S','D','T') /* "XSDT" */
+#define ACPI_2_0_TCPA_SIGNATURE ASCII32('T','C','P','A') /* "TCPA" */
 
 #pragma pack ()
 

_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel