From nobody Wed Oct 22 06:35:00 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) 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=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1519828076283171.4422008322614; Wed, 28 Feb 2018 06:27:56 -0800 (PST) Received: from localhost ([::1]:44623 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er2i3-0006PM-2S for importer@patchew.org; Wed, 28 Feb 2018 09:27:55 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33709) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1er2fr-0004tS-Im for qemu-devel@nongnu.org; Wed, 28 Feb 2018 09:25:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1er2fp-00020J-LG for qemu-devel@nongnu.org; Wed, 28 Feb 2018 09:25:39 -0500 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:35410 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1er2fi-0001w0-F2; Wed, 28 Feb 2018 09:25:30 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 123564026780; Wed, 28 Feb 2018 14:25:30 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3333F946B7; Wed, 28 Feb 2018 14:25:29 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 28 Feb 2018 15:23:53 +0100 Message-Id: <1519827835-239519-9-git-send-email-imammedo@redhat.com> In-Reply-To: <1519827835-239519-1-git-send-email-imammedo@redhat.com> References: <1519827835-239519-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 14:25:30 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 28 Feb 2018 14:25:30 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PATCH v2 08/10] acpi: move build_fadt() from i386 specific to generic ACPI source 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: Auger Eric , Shannon Zhao , qemu-arm@nongnu.org, "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" It will be extended and reused by follow up patch for ARM target. PS: Since it's generic function now, don't patch FIRMWARE_CTRL, DSDT fields if they don't point to tables since platform might not provide them and use X_ variants instead if applicable. Signed-off-by: Igor Mammedov Reviewed-by: Eric Auger --- v2: - conditional FIRMWARE_CTRL, DSDT patching is introduced in this patch instead of earlier "pc: acpi: isolate FADT specific data into AcpiFadtD= ata structure" as it better fits generalizing nature of this patch. (Auger Eric ) --- include/hw/acpi/aml-build.h | 3 ++ hw/acpi/aml-build.c | 105 ++++++++++++++++++++++++++++++++++++++++= ++++ hw/arm/virt-acpi-build.c | 6 +-- hw/i386/acpi-build.c | 102 ----------------------------------------= -- 4 files changed, 111 insertions(+), 105 deletions(-) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 8692ccc..6c36903 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -413,4 +413,7 @@ void build_srat_memory(AcpiSratMemoryAffinity *numamem,= uint64_t base, uint64_t len, int node, MemoryAffinityFlags flags); =20 void build_slit(GArray *table_data, BIOSLinker *linker); + +void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, + const char *oem_id, const char *oem_table_id); #endif diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 3fef5f6..8f45298 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -1678,3 +1678,108 @@ void build_slit(GArray *table_data, BIOSLinker *lin= ker) "SLIT", table_data->len - slit_start, 1, NULL, NULL); } + +/* build rev1/rev3 FADT */ +void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f, + const char *oem_id, const char *oem_table_id) +{ + int off; + int fadt_start =3D tbl->len; + + acpi_data_push(tbl, sizeof(AcpiTableHeader)); + + /* FACS address to be filled by Guest linker at runtime */ + off =3D tbl->len; + build_append_int_noprefix(tbl, 0, 4); /* FIRMWARE_CTRL */ + if (f->facs_tbl_offset) { /* don't patch if not supported by platform = */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, off, 4, + ACPI_BUILD_TABLE_FILE, *f->facs_tbl_offset); + } + + /* DSDT address to be filled by Guest linker at runtime */ + off =3D tbl->len; + build_append_int_noprefix(tbl, 0, 4); /* DSDT */ + if (f->dsdt_tbl_offset) { /* don't patch if not supported by platform = */ + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, off, 4, + ACPI_BUILD_TABLE_FILE, *f->dsdt_tbl_offset); + } + + /* ACPI1.0: INT_MODEL, ACPI2.0+: Reserved */ + build_append_int_noprefix(tbl, f->int_model /* Multiple APIC */, 1); + /* Preferred_PM_Profile */ + build_append_int_noprefix(tbl, 0 /* Unspecified */, 1); + build_append_int_noprefix(tbl, f->sci_int, 2); /* SCI_INT */ + build_append_int_noprefix(tbl, f->smi_cmd, 4); /* SMI_CMD */ + build_append_int_noprefix(tbl, f->acpi_enable_cmd, 1); /* ACPI_ENABLE = */ + build_append_int_noprefix(tbl, f->acpi_disable_cmd, 1); /* ACPI_DISABL= E */ + build_append_int_noprefix(tbl, 0 /* not supported */, 1); /* S4BIOS_RE= Q */ + /* ACPI1.0: Reserved, ACPI2.0+: PSTATE_CNT */ + build_append_int_noprefix(tbl, 0, 1); + build_append_int_noprefix(tbl, f->pm1a_evt.address, 4); /* PM1a_EVT_BL= K */ + build_append_int_noprefix(tbl, 0, 4); /* PM1b_EVT_BLK */ + build_append_int_noprefix(tbl, f->pm1a_cnt.address, 4); /* PM1a_CNT_BL= K */ + build_append_int_noprefix(tbl, 0, 4); /* PM1b_CNT_BLK */ + build_append_int_noprefix(tbl, 0, 4); /* PM2_CNT_BLK */ + build_append_int_noprefix(tbl, f->pm_tmr.address, 4); /* PM_TMR_BLK */ + build_append_int_noprefix(tbl, f->gpe0_blk.address, 4); /* GPE0_BLK */ + build_append_int_noprefix(tbl, 0, 4); /* GPE1_BLK */ + /* PM1_EVT_LEN */ + build_append_int_noprefix(tbl, f->pm1a_evt.bit_width / 8, 1); + /* PM1_CNT_LEN */ + build_append_int_noprefix(tbl, f->pm1a_cnt.bit_width / 8, 1); + build_append_int_noprefix(tbl, 0, 1); /* PM2_CNT_LEN */ + build_append_int_noprefix(tbl, f->pm_tmr.bit_width / 8, 1); /* PM_TMR_= LEN */ + /* GPE0_BLK_LEN */ + build_append_int_noprefix(tbl, f->gpe0_blk.bit_width / 8, 1); + build_append_int_noprefix(tbl, 0, 1); /* GPE1_BLK_LEN */ + build_append_int_noprefix(tbl, 0, 1); /* GPE1_BASE */ + build_append_int_noprefix(tbl, 0, 1); /* CST_CNT */ + build_append_int_noprefix(tbl, f->plvl2_lat, 2); /* P_LVL2_LAT */ + build_append_int_noprefix(tbl, f->plvl3_lat, 2); /* P_LVL3_LAT */ + build_append_int_noprefix(tbl, 0, 2); /* FLUSH_SIZE */ + build_append_int_noprefix(tbl, 0, 2); /* FLUSH_STRIDE */ + build_append_int_noprefix(tbl, 0, 1); /* DUTY_OFFSET */ + build_append_int_noprefix(tbl, 0, 1); /* DUTY_WIDTH */ + build_append_int_noprefix(tbl, 0, 1); /* DAY_ALRM */ + build_append_int_noprefix(tbl, 0, 1); /* MON_ALRM */ + build_append_int_noprefix(tbl, f->rtc_century, 1); /* CENTURY */ + build_append_int_noprefix(tbl, 0, 2); /* IAPC_BOOT_ARCH */ + build_append_int_noprefix(tbl, 0, 1); /* Reserved */ + build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ + + if (f->rev =3D=3D 1) { + goto build_hdr; + } + + build_append_gas_from_struct(tbl, &f->reset_reg); /* RESET_REG */ + build_append_int_noprefix(tbl, f->reset_val, 1); /* RESET_VALUE */ + build_append_int_noprefix(tbl, 0, 3); /* Reserved, ACPI 3.0 */ + build_append_int_noprefix(tbl, 0, 8); /* X_FIRMWARE_CTRL */ + + /* XDSDT address to be filled by Guest linker at runtime */ + off =3D tbl->len; + build_append_int_noprefix(tbl, 0, 8); /* X_DSDT */ + if (f->xdsdt_tbl_offset) { + bios_linker_loader_add_pointer(linker, + ACPI_BUILD_TABLE_FILE, off, 8, + ACPI_BUILD_TABLE_FILE, *f->xdsdt_tbl_offset); + } + + build_append_gas_from_struct(tbl, &f->pm1a_evt); /* X_PM1a_EVT_BLK */ + /* X_PM1b_EVT_BLK */ + build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->pm1a_cnt); /* X_PM1a_CNT_BLK */ + /* X_PM1b_CNT_BLK */ + build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + /* X_PM2_CNT_BLK */ + build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); + build_append_gas_from_struct(tbl, &f->pm_tmr); /* X_PM_TMR_BLK */ + build_append_gas_from_struct(tbl, &f->gpe0_blk); /* X_GPE0_BLK */ + build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); /* X_GPE1_BL= K */ + +build_hdr: + build_header(linker, tbl, (void *)(tbl->data + fadt_start), + "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_= id); +} diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index f7fa795..b644da9 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -651,8 +651,8 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) } =20 /* FADT */ -static void build_fadt(GArray *table_data, BIOSLinker *linker, - VirtMachineState *vms, unsigned dsdt_tbl_offset) +static void build_fadt_rev5(GArray *table_data, BIOSLinker *linker, + VirtMachineState *vms, unsigned dsdt_tbl_offse= t) { int fadt_start =3D table_data->len; AcpiFadtDescriptorRev5_1 *fadt =3D acpi_data_push(table_data, sizeof(*= fadt)); @@ -761,7 +761,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTa= bles *tables) =20 /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ acpi_add_table(table_offsets, tables_blob); - build_fadt(tables_blob, tables->linker, vms, dsdt); + build_fadt_rev5(tables_blob, tables->linker, vms, dsdt); =20 acpi_add_table(table_offsets, tables_blob); build_madt(tables_blob, tables->linker, vms); diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d1b387e..ebde2cd 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -298,108 +298,6 @@ build_facs(GArray *table_data, BIOSLinker *linker) facs->length =3D cpu_to_le32(sizeof(*facs)); } =20 -/* FADT */ -static void -build_fadt(GArray *tbl, BIOSLinker *linker, AcpiFadtData *f, - const char *oem_id, const char *oem_table_id) -{ - int off; - int fadt_start =3D tbl->len; - - acpi_data_push(tbl, sizeof(AcpiTableHeader)); - - /* FACS address to be filled by Guest linker at runtime */ - off =3D tbl->len; - build_append_int_noprefix(tbl, 0, 4); /* FIRMWARE_CTRL */ - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, off, 4, - ACPI_BUILD_TABLE_FILE, *f->facs_tbl_offset); - - /* DSDT address to be filled by Guest linker at runtime */ - off =3D tbl->len; - build_append_int_noprefix(tbl, 0, 4); /* DSDT */ - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, off, 4, - ACPI_BUILD_TABLE_FILE, *f->dsdt_tbl_offset); - - /* ACPI1.0: INT_MODEL, ACPI2.0+: Reserved */ - build_append_int_noprefix(tbl, f->int_model /* Multiple APIC */, 1); - /* Preferred_PM_Profile */ - build_append_int_noprefix(tbl, 0 /* Unspecified */, 1); - build_append_int_noprefix(tbl, f->sci_int, 2); /* SCI_INT */ - build_append_int_noprefix(tbl, f->smi_cmd, 4); /* SMI_CMD */ - build_append_int_noprefix(tbl, f->acpi_enable_cmd, 1); /* ACPI_ENABLE = */ - build_append_int_noprefix(tbl, f->acpi_disable_cmd, 1); /* ACPI_DISABL= E */ - build_append_int_noprefix(tbl, 0 /* not supported */, 1); /* S4BIOS_RE= Q */ - /* ACPI1.0: Reserved, ACPI2.0+: PSTATE_CNT */ - build_append_int_noprefix(tbl, 0, 1); - build_append_int_noprefix(tbl, f->pm1a_evt.address, 4); /* PM1a_EVT_BL= K */ - build_append_int_noprefix(tbl, 0, 4); /* PM1b_EVT_BLK */ - build_append_int_noprefix(tbl, f->pm1a_cnt.address, 4); /* PM1a_CNT_BL= K */ - build_append_int_noprefix(tbl, 0, 4); /* PM1b_CNT_BLK */ - build_append_int_noprefix(tbl, 0, 4); /* PM2_CNT_BLK */ - build_append_int_noprefix(tbl, f->pm_tmr.address, 4); /* PM_TMR_BLK */ - build_append_int_noprefix(tbl, f->gpe0_blk.address, 4); /* GPE0_BLK */ - build_append_int_noprefix(tbl, 0, 4); /* GPE1_BLK */ - /* PM1_EVT_LEN */ - build_append_int_noprefix(tbl, f->pm1a_evt.bit_width / 8, 1); - /* PM1_CNT_LEN */ - build_append_int_noprefix(tbl, f->pm1a_cnt.bit_width / 8, 1); - build_append_int_noprefix(tbl, 0, 1); /* PM2_CNT_LEN */ - build_append_int_noprefix(tbl, f->pm_tmr.bit_width / 8, 1); /* PM_TMR_= LEN */ - /* GPE0_BLK_LEN */ - build_append_int_noprefix(tbl, f->gpe0_blk.bit_width / 8, 1); - build_append_int_noprefix(tbl, 0, 1); /* GPE1_BLK_LEN */ - build_append_int_noprefix(tbl, 0, 1); /* GPE1_BASE */ - build_append_int_noprefix(tbl, 0, 1); /* CST_CNT */ - build_append_int_noprefix(tbl, f->plvl2_lat, 2); /* P_LVL2_LAT */ - build_append_int_noprefix(tbl, f->plvl3_lat, 2); /* P_LVL3_LAT */ - build_append_int_noprefix(tbl, 0, 2); /* FLUSH_SIZE */ - build_append_int_noprefix(tbl, 0, 2); /* FLUSH_STRIDE */ - build_append_int_noprefix(tbl, 0, 1); /* DUTY_OFFSET */ - build_append_int_noprefix(tbl, 0, 1); /* DUTY_WIDTH */ - build_append_int_noprefix(tbl, 0, 1); /* DAY_ALRM */ - build_append_int_noprefix(tbl, 0, 1); /* MON_ALRM */ - build_append_int_noprefix(tbl, f->rtc_century, 1); /* CENTURY */ - build_append_int_noprefix(tbl, 0, 2); /* IAPC_BOOT_ARCH */ - build_append_int_noprefix(tbl, 0, 1); /* Reserved */ - build_append_int_noprefix(tbl, f->flags, 4); /* Flags */ - - if (f->rev =3D=3D 1) { - goto build_hdr; - } - - build_append_gas_from_struct(tbl, &f->reset_reg); /* RESET_REG */ - build_append_int_noprefix(tbl, f->reset_val, 1); /* RESET_VALUE */ - build_append_int_noprefix(tbl, 0, 3); /* Reserved, ACPI 3.0 */ - build_append_int_noprefix(tbl, 0, 8); /* X_FIRMWARE_CTRL */ - - /* XDSDT address to be filled by Guest linker at runtime */ - off =3D tbl->len; - build_append_int_noprefix(tbl, 0, 8); /* X_DSDT */ - if (f->xdsdt_tbl_offset) { - bios_linker_loader_add_pointer(linker, - ACPI_BUILD_TABLE_FILE, off, 8, - ACPI_BUILD_TABLE_FILE, *f->xdsdt_tbl_offset); - } - - build_append_gas_from_struct(tbl, &f->pm1a_evt); /* X_PM1a_EVT_BLK */ - /* X_PM1b_EVT_BLK */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); - build_append_gas_from_struct(tbl, &f->pm1a_cnt); /* X_PM1a_CNT_BLK */ - /* X_PM1b_CNT_BLK */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); - /* X_PM2_CNT_BLK */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); - build_append_gas_from_struct(tbl, &f->pm_tmr); /* X_PM_TMR_BLK */ - build_append_gas_from_struct(tbl, &f->gpe0_blk); /* X_GPE0_BLK */ - build_append_gas(tbl, AML_AS_SYSTEM_MEMORY, 0 , 0, 0, 0); /* X_GPE1_BL= K */ - -build_hdr: - build_header(linker, tbl, (void *)(tbl->data + fadt_start), - "FACP", tbl->len - fadt_start, f->rev, oem_id, oem_table_= id); -} - void pc_madt_cpu_entry(AcpiDeviceIf *adev, int uid, const CPUArchIdList *apic_ids, GArray *entry) { --=20 2.7.4