From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvr5h-0002fX-HW for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Uvr5e-0000Ek-7a for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:33 -0400 Received: from mx1.redhat.com ([209.132.183.28]:14346) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Uvr5d-0000EQ-UP for qemu-devel@nongnu.org; Sun, 07 Jul 2013 11:41:30 -0400 Date: Sun, 7 Jul 2013 18:42:43 +0300 From: "Michael S. Tsirkin" Message-ID: <1373211589-8097-5-git-send-email-mst@redhat.com> References: <1373211589-8097-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1373211589-8097-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PATCH v2 4/5] acpi: load and link tables from /etc/acpi/ List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: seabios@seabios.org Cc: qemu-devel@nongnu.org Load files in /etc/acpi/, link them using a linker script and use for acpi tables, including the RSDP. Presense of RSDP in this directory completely disables generating and loading legacy acpi tables. Signed-off-by: Michael S. Tsirkin --- src/acpi.c | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/src/acpi.c b/src/acpi.c index a81f0cb..07d311a 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -27,6 +27,7 @@ #include "config.h" // CONFIG_* #include "paravirt.h" // RamSize #include "dev-q35.h" +#include "linker.h" #include "acpi-dsdt.hex" @@ -599,6 +600,34 @@ static const struct pci_device_id acpi_find_tbl[] = { struct rsdp_descriptor *RsdpAddr; +/* Look for RSDP signature in files loaded in FSEG */ +struct rsdp_descriptor * +acpi_find_rsdp_rom(void) +{ + struct romfile_s *file = NULL; + struct rsdp_descriptor *rsdp = NULL; + for (;;) { + file = romfile_findprefix("", file); + if (!file) + break; + + if (!file->data || !pmm_test_fseg(file->data) || + file->size < sizeof(rsdp->signature)) + continue; + + void *data; + + for (data = file->data; + data + sizeof(*rsdp) <= file->data + file->size; + data++) { + rsdp = data; + if (rsdp->signature == cpu_to_le64(RSDP_SIGNATURE)) + return rsdp; + } + } + return NULL; +} + #define MAX_ACPI_TABLES 20 void acpi_setup(void) @@ -608,6 +637,16 @@ acpi_setup(void) dprintf(3, "init ACPI tables\n"); + linker_loader_execute("/etc/linker-script"); + + RsdpAddr = acpi_find_rsdp_rom(); + + if (RsdpAddr) { + return; + } + + dprintf(3, "generate ACPI tables\n"); + // This code is hardcoded for PIIX4 Power Management device. struct pci_device *pci = pci_find_init_device(acpi_find_tbl, NULL); if (!pci) -- MST