acpi-build: add -acpitable support
cover acpi-build: add -acpitable support
This small patchset is on top of my acpi series v9 - as that is very big by now, sending as incremental patches to simplify review.
Michael S. Tsirkin (3):
acpi: add interface to access user-installed tables
pc: use new api to add builtin tables
acpi-build: load tables supplied by user
include/hw/acpi/acpi.h | 4 ++++ hw/acpi/core.c | 40 ++++++++++++++++++++++++++++++++++++++++ hw/i386/acpi-build.c | 9 +++++++++ hw/i386/pc.c | 2 +- 4 files changed, 54 insertions(+), 1 deletion(-)
Signature · 1 line
MST
PATCH 1/3 acpi: add interface to access user-installed tables
Also add a new API to install builtin tables, so
that we can distinguish between the two.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- include/hw/acpi/acpi.h | 4 ++++ hw/acpi/core.c | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+)
include/hw/acpi/acpi.h +4 -0
@@ -165,6 +165,10 @@ extern int acpi_enabled;extern char unsigned *acpi_tables;extern size_t acpi_tables_len; +uint8_t *acpi_table_first (void ); +uint8_t *acpi_table_next (uint8_t *current); +unsigned acpi_table_len (void *current);void acpi_table_add (const QemuOpts *opts,Error **errp); +void acpi_table_add_builtin (const QemuOpts *opts,Error **errp);#endif /* !QEMU_HW_ACPI_H */
hw/acpi/core.c +40 -0
@@ -309,6 +309,46 @@ out:error_propagate (errp, err); } +static bool acpi_table_builtin = false; + +void acpi_table_add_builtin (const QemuOpts *opts,Error **errp) +{ + acpi_table_builtin = true; +acpi_table_add (opts, errp); +} + +unsigned acpi_table_len (void *current) +{ +struct acpi_table_header *hdr = current -sizeof (hdr->_length); +return hdr->_length; +} + +static +void *acpi_table_hdr (void *h) +{ +struct acpi_table_header *hdr = h; +return &hdr->sig; +} + +uint8_t *acpi_table_first (void ) +{ +if (acpi_table_builtin || !acpi_tables) { +return NULL ; + } +return acpi_table_hdr (acpi_tables +ACPI_TABLE_PFX_SIZE ); +} + +uint8_t *acpi_table_next (uint8_t *current) +{ +uint8_t *next = current +acpi_table_len (current); + +if (next - acpi_tables >= acpi_tables_len) { +return NULL ; + }else { +return acpi_table_hdr (next); + } +} +static void acpi_notify_wakeup (Notifier *notifier,void *data) {ACPIREGS *ar =container_of (notifier,ACPIREGS , wakeup);
Signature · 1 line
MST
PATCH 2/3 pc: use new api to add builtin tables
In reply to Michael S. TsirkinAt this point the only builtin table we have is
the DSDT used for Q35.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- hw/i386/pc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
hw/i386/pc.c +1 -1
@@ -1116,7 +1116,7 @@ void pc_acpi_init(const char *default_dsdt) opts =qemu_opts_parse (qemu_find_opts ("acpi" ), arg,0 );g_assert (opts !=NULL ); -acpi_table_add (opts, &err); +acpi_table_add_builtin (opts, &err);if (err) {error_report ("WARNING: failed to load %s: %s" , filename,error_get_pretty (err));
Signature · 1 line
MST
PATCH 3/3 acpi-build: load tables supplied by user
In reply to Michael S. TsirkinIf user supplies any SSDTs using -acpi,
install them in addition to the built-in ones.
Signed-off-by Michael S. Tsirkin <[email protected]>
--- hw/i386/acpi-build.c | 9 +++++++++ 1 file changed, 9 insertions(+)
hw/i386/acpi-build.c +9 -0
@@ -1041,6 +1041,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)AcpiMiscInfo misc;AcpiMcfgInfo mcfg;PcPciInfo pci; +uint8_t *u;acpi_get_cpu_info (&cpu);acpi_get_pm_info (&pm);
@@ -1092,6 +1093,14 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)build_mcfg_q35 (tables->table_data, tables->linker, &mcfg); } +/* Add tables supplied by user (if any) */ +for (u =acpi_table_first (); u; u =acpi_table_next (u)) { +unsigned len =acpi_table_len (u); + +acpi_add_table (table_offsets, tables->table_data); +g_array_append_vals (tables->table_data, u, len); + } +/* RSDT is pointed to by RSDP */ rsdt = tables->table_data->len;build_rsdt (tables->table_data, tables->linker, table_offsets);
Signature · 1 line
MST