From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:59451) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVIJq-0002Ol-IR for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:18:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVIJk-0007VW-Dk for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:18:22 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37101) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVI4f-0002sv-Lv for qemu-devel@nongnu.org; Thu, 25 Apr 2013 05:02:41 -0400 Date: Thu, 25 Apr 2013 12:02:32 +0300 From: "Michael S. Tsirkin" Message-ID: <4fd91502526b9977807a8dff28dcba4db670af7c.1366879705.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Subject: [Qemu-devel] [PATCH RFC 2/3] 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/ and use for acpi tables. Any files in this directory completely disable generating and loading legacy acpi tables. Signed-off-by: Michael S. Tsirkin --- src/acpi.c | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 66 insertions(+), 1 deletion(-) diff --git a/src/acpi.c b/src/acpi.c index 58cd6d7..16ea9f4 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" @@ -603,8 +604,72 @@ acpi_setup(void) if (! CONFIG_ACPI) return; + int acpi_generate = 1; + dprintf(3, "init ACPI tables\n"); + struct romfile_s *file = NULL; + for (;;) { + file = romfile_findprefix("/etc/acpi/", file); + if (!file) + break; + + /* + * Disable ACPI table generation. All ACPI tables must come from + * etc/acpi/ romfile entries. + */ + acpi_generate = 0; + + if (!file->size) + continue; + + void *data = malloc_high(file->size); + if (!data) { + warn_noalloc(); + break; + } + int ret = file->copy(file, data, file->size); + if (ret < file->size) { + free(data); + continue; + } + /* Handle RSDP and FACS quirks */ + if (file->size >= 8) { + struct rsdp_descriptor *rsdp = data; + struct acpi_table_header *hdr = data; + /* RSDP is in FSEG memory. */ + if (rsdp->signature == cpu_to_le64(RSDP_SIGNATURE)) { + data = malloc_fseg(file->size); + if (!data) { + warn_noalloc(); + break; + } + memcpy(data, rsdp, file->size); + free(rsdp); + /* Store Rsdp pointer for use by find_fadt. */ + RsdpAddr = data; + } else if (hdr->signature == FACS_SIGNATURE) { + /* FACS is aligned to a 64 bit boundary. */ + data = memalign_high(64, file->size); + if (!data) { + warn_noalloc(); + break; + } + memcpy(data, hdr, file->size); + free(hdr); + } + } + file->data = data; + } + + linker_link("/etc/linker-script"); + + if (!acpi_generate) { + 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) @@ -630,7 +695,7 @@ acpi_setup(void) if (pci->device == PCI_DEVICE_ID_INTEL_ICH9_LPC) ACPI_INIT_TABLE(build_mcfg_q35()); - struct romfile_s *file = NULL; + file = NULL; for (;;) { file = romfile_findprefix("acpi/", file); if (!file) -- MST