qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Richard Henderson <richard.henderson@linaro.org>
To: qemu-devel@nongnu.org
Cc: Eric Auger <eric.auger@redhat.com>,
	Andrew Jones <drjones@redhat.com>,
	"Michael S . Tsirkin" <mst@redhat.com>,
	Igor Mammedov <imammedo@redhat.com>
Subject: [PULL 10/19] hw/arm/virt_acpi_build: Generate DBG2 table
Date: Thu, 21 Oct 2021 08:25:32 -0700	[thread overview]
Message-ID: <20211021152541.781175-11-richard.henderson@linaro.org> (raw)
In-Reply-To: <20211021152541.781175-1-richard.henderson@linaro.org>

From: Eric Auger <eric.auger@redhat.com>

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=MSDN

Signed-off-by: Eric Auger <eric.auger@redhat.com>
Reviewed-by: Andrew Jones <drjones@redhat.com>
Reviewed-by: Igor Mammedov <imammedo@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20211019080037.930641-3-eric.auger@redhat.com>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 hw/arm/virt-acpi-build.c | 63 +++++++++++++++++++++++++++++++++++++++-
 1 file changed, 62 insertions(+), 1 deletion(-)

diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
index 9c4730f4ab..d3bb4cba3e 100644
--- a/hw/arm/virt-acpi-build.c
+++ b/hw/arm/virt-acpi-build.c
@@ -626,6 +626,64 @@ 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 = 0, .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,
+                              vms->memmap[VIRT_UART].size, 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)
@@ -885,7 +943,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);
 
@@ -908,6 +966,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);
-- 
2.25.1



  parent reply	other threads:[~2021-10-21 15:42 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 15:25 [PULL 00/19] target/arm patch queue Richard Henderson
2021-10-21 15:25 ` [PULL 01/19] tests/acpi: Get prepared for IORT E.b revision upgrade Richard Henderson
2021-10-21 15:25 ` [PULL 02/19] hw/arm/virt-acpi-build: IORT upgrade up to revision E.b Richard Henderson
2021-10-21 15:25 ` [PULL 03/19] tests/acpi: Generate reference blob for IORT rev E.b Richard Henderson
2021-10-21 15:25 ` [PULL 04/19] hw/arm/virt: Don't create device-tree node for empty NUMA node Richard Henderson
2021-10-21 15:25 ` [PULL 05/19] roms/edk2: Only init brotli submodule to build BaseTools Richard Henderson
2021-10-21 15:25 ` [PULL 06/19] roms/edk2: Only initialize required submodules Richard Henderson
2021-10-21 15:25 ` [PULL 07/19] hw/arm/sbsa-ref: Fixed cpu type error message typo Richard Henderson
2021-10-21 15:25 ` [PULL 08/19] hw/elf_ops.h: switch to ssize_t for elf loader return type Richard Henderson
2021-10-21 15:25 ` [PULL 09/19] tests/acpi: Add void table for virt/DBG2 bios-tables-test Richard Henderson
2021-10-21 15:25 ` Richard Henderson [this message]
2021-10-21 15:25 ` [PULL 11/19] bios-tables-test: Generate reference table for virt/DBG2 Richard Henderson
2021-10-21 15:25 ` [PULL 12/19] hw/arm/virt: Only describe cpu topology since virt-6.2 Richard Henderson
2021-10-21 15:25 ` [PULL 13/19] device_tree: Add qemu_fdt_add_path Richard Henderson
2021-10-21 15:25 ` [PULL 14/19] hw/arm/virt: Add cpu-map to device tree Richard Henderson
2021-10-21 15:25 ` [PULL 15/19] hw/acpi/aml-build: Add Processor hierarchy node structure Richard Henderson
2021-10-21 15:25 ` [PULL 16/19] hw/acpi/aml-build: Add PPTT table Richard Henderson
2021-10-21 15:25 ` [PULL 17/19] tests/data/acpi/virt: Add an empty expected file for PPTT Richard Henderson
2021-10-21 15:25 ` [PULL 18/19] hw/arm/virt-acpi-build: Generate PPTT table Richard Henderson
2021-10-21 15:25 ` [PULL 19/19] tests/data/acpi/virt: Update the empty expected file for PPTT Richard Henderson
2021-10-21 19:19 ` [PULL 00/19] target/arm patch queue Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211021152541.781175-11-richard.henderson@linaro.org \
    --to=richard.henderson@linaro.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).