pc: cleanup and convert TMP ACPI device description to AML API
PATCH 1/1 pc: cleanup and convert TMP ACPI device description to AML API
remove some code duplication in acpi-build.c and drop 5 ASL and binary blobs files with TPM ACPI device description, replacing them with 1 small hunk written in AML API.
--- hw/i386/Makefile.objs | 3 +- hw/i386/acpi-build.c | 40 ++++++--------- hw/i386/ssdt-tpm-common.dsl | 36 ------------- hw/i386/ssdt-tpm.dsl | 29 ----------- hw/i386/ssdt-tpm.hex.generated | 109 ---------------------------------------- hw/i386/ssdt-tpm2.dsl | 29 ----------- hw/i386/ssdt-tpm2.hex.generated | 109 ---------------------------------------- 7 files changed, 16 insertions(+), 339 deletions(-) delete mode 100644 hw/i386/ssdt-tpm-common.dsl delete mode 100644 hw/i386/ssdt-tpm.dsl delete mode 100644 hw/i386/ssdt-tpm.hex.generated delete mode 100644 hw/i386/ssdt-tpm2.dsl delete mode 100644 hw/i386/ssdt-tpm2.hex.generated
hw/i386/Makefile.objs +1 -2
@@ -8,8 +8,7 @@ obj-$(CONFIG_XEN) += ../xenpv/ xen/ obj-y += kvmvapic.o obj-y += acpi-build.o hw/i386/acpi-build.o: hw/i386/acpi-build.c \ - hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/ssdt-tpm.hex hw/i386/ssdt-tpm2.hex + hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)
hw/i386/acpi-build.c +15 -25
@@ -433,9 +433,6 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, table_data->len - madt_start, 1); } -#include "hw/i386/ssdt-tpm.hex" -#include "hw/i386/ssdt-tpm2.hex" -/* Assign BSEL property to all buses. In the future, this can be changed * to only assign to buses that support hotplug. */
@@ -1329,6 +1326,19 @@ build_ssdt(GArray *table_data, GArray *linker,Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support hotplug. */ build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); + +if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { + dev =aml_device ("ISA.TPM" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); +aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); + crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , +TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); +aml_append (crs,aml_irq_no_flags (TPM_TIS_IRQ )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +aml_append (sb_scope, scope); } }
@@ -1384,22 +1394,9 @@ build_tpm_tcpa(GArray *table_data, GArray *linker, GArray *tcpalog) }static void -build_tpm_ssdt (GArray *table_data,GArray *linker) -{ -void *tpm_ptr; - - tpm_ptr =acpi_data_push (table_data,sizeof (ssdt_tpm_aml)); -memcpy (tpm_ptr, ssdt_tpm_aml,sizeof (ssdt_tpm_aml)); -} - -static void build_tpm2 (GArray *table_data,GArray *linker) {Acpi20TPM2 *tpm2_ptr; -void *tpm_ptr; - - tpm_ptr =acpi_data_push (table_data,sizeof (ssdt_tpm2_aml)); -memcpy (tpm_ptr, ssdt_tpm2_aml,sizeof (ssdt_tpm2_aml)); tpm2_ptr =acpi_data_push (table_data,sizeof *tpm2_ptr);
@@ -1727,16 +1724,9 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_tpm_tcpa (tables_blob, tables->linker, tables->tcpalog); -acpi_add_table (table_offsets, tables_blob); -switch (misc.tpm_version) { -case TPM_VERSION_1_2 : -build_tpm_ssdt (tables_blob, tables->linker); -break ; -case TPM_VERSION_2_0 : +if (misc.tpm_version ==TPM_VERSION_2_0 ) { +acpi_add_table (table_offsets, tables_blob);build_tpm2 (tables_blob, tables->linker); -break ; -default : -assert (false); } }if (guest_info->numa_nodes) {
hw/i386/ssdt-tpm-common.dsl deleted +0 -36
@@ -1,36 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ - -/* - * Common parts for TPM 1.2 and TPM 2 (with slight differences for PPI) - * to be #included - */ - - - External(\_SB.PCI0.ISA, DeviceObj) - Scope(\_SB.PCI0.ISA) { - /* TPM with emulated TPM TIS interface */ - Device (TPM) { - Name (_HID, EisaID ("PNP0C31")) - Name (_CRS, ResourceTemplate () - { - Memory32Fixed (ReadWrite, TPM_TIS_ADDR_BASE, TPM_TIS_ADDR_SIZE) - IRQNoFlags () {TPM_TIS_IRQ} - }) - Method (_STA, 0, NotSerialized) { - Return (0x0F) - } - } - }
hw/i386/ssdt-tpm.dsl deleted +0 -29
@@ -1,29 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ -#include "hw/acpi/tpm.h" - -ACPI_EXTRACT_ALL_CODE ssdt_tpm_aml - -DefinitionBlock ( - "ssdt-tpm.aml", // Output Filename - "SSDT", // Signature - 0x01, // SSDT Compliance Revision - "BXPC", // OEMID - "BXSSDT", // TABLE ID - 0x1 // OEM Revision - ) -{ -#include "ssdt-tpm-common.dsl" -}
hw/i386/ssdt-tpm.hex.generated deleted +0 -109
109 lines not on this page · raw message
hw/i386/ssdt-tpm2.dsl deleted +0 -29
@@ -1,29 +0,0 @@ -/* - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - - * You should have received a copy of the GNU General Public License along - * with this program; if not, see <http://www.gnu.org/licenses/>. - */ -#include "hw/acpi/tpm.h" - -ACPI_EXTRACT_ALL_CODE ssdt_tpm2_aml - -DefinitionBlock ( - "ssdt-tpm2.aml", // Output Filename - "SSDT", // Signature - 0x01, // SSDT Compliance Revision - "BXPC", // OEMID - "BXSSDT", // TABLE ID - 0x1 // OEM Revision - ) -{ -#include "ssdt-tpm-common.dsl" -}
hw/i386/ssdt-tpm2.hex.generated deleted +0 -109
109 lines not on this page · raw message
Signature · 1 line
1.8.3.1
Igor Mammedov <[email protected]> wrote on 06/08/2015 11:31:53 PM:
Quoted 5 lines
From: Igor Mammedov <[email protected]>
To: [email protected]
Cc: [email protected], Stefan Berger/Watson/IBM@IBMUS
Date: 06/08/2015 11:32 PM
Subject: [PATCH] pc: cleanup and convert TMP ACPI device descriptionto
AML API
Quoted 42 lines
remove some code duplication in
acpi-build.cand drop 5 ASL and binary blobs files with TPM ACPI device description, replacing them with 1 small hunk written in AML API.Signed-off-by Igor Mammedov <[email protected]>--- hw/i386/Makefile.objs | 3 +- hw/i386/acpi-build.c | 40 ++++++--------- hw/i386/ssdt-tpm-common.dsl | 36 ------------- hw/i386/ssdt-tpm.dsl | 29 ----------- hw/i386/ssdt-tpm.hex.generated | 109 ---------------------------------------- hw/i386/ssdt-tpm2.dsl | 29 ----------- hw/i386/ssdt-tpm2.hex.generated | 109 ---------------------------------------- 7 files changed, 16 insertions(+), 339 deletions(-) delete mode 100644 hw/i386/ssdt-tpm-common.dsl delete mode 100644 hw/i386/ssdt-tpm.dsl delete mode 100644 hw/i386/ssdt-tpm.hex.generated delete mode 100644 hw/i386/ssdt-tpm2.dsl delete mode 100644 hw/i386/ssdt-tpm2.hex.generatedhw/i386/Makefile.objs +1
-2@@ -8,8 +8,7 @@ obj-$(CONFIG_XEN) += ../xenpv/ xen/ obj-y += kvmvapic.o obj-y += acpi-build.o hw/i386/acpi-build.o: hw/i386/acpi-build.c \ - hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex \ - hw/i386/ssdt-tpm.hex hw/i386/ssdt-tpm2.hex + hw/i386/acpi-dsdt.hex hw/i386/q35-acpi-dsdt.hex iasl-option=$(shell if test -z "`$(1) $(2) 2>&1 > /dev/null`" \ ; then echo "$(2)"; else echo "$(3)"; fi ;)hw/i386/acpi-build.c +0
-0
hw/i386/acpi-build.c build_madt(GArray *table_data, GArray *linker, · line 437
Quoted 8 lines
hw/i386/acpi-build.c +0
-3@@ -433,9 +433,6 @@ build_madt(GArray *table_data, GArray *linker, AcpiCpuInfo *cpu, table_data->len - madt_start, 1); } -#include "hw/i386/ssdt-tpm.hex" -#include "hw/i386/ssdt-tpm2.hex" -/* Assign BSEL property to all buses. In the future, this can be
changed
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1327
Quoted 5 lines
hw/i386/acpi-build.c +0
-0* to only assign to buses that support hotplug. */
hw/i386/acpi-build.c +0
-0@@ -1329,6 +1326,19 @@ build_ssdt(GArray *table_data, GArray *linker,Aml *scope =aml_scope ("PCI0" );/* Scan all PCI buses. Generate tables to support
hotplug. */
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1335
Quoted 8 lines
hw/i386/acpi-build.c +5
-0build_append_pci_bus_devices (scope, bus, pm->pcihp_bridge_en); + +if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { + dev =aml_device ("ISA.TPM" ); +aml_append (dev,aml_name_decl ("_HID" ,aml_eisaid ("PNP0C31" ))); + aml_append(dev, aml_name_decl("_STA",
aml_int(0xF)));
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1337
Quoted 2 lines
hw/i386/acpi-build.c +2
-0+ crs =aml_resource_template (); + aml_append(crs,
aml_memory32_fixed(TPM_TIS_ADDR_BASE,
hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1342
Quoted 7 lines
hw/i386/acpi-build.c +6
-0+ TPM_TIS_ADDR_SIZE, AML_READ_WRITE)); +aml_append (crs,aml_irq_no_flags (TPM_TIS_IRQ )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +aml_append (sb_scope, scope);
Once we add the _DSM to it from the link below, it will become longer and maybe also more complicated. So I would put it into its own function already?
http://lists.nongnu.org/archive/html/qemu-devel/2015-05/msg05353.html
My preference would be to wait until that _DSM has been added to it.
Quoted 20 lines · Stefan Berger
Quoted 5 lines
hw/i386/acpi-build.c +4
-0+ +if (misc->tpm_version !=TPM_VERSION_UNSPEC ) { + dev =aml_device ("ISA.TPM" ); + aml_append(dev, aml_name_decl("_HID",
aml_eisaid("PNP0C31")));hw/i386/acpi-build.c build_ssdt(GArray *table_data, GArray *linker, · line 1342
Quoted 10 lines
hw/i386/acpi-build.c +9
-0+aml_append (dev,aml_name_decl ("_STA" ,aml_int (0xF ))); + crs =aml_resource_template (); +aml_append (crs,aml_memory32_fixed (TPM_TIS_ADDR_BASE , +TPM_TIS_ADDR_SIZE ,AML_READ_WRITE )); +aml_append (crs,aml_irq_no_flags (TPM_TIS_IRQ )); +aml_append (dev,aml_name_decl ("_CRS" , crs)); +aml_append (scope, dev); + } +aml_append (sb_scope, scope);Once we add the
_DSMto it from the link below, it will become longer and maybe also more complicated. So I would put it into its own function already?
http://lists.nongnu.org/archive/html/qemu-devel/2015-05/msg05353.html
Quoted 2 lines
My preference would be to wait until that
_DSMhas been added to it.
That would make Igor do even more work rewriting code from ASL to C. This patch shows C isn't harder than DSL so I don't think we can justify doing the work twice.
I'll apply this as-is for now.
Signature · 1 line
MST