Dynamically add probed devices to the ACPI's XSDT and RSDT using SSDT entries
PATCH 1/1 Dynamically add probed devices to the ACPI's XSDT and RSDT using SSDT entries
The attached patch enables the hvmloader to dynamically add probed for devices to the ACPI's XSDT and RSDT tables using SSDT entries. I have implemented the probing for the TPM TIS interface.
First the static ACPI table is copied into the 0xe000 segment and then devices may be probed and their SSDT ACPI entries may be copied behind the static ACPI tables considering the barrier at 0xf 0000 where the BIOS lives. The SSDT entries are linked to the XSDT and RSDT tables which for now has 3 empty slots. The XSDT table is then updated and checksummed again. I rearranged those ACPI functions that are commonly used to be in acpi_utils.c.
xen-unstable.hg/tools/firmware/hvmloader/hvmloader.c +7 -0
@@ -25,6 +25,7 @@#include "../acpi/acpi2_0.h" /* for ACPI_PHYSICAL_ADDRESS */ #include "hypercall.h" #include "util.h" +#include "acpi_utils.h" #include "smbios.h" #include <xen/version.h> #include <xen/hvm/params.h>
@@ -195,12 +196,18 @@ main(void)puts ("Loading ACPI ...\n" );acpi_madt_update ((unsigned char *) acpi);if (ACPI_PHYSICAL_ADDRESS +sizeof (acpi) <=0xF0000 ) { +unsigned char *freemem = (unsigned char *) + (ACPI_PHYSICAL_ADDRESS +sizeof (acpi));/* * Make sure acpi table does not overlap rombios * currently acpi less than 8K will be OK. */ memcpy ((void *)ACPI_PHYSICAL_ADDRESS , acpi,sizeof (acpi)); +acpi_update ((unsigned char *)ACPI_PHYSICAL_ADDRESS , +sizeof (acpi), + (unsigned char *)0xF0000 , + &freemem); } }
xen-unstable.hg/tools/firmware/hvmloader/Makefile +30 -2
@@ -40,13 +40,29 @@ OBJCOPY = objcopy CFLAGS += $(DEFINES) -I. $(XENINC) -fno-builtin -O2 -msoft-float LDFLAGS = -nostdlib -Wl,-N -Wl,-Ttext -Wl,$(LOADADDR) -SRCS = hvmloader.c acpi_madt.c mp_tables.c util.c smbios.c +vpath iasl $(PATH) + +SRCS = hvmloader.c \ + acpi_madt.c \ + acpi_rsdt.c \ + acpi_utils.c \ + acpi_xsdt.c \ + mp_tables.c \ + util.c \ + smbios.c OBJS = $(patsubst %.c,%.o,$(SRCS)) +SSDT_SRCS = acpi_ssdt_tpm.h .PHONY: all all: hvmloader -hvmloader: roms.h $(SRCS) +acpi_ssdt_tpm.h: acpi_ssdt_tpm.asl + $(MAKE) iasl + iasl -tc $^ + cat acpi_ssdt_tpm.hex | sed "s/AmlCode/AmlCode_TPM/" > $@ + rm -rf acpi_ssdt_tpm.hex + +hvmloader: roms.h $(SSDT_SRCS) $(SRCS) $(CC) $(CFLAGS) -c $(SRCS) $(CC) $(CFLAGS) $(LDFLAGS) -o hvmloader.tmp $(OBJS) $(OBJCOPY) hvmloader.tmp hvmloader
@@ -59,6 +75,18 @@ roms.h: ../rombios/BIOS-bochs-latest ../ sh ./mkhex vmxassist ../vmxassist/vmxassist.bin >> roms.h sh ./mkhex acpi ../acpi/acpi.bin >> roms.h +iasl: + @echo + @echo "ACPI ASL compiler(iasl) is needed" + @echo "Download Intel ACPI CA" + @echo "If wget failed, please download and compile manually from" + @echo "http://developer.intel.com/technology/iapc/acpi/downloads.htm" + @echo + wget $(IASL_URL) + tar xzf $(IASL_VER).tar.gz + make -C $(IASL_VER)/compiler + $(INSTALL_PROG) $(IASL_VER)/compiler/iasl /usr/bin/iasl + .PHONY: clean clean: rm -f roms.h acpi.h
xen-unstable.hg/tools/firmware/acpi/acpi2_0.h +1 -1
@@ -111,7 +111,7 @@ typedef struct {// // The maximum number of entrys in RSDT or XSDT // -#define ACPI_MAX_NUM_TABLES 2 +#define ACPI_MAX_NUM_TABLES 5// // Root System Description Table (RSDT)
xen-unstable.hg/tools/firmware/acpi/acpi_build.c +8 -0
@@ -105,6 +105,7 @@ UpdateTable(* Caculate the checksum */ { +int i;// RSDP Update table->Rsdp->RsdtAddress = (uint32_t )(ACPI_PHYSICAL_ADDRESS + table->RsdtOffset);
@@ -132,6 +133,9 @@ UpdateTable(FIELD_OFFSET (ACPI_TABLE_HEADER , Checksum), table->Rsdt->Header.Length ); + +for (i =2 ; i <ACPI_MAX_NUM_TABLES ; i++) + table->Rsdt->Entry[i] =0 ;//XSDT Update table->Xsdt->Entry[0] = (uint64_t)(ACPI_PHYSICAL_ADDRESS +
@@ -145,6 +149,10 @@ UpdateTable( table->Xsdt->Header.Length ); +for (i =2 ; i <ACPI_MAX_NUM_TABLES ; i++) + table->Xsdt->Entry[i] =0 ; + +// FADT Update table->Fadt->Dsdt = (uint32_t )(ACPI_PHYSICAL_ADDRESS + table->DsdtOffset);
xen-unstable.hg/tools/firmware/hvmloader/acpi_madt.c +5 -28
@@ -20,7 +20,9 @@#include "../acpi/acpi2_0.h" #include "../acpi/acpi_madt.h" +#include "acpi_rsdt.h" #include "util.h" +#include "acpi_utils.h" #include <xen/hvm/hvm_info_table.h> #define NULL ((void*)0)
@@ -87,22 +89,12 @@ get_acpi_enabled(void)static void *acpi_madt_get_madt (unsigned char *acpi_start) { -ACPI_2_0_RSDP *rsdp=NULL ;ACPI_2_0_RSDT *rsdt=NULL ;ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE *madt; - rsdp = (ACPI_2_0_RSDP *)(acpi_start +sizeof (ACPI_2_0_FACS )); -if (rsdp->Signature !=ACPI_2_0_RSDP_SIGNATURE ) { -puts ("Bad RSDP signature\n" ); -return NULL ; - } - - rsdt= (ACPI_2_0_RSDT *) - (acpi_start + rsdp->RsdtAddress -ACPI_PHYSICAL_ADDRESS ); -if (rsdt->Header.Signature !=ACPI_2_0_RSDT_SIGNATURE ) { -puts ("Bad RSDT signature\n" ); -return NULL ; - } + rsdt =acpi_rsdt_get (acpi_start); +if (rsdt ==NULL ) +return NULL ; madt = (ACPI_MULTIPLE_APIC_DESCRIPTION_TABLE *) ( acpi_start+ rsdt->Entry[1 ] -ACPI_PHYSICAL_ADDRESS );
@@ -115,21 +107,6 @@ acpi_madt_get_madt(unsigned char *acpi_sreturn madt; } -static 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; -} - static int acpi_madt_set_local_apics( int nr_vcpu,
xen-unstable.hg/tools/firmware/hvmloader/acpi_ssdt_tpm.asl new file +29 -0
@@ -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,) + }) + } +}
xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.c new file +82 -0
82 lines not on this page · raw message
xen-unstable.hg/tools/firmware/hvmloader/acpi_utils.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* Commonly used ACPI utility functions. +* +* Yu Ke, [email protected] +* 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); + +#endif
xen-unstable.hg/tools/firmware/hvmloader/acpi_ssdt_tpm.h new file +25 -0
@@ -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 , +};
xen-unstable.hg/tools/firmware/hvmloader/acpi_xsdt.c new file +89 -0
89 lines not on this page · raw message
xen-unstable.hg/tools/firmware/hvmloader/acpi_xsdt.h new file +16 -0
@@ -0,0 +1,16 @@ +/* +* acpi_xsdt.h: Handling of XSDT entries. +* +* Copyright (c) 2006, IBM Corporation. +*/ +#ifndef ACPI_XSDT_H +#define ACPI_XSDT_H + +ACPI_2_0_XSDT *acpi_xsdt_get (unsigned char *acpi_start); +unsigned char *acpi_xsdt_add_entry (unsigned char *acpi_start, +unsigned char **freemem, +unsigned char *limit, +unsigned char *table, +unsigned int table_size); + +#endif
xen-unstable.hg/tools/firmware/hvmloader/acpi_rsdt.c new file +76 -0
76 lines not on this page · raw message
xen-unstable.hg/tools/firmware/hvmloader/acpi_rsdt.h new file +15 -0
@@ -0,0 +1,15 @@ +/* +* acpi_xsdt.h: Handling of ACPI RSDT table and entries. +* +* Copyright (c) 2005, Intel Corporation. +* Copyright (c) 2006, IBM Corporation. +*/ +#ifndef ACPI_RSDT_H +#define ACPI_RSDT_H + +ACPI_2_0_RSDT *acpi_rsdt_get (unsigned char *acpi_start); +int acpi_rsdt_add_entry_pointer (unsigned char *acpi_start, +unsigned char *entry); + + +#endif
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel