From patchwork Tue Sep 20 00:19:29 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Boris Ostrovsky X-Patchwork-Id: 9340823 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 8B289607D0 for ; Tue, 20 Sep 2016 00:28:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DA732844B for ; Tue, 20 Sep 2016 00:28:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 70BD328697; Tue, 20 Sep 2016 00:28:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=2.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4652C2844B for ; Tue, 20 Sep 2016 00:28:33 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bm8sG-0007jY-VN; Tue, 20 Sep 2016 00:25:24 +0000 Received: from mail6.bemta3.messagelabs.com ([195.245.230.39]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1bm8sF-0007gF-Hj for xen-devel@lists.xen.org; Tue, 20 Sep 2016 00:25:23 +0000 Received: from [85.158.137.68] by server-5.bemta-3.messagelabs.com id 31/8A-03281-2F180E75; Tue, 20 Sep 2016 00:25:22 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrJLMWRWlGSWpSXmKPExsXSO6nOVfdj44N wg+VNphZLPi5mcWD0OLr7N1MAYxRrZl5SfkUCa8bpeUoFnwMrNjydwNzAOMmli5GLQ0hgIpPE lp3HmCGcL4wSh9b+YoNwNjJKrP27lhXC6WGU+DjrLpDDycEmYCRx9uh0RhBbREBa4trny2A2s 8ATRomdN9K7GDk4hAU8JBa+swIJswioStxreMQIEuYV8JY4sScJJCwhoCAx5eF7ZhCbEyg88e oTVpASIQEvif3N3hAlhhKfNy5lnsDIt4CRYRWjRnFqUVlqka6hkV5SUWZ6RkluYmaOrqGBsV5 uanFxYnpqTmJSsV5yfu4mRmCQMADBDsZX3c6HGCU5mJREeeX4HoQL8SXlp1RmJBZnxBeV5qQW H2KU4eBQkuC1BgadkGBRanpqRVpmDjBcYdISHDxKIrxRIGne4oLE3OLMdIjUKUZFKXHeXJCEA EgiozQPrg0WI5cYZaWEeRmBDhHiKUgtys0sQZV/xSjOwagkzGsOMoUnM68EbvoroMVMQIsZe+ 6DLC5JREhJNTA28UkGsMU+4Tj8zlE98vab7y6The5mnvy09L2sRkd2uEtfb78BW++XBLZbfUc f7PQ9u3uJq9Lyfs93aTY6/v8XPcoJmaCfV3bjdFZEr2FtgPtyc9O2/oeynyacMTLQOVLPcqm3 QU6Jefas/TImR8r2RTwq7rFa7s58yrorcLFzwG6Hm07t3UosxRmJhlrMRcWJAC+2rtKMAgAA X-Env-Sender: boris.ostrovsky@oracle.com X-Msg-Ref: server-13.tower-31.messagelabs.com!1474331119!60965421!1 X-Originating-IP: [141.146.126.69] X-SpamReason: No, hits=0.0 required=7.0 tests=sa_preprocessor: VHJ1c3RlZCBJUDogMTQxLjE0Ni4xMjYuNjkgPT4gMjc3MjE4\n X-StarScan-Received: X-StarScan-Version: 8.84; banners=-,-,- X-VirusChecked: Checked Received: (qmail 6733 invoked from network); 20 Sep 2016 00:25:21 -0000 Received: from aserp1040.oracle.com (HELO aserp1040.oracle.com) (141.146.126.69) by server-13.tower-31.messagelabs.com with DHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 20 Sep 2016 00:25:21 -0000 Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by aserp1040.oracle.com (Sentrion-MTA-4.3.2/Sentrion-MTA-4.3.2) with ESMTP id u8K0PAq5019962 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 20 Sep 2016 00:25:11 GMT Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by userv0022.oracle.com (8.14.4/8.13.8) with ESMTP id u8K0PANa008030 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Tue, 20 Sep 2016 00:25:10 GMT Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by userv0121.oracle.com (8.13.8/8.13.8) with ESMTP id u8K0P9vI014815; Tue, 20 Sep 2016 00:25:10 GMT Received: from ovs104.us.oracle.com (/10.149.76.204) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 19 Sep 2016 17:25:09 -0700 From: Boris Ostrovsky To: xen-devel@lists.xen.org Date: Mon, 19 Sep 2016 20:19:29 -0400 Message-Id: <1474330779-10645-12-git-send-email-boris.ostrovsky@oracle.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1474330779-10645-1-git-send-email-boris.ostrovsky@oracle.com> References: <1474330779-10645-1-git-send-email-boris.ostrovsky@oracle.com> X-Source-IP: userv0022.oracle.com [156.151.31.74] Cc: wei.liu2@citrix.com, andrew.cooper3@citrix.com, ian.jackson@eu.citrix.com, julien.grall@arm.com, jbeulich@suse.com, zhaoshenglong@huawei.com, Boris Ostrovsky , roger.pau@citrix.com Subject: [Xen-devel] [PATCH v4 11/21] acpi/hvmloader: Include file/paths adjustments X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Acked-by: Jan Beulich --- 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=\"\". 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 #include #include @@ -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 #include #include #include 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 #include #include 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 +#include 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 +#include #include #include #include @@ -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 void outb(uint16_t addr, uint8_t val); void outw(uint16_t addr, uint16_t val);