From nobody Thu Nov 6 19:51:27 2025 Delivered-To: importer@patchew.org Received-SPF: temperror (zoho.com: Error in retrieving data from DNS) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=temperror (zoho.com: Error in retrieving data from DNS) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=linux.intel.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1543250349318347.2823685537977; Mon, 26 Nov 2018 08:39:09 -0800 (PST) Received: from localhost ([::1]:37567 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRJud-0007mU-Ox for importer@patchew.org; Mon, 26 Nov 2018 11:39:07 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37794) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gRJmc-0000ub-7l for qemu-devel@nongnu.org; Mon, 26 Nov 2018 11:30:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gRJma-0004Zw-Ff for qemu-devel@nongnu.org; Mon, 26 Nov 2018 11:30:50 -0500 Received: from mga11.intel.com ([192.55.52.93]:54537) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gRJma-0004YC-7w; Mon, 26 Nov 2018 11:30:48 -0500 Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Nov 2018 08:30:47 -0800 Received: from sunandos-mobl2.ger.corp.intel.com (HELO localhost.localdomain) ([10.251.82.176]) by fmsmga008.fm.intel.com with ESMTP; 26 Nov 2018 08:30:44 -0800 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,283,1539673200"; d="scan'208";a="90954243" From: Samuel Ortiz To: qemu-devel@nongnu.org Date: Mon, 26 Nov 2018 17:29:38 +0100 Message-Id: <20181126162942.21258-6-sameo@linux.intel.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181126162942.21258-1-sameo@linux.intel.com> References: <20181126162942.21258-1-sameo@linux.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 192.55.52.93 Subject: [Qemu-devel] [PATCH 5/8] hw: arm: Convert the RSDP build to the buid_append_foo() API X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Laurent Vivier , Peter Maydell , Thomas Huth , Eduardo Habkost , Ben Warren , "Michael S. Tsirkin" , Shannon Zhao , qemu-arm@nongnu.org, Paolo Bonzini , Igor Mammedov , Richard Henderson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" build_rsdp() is now closely following the ACPI spec instead of filling a mapped and packed C structure. With this change we will eventually be able to get rid of the AcpiRsdpDescriptor structure as we're just appending values to the RSDP file directly and not mapping this structure in memory any more. Signed-off-by: Samuel Ortiz --- include/hw/acpi/acpi-defs.h | 22 ++++++++++++++ hw/arm/virt-acpi-build.c | 60 ++++++++++++++++++++++++------------- 2 files changed, 61 insertions(+), 21 deletions(-) diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h index e7fd24c6c5..9b2f6b8043 100644 --- a/include/hw/acpi/acpi-defs.h +++ b/include/hw/acpi/acpi-defs.h @@ -61,9 +61,31 @@ typedef struct AcpiRsdpData { unsigned *xsdt_tbl_offset; } AcpiRsdpData; =20 +/* RSDP signature */ +#define ACPI_RSDP_SIGNATURE "RSD PTR " + +/* RSDP Revisions */ #define ACPI_RSDP_REV_1 0 #define ACPI_RSDP_REV_2 2 =20 +/* RSDP lengths */ +#define ACPI_RSDP_REV_1_LEN 20 +#define ACPI_RSDP_REV_2_LEN 36 +#define ACPI_RSDP_SIG_LEN 8 +#define ACPI_RSDP_OEMID_LEN 6 +#define ACPI_RSDP_REVISION_LEN 1 +#define ACPI_RSDP_LEN_LEN 4 +#define ACPI_RSDP_CHECKSUM_LEN 1 +#define ACPI_RSDP_RESERVED_LEN 3 + +/* RSDP offsets */ +#define ACPI_RSDP_CHECKSUM_OFFSET 8 +#define ACPI_RSDP_REVISION_OFFSET 15 +#define ACPI_RSDP_RSDT_OFFSET 16 +#define ACPI_RSDP_XSDT_OFFSET 24 +#define ACPI_RSDP_EXT_CHECKSUM_OFFSET 32 + + /* Table structure from Linux kernel (the ACPI tables are under the BSD license) */ =20 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 2dad465ecf..d47978a55e 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -368,35 +368,53 @@ static void acpi_dsdt_add_power_button(Aml *scope) =20 /* RSDP */ static void -build_rsdp(GArray *rsdp_table, BIOSLinker *linker, AcpiRsdpData *rsdp_data) +build_rsdp(GArray *tbl, BIOSLinker *linker, AcpiRsdpData *rsdp_data) { - AcpiRsdpDescriptor *rsdp =3D acpi_data_push(rsdp_table, sizeof *rsdp); - unsigned xsdt_pa_size =3D sizeof(rsdp->xsdt_physical_address); - unsigned xsdt_pa_offset =3D - (char *)&rsdp->xsdt_physical_address - rsdp_table->data; - - bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, rsdp_table, 16, + bios_linker_loader_alloc(linker, ACPI_BUILD_RSDP_FILE, tbl, 16, true /* fseg memory */); =20 - memcpy(&rsdp->signature, "RSD PTR ", sizeof(rsdp->signature)); - memcpy(rsdp->oem_id, rsdp_data->oem_id, sizeof(rsdp->oem_id)); - rsdp->length =3D cpu_to_le32(sizeof(*rsdp)); - rsdp->revision =3D rsdp_data->revision; + /* RSDP signature */ + g_array_append_vals(tbl, ACPI_RSDP_SIGNATURE, ACPI_RSDP_SIG_LEN); + + /* Space for the checksum */ + build_append_int_noprefix(tbl, 0, ACPI_RSDP_CHECKSUM_LEN); + + /* OEM ID */ + g_array_append_vals(tbl, rsdp_data->oem_id, ACPI_RSDP_OEMID_LEN); + + /* Revision */ + build_append_int_noprefix(tbl, rsdp_data->revision, + ACPI_RSDP_REVISION_LEN); =20 - /* Address to be filled by Guest linker */ + /* Space for the RSDT address (32 bit) */ + build_append_int_noprefix(tbl, 0, 4); + + /* Length */ + build_append_int_noprefix(tbl, ACPI_RSDP_REV_2_LEN, ACPI_RSDP_LEN_LEN); + + /* XSDT address to be filled by guest linker */ + build_append_int_noprefix(tbl, 0, 8); /* XSDT address (64 bit) */ bios_linker_loader_add_pointer(linker, - ACPI_BUILD_RSDP_FILE, xsdt_pa_offset, xsdt_pa_size, - ACPI_BUILD_TABLE_FILE, *rsdp_data->xsdt_tbl_offset); + ACPI_BUILD_RSDP_FILE, + ACPI_RSDP_XSDT_OFFSET, 8, + ACPI_BUILD_TABLE_FILE, + *rsdp_data->xsdt_tbl_offset); + + /* Space for the extended checksum */ + build_append_int_noprefix(tbl, 0, ACPI_RSDP_CHECKSUM_LEN); + + /* Space for the reserved bytes */ + build_append_int_noprefix(tbl, 0, ACPI_RSDP_RESERVED_LEN); =20 - /* Checksum to be filled by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, - (char *)rsdp - rsdp_table->data, 20 /* ACPI rev 1.0 RSDP size */, - (char *)&rsdp->checksum - rsdp_table->data); + /* Checksum to be filled by guest linker */ + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, 0, + ACPI_RSDP_REV_1_LEN, + ACPI_RSDP_CHECKSUM_OFFSET); =20 /* Extended checksum to be filled by Guest linker */ - bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, - (char *)rsdp - rsdp_table->data, 36 /* ACPI rev 2.0 RSDP size */, - (char *)&rsdp->extended_checksum - rsdp_table->data); + bios_linker_loader_add_checksum(linker, ACPI_BUILD_RSDP_FILE, 0, + ACPI_RSDP_REV_2_LEN, + ACPI_RSDP_EXT_CHECKSUM_OFFSET); } =20 static void --=20 2.19.1