hw/arm/virt_acpi_build: Generate DBG2 table
v3 cover hw/arm/virt_acpi_build: Generate DBG2 table
This series generates the ACPI DBG2 table along with machvirt. It applies on top of Igor's
[PATCH v4 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables
The DBG2 specification can be found at
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table.
DBG2 is mandated by ARM SBBR since its v1.0 release (the rationale behind is Windows requires it on all systems).
The DBG2 is used to describe a debug port, used by the kernel debugger.
This series and its dependency can be found at
https://github.com/eauger/qemu.git
branch: igor_acpi_refactoring_v4_dbg2_v3
History:
v2 -> v3:
- addressed all comments from Igor on v2:
patches 2/3 swapped
style adjustments in "hw/arm/virt_acpi_build: Generate DBG2 table"
+ more precision on spec references
v1 -> v2:
- rebase on top of Igor's series and use acpi_init_table/acpi_table_composed and build_append_int_noprefix()
Eric Auger (3):
tests/acpi: Add void table for virt/DBG2 bios-tables-test hw/arm/virt_acpi_build: Generate DBG2 table
bios-tables-test: Generate reference table for virt/DBG2
hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++- tests/data/acpi/virt/DBG2 | Bin 0 -> 87 bytes 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/virt/DBG2
Signature · 1 line
2.26.3
PATCH v3 1/3 tests/acpi: Add void table for virt/DBG2 bios-tables-test
Add placeholders for DBG2 reference table for virt tests and ignore till reference blob is added.
---
v2 -> v3:
- commit msg rewording according to Igor's suggestion and added Igor's A-b.
--- tests/qtest/bios-tables-test-allowed-diff.h | 1 + tests/data/acpi/virt/DBG2 | 0 2 files changed, 1 insertion(+) create mode 100644 tests/data/acpi/virt/DBG2
tests/qtest/bios-tables-test-allowed-diff.h +1 -0
@@ -1 +1,2 @@/* List of comma-separated changed AML files to ignore */ +"tests/data/acpi/virt/DBG2",
tests/data/acpi/virt/DBG2 new file +0 -0
Signature · 1 line
2.26.3
PATCH v3 2/3 hw/arm/virt_acpi_build: Generate DBG2 table
In reply to Eric AugerARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDN
---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision references
v1 -> v2:
- rebased on Igor's refactoring
--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +61 -1
@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) +{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + +4 /* AddressSize[] */ + + namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */ +build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 ); + +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT)
@@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);
@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);
Signature · 1 line
2.26.3
Quoted 73 lines · On Mon, 27 Sep 2021 15:17:31 +0200 Eric Auger <[email protected]> wrote:
ARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDNSigned-off-by Eric Auger <[email protected]>---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision referencesv1 -> v2:
- rebased on Igor's refactoring--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +40
-0@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms) +{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id, + .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + +4 /* AddressSize[] */ + + namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 668
Quoted 10 lines
hw/arm/virt-acpi-build.c +10
-0+build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 );
s/0x1000/vms->memmap[VIRT_UART].size/?
Quoted 29 lines
hw/arm/virt-acpi-build.c +11
-1+ +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) @@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);
Quoted 30 lines · Eric Auger
ARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDNSigned-off-by Eric Auger <[email protected]>---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision referencesv1 -> v2:
- rebased on Igor's refactoring--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +0
-0
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 621
Quoted 6 lines
hw/arm/virt-acpi-build.c +3
-0@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms)
nit: I didn't think QEMU liked this style, i.e. QEMU prefers
static void build_dbg2(GArray *table_data, BIOSLinker *linker,
VirtMachineState *vms)
Eh, I see that hw/arm/virt-acpi-build.c is full of the format you have here, so never mind.
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 623
Quoted 2 lines
hw/arm/virt-acpi-build.c +2
-0+{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id,
Can you explain where the .rev = 3 comes from? The spec says "For this version of the specification, this value is 0."
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 633
Quoted 10 lines
hw/arm/virt-acpi-build.c +10
-0+ .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + + 4 /* AddressSize[] */ +
I'd personally prefer the '+' before the comment, but maybe Igor has a special ACPI code format preference here.
Quoted 67 lines
hw/arm/virt-acpi-build.c +46
-1+ namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */ +build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 ); + +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) @@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);Signature · 1 line
2.26.3
Thanks,
drew
Hi,
Quoted 42 lines · Andrew Jones
Quoted 30 lines · Eric Auger
ARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDNSigned-off-by Eric Auger <[email protected]>---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision referencesv1 -> v2:
- rebased on Igor's refactoring--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +0
-0hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 621
Quoted 6 lines
hw/arm/virt-acpi-build.c +3
-0@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms)nit: I didn't think QEMU liked this style, i.e. QEMU prefers
static void build_dbg2(GArray
*table_data, BIOSLinker *linker,
VirtMachineState *vms)
Quoted 7 lines
Eh, I see that
hw/arm/virt-acpi-build.cis full of the format you have here, so never mind.hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 623
Quoted 2 lines
hw/arm/virt-acpi-build.c +2
-0+{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id,Can you explain where the .rev = 3 comes from? The spec says "For this version of the specification, this value is 0."
The above revision field belongs to the acpi table header. Not to be mixed with the Revision field of the DBG2 table
which is set below (set to 0):
+ build_append_int_noprefix(table_data, 0, 1); /* Revision */
Besides that's a good question. I have rev=3 here but that must come from a copy/paste. when googling I found
https://lists.denx.de/pipermail/u-boot/2015-June/217134.html
/header->revision = 1; /* ACPI 1.0/2.0: 1, ACPI 3.0: 2, ACPI 4.0: 3 */ Not sure if 3 is the right value though? Igor, please could you advise? Thanks Eric /
Quoted 85 lines
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 633
Quoted 12 lines
hw/arm/virt-acpi-build.c +10
-0+ .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + + 4 /* AddressSize[] */ +I'd personally prefer the '+' before the comment, but maybe Igor has a special ACPI code format preference here.
Quoted 67 lines
hw/arm/virt-acpi-build.c +46
-1+ namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */ +build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 ); + +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) @@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);Signature · 1 line
2.26.3Thanks,
drew
Quoted 58 lines · On Wed, 6 Oct 2021 11:57:07 +0200 Eric Auger <[email protected]> wrote:
Hi,
Quoted 42 lines · Andrew Jones
Quoted 30 lines · Eric Auger
ARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDNSigned-off-by Eric Auger <[email protected]>---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision referencesv1 -> v2:
- rebased on Igor's refactoring--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +0
-0hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 621
Quoted 6 lines
hw/arm/virt-acpi-build.c +3
-0@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms)nit: I didn't think QEMU liked this style, i.e. QEMU prefers
static void build_dbg2(GArray
*table_data, BIOSLinker *linker,
VirtMachineState *vms)Quoted 7 lines
Eh, I see that
hw/arm/virt-acpi-build.cis full of the format you have here, so never mind.hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 623
Quoted 2 lines
hw/arm/virt-acpi-build.c +2
-0+{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id,Can you explain where the .rev = 3 comes from? The spec says "For this version of the specification, this value is 0."
The above revision field belongs to the acpi table header. Not to be mixed with the Revision field of the DBG2 table
which is set below (set to 0):+
build_append_int_noprefix(table_data, 0, 1); /* Revision */
Quoted 8 lines
Besides that's a good question. I have rev=3 here but that must come from a copy/paste. when googling I found
https://lists.denx.de/pipermail/u-boot/2015-June/217134.html
/header->revision = 1; /* ACPI 1.0/2.0: 1, ACPI 3.0: 2, ACPI 4.0: 3 */ Not sure if 3 is the right value though? Igor, please could you advise? Thanks Eric /
"Table 1. Debug Port Table 2 format"
says table revision must be 0
Quoted 14 lines
Quoted 14 lines
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 633
Quoted 12 lines
hw/arm/virt-acpi-build.c +10
-0+ .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + + 4 /* AddressSize[] */ +I'd personally prefer the '+' before the comment, but maybe Igor has a special ACPI code format preference here.
indeed '+' before comment should look better
Quoted 72 lines
Quoted 71 lines
Quoted 68 lines
hw/arm/virt-acpi-build.c +46
-1+ namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */ +build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 ); + +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) @@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);Signature · 1 line
2.26.3Thanks,
drew
Hi,
Quoted 64 lines · Igor Mammedov
Quoted 61 lines · On Wed, 6 Oct 2021 11:57:07 +0200 Eric Auger <[email protected]> wrote:
Hi,
Quoted 42 lines · Andrew Jones
Quoted 30 lines · Eric Auger
ARM SBBR specification mandates DBG2 table (Debug Port Table 2) since v1.0 (ARM DEN0044F 8.3.1.7 DBG2).
The DBG2 table allows to describe one or more debug ports.
Generate an DBG2 table featuring a single debug port, the PL011.
The DBG2 specification can be found at
"Microsoft Debug Port Table 2 (DBG2)"
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDNSigned-off-by Eric Auger <[email protected]>---
v2 -> v3:
Took into account all comments from Igor on v2:
mostly style adjustment, revision referencesv1 -> v2:
- rebased on Igor's refactoring--- hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-)hw/arm/virt-acpi-build.c +0
-0hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 621
Quoted 6 lines
hw/arm/virt-acpi-build.c +3
-0@@ -616,6 +616,63 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)acpi_table_end (linker, &table); } +/* Debug Port Table 2 (DBG2) */ +static void +build_dbg2 (GArray *table_data,BIOSLinker *linker,VirtMachineState *vms)nit: I didn't think QEMU liked this style, i.e. QEMU prefers
static void build_dbg2(GArray
*table_data, BIOSLinker *linker,
VirtMachineState *vms)Quoted 7 lines
Eh, I see that
hw/arm/virt-acpi-build.cis full of the format you have here, so never mind.hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 623
Quoted 2 lines
hw/arm/virt-acpi-build.c +2
-0+{ +AcpiTable table = { .sig ="DBG2" , .rev =3 , .oem_id = vms->oem_id,Can you explain where the .rev = 3 comes from? The spec says "For this version of the specification, this value is 0."
The above revision field belongs to the acpi table header. Not to be mixed with the Revision field of the DBG2 table
which is set below (set to 0):+
build_append_int_noprefix(table_data, 0, 1); /* Revision */Besides that's a good question. I have rev=3 here but that must come from a copy/paste. when googling I found
Quoted 7 lines
Quoted 5 lines
https://lists.denx.de/pipermail/u-boot/2015-June/217134.html
/header->revision = 1; /* ACPI 1.0/2.0: 1, ACPI 3.0: 2, ACPI 4.0: 3 */ Not sure if 3 is the right value though? Igor, please could you advise? Thanks Eric /"Table 1. Debug Port Table 2 format"
says table revision must be 0
Hum OK, sorry was confused by the 2 different revision fields. I will fix that.
Quoted 14 lines
Quoted 14 lines
Quoted 14 lines
hw/arm/virt-acpi-build.c build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms) · line 633
Quoted 12 lines
hw/arm/virt-acpi-build.c +10
-0+ .oem_table_id = vms->oem_table_id }; +int dbg2devicelength; +const char name[] ="COM0" ; +const int namespace_length =sizeof (name); + +acpi_table_begin (&table, table_data); + + dbg2devicelength =22 /* BaseAddressRegister[] offset */ + +12 /* BaseAddressRegister[] */ + + 4 /* AddressSize[] */ +I'd personally prefer the '+' before the comment, but maybe Igor has a special ACPI code format preference here.
Quoted 1 line
indeed '+' before comment should look better
OK
Eric
Quoted 72 lines
Quoted 72 lines
Quoted 72 lines
Quoted 69 lines
hw/arm/virt-acpi-build.c +46
-1+ namespace_length/* NamespaceString[] */ ; + +/* OffsetDbgDeviceInfo */ +build_append_int_noprefix (table_data,44 ,4 ); +/* NumberDbgDeviceInfo */ +build_append_int_noprefix (table_data,1 ,4 ); + +/* Table 2. Debug Device Information structure format */ +build_append_int_noprefix (table_data,0 ,1 );/* Revision */ +build_append_int_noprefix (table_data, dbg2devicelength,2 );/* Length */ +/* NumberofGenericAddressRegisters */ +build_append_int_noprefix (table_data,1 ,1 ); +/* NameSpaceStringLength */ +build_append_int_noprefix (table_data, namespace_length,2 ); +build_append_int_noprefix (table_data,38 ,2 );/* NameSpaceStringOffset */ +build_append_int_noprefix (table_data,0 ,2 );/* OemDataLength */ +/* OemDataOffset (0 means no OEM data) */ +build_append_int_noprefix (table_data,0 ,2 ); + +/* Port Type */ +build_append_int_noprefix (table_data,0x8000 /* Serial */ ,2 ); +/* Port Subtype */ +build_append_int_noprefix (table_data,0x3 /* ARM PL011 UART */ ,2 ); +build_append_int_noprefix (table_data,0 ,2 );/* Reserved */ +/* BaseAddressRegisterOffset */ +build_append_int_noprefix (table_data,22 ,2 ); +/* AddressSizeOffset */ +build_append_int_noprefix (table_data,34 ,2 ); + +/* BaseAddressRegister[] */ +build_append_gas (table_data,AML_AS_SYSTEM_MEMORY ,8 ,0 ,1 , + vms->memmap[VIRT_UART ].base); + +/* AddressSize[] */ +build_append_int_noprefix (table_data,0x1000 /* Register Space */ ,4 ); + +/* NamespaceString[] */ +g_array_append_vals (table_data, name, namespace_length); + +acpi_table_end (linker, &table); +}; +/* * ACPI spec, Revision 5.1 Errata A * 5.2.12 Multiple APIC Description Table (MADT) @@ -875,7 +932,7 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables) dsdt = tables_blob->len;build_dsdt (tables_blob, tables->linker, vms); -/* FADT MADT GTDT MCFG SPCR pointed to by RSDT */ +/* FADT MADT GTDT MCFG SPCR DBG2 pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt_rev5 (tables_blob, tables->linker, vms, dsdt);@@ -898,6 +955,9 @@ void virt_acpi_build(VirtMachineState *vms, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_spcr (tables_blob, tables->linker, vms); +acpi_add_table (table_offsets, tables_blob); +build_dbg2 (tables_blob, tables->linker, vms); +if (vms->ras) {build_ghes_error_table (tables->hardware_errors, tables->linker);acpi_add_table (table_offsets, tables_blob);Signature · 1 line
2.26.3Thanks,
drew
PATCH v3 3/3 bios-tables-test: Generate reference table for virt/DBG2
In reply to Eric AugerAdd the DBG2 table generated withtests/data/acpi/rebuild-expected-aml.sh
---
Tested by comparing the content with the table generated by EDK2 along with the SBSA-REF machine (code generated by DynamicTablesPkg/Library/Acpi/Arm/AcpiDbg2LibArm/Dbg2Generator.c).
I reused the Generic Address Structure filled by QEMU in the SPCR, ie. bit_width = 8 and byte access. While EDK2 sets bit_width = 32 and dword access. Also the name exposed by acpica tools is different:
'COM0' in my case where '\_SB.COM0' in SBSA-REF case?
Here is the human readable content:
[000h 0000 4] Signature : "DBG2" [Debug Port table type 2] [004h 0004 4] Table Length : 00000057 [008h 0008 1] Revision : 03 [009h 0009 1] Checksum : C8 [00Ah 0010 6] Oem ID : "BOCHS " [010h 0016 8] Oem Table ID : "BXPC " [018h 0024 4] Oem Revision : 00000001 [01Ch 0028 4] Asl Compiler ID : "BXPC" [020h 0032 4] Asl Compiler Revision : 00000001
[024h 0036 4] Info Offset : 0000002C
[028h 0040 4] Info Count : 00000001
[02Ch 0044 1] Revision : 00 [02Dh 0045 2] Length : 002B [02Fh 0047 1] Register Count : 01 [030h 0048 2] Namepath Length : 0005 [032h 0050 2] Namepath Offset : 0026 [034h 0052 2] OEM Data Length : 0000 [Optional field not present] [036h 0054 2] OEM Data Offset : 0000 [Optional field not present] [038h 0056 2] Port Type : 8000 [03Ah 0058 2] Port Subtype : 0003 [03Ch 0060 2] Reserved : 0000 [03Eh 0062 2] Base Address Offset : 0016 [040h 0064 2] Address Size Offset : 0022
[042h 0066 12] Base Address Register : [Generic Address Structure]
[042h 0066 1] Space ID : 00 [SystemMemory] [043h 0067 1] Bit Width : 08 [044h 0068 1] Bit Offset : 00 [045h 0069 1] Encoded Access Width : 01 [Byte Access:8] [046h 0070 8] Address : 0000000009000000
[04Eh 0078 4] Address Size : 00001000
[052h 0082 5] Namepath : "COM0"
--- tests/qtest/bios-tables-test-allowed-diff.h | 1 - tests/data/acpi/virt/DBG2 | Bin 0 -> 87 bytes 2 files changed, 1 deletion(-)
tests/qtest/bios-tables-test-allowed-diff.h +0 -1
@@ -1,2 +1 @@/* List of comma-separated changed AML files to ignore */ -"tests/data/acpi/virt/DBG2",
tests/data/acpi/virt/DBG2 binary +0 -0
Signature · 1 line
2.26.3
Quoted 8 lines · Eric Auger
This series generates the ACPI DBG2 table along with machvirt. It applies on top of Igor's
[PATCH v4 00/35] acpi: refactor error pronebuild_header()and packed structures usage in ACPI tablesThe DBG2 specification can be found at
https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table.
Quoted 8 lines
DBG2 is mandated by ARM SBBR since its v1.0 release (the rationale behind is Windows requires it on all systems).
The DBG2 is used to describe a debug port, used by the kernel debugger.
This series and its dependency can be found at
https://github.com/eauger/qemu.git
branch:igor_acpi_refactoring_v4_dbg2_v3
Quoted 24 lines
History:
v2 -> v3:
- addressed all comments from Igor on v2:
patches 2/3 swapped
style adjustments in "hw/arm/virt_acpi_build: Generate DBG2 table"
+ more precision on spec referencesv1 -> v2:
- rebase on top of Igor's series and use acpi_init_table/acpi_table_composed andbuild_append_int_noprefix()Eric Auger (3):
tests/acpi: Add void table forvirt/DBG2bios-tables-test hw/arm/virt_acpi_build: Generate DBG2 table
bios-tables-test: Generate reference table forvirt/DBG2hw/arm/virt-acpi-build.c | 62 +++++++++++++++++++++++++++++++++++++- tests/data/acpi/virt/DBG2 | Bin 0 -> 87 bytes 2 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 tests/data/acpi/virt/DBG2Signature · 1 line
2.26.3