ACPI: ARM: add SPCR table
v2 cover ACPI: ARM: add SPCR table
Adding this table allows the guest to boot without the console= parameter added to the kernel command line. And anyway, kernel doc Documentation/arm64/acpi_object_usage.txt says it's a required table for arm64.
v2:
- checkpatch style fixes [Shannon]
- table is revision 2, not 5 [Shannon]
- use AML_SYSTEM_MEMORY [Shannon]
- tested-by Shannon
Andrew Jones (2):
ACPI: Add definitions for the SPCR table
hw/arm/virt-acpi-build: Add SPCR table
hw/arm/virt-acpi-build.c | 43 ++++++++++++++++++++++++++- include/hw/acpi/acpi-defs.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 114 insertions(+), 1 deletion(-)
Signature · 1 line
1.8.3.1
PATCH v2 1/2 ACPI: Add definitions for the SPCR table
SPCR is the Serial Port Console Redirection table. See the document linked from http://uefi.org/acpi. For serial port types, "Interface Type", see the documentation for the Debug Port Table 2 (DBG2).
--- include/hw/acpi/acpi-defs.h | 72 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 72 insertions(+)
include/hw/acpi/acpi-defs.h +72 -0
@@ -197,6 +197,78 @@ enum { };/* +* ACPI Serial Port Console Redirection Table +*/ +enum { +ACPI_SERIAL_16550_COMPAT =0 , +ACPI_SERIAL_16550_SUBSET_COMPAT =1 , +ACPI_SERIAL_ARM_PL011_UART =3 , +}; + +enum { +ACPI_SERIAL_ITYPE_PC =1 , +ACPI_SERIAL_ITYPE_APIC =2 , +ACPI_SERIAL_ITYPE_SAPIC =4 , +ACPI_SERIAL_ITYPE_ARMH_GIC =8 , +}; + +enum { +ACPI_SERIAL_BAUD_9600 =3 , +ACPI_SERIAL_BAUD_19200 =4 , +ACPI_SERIAL_BAUD_57600 =6 , +ACPI_SERIAL_BAUD_115200 =7 , +}; + +enum { +ACPI_SERIAL_FLOW_DCD_REQUIRED =1 , +ACPI_SERIAL_FLOW_HW =2 , +ACPI_SERIAL_FLOW_SW =4 , +}; + +enum { +ACPI_SERIAL_TERM_VT100 =0 , +ACPI_SERIAL_TERM_VT100_PLUS =1 , +ACPI_SERIAL_TERM_VT_UTF8 =2 , +ACPI_SERIAL_TERM_ANSI =3 , +}; + +struct AcpiSerialPortConsoleRedirection { +ACPI_TABLE_HEADER_DEF /* ACPI common table header */ + uint8_t interface_type; /* See ACPI_SERIAL_ enums */ +uint8_t reserved1[3 ];/* Reserved, must be 0 */ +struct AcpiGenericAddress base_address; +uint8_t interrupt_types;/* Interrupt type support mask, +* see ACPI_SERIAL_ITYPE_ enums */ +uint8_t irq;/* PC irq used. 0 if ACPI_SERIAL_ITYPE_PC +* is not set, else must be one of +* 2-7,9-12,14-15 */ +uint32_t gsi;/* Not valid if only ACPI_SERIAL_ITYPE_PC +* is set in the interrupt_types mask */ +uint8_t baud;/* See ACPI_SERIAL_BAUD_ enums */ +uint8_t parity;/* 0 = no parity, 1-255 reserved */ +uint8_t stopbits;/* Must be 1 */ +uint8_t flowctrl;/* See ACPI_SERIAL_FLOW_ enums */ +uint8_t term_type;/* See ACPI_SERIAL_TERM_ enums */ +uint8_t reserved2;/* Reserved, must be 0 */ +uint16_t pci_device_id;/* 0xffff, if not a pci dev */ +uint16_t pci_vendor_id;/* 0xffff, if not a pci dev */ +uint8_t pci_bus;/* PCI bus number, 0 if not a pci dev */ +uint8_t pci_slot;/* PCI slot number, 0 if not a pci dev */ +uint8_t pci_func;/* PCI function num, 0 if not a pci dev */ +uint32_t pci_flags;/* PCI compatibility mask, +* bits 1-31 reserved +* bit0 = 0, if not a pci dev +* bit0 = 1, don't suppress PNP or +* power management +*/ +uint8_t pci_seg;/* PCI segment number, 0 for systems +with less than 255 PCI busses */ +uint32_t reserved3;/* Reserved, must be 0 */ +}QEMU_PACKED ; +typedef struct AcpiSerialPortConsoleRedirection +AcpiSerialPortConsoleRedirection ; + +/* * ACPI 1.0 Root System Description Table (RSDT) */ struct AcpiRsdtDescriptorRev1
Signature · 1 line
1.8.3.1
PATCH v2 2/2 hw/arm/virt-acpi-build: Add SPCR table
In reply to Andrew Jones--- hw/arm/virt-acpi-build.c | 43 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-)
hw/arm/virt-acpi-build.c +42 -1
@@ -84,6 +84,12 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,aml_interrupt (AML_CONSUMER ,AML_LEVEL ,AML_ACTIVE_HIGH , AML_EXCLUSIVE, uart_irq));aml_append (dev,aml_name_decl ("_CRS" , crs)); + +/* The _ADR entry is used to link this device to the UART described +* in the SPCR table. +*/ +aml_append (dev,aml_name_decl ("_ADR" ,aml_int (uart_memmap->base))); +aml_append (scope, dev); }
@@ -334,6 +340,38 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt) }static void +build_spcr (GArray *table_data,GArray *linker,VirtGuestInfo *guest_info) +{ +AcpiSerialPortConsoleRedirection *spcr; +const MemMapEntry *memmap = &guest_info->memmap[VIRT_UART ]; +int irq = guest_info->irqmap[VIRT_UART ] +ARM_SPI_BASE ; + + spcr =acpi_data_push (table_data,sizeof (*spcr)); + + spcr->interface_type =ACPI_SERIAL_ARM_PL011_UART ; + + spcr->base_address.space_id =AML_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 (memmap->base); + + spcr->interrupt_types =ACPI_SERIAL_ITYPE_ARMH_GIC ; + spcr->gsi =cpu_to_le32 (irq); + + spcr->baud =ACPI_SERIAL_BAUD_9600 ; + spcr->parity =0 ; + spcr->stopbits =1 ; + spcr->flowctrl =ACPI_SERIAL_FLOW_HW ; + spcr->term_type =ACPI_SERIAL_TERM_VT100 ; + + spcr->pci_device_id =0xffff ; + spcr->pci_vendor_id =0xffff ; + +build_header (linker, table_data, (void *)spcr,"SPCR" ,sizeof (*spcr),2 ); +} + +static void build_mcfg (GArray *table_data,GArray *linker,VirtGuestInfo *guest_info) {AcpiTableMcfg *mcfg;
@@ -514,7 +552,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 pointed to by RSDT */ +/* FADT MADT GTDT SPCR pointed to by RSDT */ acpi_add_table (table_offsets, tables_blob);build_fadt (tables_blob, tables->linker, dsdt);
@@ -527,6 +565,9 @@ void virt_acpi_build(VirtGuestInfo *guest_info, AcpiBuildTables *tables)acpi_add_table (table_offsets, tables_blob);build_mcfg (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 */ rsdt = tables_blob->len;build_rsdt (tables_blob, tables->linker, table_offsets);
Signature · 1 line
1.8.3.1