[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] [xen-unstable] [HVMLOADER][ACPI] Move SSDT initialisation to acpi/ dir.



# HG changeset patch
# User kfraser@xxxxxxxxxxxxxxxxxxxxx
# Node ID 514ed4f0e5da6eb0b0bd8727194296434c4b5005
# Parent  6c2c7ff6265a9c47bb851c89dde5aae4ed58de02
[HVMLOADER][ACPI] Move SSDT initialisation to acpi/ dir.
This kills off a few hundred lines of unnecessary code.
Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>
---
 tools/firmware/hvmloader/acpi_ssdt_tpm.asl |   29 --
 tools/firmware/hvmloader/acpi_ssdt_tpm.h   |   25 --
 tools/firmware/hvmloader/acpi_utils.c      |  318 -----------------------------
 tools/firmware/hvmloader/acpi_utils.h      |   36 ---
 tools/firmware/hvmloader/Makefile          |    4 
 tools/firmware/hvmloader/acpi/Makefile     |    8 
 tools/firmware/hvmloader/acpi/acpi2_0.h    |   17 -
 tools/firmware/hvmloader/acpi/build.c      |  118 +++++++---
 tools/firmware/hvmloader/acpi/ssdt_tpm.asl |   29 ++
 tools/firmware/hvmloader/acpi/ssdt_tpm.h   |   25 ++
 tools/firmware/hvmloader/hvmloader.c       |    9 
 tools/firmware/hvmloader/mp_tables.c       |    1 
 tools/firmware/hvmloader/util.h            |    3 
 13 files changed, 153 insertions(+), 469 deletions(-)

diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/Makefile
--- a/tools/firmware/hvmloader/Makefile Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/Makefile Tue Nov 28 15:47:52 2006 +0000
@@ -40,7 +40,7 @@ CFLAGS  += $(DEFINES) -I. $(XENINC) -fno
 CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
 LDFLAGS  = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
 
-SRCS = hvmloader.c mp_tables.c util.c smbios.c acpi_utils.c
+SRCS = hvmloader.c mp_tables.c util.c smbios.c
 OBJS = $(patsubst %.c,%.o,$(SRCS))
 
 .PHONY: all
@@ -65,5 +65,5 @@ roms.h:       ../rombios/BIOS-bochs-latest ../
 .PHONY: clean
 clean:
        rm -f roms.h acpi.h
-       rm -f hvmloader hvmloader.tmp hvmloader.o $(OBJS)
+       rm -f hvmloader hvmloader.tmp *.o
        $(MAKE) -C acpi clean
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi/Makefile
--- a/tools/firmware/hvmloader/acpi/Makefile    Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/acpi/Makefile    Tue Nov 28 15:47:52 2006 +0000
@@ -30,12 +30,18 @@ vpath iasl $(PATH)
 vpath iasl $(PATH)
 all: acpi.a
 
+ssdt_tpm.h: ssdt_tpm.asl
+       $(MAKE) iasl
+       iasl -tc ssdt_tpm.asl
+       mv ssdt_tpm.hex ssdt_tpm.h
+       rm -f *.aml
+
 dsdt.c: dsdt.asl
        $(MAKE) iasl
        iasl -tc dsdt.asl
        mv dsdt.hex dsdt.c
        echo "int DsdtLen=sizeof(AmlCode);" >> dsdt.c
