From: Igor Mammedov <imammedo@redhat.com>
To: Eric Auger <eauger@redhat.com>
Cc: peter.maydell@linaro.org, drjones@redhat.com, mst@redhat.com,
qemu-devel@nongnu.org, shannon.zhaosl@gmail.com,
qemu-arm@nongnu.org
Subject: Re: [PATCH v2 31/35] acpi: arm/virt: build_spcr: use acpi_init_table()/acpi_table_composed() instead of build_header()
Date: Fri, 3 Sep 2021 09:52:52 +0200 [thread overview]
Message-ID: <20210903095252.5408f43b@redhat.com> (raw)
In-Reply-To: <9c3ae446-3ed4-7a49-721a-95ad3e6d66cf@redhat.com>
On Thu, 2 Sep 2021 17:49:55 +0200
Eric Auger <eauger@redhat.com> wrote:
> Hi Igor,
>
> On 7/8/21 5:46 PM, Igor Mammedov wrote:
> > it replaces error-prone pointer arithmetic for build_header() API,
> > with 2 calls to start and finish table creation,
> > which hides offsets magic from API user.
> >
> > while at it, replace packed structure with endian agnostic
> > build_append_FOO() API.
> >
> > Signed-off-by: Igor Mammedov <imammedo@redhat.com>
> > ---
> > CC: drjones@redhat.com
> > CC: peter.maydell@linaro.org
> > CC: shannon.zhaosl@gmail.com
> > CC: qemu-arm@nongnu.org
> > ---
> > include/hw/acpi/acpi-defs.h | 32 -----------------
> > hw/arm/virt-acpi-build.c | 68 ++++++++++++++++++++++---------------
> > 2 files changed, 41 insertions(+), 59 deletions(-)
> >
> > diff --git a/include/hw/acpi/acpi-defs.h b/include/hw/acpi/acpi-defs.h
> > index 6f2f08a9de..012c4ffb3a 100644
> > --- a/include/hw/acpi/acpi-defs.h
> > +++ b/include/hw/acpi/acpi-defs.h
> > @@ -117,38 +117,6 @@ typedef struct AcpiFadtData {
> > #define ACPI_FADT_ARM_PSCI_COMPLIANT (1 << 0)
> > #define ACPI_FADT_ARM_PSCI_USE_HVC (1 << 1)
> >
> > -/*
> > - * Serial Port Console Redirection Table (SPCR), Rev. 1.02
> > - *
> > - * For .interface_type see Debug Port Table 2 (DBG2) serial port
> > - * subtypes in Table 3, Rev. May 22, 2012
> > - */
> > -struct AcpiSerialPortConsoleRedirection {
> > - ACPI_TABLE_HEADER_DEF
> > - uint8_t interface_type;
> > - uint8_t reserved1[3];
> > - struct AcpiGenericAddress base_address;
> > - uint8_t interrupt_types;
> > - uint8_t irq;
> > - uint32_t gsi;
> > - uint8_t baud;
> > - uint8_t parity;
> > - uint8_t stopbits;
> > - uint8_t flowctrl;
> > - uint8_t term_type;
> > - uint8_t reserved2;
> > - uint16_t pci_device_id;
> > - uint16_t pci_vendor_id;
> > - uint8_t pci_bus;
> > - uint8_t pci_slot;
> > - uint8_t pci_func;
> > - uint32_t pci_flags;
> > - uint8_t pci_seg;
> > - uint32_t reserved3;
> > -} QEMU_PACKED;
> > -typedef struct AcpiSerialPortConsoleRedirection
> > - AcpiSerialPortConsoleRedirection;
> > -
> > /*
> > * ACPI 1.0 Firmware ACPI Control Structure (FACS)
> > */
> > diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> > index a07540affb..e8553dcae5 100644
> > --- a/hw/arm/virt-acpi-build.c
> > +++ b/hw/arm/virt-acpi-build.c
> > @@ -349,39 +349,53 @@ build_iort(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> > acpi_table_composed(linker, &table);
> > }
> >
> > +/*
> > + * Serial Port Console Redirection Table (SPCR)
> > + * Rev: 1.07
> > + */
> was
> /*
> * Serial Port Console Redirection Table (SPCR), Rev. 1.02
> */
>
> By the way
> https://uefi.org/acpi/specs does not list 1.02 nor 1.07
> https://docs.microsoft.com/en-us/windows-hardware/drivers/serports/serial-port-console-redirection-table
> ?
That's problem with using MS 'specifications', which is a web page
pointing to the current revision only. (I wasn't able to find
1.02 revision to use doc comments).
So I had to use currently available, which is 1.07 currently,
which seems to be binary compatible with our original 1.02
(that's why it passes bios-tables-test).
>
> > static void
> > build_spcr(GArray *table_data, BIOSLinker *linker, VirtMachineState *vms)
> > {
> > - AcpiSerialPortConsoleRedirection *spcr;
> > - const MemMapEntry *uart_memmap = &vms->memmap[VIRT_UART];
> > - int irq = vms->irqmap[VIRT_UART] + ARM_SPI_BASE;
> > - int spcr_start = table_data->len;
> > -
> > - spcr = acpi_data_push(table_data, sizeof(*spcr));
> > -
> > - spcr->interface_type = 0x3; /* ARM PL011 UART */
> > -
> > - spcr->base_address.space_id = AML_AS_SYSTEM_MEMORY;
> > - spcr->base_address.bit_width = 8;
> > - spcr->base_address.bit_offset = 0;
> > - spcr->base_address.access_width = 1;
> > - spcr->base_address.address = cpu_to_le64(uart_memmap->base);
> > -
> > - spcr->interrupt_types = (1 << 3); /* Bit[3] ARMH GIC interrupt */
> > - spcr->gsi = cpu_to_le32(irq); /* Global System Interrupt */
> > + AcpiTable table = { .sig = "SPCR", .rev = 2, .oem_id = vms->oem_id,
> > + .oem_table_id = vms->oem_table_id };
> >
> > - spcr->baud = 3; /* Baud Rate: 3 = 9600 */
> > - spcr->parity = 0; /* No Parity */
> > - spcr->stopbits = 1; /* 1 Stop bit */
> > - spcr->flowctrl = (1 << 1); /* Bit[1] = RTS/CTS hardware flow control */
> > - spcr->term_type = 0; /* Terminal Type: 0 = VT100 */
> > + acpi_init_table(&table, table_data);
> >
> > - spcr->pci_device_id = 0xffff; /* PCI Device ID: not a PCI device */
> > - spcr->pci_vendor_id = 0xffff; /* PCI Vendor ID: not a PCI device */
> > + /* Interface Type */
> > + build_append_int_noprefix(table_data, 3, 1); /* ARM PL011 UART */
> > + build_append_int_noprefix(table_data, 0, 3); /* Reserved */
> > + /* Base Address */
> > + build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 8, 0, 1,
> > + vms->memmap[VIRT_UART].base);
> > + /* Interrupt Type */
> > + build_append_int_noprefix(table_data,
> > + (1 << 3) /* Bit[3] ARMH GIC interrupt */, 1);
> > + build_append_int_noprefix(table_data, 0, 1); /* IRQ */
> > + /* Global System Interrupt */
> > + build_append_int_noprefix(table_data,
> > + vms->irqmap[VIRT_UART] + ARM_SPI_BASE, 4);
> > + build_append_int_noprefix(table_data, 3 /* 9600 */, 1); /* Baud Rate */
> > + build_append_int_noprefix(table_data, 0 /* No Parity */, 1); /* Parity */
> > + /* Stop Bits */
> > + build_append_int_noprefix(table_data, 1 /* 1 Stop bit */, 1);
> > + /* Flow Control */
> > + build_append_int_noprefix(table_data,
> > + (1 << 1) /* RTS/CTS hardware flow control */, 1);
> > + /* Terminal Type */
> > + build_append_int_noprefix(table_data, 0 /* VT100 */, 1);
> > + build_append_int_noprefix(table_data, 0, 1); /* Language */
> reserved2 -> language in 1.07? but that's fine
> maybe just mention it in the commit msg?
sure, I'll add that into commit message.
> > + /* PCI Device ID */
> > + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2);
> > + /* PCI Vendor ID */
> > + build_append_int_noprefix(table_data, 0xffff /* not a PCI device*/, 2);
> > + build_append_int_noprefix(table_data, 0, 1); /* PCI Bus Number */
> > + build_append_int_noprefix(table_data, 0, 1); /* PCI Device Number */
> > + build_append_int_noprefix(table_data, 0, 1); /* PCI Function Number */
> > + build_append_int_noprefix(table_data, 0, 4); /* PCI Flags */
> > + build_append_int_noprefix(table_data, 0, 1); /* PCI Segment */
> > + build_append_int_noprefix(table_data, 0, 4); /* Reserved */
> >
> > - build_header(linker, table_data, (void *)(table_data->data + spcr_start),
> > - "SPCR", table_data->len - spcr_start, 2, vms->oem_id,
> > - vms->oem_table_id);
> > + acpi_table_composed(linker, &table);
> > }
> >
> > /*
> >
> Reviewed-by: Eric Auger <eric.auger@redhat.com>
>
> Eric
>
next prev parent reply other threads:[~2021-09-03 7:54 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-08 15:45 [PATCH v2 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 01/35] acpi: add helper routines to initialize " Igor Mammedov
2021-09-02 12:56 ` Eric Auger
2021-09-03 7:12 ` Igor Mammedov
2021-09-03 7:22 ` Eric Auger
2021-09-06 12:17 ` Igor Mammedov
2021-09-04 19:57 ` Michael S. Tsirkin
2021-09-06 12:14 ` Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 02/35] acpi: build_rsdt: use acpi_init_table()/acpi_table_composed() instead of build_header() Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 03/35] acpi: build_xsdt: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 04/35] acpi: build_slit: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 05/35] acpi: build_fadt: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 06/35] acpi: build_tpm2: " Igor Mammedov
2021-09-02 12:59 ` Eric Auger
2021-07-08 15:45 ` [PATCH v2 07/35] acpi: acpi_build_hest: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 08/35] acpi: build_mcfg: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 09/35] acpi: build_hmat: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 10/35] acpi: nvdimm_build_nfit: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 11/35] acpi: nvdimm_build_ssdt: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 12/35] acpi: vmgenid_build_acpi: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 13/35] acpi: x86: build_dsdt: " Igor Mammedov
2021-09-02 15:35 ` Eric Auger
2021-07-08 15:45 ` [PATCH v2 14/35] acpi: build_hpet: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 15/35] acpi: build_tpm_tcpa: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 16/35] acpi: arm/x86: build_srat: " Igor Mammedov
2021-07-08 15:45 ` [PATCH v2 17/35] acpi: use build_append_int_noprefix() API to compose SRAT table Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 18/35] acpi: build_dmar_q35: use acpi_init_table()/acpi_table_composed() instead of build_header() Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 19/35] acpi: build_waet: " Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 20/35] acpi: build_amd_iommu: " Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 21/35] acpi: madt: arm/x86: " Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 22/35] acpi: x86: remove dead code Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 23/35] acpi: x86: set enabled when composing _MAT entries Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 24/35] acpi: x86: madt: use build_append_int_noprefix() API to compose MADT table Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 25/35] acpi: arm/virt: " Igor Mammedov
2021-09-03 13:45 ` Eric Auger
2021-09-06 12:40 ` Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 26/35] acpi: build_dsdt_microvm: use acpi_init_table()/acpi_table_composed() instead of build_header() Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 27/35] acpi: arm: virt: build_dsdt: " Igor Mammedov
2021-09-02 15:34 ` Eric Auger
2021-07-08 15:46 ` [PATCH v2 28/35] acpi: arm: virt: build_iort: " Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 29/35] acpi: arm/virt: convert build_iort() to endian agnostic build_append_FOO() API Igor Mammedov
2021-07-09 7:11 ` Michael S. Tsirkin
2021-07-09 8:59 ` Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 30/35] acpi: arm/virt: build_spcr: fix invalid cast Igor Mammedov
2021-09-02 15:51 ` Eric Auger
2021-07-08 15:46 ` [PATCH v2 31/35] acpi: arm/virt: build_spcr: use acpi_init_table()/acpi_table_composed() instead of build_header() Igor Mammedov
2021-09-02 15:49 ` Eric Auger
2021-09-03 7:52 ` Igor Mammedov [this message]
2021-07-08 15:46 ` [PATCH v2 32/35] acpi: arm/virt: build_gtdt: " Igor Mammedov
2021-09-02 16:07 ` Eric Auger
2021-07-08 15:46 ` [PATCH v2 33/35] acpi: build_facs: use build_append_int_noprefix() API to compose table Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 34/35] acpi: remove no longer used build_header() Igor Mammedov
2021-07-08 15:46 ` [PATCH v2 35/35] acpi: AcpiGenericAddress no longer used to map/access fields of MMIO, drop packed attribute Igor Mammedov
2021-07-13 15:45 ` [PATCH v2 00/35] acpi: refactor error prone build_header() and packed structures usage in ACPI tables Michael S. Tsirkin
2021-07-14 8:53 ` Igor Mammedov
2021-07-14 10:31 ` Michael S. Tsirkin
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=20210903095252.5408f43b@redhat.com \
--to=imammedo@redhat.com \
--cc=drjones@redhat.com \
--cc=eauger@redhat.com \
--cc=mst@redhat.com \
--cc=peter.maydell@linaro.org \
--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 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).