ia64/xen-unstable

changeset 12634:514ed4f0e5da

[HVMLOADER][ACPI] Move SSDT initialisation to acpi/ dir.
This kills off a few hundred lines of unnecessary code.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@localhost.localdomain
date Tue Nov 28 15:47:52 2006 +0000 (2006-11-28)
parents 6c2c7ff6265a
children fe15bf5a58ad
files tools/firmware/hvmloader/Makefile tools/firmware/hvmloader/acpi/Makefile tools/firmware/hvmloader/acpi/acpi2_0.h tools/firmware/hvmloader/acpi/build.c tools/firmware/hvmloader/acpi/ssdt_tpm.asl tools/firmware/hvmloader/acpi/ssdt_tpm.h tools/firmware/hvmloader/acpi_ssdt_tpm.asl tools/firmware/hvmloader/acpi_ssdt_tpm.h tools/firmware/hvmloader/acpi_utils.c tools/firmware/hvmloader/acpi_utils.h tools/firmware/hvmloader/hvmloader.c tools/firmware/hvmloader/mp_tables.c tools/firmware/hvmloader/util.h
line diff
     1.1 --- a/tools/firmware/hvmloader/Makefile	Tue Nov 28 15:25:26 2006 +0000
     1.2 +++ b/tools/firmware/hvmloader/Makefile	Tue Nov 28 15:47:52 2006 +0000
     1.3 @@ -40,7 +40,7 @@ OBJCOPY  = objcopy
     1.4  CFLAGS  += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float
     1.5  LDFLAGS  = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR)
     1.6  
     1.7 -SRCS = hvmloader.c mp_tables.c util.c smbios.c acpi_utils.c
     1.8 +SRCS = hvmloader.c mp_tables.c util.c smbios.c
     1.9  OBJS = $(patsubst %.c,%.o,$(SRCS))
    1.10  
    1.11  .PHONY: all
    1.12 @@ -65,5 +65,5 @@ roms.h:	../rombios/BIOS-bochs-latest ../
    1.13  .PHONY: clean
    1.14  clean:
    1.15  	rm -f roms.h acpi.h
    1.16 -	rm -f hvmloader hvmloader.tmp hvmloader.o $(OBJS)
    1.17 +	rm -f hvmloader hvmloader.tmp *.o
    1.18  	$(MAKE) -C acpi clean
     2.1 --- a/tools/firmware/hvmloader/acpi/Makefile	Tue Nov 28 15:25:26 2006 +0000
     2.2 +++ b/tools/firmware/hvmloader/acpi/Makefile	Tue Nov 28 15:47:52 2006 +0000
     2.3 @@ -30,12 +30,18 @@ IASL_URL = http://developer.intel.com/te
     2.4  vpath iasl $(PATH)
     2.5  all: acpi.a
     2.6  
     2.7 +ssdt_tpm.h: ssdt_tpm.asl
     2.8 +	$(MAKE) iasl
     2.9 +	iasl -tc ssdt_tpm.asl
    2.10 +	mv ssdt_tpm.hex ssdt_tpm.h
    2.11 +	rm -f *.aml
    2.12 +
    2.13  dsdt.c: dsdt.asl
    2.14  	$(MAKE) iasl
    2.15  	iasl -tc dsdt.asl
    2.16  	mv dsdt.hex dsdt.c
    2.17  	echo "int DsdtLen=sizeof(AmlCode);" >> dsdt.c
    2.18 -	rm *.aml
    2.19 +	rm -f *.aml
    2.20  
    2.21  iasl:
    2.22  	@echo
     3.1 --- a/tools/firmware/hvmloader/acpi/acpi2_0.h	Tue Nov 28 15:25:26 2006 +0000
     3.2 +++ b/tools/firmware/hvmloader/acpi/acpi2_0.h	Tue Nov 28 15:47:52 2006 +0000
     3.3 @@ -119,7 +119,7 @@ struct acpi_20_rsdp {
     3.4   */
     3.5  struct acpi_20_rsdt {
     3.6      struct acpi_header header;
     3.7 -    uint32_t entry[ACPI_MAX_NUM_TABLES];
     3.8 +    uint32_t entry[1];
     3.9  };
    3.10  #define ACPI_2_0_RSDT_REVISION 0x01
    3.11  
    3.12 @@ -128,20 +128,19 @@ struct acpi_20_rsdt {
    3.13   */
    3.14  struct acpi_20_xsdt {
    3.15      struct acpi_header header;
    3.16 -    uint64_t entry[ACPI_MAX_NUM_TABLES];
    3.17 +    uint64_t entry[1];
    3.18  };
    3.19  #define ACPI_2_0_XSDT_REVISION 0x01
    3.20  
    3.21  /*
    3.22   * TCG Hardware Interface Table (TCPA)
    3.23   */
    3.24 -
    3.25 -typedef struct _ACPI_2_0_TCPA_CLIENT {
    3.26 +struct acpi_20_tcpa {
    3.27      struct acpi_header header;
    3.28 -    uint16_t PlatformClass;
    3.29 -    uint32_t LAML;
    3.30 -    uint64_t LASA;
    3.31 -} ACPI_2_0_TCPA_CLIENT;
    3.32 +    uint16_t platform_class;
    3.33 +    uint32_t laml;
    3.34 +    uint64_t lasa;
    3.35 +};
    3.36  
    3.37  #define ACPI_2_0_TCPA_REVISION 0x02
    3.38  #define ACPI_2_0_TCPA_LAML_SIZE (64*1024)
     4.1 --- a/tools/firmware/hvmloader/acpi/build.c	Tue Nov 28 15:25:26 2006 +0000
     4.2 +++ b/tools/firmware/hvmloader/acpi/build.c	Tue Nov 28 15:47:52 2006 +0000
     4.3 @@ -17,8 +17,12 @@
     4.4   */
     4.5  
     4.6  #include "acpi2_0.h"
     4.7 +#include "ssdt_tpm.h"
     4.8  #include "../config.h"
     4.9  #include "../util.h"
    4.10 +#include <xen/hvm/e820.h>
    4.11 +
    4.12 +#define align16(sz) (((sz) + 15) & ~15)
    4.13  
    4.14  extern struct acpi_20_rsdp Rsdp;
    4.15  extern struct acpi_20_rsdt Rsdt;
    4.16 @@ -103,39 +107,85 @@ int construct_madt(struct acpi_20_madt *
    4.17      madt->header.length = offset;
    4.18      set_checksum(madt, offsetof(struct acpi_header, checksum), offset);
    4.19  
    4.20 -    return offset;
    4.21 +    return align16(offset);
    4.22  }
    4.23  
    4.24 -/*
    4.25 - * Copy all the ACPI table to buffer.
    4.26 - * Buffer layout: FACS, DSDT, FADT, MADT, XSDT, RSDT, RSDP.
    4.27 - */
    4.28 +int construct_secondary_tables(uint8_t *buf, unsigned long *table_ptrs)
    4.29 +{
    4.30 +    int offset = 0, nr_tables = 0;
    4.31 +    struct acpi_20_madt *madt;
    4.32 +    struct acpi_20_tcpa *tcpa;
    4.33 +    static const uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
    4.34 +
    4.35 +    /* MADT. */
    4.36 +    if ( (get_vcpu_nr() > 1) || get_apic_mode() )
    4.37 +    {
    4.38 +        madt = (struct acpi_20_madt *)&buf[offset];
    4.39 +        offset += construct_madt(madt);
    4.40 +        table_ptrs[nr_tables++] = (unsigned long)madt;
    4.41 +    }
    4.42 +
    4.43 +    /* TPM TCPA and SSDT. */
    4.44 +    if ( memcmp((char *)0xFED40F00, tis_did_vid_rid,
    4.45 +                sizeof(tis_did_vid_rid)) == 0 ) /* Probe for TIS interface. */
    4.46 +    {
    4.47 +        memcpy(&buf[offset], AmlCode_TPM, sizeof(AmlCode_TPM));
    4.48 +        table_ptrs[nr_tables++] = (unsigned long)&buf[offset];
    4.49 +        offset += align16(sizeof(AmlCode_TPM));
    4.50 +
    4.51 +        tcpa = (struct acpi_20_tcpa *)&buf[offset];
    4.52 +        memset(tcpa, 0, sizeof(*tcpa));
    4.53 +        offset += align16(sizeof(*tcpa));
    4.54 +        table_ptrs[nr_tables++] = (unsigned long)tcpa;
    4.55 +
    4.56 +        tcpa->header.signature = ACPI_2_0_TCPA_SIGNATURE;
    4.57 +        tcpa->header.length    = sizeof(*tcpa);
    4.58 +        tcpa->header.revision  = ACPI_2_0_TCPA_REVISION;
    4.59 +        strncpy(tcpa->header.oem_id, "IBM   ", 6);
    4.60 +        tcpa->header.oem_table_id = ASCII64(' ', ' ', ' ', ' ',
    4.61 +                                            ' ', 'x', 'e', 'n');
    4.62 +        tcpa->header.oem_revision = 1;
    4.63 +        tcpa->header.creator_id   = ASCII32('I', 'B', 'M', ' ');
    4.64 +        tcpa->header.creator_revision = 1;
    4.65 +        tcpa->lasa = e820_malloc(
    4.66 +            ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
    4.67 +        if ( tcpa->lasa )
    4.68 +        {
    4.69 +            tcpa->laml = ACPI_2_0_TCPA_LAML_SIZE;
    4.70 +            memset((char *)(unsigned long)tcpa->lasa, 0, tcpa->laml);
    4.71 +            set_checksum(tcpa,
    4.72 +                         offsetof(struct acpi_header, checksum),
    4.73 +                         tcpa->header.length);
    4.74 +        }
    4.75 +    }
    4.76 +
    4.77 +    table_ptrs[nr_tables] = 0;
    4.78 +    return align16(offset);
    4.79 +}
    4.80 +
    4.81 +/* Copy all the ACPI table to buffer. */
    4.82  int acpi_build_tables(uint8_t *buf)
    4.83  {
    4.84      struct acpi_20_rsdp *rsdp;
    4.85      struct acpi_20_rsdt *rsdt;
    4.86      struct acpi_20_xsdt *xsdt;
    4.87      struct acpi_20_fadt *fadt;
    4.88 -    struct acpi_20_madt *madt = 0;
    4.89      struct acpi_20_facs *facs;
    4.90      unsigned char       *dsdt;
    4.91 -    int offset = 0, requires_madt;
    4.92 -
    4.93 -    requires_madt = ((get_vcpu_nr() > 1) || get_apic_mode());
    4.94 -
    4.95 -#define inc_offset(sz)  (offset = (offset + (sz) + 15) & ~15)
    4.96 +    unsigned long        secondary_tables[16];
    4.97 +    int                  offset = 0, i;
    4.98  
    4.99      facs = (struct acpi_20_facs *)&buf[offset];
   4.100      memcpy(facs, &Facs, sizeof(struct acpi_20_facs));
   4.101 -    inc_offset(sizeof(struct acpi_20_facs));
   4.102 +    offset += align16(sizeof(struct acpi_20_facs));
   4.103  
   4.104      dsdt = (unsigned char *)&buf[offset];
   4.105      memcpy(dsdt, &AmlCode, DsdtLen);
   4.106 -    inc_offset(DsdtLen);
   4.107 +    offset += align16(DsdtLen);
   4.108  
   4.109      fadt = (struct acpi_20_fadt *)&buf[offset];
   4.110      memcpy(fadt, &Fadt, sizeof(struct acpi_20_fadt));
   4.111 -    inc_offset(sizeof(struct acpi_20_fadt));
   4.112 +    offset += align16(sizeof(struct acpi_20_fadt));
   4.113      fadt->dsdt   = (unsigned long)dsdt;
   4.114      fadt->x_dsdt = (unsigned long)dsdt;
   4.115      fadt->firmware_ctrl   = (unsigned long)facs;
   4.116 @@ -144,43 +194,33 @@ int acpi_build_tables(uint8_t *buf)
   4.117                   offsetof(struct acpi_header, checksum),
   4.118                   sizeof(struct acpi_20_fadt));
   4.119  
   4.120 -    if ( requires_madt )
   4.121 -    {
   4.122 -        madt = (struct acpi_20_madt *)&buf[offset];
   4.123 -        inc_offset(construct_madt(madt));
   4.124 -    }
   4.125 +    offset += construct_secondary_tables(&buf[offset], secondary_tables);
   4.126  
   4.127      xsdt = (struct acpi_20_xsdt *)&buf[offset];
   4.128 -    memcpy(xsdt, &Xsdt, sizeof(struct acpi_20_xsdt));
   4.129 -    inc_offset(sizeof(struct acpi_20_xsdt));
   4.130 +    memcpy(xsdt, &Xsdt, sizeof(struct acpi_header));
   4.131      xsdt->entry[0] = (unsigned long)fadt;
   4.132 -    xsdt->header.length = sizeof(struct acpi_header) + sizeof(uint64_t);
   4.133 -    if ( requires_madt )
   4.134 -    {
   4.135 -        xsdt->entry[1] = (unsigned long)madt;
   4.136 -        xsdt->header.length += sizeof(uint64_t);
   4.137 -    }
   4.138 +    for ( i = 0; secondary_tables[i]; i++ )
   4.139 +        xsdt->entry[i+1] = secondary_tables[i];
   4.140 +    xsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint64_t);
   4.141 +    offset += align16(xsdt->header.length);
   4.142      set_checksum(xsdt,
   4.143                   offsetof(struct acpi_header, checksum),
   4.144                   xsdt->header.length);
   4.145  
   4.146      rsdt = (struct acpi_20_rsdt *)&buf[offset];
   4.147 -    memcpy(rsdt, &Rsdt, sizeof(struct acpi_20_rsdt));
   4.148 -    inc_offset(sizeof(struct acpi_20_rsdt));
   4.149 +    memcpy(rsdt, &Rsdt, sizeof(struct acpi_header));
   4.150      rsdt->entry[0] = (unsigned long)fadt;
   4.151 -    rsdt->header.length = sizeof(struct acpi_header) + sizeof(uint32_t);
   4.152 -    if ( requires_madt )
   4.153 -    {
   4.154 -        rsdt->entry[1] = (unsigned long)madt;
   4.155 -        rsdt->header.length += sizeof(uint32_t);
   4.156 -    }
   4.157 +    for ( i = 0; secondary_tables[i]; i++ )
   4.158 +        rsdt->entry[i+1] = secondary_tables[i];
   4.159 +    rsdt->header.length = sizeof(struct acpi_header) + (i+1)*sizeof(uint32_t);
   4.160 +    offset += align16(rsdt->header.length);
   4.161      set_checksum(rsdt,
   4.162                   offsetof(struct acpi_header, checksum),
   4.163                   rsdt->header.length);
   4.164  
   4.165      rsdp = (struct acpi_20_rsdp *)&buf[offset];
   4.166      memcpy(rsdp, &Rsdp, sizeof(struct acpi_20_rsdp));
   4.167 -    inc_offset(sizeof(struct acpi_20_rsdp));
   4.168 +    offset += align16(sizeof(struct acpi_20_rsdp));
   4.169      rsdp->rsdt_address = (unsigned long)rsdt;
   4.170      rsdp->xsdt_address = (unsigned long)xsdt;
   4.171      set_checksum(rsdp,
   4.172 @@ -190,8 +230,6 @@ int acpi_build_tables(uint8_t *buf)
   4.173                   offsetof(struct acpi_20_rsdp, extended_checksum),
   4.174                   sizeof(struct acpi_20_rsdp));
   4.175  
   4.176 -#undef inc_offset
   4.177 -
   4.178      return offset;
   4.179  }
   4.180  
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.asl	Tue Nov 28 15:47:52 2006 +0000
     5.3 @@ -0,0 +1,29 @@
     5.4 +//**********************************************************************//
     5.5 +//*
     5.6 +//* Copyright (c) 2006, IBM Corporation.
     5.7 +//*
     5.8 +//* This program is free software; you can redistribute it and/or modify it
     5.9 +//* under the terms and conditions of the GNU General Public License,
    5.10 +//* version 2, as published by the Free Software Foundation.
    5.11 +//*
    5.12 +//* This program is distributed in the hope it will be useful, but WITHOUT
    5.13 +//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    5.14 +//* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    5.15 +//* more details.
    5.16 +//*
    5.17 +//* You should have received a copy of the GNU General Public License along with
    5.18 +//* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    5.19 +//* Place - Suite 330, Boston, MA 02111-1307 USA.
    5.20 +
    5.21 +//*  SSDT for TPM TIS Interface for Xen with Qemu device model
    5.22 +
    5.23 +DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
    5.24 +{
    5.25 +    Device (TPM) {
    5.26 +        Name (_HID, EisaId ("PNP0C31"))
    5.27 +        Name (_CRS, ResourceTemplate ()
    5.28 +        {
    5.29 +            Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
    5.30 +        })
    5.31 +    }
    5.32 +}
    5.33 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/tools/firmware/hvmloader/acpi/ssdt_tpm.h	Tue Nov 28 15:47:52 2006 +0000
     6.3 @@ -0,0 +1,25 @@
     6.4 +/*
     6.5 + * 
     6.6 + * Intel ACPI Component Architecture
     6.7 + * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
     6.8 + * Copyright (C) 2000 - 2006 Intel Corporation
     6.9 + * Supports ACPI Specification Revision 3.0a
    6.10 + * 
    6.11 + * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
    6.12 + * 
    6.13 + * C source code output
    6.14 + *
    6.15 + */
    6.16 +unsigned char AmlCode_TPM[] =
    6.17 +{
    6.18 +    0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
    6.19 +    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
    6.20 +    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
    6.21 +    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    6.22 +    0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
    6.23 +    0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
    6.24 +    0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
    6.25 +    0x52,0x53,0x11,0x11,0x0A,0x0E,0x86,0x09,  /* 00000038    "RS......" */
    6.26 +    0x00,0x01,0x00,0x00,0xD4,0xFE,0x00,0x50,  /* 00000040    ".......P" */
    6.27 +    0x00,0x00,0x79,0x00,
    6.28 +};
     7.1 --- a/tools/firmware/hvmloader/acpi_ssdt_tpm.asl	Tue Nov 28 15:25:26 2006 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,29 +0,0 @@
     7.4 -//**********************************************************************//
     7.5 -//*
     7.6 -//* Copyright (c) 2006, IBM Corporation.
     7.7 -//*
     7.8 -//* This program is free software; you can redistribute it and/or modify it
     7.9 -//* under the terms and conditions of the GNU General Public License,
    7.10 -//* version 2, as published by the Free Software Foundation.
    7.11 -//*
    7.12 -//* This program is distributed in the hope it will be useful, but WITHOUT
    7.13 -//* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    7.14 -//* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    7.15 -//* more details.
    7.16 -//*
    7.17 -//* You should have received a copy of the GNU General Public License along with
    7.18 -//* this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    7.19 -//* Place - Suite 330, Boston, MA 02111-1307 USA.
    7.20 -
    7.21 -//*  SSDT for TPM TIS Interface for Xen with Qemu device model
    7.22 -
    7.23 -DefinitionBlock ("SSDT_TPM.aml", "SSDT", 1, "IBM","xen", 2006)
    7.24 -{
    7.25 -    Device (TPM) {
    7.26 -        Name (_HID, EisaId ("PNP0C31"))
    7.27 -        Name (_CRS, ResourceTemplate ()
    7.28 -        {
    7.29 -            Memory32Fixed (ReadWrite, 0xFED40000, 0x5000,)
    7.30 -        })
    7.31 -    }
    7.32 -}
    7.33 \ No newline at end of file
     8.1 --- a/tools/firmware/hvmloader/acpi_ssdt_tpm.h	Tue Nov 28 15:25:26 2006 +0000
     8.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     8.3 @@ -1,25 +0,0 @@
     8.4 -/*
     8.5 - * 
     8.6 - * Intel ACPI Component Architecture
     8.7 - * ASL Optimizing Compiler version 20060707 [Sep 11 2006]
     8.8 - * Copyright (C) 2000 - 2006 Intel Corporation
     8.9 - * Supports ACPI Specification Revision 3.0a
    8.10 - * 
    8.11 - * Compilation of "acpi_ssdt_tpm.asl" - Mon Oct 30 11:28:27 2006
    8.12 - * 
    8.13 - * C source code output
    8.14 - *
    8.15 - */
    8.16 -unsigned char AmlCode_TPM[] =
    8.17 -{
    8.18 -    0x53,0x53,0x44,0x54,0x4C,0x00,0x00,0x00,  /* 00000000    "SSDTL..." */
    8.19 -    0x01,0x6D,0x49,0x42,0x4D,0x00,0x00,0x00,  /* 00000008    ".mIBM..." */
    8.20 -    0x78,0x65,0x6E,0x00,0x00,0x00,0x00,0x00,  /* 00000010    "xen....." */
    8.21 -    0xD6,0x07,0x00,0x00,0x49,0x4E,0x54,0x4C,  /* 00000018    "....INTL" */
    8.22 -    0x07,0x07,0x06,0x20,0x5B,0x82,0x26,0x54,  /* 00000020    "... [.&T" */
    8.23 -    0x50,0x4D,0x5F,0x08,0x5F,0x48,0x49,0x44,  /* 00000028    "PM_._HID" */
    8.24 -    0x0C,0x41,0xD0,0x0C,0x31,0x08,0x5F,0x43,  /* 00000030    ".A..1._C" */
    8.25 -    0x52,0x53,0x11,0x11,0x0A,0x0E,0x86,0x09,  /* 00000038    "RS......" */
    8.26 -    0x00,0x01,0x00,0x00,0xD4,0xFE,0x00,0x50,  /* 00000040    ".......P" */
    8.27 -    0x00,0x00,0x79,0x00,
    8.28 -};
     9.1 --- a/tools/firmware/hvmloader/acpi_utils.c	Tue Nov 28 15:25:26 2006 +0000
     9.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     9.3 @@ -1,318 +0,0 @@
     9.4 -/*
     9.5 - * Commonly used ACPI utility functions.
     9.6 - * Probing for devices and writing SSDT entries into XSDT and RSDT tables.
     9.7 - *
     9.8 - * Yu Ke, ke.yu@intel.com
     9.9 - * Copyright (c) 2005, Intel Corporation.
    9.10 - * Copyright (c) 2006, IBM Corporation.
    9.11 - *
    9.12 - * This program is free software; you can redistribute it and/or modify it
    9.13 - * under the terms and conditions of the GNU General Public License,
    9.14 - * version 2, as published by the Free Software Foundation.
    9.15 - *
    9.16 - * This program is distributed in the hope it will be useful, but WITHOUT
    9.17 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
    9.18 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
    9.19 - * more details.
    9.20 - *
    9.21 - * You should have received a copy of the GNU General Public License along with
    9.22 - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
    9.23 - * Place - Suite 330, Boston, MA 02111-1307 USA.
    9.24 - */
    9.25 -
    9.26 -#include "acpi/acpi2_0.h"
    9.27 -#include "acpi_utils.h"
    9.28 -#include "util.h"
    9.29 -#include <xen/hvm/e820.h>
    9.30 -
    9.31 -static int acpi_rsdt_add_entry_pointer(unsigned char *acpi_start,
    9.32 -                                       unsigned char *entry);
    9.33 -static int acpi_xsdt_add_entry_pointer(unsigned char *acpi_start,
    9.34 -                                       unsigned char *entry);
    9.35 -static unsigned char *acpi_xsdt_add_entry(unsigned char *acpi_start,
    9.36 -                                          unsigned char **freemem,
    9.37 -                                          unsigned char *limit,
    9.38 -                                          unsigned char *table,
    9.39 -                                          unsigned int table_size);
    9.40 -
    9.41 -void set_checksum(void *start, int checksum_offset, int len)
    9.42 -{
    9.43 -    unsigned char sum = 0;
    9.44 -    unsigned char *ptr;
    9.45 -
    9.46 -    ptr = start;
    9.47 -    ptr[checksum_offset] = 0;
    9.48 -    while ( len-- )
    9.49 -        sum += *ptr++;
    9.50 -
    9.51 -    ptr = start;
    9.52 -    ptr[checksum_offset] = -sum;
    9.53 -}
    9.54 -
    9.55 -
    9.56 -#include "acpi_ssdt_tpm.h"
    9.57 -static void acpi_tpm_tis_probe(unsigned char *acpi_start,
    9.58 -                               unsigned char **freemem,
    9.59 -                               unsigned char *limit)
    9.60 -{
    9.61 -    unsigned char *addr;
    9.62 -    ACPI_2_0_TCPA_CLIENT *tcpa;
    9.63 -    /* check TPM_DID, TPM_VID, TPM_RID in ioemu/hw/tpm_tis.c */
    9.64 -    uint16_t tis_did_vid_rid[] = {0x0001, 0x0001, 0x0001};
    9.65 -    static const ACPI_2_0_TCPA_CLIENT Tcpa = {
    9.66 -        .header = {
    9.67 -            .signature = ACPI_2_0_TCPA_SIGNATURE,
    9.68 -            .length    = sizeof(ACPI_2_0_TCPA_CLIENT),
    9.69 -            .revision  = ACPI_2_0_TCPA_REVISION,
    9.70 -            .oem_id    = {'I', 'B', 'M', ' ', ' ', ' '},
    9.71 -            .oem_table_id = ASCII64(' ', ' ', ' ', ' ', ' ', 'x', 'e', 'n'),
    9.72 -            .oem_revision = 1,
    9.73 -            .creator_id   = ASCII32('I', 'B', 'M', ' '),
    9.74 -            .creator_revision = 1,
    9.75 -        }
    9.76 -    };
    9.77 -
    9.78 -    /* probe for TIS interface ... */
    9.79 -    if ( memcmp((char *)(0xFED40000 + 0xF00),
    9.80 -                tis_did_vid_rid,
    9.81 -                sizeof(tis_did_vid_rid)) != 0 )
    9.82 -        return;
    9.83 -
    9.84 -    printf("TIS is available\n");
    9.85 -    addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
    9.86 -                               AmlCode_TPM, sizeof(AmlCode_TPM));
    9.87 -    if ( addr == NULL )
    9.88 -        return;
    9.89 -
    9.90 -    /* legacy systems need an RSDT entry */
    9.91 -    if ( acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1 )
    9.92 -        return;
    9.93 -
    9.94 -    /* add ACPI TCPA table */
    9.95 -    addr = acpi_xsdt_add_entry(acpi_start, freemem, limit,
    9.96 -                               (unsigned char *)&Tcpa,
    9.97 -                               sizeof(Tcpa));
    9.98 -    if ( addr == NULL )
    9.99 -        return;
   9.100 -
   9.101 -    tcpa = (ACPI_2_0_TCPA_CLIENT *)addr;
   9.102 -    tcpa->LASA = e820_malloc(
   9.103 -        ACPI_2_0_TCPA_LAML_SIZE, E820_RESERVED, (uint32_t)~0);
   9.104 -    if ( tcpa->LASA )
   9.105 -    {
   9.106 -        tcpa->LAML = ACPI_2_0_TCPA_LAML_SIZE;
   9.107 -        memset((char *)(unsigned long)tcpa->LASA,
   9.108 -               0x0,
   9.109 -               tcpa->LAML);
   9.110 -        set_checksum(tcpa,
   9.111 -                     FIELD_OFFSET(struct acpi_header, checksum),
   9.112 -                     tcpa->header.length);
   9.113 -    }
   9.114 -
   9.115 -    if ( acpi_rsdt_add_entry_pointer(acpi_start, addr) != 1 )
   9.116 -        return;
   9.117 -}
   9.118 -
   9.119 -
   9.120 -/*
   9.121 - * Call functions that probe for devices and have them register their
   9.122 - * SSDT entries with the XSDT and RSDT tables.
   9.123 - */
   9.124 -void acpi_update(unsigned char *acpi_start,
   9.125 -                 unsigned long acpi_size,
   9.126 -                 unsigned char *limit,
   9.127 -                 unsigned char **freemem)
   9.128 -{
   9.129 -    acpi_tpm_tis_probe(acpi_start, freemem, limit);
   9.130 -}
   9.131 -
   9.132 -
   9.133 -/*
   9.134 - * Search for the RSDP in memory below the BIOS
   9.135 - */
   9.136 -struct acpi_20_rsdp *acpi_rsdp_get(unsigned char *acpi_start)
   9.137 -{
   9.138 -    int offset = 0;
   9.139 -    int found = 0;
   9.140 -    static int displayed = 0;
   9.141 -    struct acpi_20_rsdp *rsdp;
   9.142 -
   9.143 -    while ( &acpi_start[offset] < (unsigned char *)0xf0000 )
   9.144 -    {
   9.145 -        rsdp = (struct acpi_20_rsdp *)&acpi_start[offset];
   9.146 -        if ( rsdp->signature == ACPI_2_0_RSDP_SIGNATURE )
   9.147 -        {
   9.148 -            found = 1;
   9.149 -            break;
   9.150 -        }
   9.151 -        offset += 0x10;
   9.152 -    }
   9.153 -    
   9.154 -    if ( !found )
   9.155 -        rsdp = NULL;
   9.156 -
   9.157 -    if ( !displayed )
   9.158 -    {
   9.159 -        if ( rsdp )
   9.160 -            printf("Found RSDP at %lx\n",(long)rsdp);
   9.161 -        else
   9.162 -            printf("ERROR: RSDP was not found\n");
   9.163 -        displayed = 1;
   9.164 -    }
   9.165 -
   9.166 -    return rsdp;
   9.167 -}
   9.168 -
   9.169 -
   9.170 -struct acpi_20_rsdt *acpi_rsdt_get(unsigned char *acpi_start)
   9.171 -{
   9.172 -    struct acpi_20_rsdp *rsdp;
   9.173 -    struct acpi_20_rsdt *rsdt;
   9.174 -
   9.175 -    rsdp = acpi_rsdp_get(acpi_start);
   9.176 -    if (!rsdp)
   9.177 -        return NULL;
   9.178 -
   9.179 -    rsdt = (struct acpi_20_rsdt *)
   9.180 -        (acpi_start + rsdp->rsdt_address - ACPI_PHYSICAL_ADDRESS);
   9.181 -    if ( rsdt->header.signature != ACPI_2_0_RSDT_SIGNATURE )
   9.182 -    {
   9.183 -        printf("Bad RSDT signature\n");
   9.184 -        return NULL;
   9.185 -    }
   9.186 -
   9.187 -    return rsdt;
   9.188 -}
   9.189 -
   9.190 -/*
   9.191 - * Add an entry to the RSDT table given the pointer to the entry.
   9.192 - */
   9.193 -static int acpi_rsdt_add_entry_pointer(unsigned char *acpi_start,
   9.194 -                                       unsigned char *entry)
   9.195 -{
   9.196 -    struct acpi_20_rsdt *rsdt = acpi_rsdt_get(acpi_start);
   9.197 -    int found = 0;
   9.198 -    int i = 0;
   9.199 -
   9.200 -    /* Find an empty slot in the RSDT table. */
   9.201 -    while ( i < ACPI_MAX_NUM_TABLES )
   9.202 -    {
   9.203 -        if ( rsdt->entry[i] == 0 )
   9.204 -        {
   9.205 -            found = 1;
   9.206 -            break;
   9.207 -        }
   9.208 -        i++;
   9.209 -    }
   9.210 -
   9.211 -    if ( found )
   9.212 -    {
   9.213 -        rsdt->entry[i] = (uint64_t)(unsigned long)entry;
   9.214 -        rsdt->header.length =
   9.215 -            sizeof(struct acpi_header) +
   9.216 -            (i + 1) * sizeof(uint64_t);
   9.217 -        set_checksum(rsdt,
   9.218 -                     FIELD_OFFSET(struct acpi_header, checksum),
   9.219 -                     rsdt->header.length);
   9.220 -    }
   9.221 -
   9.222 -    return found;
   9.223 -}
   9.224 -
   9.225 -/* Get the XSDT table. */
   9.226 -struct acpi_20_xsdt *acpi_xsdt_get(unsigned char *acpi_start)
   9.227 -{
   9.228 -    struct acpi_20_rsdp *rsdp;
   9.229 -    struct acpi_20_xsdt *xsdt;
   9.230 -
   9.231 -    rsdp = acpi_rsdp_get(acpi_start);
   9.232 -    if (!rsdp)
   9.233 -        return NULL;
   9.234 -
   9.235 -    xsdt = (struct acpi_20_xsdt *)
   9.236 -        (acpi_start + rsdp->xsdt_address - ACPI_PHYSICAL_ADDRESS);
   9.237 -    if ( xsdt->header.signature != ACPI_2_0_XSDT_SIGNATURE )
   9.238 -    {
   9.239 -        printf("Bad XSDT signature\n");
   9.240 -        return NULL;
   9.241 -    }
   9.242 -    return xsdt;
   9.243 -}
   9.244 -
   9.245 -/*
   9.246 - * Add an entry to the XSDT table given the pointer to the entry.
   9.247 - */
   9.248 -static int acpi_xsdt_add_entry_pointer(unsigned char *acpi_start,
   9.249 -                                       unsigned char *entry)
   9.250 -{
   9.251 -    struct acpi_20_xsdt *xsdt = acpi_xsdt_get(acpi_start);
   9.252 -    int found = 0;
   9.253 -    int i = 0;
   9.254 -
   9.255 -    /* Find an empty slot in the XSDT table. */
   9.256 -    while ( i < ACPI_MAX_NUM_TABLES )
   9.257 -    {
   9.258 -        if ( xsdt->entry[i] == 0 )
   9.259 -        {
   9.260 -            found = 1;
   9.261 -            break;
   9.262 -        }
   9.263 -        i++;
   9.264 -    }
   9.265 -
   9.266 -    if ( found )
   9.267 -    {
   9.268 -        xsdt->entry[i] = (uint64_t)(unsigned long)entry;
   9.269 -        xsdt->header.length =
   9.270 -            sizeof(struct acpi_header) +
   9.271 -            (i + 1) * sizeof(uint64_t);
   9.272 -        set_checksum(xsdt,
   9.273 -                     FIELD_OFFSET(struct acpi_header, checksum),
   9.274 -                     xsdt->header.length);
   9.275 -    }
   9.276 -
   9.277 -    return found;
   9.278 -}
   9.279 -
   9.280 -/*
   9.281 -   add an entry to the xdst table entry pointers
   9.282 -   copy the given ssdt data to the current available memory at
   9.283 -   freemem, if it does not exceed the limit
   9.284 - */
   9.285 -static unsigned char *acpi_xsdt_add_entry(unsigned char *acpi_start,
   9.286 -                                          unsigned char **freemem,
   9.287 -                                          unsigned char *limit,
   9.288 -                                          unsigned char *table,
   9.289 -                                          unsigned int table_size)
   9.290 -{
   9.291 -    struct acpi_20_xsdt *xsdt = acpi_xsdt_get(acpi_start);
   9.292 -    int found = 0, i = 0;
   9.293 -    unsigned char *addr = NULL;
   9.294 -
   9.295 -    /* Check for an empty slot in the Xsdt table. */
   9.296 -    while ( i < ACPI_MAX_NUM_TABLES )
   9.297 -    {
   9.298 -        if ( xsdt->entry[i] == 0 )
   9.299 -        {
   9.300 -            found = 1;
   9.301 -            break;
   9.302 -        }
   9.303 -        i++;
   9.304 -    }
   9.305 -
   9.306 -    if ( found )
   9.307 -    {
   9.308 -        /* memory below hard limit ? */
   9.309 -        if ( (*freemem + table_size) <= limit )
   9.310 -        {
   9.311 -            addr = *freemem;
   9.312 -            memcpy(addr, table, table_size);
   9.313 -            printf("Copied dyn. ACPI entry to %lx\n",(long)addr);
   9.314 -            *freemem += ((table_size + 0xf) & ~0xf);
   9.315 -
   9.316 -            acpi_xsdt_add_entry_pointer(acpi_start, addr);
   9.317 -        }
   9.318 -    }
   9.319 -
   9.320 -    return addr;
   9.321 -}
    10.1 --- a/tools/firmware/hvmloader/acpi_utils.h	Tue Nov 28 15:25:26 2006 +0000
    10.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    10.3 @@ -1,36 +0,0 @@
    10.4 -/*
    10.5 - * Commonly used ACPI utility functions.
    10.6 - *
    10.7 - * Yu Ke, ke.yu@intel.com
    10.8 - * Copyright (c) 2005, Intel Corporation.
    10.9 - *
   10.10 - * This program is free software; you can redistribute it and/or modify it
   10.11 - * under the terms and conditions of the GNU General Public License,
   10.12 - * version 2, as published by the Free Software Foundation.
   10.13 - *
   10.14 - * This program is distributed in the hope it will be useful, but WITHOUT
   10.15 - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
   10.16 - * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for
   10.17 - * more details.
   10.18 - *
   10.19 - * You should have received a copy of the GNU General Public License along with
   10.20 - * this program; if not, write to the Free Software Foundation, Inc., 59 Temple
   10.21 - * Place - Suite 330, Boston, MA 02111-1307 USA.
   10.22 - */
   10.23 -#ifndef ACPI_UTILS_H
   10.24 -#define ACPI_UTILS_H
   10.25 -
   10.26 -#define FIELD_OFFSET(TYPE,Field) ((unsigned int)(&(((TYPE *) 0)->Field)))
   10.27 -
   10.28 -#define NULL ((void*)0)
   10.29 -
   10.30 -void set_checksum(void *start, int checksum_offset, int len);
   10.31 -void acpi_update(unsigned char *acpi_start,
   10.32 -                 unsigned long acpi_size,
   10.33 -                 unsigned char *limit,
   10.34 -                 unsigned char **freemem);
   10.35 -
   10.36 -struct acpi_20_rsdt *acpi_rsdt_get(unsigned char *acpi_start);
   10.37 -struct acpi_20_xsdt *acpi_xsdt_get(unsigned char *acpi_start);
   10.38 -
   10.39 -#endif
    11.1 --- a/tools/firmware/hvmloader/hvmloader.c	Tue Nov 28 15:25:26 2006 +0000
    11.2 +++ b/tools/firmware/hvmloader/hvmloader.c	Tue Nov 28 15:47:52 2006 +0000
    11.3 @@ -23,7 +23,6 @@
    11.4  #include "acpi/acpi2_0.h"  /* for ACPI_PHYSICAL_ADDRESS */
    11.5  #include "hypercall.h"
    11.6  #include "util.h"
    11.7 -#include "acpi_utils.h"
    11.8  #include "smbios.h"
    11.9  #include "config.h"
   11.10  #include "apic_regs.h"
   11.11 @@ -283,7 +282,6 @@ static void pci_setup(void)
   11.12  int main(void)
   11.13  {
   11.14      int acpi_sz;
   11.15 -    uint8_t *freemem;
   11.16  
   11.17      printf("HVM Loader\n");
   11.18  
   11.19 @@ -318,12 +316,7 @@ int main(void)
   11.20      {
   11.21          printf("Loading ACPI ...\n");
   11.22          acpi_sz = acpi_build_tables((uint8_t *)ACPI_PHYSICAL_ADDRESS);
   11.23 -        freemem = (uint8_t *)ACPI_PHYSICAL_ADDRESS + acpi_sz;
   11.24 -        ASSERT(freemem <= (uint8_t *)0xF0000);
   11.25 -        acpi_update((unsigned char *)ACPI_PHYSICAL_ADDRESS,
   11.26 -                    freemem - (uint8_t *)ACPI_PHYSICAL_ADDRESS,
   11.27 -                    (unsigned char *)0xF0000,
   11.28 -                    &freemem);
   11.29 +        ASSERT((ACPI_PHYSICAL_ADDRESS + acpi_sz) <= 0xF0000);
   11.30      }
   11.31  
   11.32      if ( check_amd() )
    12.1 --- a/tools/firmware/hvmloader/mp_tables.c	Tue Nov 28 15:25:26 2006 +0000
    12.2 +++ b/tools/firmware/hvmloader/mp_tables.c	Tue Nov 28 15:47:52 2006 +0000
    12.3 @@ -28,7 +28,6 @@
    12.4   * Place - Suite 330, Boston, MA 02111-1307 USA.
    12.5   */
    12.6  
    12.7 -#include <acpi_utils.h>
    12.8  #include "config.h"
    12.9  
   12.10  /* FIXME find a header that already has types defined!!! */
    13.1 --- a/tools/firmware/hvmloader/util.h	Tue Nov 28 15:25:26 2006 +0000
    13.2 +++ b/tools/firmware/hvmloader/util.h	Tue Nov 28 15:47:52 2006 +0000
    13.3 @@ -6,6 +6,9 @@
    13.4  #undef offsetof
    13.5  #define offsetof(t, m) ((unsigned long)&((t *)0)->m)
    13.6  
    13.7 +#undef NULL
    13.8 +#define NULL ((void*)0)
    13.9 +
   13.10  extern void __assert_failed(char *assertion, char *file, int line)
   13.11      __attribute__((noreturn));
   13.12  #define ASSERT(p) \