From patchwork Mon Apr 8 13:14:32 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 234775 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 9B7F12C0100 for ; Mon, 8 Apr 2013 23:40:00 +1000 (EST) Received: from localhost ([::1]:39456 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPCIg-0003p2-TS for incoming@patchwork.ozlabs.org; Mon, 08 Apr 2013 09:39:58 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45757) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPBrz-0004kO-UP for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:12:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UPBrv-0004fj-R7 for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:12:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45603) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UPBrv-0004fa-Kf for qemu-devel@nongnu.org; Mon, 08 Apr 2013 09:12:19 -0400 Received: from int-mx12.intmail.prod.int.phx2.redhat.com (int-mx12.intmail.prod.int.phx2.redhat.com [10.5.11.25]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r38DCIcK006799 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Mon, 8 Apr 2013 09:12:18 -0400 Received: from lacos-laptop.usersys.redhat.com (vpn1-7-196.ams2.redhat.com [10.36.7.196]) by int-mx12.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id r38DCHnd004111; Mon, 8 Apr 2013 09:12:17 -0400 From: Laszlo Ersek To: seabios@seabios.org, qemu-devel@nongnu.org Date: Mon, 8 Apr 2013 15:14:32 +0200 Message-Id: <1365426872-1856-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.25 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [seabios PATCH] install the MADT from the "etc/acpi/APIC" fw_cfg file if it's available X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Laszlo Ersek --- src/acpi.c | 29 ++++++++++++++++++++++++++++- 1 files changed, 28 insertions(+), 1 deletions(-) diff --git a/src/acpi.c b/src/acpi.c index bc4d8ea..9e128b2 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -393,6 +393,33 @@ build_madt(void) return madt; } +static void* +find_table(const char *sig, void *(*buildfn)(void)) +{ + char buf[] = "etc/acpi/QUUX"; + struct romfile_s *file; + + snprintf(buf + (sizeof buf - 1 - 4), 4 + 1, "%s", sig); + file = romfile_find(buf); + if (file != NULL && file->size >= sizeof(struct acpi_table_header)) { + void *table; + + table = malloc_high(file->size); + if (table == NULL) + warn_noalloc(); + else { + if ((*file->copy)(file, table, file->size) == file->size) { + dprintf(4, "ACPI %s: using fw_cfg %s\n", sig, buf); + return table; + } + free(table); + } + } + + dprintf(4, "ACPI %s: building default\n", sig); + return (*buildfn)(); +} + // Encode a hex value static inline char getHex(u32 val) { val &= 0x0f; @@ -792,7 +819,7 @@ acpi_setup(void) struct fadt_descriptor_rev1 *fadt = build_fadt(pci); ACPI_INIT_TABLE(fadt); ACPI_INIT_TABLE(build_ssdt()); - ACPI_INIT_TABLE(build_madt()); + ACPI_INIT_TABLE(find_table("APIC", build_madt)); ACPI_INIT_TABLE(build_hpet()); ACPI_INIT_TABLE(build_srat()); if (pci->device == PCI_DEVICE_ID_INTEL_ICH9_LPC)