-       rm *.aml
+       rm -f *.aml
 
 iasl:
        @echo
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi/acpi2_0.h
--- a/tools/firmware/hvmloader/acpi/acpi2_0.h   Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/acpi/acpi2_0.h   Tue Nov 28 15:47:52 2006 +0000
@@ -119,7 +119,7 @@ struct acpi_20_rsdp {
  */
 struct acpi_20_rsdt {
     struct acpi_header header;
-    uint32_t entry[ACPI_MAX_NUM_TABLES];
+    uint32_t entry[1];
 };
 #define ACPI_2_0_RSDT_REVISION 0x01
 
@@ -128,20 +128,19 @@ struct acpi_20_rsdt {
  */
 struct acpi_20_xsdt {
     struct acpi_header header;
-    uint64_t entry[ACPI_MAX_NUM_TABLES];
+    uint64_t entry[1];
 };
 #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;
+struct acpi_20_tcpa {
+    struct acpi_header header;
+    uint16_t platform_class;
+    uint32_t laml;
+    uint64_t lasa;
+};
 
 #define ACPI_2_0_TCPA_REVISION 0x02
 #define ACPI_2_0_TCPA_LAML_SIZE (64*1024)
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi/build.c
--- a/tools/firmware/hvmloader/acpi/build.c     Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/acpi/build.c     Tue Nov 28 15:47:52 2006 +0000
@@ -17,8 +17,12 @@
  */
 
 #include "acpi2_0.h"
+#include "ssdt_tpm.h"
 #include "../config.h"
 #include "../util.h"
+#include <xen/hvm/e820.h>
+
+#define align16(sz) (((sz) + 15) & ~15)
 
 extern struct acpi_20_rsdp Rsdp;
 extern struct acpi_20_rsdt Rsdt;
@@ -103,39 +107,85 @@ int construct_madt(struct acpi_20_madt *
     madt->header.length = offset;
     set_checksum(madt, offsetof(struct acpi_header, checksum), offset);
 
-    return offset;
-}
-
-/*
- * Copy all the ACPI table to buffer.
- * Buffer layout: FACS, DSDT, FADT, MADT, XSDT, RSDT, RSDP.
- */
+    return align16(offset);
+}
+
+int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
+{
+    int offset = 0, nr_tables = 0;
+    struct acpi_20_madt *madt;
+    struct acpi_20_tcpa *tcpa;
+    static const uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
+
+    /* MADT. */
+    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
+    {
+        madt = (struct acpi_20_madt *)&buf[offset];
+        offset += construct_madt(madt);
+        table_ptrs[nr_tables++] = (unsigned long)madt;
+    }
+
+    /* TPM TCPA and SSDT. */
+    if ( memcmp((char *)0xFED40F00, tis_did_vid_rid,
+                sizeof(tis_did_vid_rid)) == 0 ) /* Probe for TIS interface. */
+    {
+        memcpy(&buf[offset], AmlCode_TPM, sizeof(AmlCode_TPM));
+        table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
+        offset += align16(sizeof(AmlCode_TPM));
+
+        tcpa = (struct acpi_20_tcpa *)&buf[offset];
+        memset(tcpa, 0, sizeof(*tcpa));
+        offset += align16(sizeof(*tcpa));
+        table_ptrs[nr_tables++] = (unsigned long)tcpa;
+
+        tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
+        tcpa->header.length    = sizeof(*tcpa);
+        tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
+        strncpy(tcpa->header.oem_id, "IBM   ", 6);
+        tcpa->header.oem_table_id = ASCII64(' ', ' ', ' ', ' ',
+                                            ' ', 'x', 'e', 'n');
+        tcpa->header.oem_revision = 1;
+        tcpa->header.creator_id   = ASCII32('I', 'B', 'M', ' ');
+        tcpa->header.creator_revision = 1;
+        tcpa->lasa = e820_malloc(
+            ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
+        if ( tcpa->lasa )
+        {
+            tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
+            memset((char *)(unsigned long)tcpa->lasa, 0, tcpa->laml);
+            set_checksum(tcpa,
+                         offsetof(struct acpi_header, checksum),
+                         tcpa->header.length);
+        }
+    }
+
+    table_ptrs[nr_tables] = 0;
+    return align16(offset);
+}
+
+/* Copy all the ACPI table to buffer. */
 int acpi_build_tables(uint8_t *buf)
 {
     struct acpi_20_rsdp *rsdp;
     struct acpi_20_rsdt *rsdt;
     struct acpi_20_xsdt *xsdt;
     struct acpi_20_fadt *fadt;
-    struct acpi_20_madt *madt = 0;
     struct acpi_20_facs *facs;
     unsigned char       *dsdt;
-    int offset = 0, requires_madt;
-
-    requires_madt = ((get_vcpu_nr() > 1) || get_apic_mode());
-
-#define inc_offset(sz)  (offset = (offset + (sz) + 15) & ~15)
+    unsigned long        secondary_tables[16];
+    int                  offset = 0, i;
 
     facs = (struct acpi_20_facs *)&buf[offset];
     memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
-    inc_offset(sizeof(struct acpi_20_facs));
+    offset += align16(sizeof(struct acpi_20_facs));
 
     dsdt = (unsigned char *)&buf[offset];
     memcpy(dsdt, &AmlCode, DsdtLen);
-    inc_offset(DsdtLen);
+    offset += align16(DsdtLen);
 
     fadt = (struct acpi_20_fadt *)&buf[offset];
     memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
-    inc_offset(sizeof(struct acpi_20_fadt));
+    offset += align16(sizeof(struct acpi_20_fadt));
     fadt->dsdt   = (unsigned long)dsdt;
     fadt->x_dsdt = (unsigned long)dsdt;
     fadt->firmware_ctrl   = (unsigned long)facs;
@@ -144,43 +194,33 @@ int acpi_build_tables(uint8_t *buf)
                  offsetof(struct acpi_header, checksum),
                  sizeof(struct acpi_20_fadt));
 
-    if ( requires_madt )
-    {
-        madt = (struct acpi_20_madt *)&buf[offset];
-        inc_offset(construct_madt(madt));
-    }
+    offset += construct_secondary_tables(&buf[offset], secondary_tables);
 
     xsdt = (struct acpi_20_xsdt *)&buf[offset];
-    memcpy(xsdt, &Xsdt, sizeof(struct acpi_20_xsdt));
-    inc_offset(sizeof(struct acpi_20_xsdt));
+    memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
     xsdt->entry[0] = (unsigned long)fadt;
-    xsdt->header.length = sizeof(struct acpi_header) + sizeof(uint64_t);
-    if ( requires_madt )
-    {
-        xsdt->entry[1] = (unsigned long)madt;
-        xsdt->header.length += sizeof(uint64_t);
-    }
+    for ( i = 0; secondary_tables[i]; i++ )
+        xsdt->entry[i+1] = secondary_tables[i];
+    xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
+    offset += align16(xsdt->header.length);
     set_checksum(xsdt,
                  offsetof(struct acpi_header, checksum),
                  xsdt->header.length);
 
     rsdt = (struct acpi_20_rsdt *)&buf[offset];
-    memcpy(rsdt, &Rsdt, sizeof(struct acpi_20_rsdt));
-    inc_offset(sizeof(struct acpi_20_rsdt));
+    memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
     rsdt->entry[0] = (unsigned long)fadt;
-    rsdt->header.length = sizeof(struct acpi_header) + sizeof(uint32_t);
-    if ( requires_madt )
-    {
-        rsdt->entry[1] = (unsigned long)madt;
-        rsdt->header.length += sizeof(uint32_t);
-    }
+    for ( i = 0; secondary_tables[i]; i++ )
+        rsdt->entry[i+1] = secondary_tables[i];
+    rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
+    offset += align16(rsdt->header.length);
     set_checksum(rsdt,
                  offsetof(struct acpi_header, checksum),
                  rsdt->header.length);
 
     rsdp = (struct acpi_20_rsdp *)&buf[offset];
     memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
-    inc_offset(sizeof(struct acpi_20_rsdp));
+    offset += align16(sizeof(struct acpi_20_rsdp));
     rsdp->rsdt_address = (unsigned long)rsdt;
     rsdp->xsdt_address = (unsigned long)xsdt;
     set_checksum(rsdp,
@@ -189,8 +229,6 @@ int acpi_build_tables(uint8_t *buf)
     set_checksum(rsdp,
                  offsetof(struct acpi_20_rsdp, extended_checksum),
                  sizeof(struct acpi_20_rsdp));
-
-#undef inc_offset
 
     return offset;
 }
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/hvmloader.c
--- a/tools/firmware/hvmloader/hvmloader.c      Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/hvmloader.c      Tue Nov 28 15:47:52 2006 +0000
@@ -23,7 +23,6 @@
 #include "acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
 #include "hypercall.h"
 #include "util.h"
-#include "acpi_utils.h"
 #include "smbios.h"
 #include "config.h"
 #include "apic_regs.h"
@@ -283,7 +282,6 @@ int main(void)
 int main(void)
 {
     int acpi_sz;
-    uint8_t *freemem;
 
     printf("HVM Loader\n");
 
@@ -318,12 +316,7 @@ int main(void)
     {
         printf("Loading ACPI ...\n");
         acpi_sz = acpi_build_tables((uint8_t *)ACPI_PHYSICAL_ADDRESS);
-        freemem = (uint8_t *)ACPI_PHYSICAL_ADDRESS + acpi_sz;
-        ASSERT(freemem <= (uint8_t *)0xF0000);
-        acpi_update((unsigned char *)ACPI_PHYSICAL_ADDRESS,
-                    freemem - (uint8_t *)ACPI_PHYSICAL_ADDRESS,
-                    (unsigned char *)0xF0000,
-                    &freemem);
+        ASSERT((ACPI_PHYSICAL_ADDRESS + acpi_sz) <= 0xF0000);
     }
 
     if ( check_amd() )
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/mp_tables.c
--- a/tools/firmware/hvmloader/mp_tables.c      Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/mp_tables.c      Tue Nov 28 15:47:52 2006 +0000
@@ -28,7 +28,6 @@
  * Place - Suite 330, Boston, MA 02111-1307 USA.
  */
 
-#include <acpi_utils.h>
 #include "config.h"
 
 /* FIXME find a header that already has types defined!!! */
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/util.h
--- a/tools/firmware/hvmloader/util.h   Tue Nov 28 15:25:26 2006 +0000
+++ b/tools/firmware/hvmloader/util.h   Tue Nov 28 15:47:52 2006 +0000
@@ -5,6 +5,9 @@
 
 #undef offsetof
 #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
+
+#undef NULL
+#define NULL ((void*)0)
 
 extern void __assert_failed(char *assertion, char *file, int line)
     __attribute__((noreturn));
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi/ssdt_tpm.asl
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl        Tue Nov 28 15:47:52 
2006 +0000
@@ -0,0 +1,29 @@
+//**********************************************************************//
+//*
+//* Copyright (c) 2006, IBM Corporation.
+//*
+//* This program is free software; you can redistribute it and/or modify it
+//* under the terms and conditions of the GNU General Public License,
+//* version 2, as published by the Free Software Foundation.
+//*
+//* This program is distributed in the hope it will be useful, but WITHOUT
+//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+//* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
+//* more details.
+//*
+//* You should have received a copy of the GNU General Public License along 
with
+//* this program; if not, write to the Free Software Foundation, Inc., 59 
Temple
+//* Place - Suite 330, Boston, MA 02111-1307 USA.
+
+//*  SSDT for TPM TIS Interface for Xen with Qemu device model
+
+DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
+{
+    Device (TPM) {
+        Name (_HID, EisaId ("PNP0C31"))
+        Name (_CRS, ResourceTemplate ()
+        {
+            Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
+        })
+    }
+}
\ No newline at end of file
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi/ssdt_tpm.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.h  Tue Nov 28 15:47:52 2006 +0000
@@ -0,0 +1,25 @@
+/*
+ * 
+ * Intel ACPI Component Architecture
+ * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
+ * Copyright (C) 2000 - 2006 Intel Corporation
+ * Supports ACPI Specification Revision 3.0a
+ * 
+ * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
+ * 
+ * C source code output
+ *
+ */
+unsigned char AmlCode_TPM[] =
+{
+    0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
+    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
+    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
+    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
+    0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
+    0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
+    0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
+    0x52,0x53,0x11,0x11,0x0A,0x0E,0x86,0x09,  /* 00000038    "RS......" */
+    0x00,0x01,0x00,0x00,0xD4,0xFE,0x00,0x50,  /* 00000040    ".......P" */
+    0x00,0x00,0x79,0x00,
+};
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi_ssdt_tpm.asl
--- a/tools/firmware/hvmloader/acpi_ssdt_tpm.asl        Tue Nov 28 15:25:26 
2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,29 +0,0 @@
-//**********************************************************************//
-//*
-//* Copyright (c) 2006, IBM Corporation.
-//*
-//* This program is free software; you can redistribute it and/or modify it
-//* under the terms and conditions of the GNU General Public License,
-//* version 2, as published by the Free Software Foundation.
-//*
-//* This program is distributed in the hope it will be useful, but WITHOUT
-//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
-//* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
-//* more details.
-//*
-//* You should have received a copy of the GNU General Public License along 
with
-//* this program; if not, write to the Free Software Foundation, Inc., 59 
Temple
-//* Place - Suite 330, Boston, MA 02111-1307 USA.
-
-//*  SSDT for TPM TIS Interface for Xen with Qemu device model
-
-DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
-{
-    Device (TPM) {
-        Name (_HID, EisaId ("PNP0C31"))
-        Name (_CRS, ResourceTemplate ()
-        {
-            Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
-        })
-    }
-}
\ No newline at end of file
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi_ssdt_tpm.h
--- a/tools/firmware/hvmloader/acpi_ssdt_tpm.h  Tue Nov 28 15:25:26 2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,25 +0,0 @@
-/*
- * 
- * Intel ACPI Component Architecture
- * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
- * Copyright (C) 2000 - 2006 Intel Corporation
- * Supports ACPI Specification Revision 3.0a
- * 
- * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
- * 
- * C source code output
- *
- */
-unsigned char AmlCode_TPM[] =
-{
-    0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
-    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
-    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
-    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
-    0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
-    0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
-    0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
-    0x52,0x53,0x11,0x11,0x0A,0x0E,0x86,0x09,  /* 00000038    "RS......" */
-    0x00,0x01,0x00,0x00,0xD4,0xFE,0x00,0x50,  /* 00000040    ".......P" */
-    0x00,0x00,0x79,0x00,
-};
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi_utils.c
--- a/tools/firmware/hvmloader/acpi_utils.c     Tue Nov 28 15:25:26 2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,318 +0,0 @@
-/*
- * Commonly used ACPI utility functions.
- * Probing for devices and writing SSDT entries into XSDT and RSDT tables.
- *
- * Yu Ke, ke.yu@xxxxxxxxx
- * Copyright (c) 2005, Intel Corporation.
- * Copyright (c) 2006, IBM Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- */
-
-#include "acpi/acpi2_0.h"
-#include "acpi_utils.h"
-#include "util.h"
-#include <xen/hvm/e820.h>
-
-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,
-                                          unsigned char *table,
-                                          unsigned int table_size);
-
-void set_checksum(void *start, int checksum_offset, int len)
-{
-    unsigned char sum = 0;
-    unsigned char *ptr;
-
-    ptr = start;
-    ptr[checksum_offset] = 0;
-    while ( len-- )
-        sum += *ptr++;
-
-    ptr = start;
-    ptr[checksum_offset] = -sum;
-}
-
-
-#include "acpi_ssdt_tpm.h"
-static void acpi_tpm_tis_probe(unsigned char *acpi_start,
-                               unsigned char **freemem,
-                               unsigned char *limit)
-{
-    unsigned char *addr;
-    ACPI_2_0_TCPA_CLIENT *tcpa;
-    /* 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 = {
-        .header = {
-            .signature = ACPI_2_0_TCPA_SIGNATURE,
-            .length    = sizeof(ACPI_2_0_TCPA_CLIENT),
-            .revision  = ACPI_2_0_TCPA_REVISION,
-            .oem_id    = {'I', 'B', 'M', ' ', ' ', ' '},
-            .oem_table_id = ASCII64(' ', ' ', ' ', ' ', ' ', 'x', 'e', 'n'),
-            .oem_revision = 1,
-            .creator_id   = ASCII32('I', 'B', 'M', ' '),
-            .creator_revision = 1,
-        }
-    };
-
-    /* probe for TIS interface ... */
-    if ( memcmp((char *)(0xFED40000 + 0xF00),
-                tis_did_vid_rid,
-                sizeof(tis_did_vid_rid)) != 0 )
-        return;
-
-    printf("TIS is available\n");
-    addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
-                               AmlCode_TPM, sizeof(AmlCode_TPM));
-    if ( addr == NULL )
-        return;
-
-    /* legacy systems need an RSDT entry */
-    if ( acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1 )
-        return;
-
-    /* add ACPI TCPA table */
-    addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
-                               (unsigned char *)&Tcpa,
-                               sizeof(Tcpa));
-    if ( addr == NULL )
-        return;
-
-    tcpa = (ACPI_2_0_TCPA_CLIENT *)addr;
-    tcpa->LASA = e820_malloc(
-        ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
-    if ( tcpa->LASA )
-    {
-        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);
-    }
-
-    if ( acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1 )
-        return;
-}
-
-
-/*
- * Call functions that probe for devices and have them register their
- * SSDT entries with the XSDT and RSDT tables.
- */
-void acpi_update(unsigned char *acpi_start,
-                 unsigned long acpi_size,
-                 unsigned char *limit,
-                 unsigned char **freemem)
-{
-    acpi_tpm_tis_probe(acpi_start, freemem, limit);
-}
-
-
-/*
- * Search for the RSDP in memory below the BIOS
- */
-struct acpi_20_rsdp *acpi_rsdp_get(unsigned char *acpi_start)
-{
-    int offset = 0;
-    int found = 0;
-    static int displayed = 0;
-    struct acpi_20_rsdp *rsdp;
-
-    while ( &acpi_start[offset] < (unsigned char *)0xf0000 )
-    {
-        rsdp = (struct acpi_20_rsdp *)&acpi_start[offset];
-        if ( rsdp->signature == ACPI_2_0_RSDP_SIGNATURE )
-        {
-            found = 1;
-            break;
-        }
-        offset += 0x10;
-    }
-    
-    if ( !found )
-        rsdp = NULL;
-
-    if ( !displayed )
-    {
-        if ( rsdp )
-            printf("Found RSDP at %lx\n",(long)rsdp);
-        else
-            printf("ERROR: RSDP was not found\n");
-        displayed = 1;
-    }
-
-    return rsdp;
-}
-
-
-struct acpi_20_rsdt *acpi_rsdt_get(unsigned char *acpi_start)
-{
-    struct acpi_20_rsdp *rsdp;
-    struct acpi_20_rsdt *rsdt;
-
-    rsdp = acpi_rsdp_get(acpi_start);
-    if (!rsdp)
-        return NULL;
-
-    rsdt = (struct acpi_20_rsdt *)
-        (acpi_start + rsdp->rsdt_address - ACPI_PHYSICAL_ADDRESS);
-    if ( rsdt->header.signature != ACPI_2_0_RSDT_SIGNATURE )
-    {
-        printf("Bad RSDT signature\n");
-        return NULL;
-    }
-
-    return rsdt;
-}
-
-/*
- * Add an entry to the RSDT table given the pointer to the entry.
- */
-static int acpi_rsdt_add_entry_pointer(unsigned char *acpi_start,
-                                       unsigned char *entry)
-{
-    struct acpi_20_rsdt *rsdt = acpi_rsdt_get(acpi_start);
-    int found = 0;
-    int i = 0;
-
-    /* Find an empty slot in the RSDT table. */
-    while ( i < ACPI_MAX_NUM_TABLES )
-    {
-        if ( rsdt->entry[i] == 0 )
-        {
-            found = 1;
-            break;
-        }
-        i++;
-    }
-
-    if ( found )
-    {
-        rsdt->entry[i] = (uint64_t)(unsigned long)entry;
-        rsdt->header.length =
-            sizeof(struct acpi_header) +
-            (i + 1) * sizeof(uint64_t);
-        set_checksum(rsdt,
-                     FIELD_OFFSET(struct acpi_header, checksum),
-                     rsdt->header.length);
-    }
-
-    return found;
-}
-
-/* Get the XSDT table. */
-struct acpi_20_xsdt *acpi_xsdt_get(unsigned char *acpi_start)
-{
-    struct acpi_20_rsdp *rsdp;
-    struct acpi_20_xsdt *xsdt;
-
-    rsdp = acpi_rsdp_get(acpi_start);
-    if (!rsdp)
-        return NULL;
-
-    xsdt = (struct acpi_20_xsdt *)
-        (acpi_start + rsdp->xsdt_address - ACPI_PHYSICAL_ADDRESS);
-    if ( xsdt->header.signature != ACPI_2_0_XSDT_SIGNATURE )
-    {
-        printf("Bad XSDT signature\n");
-        return NULL;
-    }
-    return xsdt;
-}
-
-/*
- * 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;
-
-    /* Find an 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
- */
-static unsigned char *acpi_xsdt_add_entry(unsigned char *acpi_start,
-                                          unsigned char **freemem,
-                                          unsigned char *limit,
-                                          unsigned char *table,
-                                          unsigned int table_size)
-{
-    struct acpi_20_xsdt *xsdt = acpi_xsdt_get(acpi_start);
-    int found = 0, i = 0;
-    unsigned char *addr = NULL;
-
-    /* Check for an empty slot in the Xsdt table. */
-    while ( i < ACPI_MAX_NUM_TABLES )
-    {
-        if ( xsdt->entry[i] == 0 )
-        {
-            found = 1;
-            break;
-        }
-        i++;
-    }
-
-    if ( found )
-    {
-        /* memory below hard limit ? */
-        if ( (*freemem + table_size) <= limit )
-        {
-            addr = *freemem;
-            memcpy(addr, table, table_size);
-            printf("Copied dyn. ACPI entry to %lx\n",(long)addr);
-            *freemem += ((table_size + 0xf) & ~0xf);
-
-            acpi_xsdt_add_entry_pointer(acpi_start, addr);
-        }
-    }
-
-    return addr;
-}
diff -r 6c2c7ff6265a -r 514ed4f0e5da tools/firmware/hvmloader/acpi_utils.h
--- a/tools/firmware/hvmloader/acpi_utils.h     Tue Nov 28 15:25:26 2006 +0000
+++ /dev/null   Thu Jan 01 00:00:00 1970 +0000
@@ -1,36 +0,0 @@
-/*
- * Commonly used ACPI utility functions.
- *
- * Yu Ke, ke.yu@xxxxxxxxx
- * Copyright (c) 2005, Intel Corporation.
- *
- * This program is free software; you can redistribute it and/or modify it
- * under the terms and conditions of the GNU General Public License,
- * version 2, as published by the Free Software Foundation.
- *
- * This program is distributed in the hope it will be useful, but WITHOUT
- * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
- * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
- * more details.
- *
- * You should have received a copy of the GNU General Public License along with
- * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
- * Place - Suite 330, Boston, MA 02111-1307 USA.
- */
-#ifndef ACPI_UTILS_H
-#define ACPI_UTILS_H
-
-#define FIELD_OFFSET(TYPE,Field) ((unsigned int)(&(((TYPE *) 0)->Field)))
-
-#define NULL ((void*)0)
-
-void set_checksum(void *start, int checksum_offset, int len);
-void acpi_update(unsigned char *acpi_start,
-                 unsigned long acpi_size,
-                 unsigned char *limit,
-                 unsigned char **freemem);
-
-struct acpi_20_rsdt *acpi_rsdt_get(unsigned char *acpi_start);
-struct acpi_20_xsdt *acpi_xsdt_get(unsigned char *acpi_start);
-
-#endif

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.