* [Qemu-devel] [PATCH] pc: cleanup and convert TMP ACPI device description to AML API
@ 2015-06-09 3:31 Igor Mammedov
2015-06-09 10:40 ` Stefan Berger
0 siblings, 1 reply; 3+ messages in thread
From: Igor Mammedov @ 2015-06-09 3:31 UTC (permalink / raw)
To: qemu-devel; +Cc: stefanb, mst
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.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
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
diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
index 0be5d97..bd4f147 100644
--- a/hw/i386/Makefile.objs
+++ b/hw/i386/Makefile.objs
@@ -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 ;)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 5593e41..c5f559e 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -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) {
diff --git a/hw/i386/ssdt-tpm-common.dsl b/hw/i386/ssdt-tpm-common.dsl
deleted file mode 100644
index 9da4970..0000000
--- a/hw/i386/ssdt-tpm-common.dsl
+++ /dev/null
@@ -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)
- }
- }
- }
diff --git a/hw/i386/ssdt-tpm.dsl b/hw/i386/ssdt-tpm.dsl
deleted file mode 100644
index d81478c..0000000
--- a/hw/i386/ssdt-tpm.dsl
+++ /dev/null
@@ -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"
-}
diff --git a/hw/i386/ssdt-tpm.hex.generated b/hw/i386/ssdt-tpm.hex.generated
deleted file mode 100644
index 874418c..0000000
--- a/hw/i386/ssdt-tpm.hex.generated
+++ /dev/null
@@ -1,109 +0,0 @@
-static unsigned char ssdt_tpm_aml[] = {
-0x53,
-0x53,
-0x44,
-0x54,
-0x6b,
-0x0,
-0x0,
-0x0,
-0x1,
-0x37,
-0x42,
-0x58,
-0x50,
-0x43,
-0x0,
-0x0,
-0x42,
-0x58,
-0x53,
-0x53,
-0x44,
-0x54,
-0x0,
-0x0,
-0x1,
-0x0,
-0x0,
-0x0,
-0x49,
-0x4e,
-0x54,
-0x4c,
-0x7,
-0x11,
-0x14,
-0x20,
-0x10,
-0x46,
-0x4,
-0x5c,
-0x2f,
-0x3,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x49,
-0x53,
-0x41,
-0x5f,
-0x5b,
-0x82,
-0x33,
-0x54,
-0x50,
-0x4d,
-0x5f,
-0x8,
-0x5f,
-0x48,
-0x49,
-0x44,
-0xc,
-0x41,
-0xd0,
-0xc,
-0x31,
-0x8,
-0x5f,
-0x43,
-0x52,
-0x53,
-0x11,
-0x14,
-0xa,
-0x11,
-0x86,
-0x9,
-0x0,
-0x1,
-0x0,
-0x0,
-0xd4,
-0xfe,
-0x0,
-0x50,
-0x0,
-0x0,
-0x22,
-0x20,
-0x0,
-0x79,
-0x0,
-0x14,
-0x9,
-0x5f,
-0x53,
-0x54,
-0x41,
-0x0,
-0xa4,
-0xa,
-0xf
-};
diff --git a/hw/i386/ssdt-tpm2.dsl b/hw/i386/ssdt-tpm2.dsl
deleted file mode 100644
index 58bbbf8..0000000
--- a/hw/i386/ssdt-tpm2.dsl
+++ /dev/null
@@ -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"
-}
diff --git a/hw/i386/ssdt-tpm2.hex.generated b/hw/i386/ssdt-tpm2.hex.generated
deleted file mode 100644
index 9ea8271..0000000
--- a/hw/i386/ssdt-tpm2.hex.generated
+++ /dev/null
@@ -1,109 +0,0 @@
-static unsigned char ssdt_tpm2_aml[] = {
-0x53,
-0x53,
-0x44,
-0x54,
-0x6b,
-0x0,
-0x0,
-0x0,
-0x1,
-0x37,
-0x42,
-0x58,
-0x50,
-0x43,
-0x0,
-0x0,
-0x42,
-0x58,
-0x53,
-0x53,
-0x44,
-0x54,
-0x0,
-0x0,
-0x1,
-0x0,
-0x0,
-0x0,
-0x49,
-0x4e,
-0x54,
-0x4c,
-0x7,
-0x11,
-0x14,
-0x20,
-0x10,
-0x46,
-0x4,
-0x5c,
-0x2f,
-0x3,
-0x5f,
-0x53,
-0x42,
-0x5f,
-0x50,
-0x43,
-0x49,
-0x30,
-0x49,
-0x53,
-0x41,
-0x5f,
-0x5b,
-0x82,
-0x33,
-0x54,
-0x50,
-0x4d,
-0x5f,
-0x8,
-0x5f,
-0x48,
-0x49,
-0x44,
-0xc,
-0x41,
-0xd0,
-0xc,
-0x31,
-0x8,
-0x5f,
-0x43,
-0x52,
-0x53,
-0x11,
-0x14,
-0xa,
-0x11,
-0x86,
-0x9,
-0x0,
-0x1,
-0x0,
-0x0,
-0xd4,
-0xfe,
-0x0,
-0x50,
-0x0,
-0x0,
-0x22,
-0x20,
-0x0,
-0x79,
-0x0,
-0x14,
-0x9,
-0x5f,
-0x53,
-0x54,
-0x41,
-0x0,
-0xa4,
-0xa,
-0xf
-};
--
1.8.3.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pc: cleanup and convert TMP ACPI device description to AML API
2015-06-09 3:31 [Qemu-devel] [PATCH] pc: cleanup and convert TMP ACPI device description to AML API Igor Mammedov
@ 2015-06-09 10:40 ` Stefan Berger
2015-06-21 10:07 ` Michael S. Tsirkin
0 siblings, 1 reply; 3+ messages in thread
From: Stefan Berger @ 2015-06-09 10:40 UTC (permalink / raw)
To: Igor Mammedov; +Cc: qemu-devel, mst
[-- Attachment #1: Type: text/plain, Size: 3713 bytes --]
Igor Mammedov <imammedo@redhat.com> wrote on 06/08/2015 11:31:53 PM:
> From: Igor Mammedov <imammedo@redhat.com>
> To: qemu-devel@nongnu.org
> Cc: mst@redhat.com, Stefan Berger/Watson/IBM@IBMUS
> Date: 06/08/2015 11:32 PM
> Subject: [PATCH] pc: cleanup and convert TMP ACPI device descriptionto
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.
>
> Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> ---
> 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
>
> diff --git a/hw/i386/Makefile.objs b/hw/i386/Makefile.objs
> index 0be5d97..bd4f147 100644
> --- a/hw/i386/Makefile.objs
> +++ b/hw/i386/Makefile.objs
> @@ -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 ;)
> diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> index 5593e41..c5f559e 100644
> --- a/hw/i386/acpi-build.c
> +++ b/hw/i386/acpi-build.c
> @@ -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);
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.
[-- Attachment #2: Type: text/html, Size: 5862 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] [PATCH] pc: cleanup and convert TMP ACPI device description to AML API
2015-06-09 10:40 ` Stefan Berger
@ 2015-06-21 10:07 ` Michael S. Tsirkin
0 siblings, 0 replies; 3+ messages in thread
From: Michael S. Tsirkin @ 2015-06-21 10:07 UTC (permalink / raw)
To: Stefan Berger; +Cc: Igor Mammedov, qemu-devel
On Tue, Jun 09, 2015 at 06:40:48AM -0400, Stefan Berger wrote:
> > +
> > + 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);
>
> 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.
>
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.
--
MST
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-06-21 10:07 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-06-09 3:31 [Qemu-devel] [PATCH] pc: cleanup and convert TMP ACPI device description to AML API Igor Mammedov
2015-06-09 10:40 ` Stefan Berger
2015-06-21 10:07 ` Michael S. Tsirkin
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.