All of lore.kernel.org
 help / color / mirror / Atom feed
From: Igor Mammedov <imammedo@redhat.com>
To: Eric Auger <eric.auger@redhat.com>
Cc: peter.maydell@linaro.org, drjones@redhat.com, gshan@redhat.com,
	mst@redhat.com, qemu-devel@nongnu.org, shannon.zhaosl@gmail.com,
	qemu-arm@nongnu.org, philmd@redhat.com, ardb@kernel.org,
	eric.auger.pro@gmail.com
Subject: Re: [PATCH v2 3/3] hw/arm/virt_acpi_build: Generate DBG2 table
Date: Tue, 7 Sep 2021 12:18:06 +0200	[thread overview]
Message-ID: <20210907121806.79c74f27@redhat.com> (raw)
In-Reply-To: <20210906123139.93593-4-eric.auger@redhat.com>

On Mon,  6 Sep 2021 14:31:39 +0200
Eric Auger <eric.auger@redhat.com> wrote:

> ARM SBBR specification  mandates DBG2 table (Debug Port Table 2).
                        ^^ revision here, and possibly a pointer [chapter]
                           to concrete place in spec where it's said.

> this latter 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:
> https://docs.microsoft.com/en-us/windows-hardware/drivers/bringup/acpi-debug-port-table?redirectedfrom=MSDN

links tend to go stale, I'd use a combo of name and optionally link here:
 "Microsoft Debug Port Table 2 (DBG2)"
    link
 
> Signed-off-by: Eric Auger <eric.auger@redhat.com>

table looks correct,
so only style related thing to fix to match the common
ACPI code style.

> 
> ---
> v1 -> v2:
> - rebased on Igor's refactoring
> ---
>  hw/arm/virt-acpi-build.c | 64 +++++++++++++++++++++++++++++++++++++++-
>  1 file changed, 63 insertions(+), 1 deletion(-)
> 
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 488ea04eed7..de604e79779 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -512,6 +512,65 @@ build_gtdt(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
>      acpi_table_composed(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, baseaddroffset = 22, namespace_length;
> +    char name[] = "COM0";
const?

Also I'd move here:
       const int namespace_length = sizeof(name);

> +
> +    acpi_init_table(&table, table_data);
> +
> +    namespace_length = sizeof name;
> +    dbg2devicelength = baseaddroffset +
> +                       sizeof(struct AcpiGenericAddress) + 4 + namespace_length;
                          ^^^^, fragile as it's subject to alignment which depends on target

I suggest following style:
       
       dbg2devicelength = 22 /* BaseAddressRegister[] offset, fixed size table header */ +
                          12 /* BaseAddressRegister[] */ +
                          4 /* AddressSize[] */
                          namespace_length /* NamespaceString[] */;

       and drop 'baseaddroffset' and 'sizeof(struct AcpiGenericAddress)'
       to be more consistent with other ACPI code to annotate where lengths come from

> +    /* offset to the first debug struct */
         comment should be verbatim field name from spec table, i.e. in this case 
            /* OffsetDbgDeviceInfo */
         ditto for the rest of field comments

> +    build_append_int_noprefix(table_data, 44, 4);
> +    /* number of debug device info struct entries */
> +    build_append_int_noprefix(table_data, 1, 4);
> +
> +    /* debug device info structure */

copy from spec, for ease to find it using just copy/past,

 /* Table 2. Debug Device Information structure format */

> +    /* revision */
> +    build_append_int_noprefix(table_data, 0, 1);
> +    /* length */
> +    build_append_int_noprefix(table_data, dbg2devicelength, 2);
> +    /* register count */
> +    build_append_int_noprefix(table_data, 1, 1);
> +    /* name path length */
> +    build_append_int_noprefix(table_data, namespace_length, 2);
> +    /* name path offset */
> +    build_append_int_noprefix(table_data, 38, 2);
> +    /* oem data length */
> +    build_append_int_noprefix(table_data, 0, 2);
> +    /* oem data offset (0 means no OEM data) */
> +    build_append_int_noprefix(table_data, 0, 2);
> +    /* port type (serial port) */
> +    build_append_int_noprefix(table_data, 0x8000, 2);
values could be annotated like following, using description from spec:

          build_append_int_noprefix(table_data, 0x8000 /* Serial */, 2);

> +    /* port subtype (ARM PL011)*/
> +    build_append_int_noprefix(table_data, 0x3, 2);
                                             0x3 /* ARM PL011 UART */

it gives checkpatch warning but all APCI code uses this style,
so it's fine

> +    /* reserved */
> +    build_append_int_noprefix(table_data, 0, 2);
> +    /* base address offset */
> +    build_append_int_noprefix(table_data, 22, 2);
> +    /* address size offset */
> +    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 (PL011 UART length) */
> +    build_append_int_noprefix(table_data, 0x1000, 4);
                                             ^^^^
at least point out where it comes from or use macro to define
value and use it here and in pl011_init()


> +
> +    /* NamespaceString */
> +    g_array_append_vals(table_data, name, namespace_length);
> +
> +    acpi_table_composed(linker, &table);
> +};
> +
>  /*
>   * ACPI spec, Revision 5.1 Errata A
>   * 5.2.12 Multiple APIC Description Table (MADT)
> @@ -770,7 +829,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);
>  
> @@ -793,6 +852,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);



  reply	other threads:[~2021-09-07 10:19 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-09-06 12:31 [PATCH v2 0/3] hw/arm/virt_acpi_build: Generate DBG2 table Eric Auger
2021-09-06 12:31 ` [PATCH v2 1/3] tests/acpi: Add void table for virt/DBG2 bios-tables-test Eric Auger
2021-09-07 10:20   ` Igor Mammedov
2021-09-06 12:31 ` [PATCH v2 2/3] bios-tables-test: Generate reference table for virt/DBG2 Eric Auger
2021-09-06 12:31 ` [PATCH v2 3/3] hw/arm/virt_acpi_build: Generate DBG2 table Eric Auger
2021-09-07 10:18   ` Igor Mammedov [this message]
2021-09-07  7:02 ` [PATCH v2 0/3] " Igor Mammedov
2021-09-08  9:14 ` Andrew Jones
2021-09-09 15:41   ` Eric Auger

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=20210907121806.79c74f27@redhat.com \
    --to=imammedo@redhat.com \
    --cc=ardb@kernel.org \
    --cc=drjones@redhat.com \
    --cc=eric.auger.pro@gmail.com \
    --cc=eric.auger@redhat.com \
    --cc=gshan@redhat.com \
    --cc=mst@redhat.com \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@redhat.com \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    --cc=shannon.zhaosl@gmail.com \
    /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 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.