From patchwork Tue Jun 22 08:53:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Isaku Yamahata X-Patchwork-Id: 56441 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 628E8B6F07 for ; Tue, 22 Jun 2010 19:28:59 +1000 (EST) Received: from localhost ([127.0.0.1]:49971 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQzmq-000316-8a for incoming@patchwork.ozlabs.org; Tue, 22 Jun 2010 05:28:56 -0400 Received: from [140.186.70.92] (port=33348 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OQzPw-0007hG-UJ for qemu-devel@nongnu.org; Tue, 22 Jun 2010 05:05:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OQzIB-0002Ge-9t for qemu-devel@nongnu.org; Tue, 22 Jun 2010 04:57:16 -0400 Received: from mail.valinux.co.jp ([210.128.90.3]:37025) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OQzIA-0002G7-NZ for qemu-devel@nongnu.org; Tue, 22 Jun 2010 04:57:15 -0400 Received: from ps.local.valinux.co.jp (vagw.valinux.co.jp [210.128.90.14]) by mail.valinux.co.jp (Postfix) with SMTP id 04BA61073BB; Tue, 22 Jun 2010 17:57:10 +0900 (JST) Received: (nullmailer pid 28761 invoked by uid 1000); Tue, 22 Jun 2010 08:53:26 -0000 Date: Tue, 22 Jun 2010 17:53:26 +0900 From: Isaku Yamahata To: seabios Message-ID: <20100622085326.GA28468@valinux.co.jp> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.19 (2009-01-05) X-Virus-Scanned: clamav-milter 0.95.2 at va-mail.local.valinux.co.jp X-Virus-Status: Clean X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: qemu-devel@nongnu.org Subject: [Qemu-devel] [PATCH v2] seabios: acpi: allow qemu to load dsdt as external acpi table. X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org allow qemu to load dsdt as external acpi table. Signed-off-by: Isaku Yamahata --- changes v1 -> v2. - load qemu table first and they try default dsdt table if qemu doesn't supply dsdt. Thus unnecessary malloc_high()/free() is avoided. --- src/acpi.c | 49 +++++++++++++++++++++++++++++++++++++++++-------- 1 files changed, 41 insertions(+), 8 deletions(-) diff --git a/src/acpi.c b/src/acpi.c index 0559443..b75f9af 100644 --- a/src/acpi.c +++ b/src/acpi.c @@ -126,6 +126,11 @@ struct fadt_descriptor_rev1 } PACKED; /* + * Differentiated System Descrition Table (DSDT) + */ +#define DSDT_SIGNATURE 0x54445344 // DSDT + +/* * MADT values and structures */ @@ -280,6 +285,11 @@ static inline u32 cpu_to_le32(u32 x) return x; } +static inline u32 le32_to_cpu(u32 x) +{ + return x; +} + static void build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev) { @@ -295,14 +305,20 @@ build_header(struct acpi_table_header *h, u32 sig, int len, u8 rev) h->checksum -= checksum(h, len); } +static void fill_dsdt(struct fadt_descriptor_rev1 *fadt, void *dsdt) +{ + fadt->dsdt = cpu_to_le32((u32)dsdt); + fadt->checksum -= checksum(fadt, sizeof(*fadt)); + dprintf(1, "ACPI DSDT=%p\n", dsdt); +} + static void* build_fadt(int bdf) { struct fadt_descriptor_rev1 *fadt = malloc_high(sizeof(*fadt)); struct facs_descriptor_rev1 *facs = memalign_high(64, sizeof(*facs)); - void *dsdt = malloc_high(sizeof(AmlCode)); - if (!fadt || !facs || !dsdt) { + if (!fadt || !facs) { warn_noalloc(); return NULL; } @@ -312,13 +328,11 @@ build_fadt(int bdf) facs->signature = FACS_SIGNATURE; facs->length = cpu_to_le32(sizeof(*facs)); - /* DSDT */ - memcpy(dsdt, AmlCode, sizeof(AmlCode)); - /* FADT */ memset(fadt, 0, sizeof(*fadt)); fadt->firmware_ctrl = cpu_to_le32((u32)facs); - fadt->dsdt = cpu_to_le32((u32)dsdt); + fadt->dsdt = 0; /* dsdt will be filled later in acpi_bios_init() + by fill_dsdt() */ fadt->model = 1; fadt->reserved1 = 0; int pm_sci_int = pci_config_readb(bdf, PCI_INTERRUPT_LINE); @@ -634,7 +648,8 @@ acpi_bios_init(void) } while(0) // Add tables - ACPI_INIT_TABLE(build_fadt(bdf)); + struct fadt_descriptor_rev1 *fadt = build_fadt(bdf); + ACPI_INIT_TABLE(fadt); ACPI_INIT_TABLE(build_ssdt()); ACPI_INIT_TABLE(build_madt()); ACPI_INIT_TABLE(build_hpet()); @@ -649,12 +664,30 @@ acpi_bios_init(void) warn_noalloc(); continue; } - ACPI_INIT_TABLE(qemu_cfg_next_acpi_table_load(addr, len)); + struct acpi_table_header *header = + qemu_cfg_next_acpi_table_load(addr, len); + if (header->signature == DSDT_SIGNATURE) { + if (fadt) { + fill_dsdt(fadt, addr); + } + } else { + ACPI_INIT_TABLE(header); + } if (tbl_idx == MAX_ACPI_TABLES) { warn_noalloc(); break; } } + if (fadt && !fadt->dsdt) { + /* default DSDT */ + void *dsdt = malloc_high(sizeof(AmlCode)); + if (!dsdt) { + warn_noalloc(); + return; + } + memcpy(dsdt, AmlCode, sizeof(AmlCode)); + fill_dsdt(fadt, dsdt); + } struct rsdt_descriptor_rev1 *rsdt; size_t rsdt_len = sizeof(*rsdt) + sizeof(u32) * tbl_idx;