From patchwork Mon Apr 15 20:47:49 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laszlo Ersek X-Patchwork-Id: 236723 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 116302C00DC for ; Tue, 16 Apr 2013 06:48:26 +1000 (EST) Received: from localhost ([::1]:43165 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URqK8-0007pX-6Z for incoming@patchwork.ozlabs.org; Mon, 15 Apr 2013 16:48:24 -0400 Received: from eggs.gnu.org ([208.118.235.92]:45036) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URqHd-0003ze-Bn for qemu-devel@nongnu.org; Mon, 15 Apr 2013 16:45:55 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1URqHY-0004dQ-K9 for qemu-devel@nongnu.org; Mon, 15 Apr 2013 16:45:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:2915) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1URqHY-0004dJ-CE for qemu-devel@nongnu.org; Mon, 15 Apr 2013 16:45:44 -0400 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id r3FKjh45014855 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK) for ; Mon, 15 Apr 2013 16:45:43 -0400 Received: from lacos-laptop.usersys.redhat.com (vpn1-4-113.ams2.redhat.com [10.36.4.113]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id r3FKjb5d030093; Mon, 15 Apr 2013 16:45:42 -0400 From: Laszlo Ersek To: qemu-devel@nongnu.org, mst@redhat.com Date: Mon, 15 Apr 2013 22:47:49 +0200 Message-Id: <1366058872-11196-5-git-send-email-lersek@redhat.com> In-Reply-To: <1366058872-11196-1-git-send-email-lersek@redhat.com> References: <1366058872-11196-1-git-send-email-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.67 on 10.5.11.11 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH v2 4/7] hw/acpi: export default ACPI headers using the type just introduced 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 This enables reuse when preparing per-table fw_cfg blobs later. Signed-off-by: Laszlo Ersek --- include/hw/acpi/acpi.h | 2 ++ hw/acpi/core.c | 39 ++++++++++++++++++++++++--------------- 2 files changed, 26 insertions(+), 15 deletions(-) diff --git a/include/hw/acpi/acpi.h b/include/hw/acpi/acpi.h index 0e26f63..bc7e107 100644 --- a/include/hw/acpi/acpi.h +++ b/include/hw/acpi/acpi.h @@ -178,4 +178,6 @@ typedef struct acpi_table_std_header { char asl_compiler_id[4]; /* ASL compiler vendor ID */ uint32_t asl_compiler_revision; /* ASL compiler revision number */ } QEMU_PACKED AcpiTableStdHdr; + +extern const AcpiTableStdHdr acpi_dfl_hdr; #endif /* !QEMU_HW_ACPI_H */ diff --git a/hw/acpi/core.c b/hw/acpi/core.c index d348f81..36a4d03 100644 --- a/hw/acpi/core.c +++ b/hw/acpi/core.c @@ -37,11 +37,20 @@ struct acpi_table_header { /* size of the extra prefix */ #define ACPI_TABLE_PFX_SIZE offsetof(struct acpi_table_header, std) -static const char unsigned dfl_hdr[sizeof(AcpiTableStdHdr)] = - "QEMU\0\0\0\0\1\0" /* sig (4), len(4), revno (1), csum (1) */ - "QEMUQEQEMUQEMU\1\0\0\0" /* OEM id (6), table (8), revno (4) */ - "QEMU\1\0\0\0" /* ASL compiler ID (4), version (4) */ - ; +const AcpiTableStdHdr acpi_dfl_hdr = { + .sig = "QEMU", + .revision = 1, + .oem_id = "QEMUQE", + .oem_table_id = "QEMUQEMU", + .asl_compiler_id = "QEMU", +#ifdef HOST_WORDS_BIGENDIAN + .oem_revision = 0x01000000, + .asl_compiler_revision = 0x01000000 +#else + .oem_revision = 1, + .asl_compiler_revision = 1 +#endif +}; char unsigned *acpi_tables; size_t acpi_tables_len; @@ -74,8 +83,8 @@ static int acpi_checksum(const uint8_t *data, int len) /* Install a copy of the ACPI table specified in @blob. * * If @has_header is set, @blob starts with the System Description Table Header - * structure. Otherwise, "dfl_hdr" is prepended. In any case, each header field - * is optionally overwritten from @hdrs. + * structure. Otherwise, "acpi_dfl_hdr" is prepended. In any case, each header + * field is optionally overwritten from @hdrs. * * It is valid to call this function with * (@blob == NULL && @bloblen == 0 && !@has_header). @@ -105,13 +114,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, if (has_header) { /* _length | ACPI header in blob | blob body * ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^ - * ACPI_TABLE_PFX_SIZE sizeof dfl_hdr body_size + * ACPI_TABLE_PFX_SIZE sizeof acpi_dfl_hdr body_size * == body_start * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * acpi_payload_size == bloblen */ - body_start = sizeof dfl_hdr; + body_start = sizeof acpi_dfl_hdr; if (bloblen < body_start) { error_setg(errp, "ACPI table claiming to have header is too " @@ -123,17 +132,17 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, } else { /* _length | ACPI header in template | blob body * ^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^ - * ACPI_TABLE_PFX_SIZE sizeof dfl_hdr body_size + * ACPI_TABLE_PFX_SIZE sizeof acpi_dfl_hdr body_size * == bloblen * * ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * acpi_payload_size */ body_start = 0; - hdr_src = dfl_hdr; + hdr_src = (const char unsigned *)&acpi_dfl_hdr; } body_size = bloblen - body_start; - acpi_payload_size = sizeof dfl_hdr + body_size; + acpi_payload_size = sizeof acpi_dfl_hdr + body_size; if (acpi_payload_size > UINT16_MAX) { error_setg(errp, "ACPI table too big, requested: %zu, max: %u", @@ -149,13 +158,13 @@ static void acpi_table_install(const char unsigned *blob, size_t bloblen, acpi_tables = g_realloc(acpi_tables, acpi_tables_len + ACPI_TABLE_PFX_SIZE + - sizeof dfl_hdr + body_size); + sizeof acpi_dfl_hdr + body_size); ext_hdr = (struct acpi_table_header *)(acpi_tables + acpi_tables_len); acpi_tables_len += ACPI_TABLE_PFX_SIZE; - memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof dfl_hdr); - acpi_tables_len += sizeof dfl_hdr; + memcpy(acpi_tables + acpi_tables_len, hdr_src, sizeof acpi_dfl_hdr); + acpi_tables_len += sizeof acpi_dfl_hdr; if (blob != NULL) { memcpy(acpi_tables + acpi_tables_len, blob + body_start, body_size);