From: Andrew Jones <drjones@redhat.com>
To: Leif Lindholm <leif.lindholm@linaro.org>
Cc: peter.maydell@linaro.org, imammedo@redhat.com, mst@redhat.com,
qemu-devel@nongnu.org, shannon.zhao@linaro.org
Subject: Re: [Qemu-devel] [PATCH v2 2/2] hw/arm/virt-acpi-build: Add DBG2 table
Date: Mon, 14 Sep 2015 18:35:17 +0200 [thread overview]
Message-ID: <20150914163517.GD4652@hawk.localdomain> (raw)
In-Reply-To: <1442156793-30708-3-git-send-email-leif.lindholm@linaro.org>
On Sun, Sep 13, 2015 at 04:06:33PM +0100, Leif Lindholm wrote:
> Add a DBG2 table, describing the pl011 UART.
>
> Signed-off-by: Leif Lindholm <leif.lindholm@linaro.org>
> ---
> hw/arm/virt-acpi-build.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 59 insertions(+), 1 deletion(-)
>
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 9088248..0ea7023 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -352,6 +352,61 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
> }
>
> static void
> +build_dbg2(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> +{
> + AcpiDebugPort2Header *dbg2;
> + AcpiDebugPort2Device *dev;
> + struct AcpiGenericAddress *addr;
> + uint32_t *addr_size;
> + char *name;
> + const MemMapEntry *uart_memmap = &guest_info->memmap[VIRT_UART];
> + int table_size, dev_size, namepath_length;
> + const char namepath[] = ".";
> +
> + namepath_length = strlen(namepath) + 1;
> + dev_size = sizeof(*dev) + sizeof(*addr) * 1 + sizeof(uint32_t) * 1 +
> + namepath_length;
> + table_size = dev_size + sizeof(AcpiDebugPort2Header);
> +
> + dbg2 = acpi_data_push(table_data, table_size);
> + dev = (void *)dbg2 + sizeof(*dbg2);
> + addr = (void *)dev + sizeof(*dev);
> + addr_size = (void *)addr + sizeof(*addr);
> + name = (void *)addr_size + sizeof(*addr_size);
> +
> + dbg2->devices_offset = sizeof(*dbg2);
> + dbg2->devices_count = 1;
> +
> + /* First (only) debug device */
> + dev->revision = 0;
> + dev->length = cpu_to_le16(dev_size);
> + dev->address_count = 1;
> + dev->namepath_length = cpu_to_le16(namepath_length);
> + dev->namepath_offset = cpu_to_le16((void *)name - (void *)dev);
> + dev->oem_data_length = 0;
> + dev->oem_data_offset = 0;
> + dev->port_type = cpu_to_le16(0x8000); /* Serial */
> + dev->port_subtype = cpu_to_le16(0x3); /* ARM PL011 UART */
> + dev->base_address_offset = cpu_to_le16((void *)addr - (void *)dev);
> + dev->address_size_offset = cpu_to_le16((void *)addr_size - (void *)dev);
> +
> + /* First (only) address */
> + addr->space_id = AML_SYSTEM_MEMORY;
> + addr->bit_width = 8;
> + addr->bit_offset = 0;
> + addr->access_width = 1;
> + addr->address = cpu_to_le64(uart_memmap->base);
> +
> + /* Size of first (only) address */
> + *addr_size = cpu_to_le32(sizeof(*addr));
> +
> + /* Namespace String for first (only) device */
> + strcpy(name, namepath);
> +
> + build_header(linker, table_data, (void *)dbg2, "DBG2", table_size, 0);
> +}
> +
> +static void
> build_spcr(GArray *table_data, GArray *linker, VirtGuestInfo *guest_info)
> {
> AcpiSerialPortConsoleRedirection *spcr;
> @@ -577,7 +632,7 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
> dsdt = tables_blob->len;
> build_dsdt(tables_blob, tables->linker, guest_info);
>
> - /* FADT MADT GTDT MCFG SPCR pointed to by RSDT */
> + /* FADT MADT GTDT MCFG DBG2 SPCR pointed to by RSDT */
> acpi_add_table(table_offsets, tables_blob);
> build_fadt(tables_blob, tables->linker, dsdt);
>
> @@ -591,6 +646,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)
> build_mcfg(tables_blob, tables->linker, guest_info);
>
> acpi_add_table(table_offsets, tables_blob);
> + build_dbg2(tables_blob, tables->linker, guest_info);
> +
> + acpi_add_table(table_offsets, tables_blob);
> build_spcr(tables_blob, tables->linker, guest_info);
>
> /* RSDT is pointed to by RSDP */
> --
> 2.1.4
>
>
This looks good to me, since it's pretty unlikely we'll ever want
more than one device, so
Reviewed-by: Andrew Jones <drjones@redhat.com>
But, when I read that the table generation had become dynamic, I was sort
of expecting something like
void dbg2_add_device(...)
{
...
}
void build_dbg2(...)
{
do_top_level_table_stuff...
for_each_debug_device
dbg2_add_device()
finalize_table...
}
drew
next prev parent reply other threads:[~2015-09-14 16:35 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-09-13 15:06 [Qemu-devel] [PATCH v2 0/2] ACPI/arm-virt: add DBG2 Leif Lindholm
2015-09-13 15:06 ` [Qemu-devel] [PATCH v2 1/2] ACPI: Add definitions for the DBG2 table Leif Lindholm
2015-09-14 16:30 ` Andrew Jones
2015-09-13 15:06 ` [Qemu-devel] [PATCH v2 2/2] hw/arm/virt-acpi-build: Add " Leif Lindholm
2015-09-14 16:35 ` Andrew Jones [this message]
2015-09-15 1:20 ` Shannon Zhao
2015-09-15 14:30 ` Leif Lindholm
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=20150914163517.GD4652@hawk.localdomain \
--to=drjones@redhat.com \
--cc=imammedo@redhat.com \
--cc=leif.lindholm@linaro.org \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shannon.zhao@linaro.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).