[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 11/21] acpi/hvmloader: Include file/paths adjustments
In prepearation to moving acpi sources into generally available libacpi: 1. Pass IOAPIC/LAPIC/PCI mask values via struct acpi_config 2. Modify include files search paths to point to acpi directory 3. Macro-ise include file for build.c that defines various utilities used by that file. Users of libacpi will be expected to define this macro when compiling build.c Signed-off-by: Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx> --- Changes in v4: * Include xen/memory.h in build.c * lapic_id() returns uint8_t tools/firmware/hvmloader/Makefile | 3 ++- tools/firmware/hvmloader/acpi/README | 16 ++++++++++++---- tools/firmware/hvmloader/acpi/build.c | 19 ++++++++++--------- tools/firmware/hvmloader/acpi/libacpi.h | 7 +++++++ tools/firmware/hvmloader/hvmloader.c | 2 +- tools/firmware/hvmloader/rombios.c | 2 +- tools/firmware/hvmloader/seabios.c | 5 +++-- tools/firmware/hvmloader/util.c | 15 +++++++++++++-- tools/firmware/rombios/32bit/Makefile | 2 +- tools/firmware/rombios/32bit/tcgbios/Makefile | 2 +- tools/firmware/rombios/32bit/util.h | 2 +- 11 files changed, 52 insertions(+), 23 deletions(-) diff --git a/tools/firmware/hvmloader/Makefile b/tools/firmware/hvmloader/Makefile index 2565832..7b3641c 100644 --- a/tools/firmware/hvmloader/Makefile +++ b/tools/firmware/hvmloader/Makefile @@ -80,7 +80,8 @@ smbios.o: CFLAGS += -D__SMBIOS_DATE__="\"$(SMBIOS_REL_DATE)\"" ACPI_PATH = acpi ACPI_FILES = dsdt_anycpu.c dsdt_15cpu.c dsdt_anycpu_qemu_xen.c ACPI_OBJS = $(patsubst %.c,%.o,$(ACPI_FILES)) build.o static_tables.o -$(ACPI_OBJS): CFLAGS += -I$(ACPI_PATH) -I. +$(ACPI_OBJS): CFLAGS += -I. -DLIBACPI_STDUTILS=\"../util.h\" +CFLAGS += -I$(ACPI_PATH) vpath build.c $(ACPI_PATH) vpath static_tables.c $(ACPI_PATH) OBJS += $(ACPI_OBJS) diff --git a/tools/firmware/hvmloader/acpi/README b/tools/firmware/hvmloader/acpi/README index 210d5ba..2b9d6e1 100644 --- a/tools/firmware/hvmloader/acpi/README +++ b/tools/firmware/hvmloader/acpi/README @@ -1,11 +1,19 @@ -ACPI Table for domain firmware +ACPI builder for domain firmware -INSTALL +BUILDING ACPI ----------------- -Simply make is OK. -# make +Users of ACPI builder are expected to provide an include file that makes available +the following: +* strncpy +* printf +* NULL +* test_bit +* offsetof +When compiling build.c, the name of this include file should be given to +compiler as -DLIBACPI_STDUTILS=\"<filename>\". See tools/firmware/hvmloader/Makefile +for an example. Note on DSDT Table ------------------ diff --git a/tools/firmware/hvmloader/acpi/build.c b/tools/firmware/hvmloader/acpi/build.c index b295ef0..00fb67e 100644 --- a/tools/firmware/hvmloader/acpi/build.c +++ b/tools/firmware/hvmloader/acpi/build.c @@ -13,15 +13,13 @@ * GNU Lesser General Public License for more details. */ +#include LIBACPI_STDUTILS #include "acpi2_0.h" #include "libacpi.h" #include "ssdt_s3.h" #include "ssdt_s4.h" #include "ssdt_tpm.h" #include "ssdt_pm.h" -#include "../config.h" -#include "../util.h" -#include "../vnuma.h" #include <xen/hvm/hvm_xs_strings.h> #include <xen/hvm/params.h> #include <xen/memory.h> @@ -82,6 +80,9 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, const struct hvm_info_table *hvminfo = config->hvminfo; int i, sz; + if ( config->lapic_id == NULL ) + return NULL; + sz = sizeof(struct acpi_20_madt); sz += sizeof(struct acpi_20_madt_intsrcovr) * 16; sz += sizeof(struct acpi_20_madt_ioapic); @@ -98,7 +99,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, madt->header.oem_revision = ACPI_OEM_REVISION; madt->header.creator_id = ACPI_CREATOR_ID; madt->header.creator_revision = ACPI_CREATOR_REVISION; - madt->lapic_addr = LAPIC_BASE_ADDRESS; + madt->lapic_addr = config->lapic_base_address; madt->flags = ACPI_PCAT_COMPAT; if ( config->table_flags & ACPI_HAS_IOAPIC ) @@ -117,7 +118,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, intsrcovr->gsi = 2; intsrcovr->flags = 0x0; } - else if ( PCI_ISA_IRQ_MASK & (1U << i) ) + else if ( config->pci_isa_irq_mask & (1U << i) ) { /* PCI: active-low level-triggered. */ intsrcovr->gsi = i; @@ -136,8 +137,8 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, memset(io_apic, 0, sizeof(*io_apic)); io_apic->type = ACPI_IO_APIC; io_apic->length = sizeof(*io_apic); - io_apic->ioapic_id = IOAPIC_ID; - io_apic->ioapic_addr = ioapic_base_address; + io_apic->ioapic_id = config->ioapic_id; + io_apic->ioapic_addr = config->ioapic_base_address; lapic = (struct acpi_20_madt_lapic *)(io_apic + 1); } @@ -153,7 +154,7 @@ static struct acpi_20_madt *construct_madt(struct acpi_ctxt *ctxt, lapic->length = sizeof(*lapic); /* Processor ID must match processor-object IDs in the DSDT. */ lapic->acpi_processor_id = i; - lapic->apic_id = LAPIC_ID(i); + lapic->apic_id = config->lapic_id(i); lapic->flags = (test_bit(i, hvminfo->vcpu_online) ? ACPI_LOCAL_APIC_ENABLED : 0); lapic++; @@ -241,7 +242,7 @@ static struct acpi_20_srat *construct_srat(struct acpi_ctxt *ctxt, processor->type = ACPI_PROCESSOR_AFFINITY; processor->length = sizeof(*processor); processor->domain = config->numa.vcpu_to_vnode[i]; - processor->apic_id = LAPIC_ID(i); + processor->apic_id = config->lapic_id(i); processor->flags = ACPI_LOCAL_APIC_AFFIN_ENABLED; processor++; } diff --git a/tools/firmware/hvmloader/acpi/libacpi.h b/tools/firmware/hvmloader/acpi/libacpi.h index 35b6f47..e386362 100644 --- a/tools/firmware/hvmloader/acpi/libacpi.h +++ b/tools/firmware/hvmloader/acpi/libacpi.h @@ -82,6 +82,13 @@ struct acpi_config { /* RSDP address */ unsigned int rsdp; + + /* x86-specific parameters */ + uint8_t (*lapic_id)(unsigned cpu); + uint32_t lapic_base_address; + uint32_t ioapic_base_address; + uint16_t pci_isa_irq_mask; + uint8_t ioapic_id; }; void acpi_build_tables(struct acpi_ctxt *ctxt, struct acpi_config *config); diff --git a/tools/firmware/hvmloader/hvmloader.c b/tools/firmware/hvmloader/hvmloader.c index bbd4e34..77b9536 100644 --- a/tools/firmware/hvmloader/hvmloader.c +++ b/tools/firmware/hvmloader/hvmloader.c @@ -24,8 +24,8 @@ #include "config.h" #include "pci_regs.h" #include "apic_regs.h" -#include "acpi/acpi2_0.h" #include "vnuma.h" +#include <acpi2_0.h> #include <xen/version.h> #include <xen/hvm/params.h> #include <xen/arch-x86/hvm/start_info.h> diff --git a/tools/firmware/hvmloader/rombios.c b/tools/firmware/hvmloader/rombios.c index 1e853ec..0df59f3 100644 --- a/tools/firmware/hvmloader/rombios.c +++ b/tools/firmware/hvmloader/rombios.c @@ -24,12 +24,12 @@ #include "../rombios/config.h" #include "smbios_types.h" -#include "acpi/libacpi.h" #include "pci_regs.h" #include "util.h" #include "hypercall.h" #include "option_rom.h" +#include <libacpi.h> #include <xen/hvm/params.h> #include <xen-tools/libs.h> diff --git a/tools/firmware/hvmloader/seabios.c b/tools/firmware/hvmloader/seabios.c index 44ff0d7..870576a 100644 --- a/tools/firmware/hvmloader/seabios.c +++ b/tools/firmware/hvmloader/seabios.c @@ -25,8 +25,9 @@ #include "util.h" #include "smbios_types.h" -#include "acpi/acpi2_0.h" -#include "acpi/libacpi.h" + +#include <acpi2_0.h> +#include <libacpi.h> extern unsigned char dsdt_anycpu_qemu_xen[]; extern int dsdt_anycpu_qemu_xen_len; diff --git a/tools/firmware/hvmloader/util.c b/tools/firmware/hvmloader/util.c index 3a423ab..6e0cfe7 100644 --- a/tools/firmware/hvmloader/util.c +++ b/tools/firmware/hvmloader/util.c @@ -22,8 +22,8 @@ #include "hypercall.h" #include "ctype.h" #include "vnuma.h" -#include "acpi/acpi2_0.h" -#include "acpi/libacpi.h" +#include <acpi2_0.h> +#include <libacpi.h> #include <stdint.h> #include <xen/xen.h> #include <xen/memory.h> @@ -883,6 +883,11 @@ static void acpi_mem_free(struct acpi_ctxt *ctxt, /* ACPI builder currently doesn't free memory so this is just a stub */ } +static uint8_t acpi_lapic_id(unsigned cpu) +{ + return LAPIC_ID(cpu); +} + void hvmloader_acpi_build_tables(struct acpi_config *config, unsigned int physical) { @@ -892,6 +897,12 @@ void hvmloader_acpi_build_tables(struct acpi_config *config, /* Allocate and initialise the acpi info area. */ mem_hole_populate_ram(ACPI_INFO_PHYSICAL_ADDRESS >> PAGE_SHIFT, 1); + config->lapic_base_address = LAPIC_BASE_ADDRESS; + config->lapic_id = acpi_lapic_id; + config->ioapic_base_address = ioapic_base_address; + config->ioapic_id = IOAPIC_ID; + config->pci_isa_irq_mask = PCI_ISA_IRQ_MASK; + if ( uart_exists(0x3f8) ) config->table_flags |= ACPI_HAS_COM1; if ( uart_exists(0x2f8) ) diff --git a/tools/firmware/rombios/32bit/Makefile b/tools/firmware/rombios/32bit/Makefile index 396906c..71399d2 100644 --- a/tools/firmware/rombios/32bit/Makefile +++ b/tools/firmware/rombios/32bit/Makefile @@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = 32bitbios_flat.h -CFLAGS += $(CFLAGS_xeninclude) -I.. +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../../hvmloader/acpi SUBDIRS = tcgbios diff --git a/tools/firmware/rombios/32bit/tcgbios/Makefile b/tools/firmware/rombios/32bit/tcgbios/Makefile index f6f2649..6822027 100644 --- a/tools/firmware/rombios/32bit/tcgbios/Makefile +++ b/tools/firmware/rombios/32bit/tcgbios/Makefile @@ -3,7 +3,7 @@ include $(XEN_ROOT)/tools/firmware/Rules.mk TARGET = tcgbiosext.o -CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. +CFLAGS += $(CFLAGS_xeninclude) -I.. -I../.. -I../../../hvmloader/acpi .PHONY: all all: $(TARGET) diff --git a/tools/firmware/rombios/32bit/util.h b/tools/firmware/rombios/32bit/util.h index e245be6..6b90c43 100644 --- a/tools/firmware/rombios/32bit/util.h +++ b/tools/firmware/rombios/32bit/util.h @@ -1,7 +1,7 @@ #ifndef UTIL_H #define UTIL_H -#include "../hvmloader/acpi/acpi2_0.h" +#include <acpi2_0.h> void outb(uint16_t addr, uint8_t val); void outw(uint16_t addr, uint16_t val); -- 1.8.3.1 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |