From: Igor Mammedov <imammedo@redhat.com>
To: qemu-devel@nongnu.org
Cc: pbonzini@redhat.com, drjones@redhat.com,
claudio.fontana@huawei.com, mst@redhat.com
Subject: [Qemu-devel] [RFC 44/47] pc: acpi-build: prepare to make ACPI tables blob opaque for table building functions
Date: Fri, 19 Dec 2014 02:02:39 +0000 [thread overview]
Message-ID: <1418954562-13716-45-git-send-email-imammedo@redhat.com> (raw)
In-Reply-To: <1418954562-13716-1-git-send-email-imammedo@redhat.com>
it allows to hide linker and direct access to table's
storage from table building function if it would use
acpi_def_block() to declare table and ASL/AML API to
compose it. Which following patch will do for
build_ssdt() function.
Signed-off-by: Igor Mammedov <imammedo@redhat.com>
---
PS:
this series does it only for build_ssdt(), but it also
could be done for other tables later by using there
acpi_def_block() to describe table's header and
adding addtional API to compose table's entries.
---
hw/i386/acpi-build.c | 85 ++++++++++++++++++++++++++--------------------------
1 file changed, 43 insertions(+), 42 deletions(-)
diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
index 3a22bdb..347448b 100644
--- a/hw/i386/acpi-build.c
+++ b/hw/i386/acpi-build.c
@@ -1253,7 +1253,7 @@ build_rsdp(GArray *rsdp_table, GArray *linker, unsigned rsdt)
typedef
struct AcpiBuildTables {
- GArray *table_data;
+ AcpiAml table_data;
GArray *rsdp;
GArray *tcpalog;
GArray *linker;
@@ -1262,9 +1262,10 @@ struct AcpiBuildTables {
static inline void acpi_build_tables_init(AcpiBuildTables *tables)
{
tables->rsdp = g_array_new(false, true /* clear */, 1);
- tables->table_data = g_array_new(false, true /* clear */, 1);
+ tables->table_data.buf = g_array_new(false, true /* clear */, 1);
tables->tcpalog = g_array_new(false, true /* clear */, 1);
tables->linker = bios_linker_loader_init();
+ tables->table_data.linker = tables->linker;
}
static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
@@ -1272,7 +1273,7 @@ static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre)
void *linker_data = bios_linker_loader_cleanup(tables->linker);
g_free(linker_data);
g_array_free(tables->rsdp, mfre);
- g_array_free(tables->table_data, true);
+ g_array_free(tables->table_data.buf, true);
g_array_free(tables->tcpalog, mfre);
}
@@ -1352,66 +1353,66 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
* We place it first since it's the only table that has alignment
* requirements.
*/
- facs = tables->table_data->len;
- build_facs(tables->table_data, tables->linker, guest_info);
+ facs = tables->table_data.buf->len;
+ build_facs(tables->table_data.buf, tables->linker, guest_info);
/* DSDT is pointed to by FADT */
- dsdt = tables->table_data->len;
- build_dsdt(tables->table_data, tables->linker, &misc);
+ dsdt = tables->table_data.buf->len;
+ build_dsdt(tables->table_data.buf, tables->linker, &misc);
/* Count the size of the DSDT and SSDT, we will need it for legacy
* sizing of ACPI tables.
*/
- aml_len += tables->table_data->len - dsdt;
+ aml_len += tables->table_data.buf->len - dsdt;
/* ACPI tables pointed to by RSDT */
- acpi_add_table(table_offsets, tables->table_data);
- build_fadt(tables->table_data, tables->linker, &pm, facs, dsdt);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_fadt(tables->table_data.buf, tables->linker, &pm, facs, dsdt);
- ssdt = tables->table_data->len;
- acpi_add_table(table_offsets, tables->table_data);
- build_ssdt(tables->table_data, tables->linker, &cpu, &pm, &misc, &pci,
+ ssdt = tables->table_data.buf->len;
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_ssdt(tables->table_data.buf, tables->linker, &cpu, &pm, &misc, &pci,
guest_info);
- aml_len += tables->table_data->len - ssdt;
+ aml_len += tables->table_data.buf->len - ssdt;
- acpi_add_table(table_offsets, tables->table_data);
- build_madt(tables->table_data, tables->linker, &cpu, guest_info);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_madt(tables->table_data.buf, tables->linker, &cpu, guest_info);
if (misc.has_hpet) {
- acpi_add_table(table_offsets, tables->table_data);
- build_hpet(tables->table_data, tables->linker);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_hpet(tables->table_data.buf, tables->linker);
}
if (misc.has_tpm) {
- acpi_add_table(table_offsets, tables->table_data);
- build_tpm_tcpa(tables->table_data, tables->linker, tables->tcpalog);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_tpm_tcpa(tables->table_data.buf, tables->linker, tables->tcpalog);
- acpi_add_table(table_offsets, tables->table_data);
- build_tpm_ssdt(tables->table_data, tables->linker);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_tpm_ssdt(tables->table_data.buf, tables->linker);
}
if (guest_info->numa_nodes) {
- acpi_add_table(table_offsets, tables->table_data);
- build_srat(tables->table_data, tables->linker, guest_info);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_srat(tables->table_data.buf, tables->linker, guest_info);
}
if (acpi_get_mcfg(&mcfg)) {
- acpi_add_table(table_offsets, tables->table_data);
- build_mcfg_q35(tables->table_data, tables->linker, &mcfg);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_mcfg_q35(tables->table_data.buf, tables->linker, &mcfg);
}
if (acpi_has_iommu()) {
- acpi_add_table(table_offsets, tables->table_data);
- build_dmar_q35(tables->table_data, tables->linker);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ build_dmar_q35(tables->table_data.buf, tables->linker);
}
/* 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);
+ acpi_add_table(table_offsets, tables->table_data.buf);
+ g_array_append_vals(tables->table_data.buf, u, len);
}
/* RSDT is pointed to by RSDP */
- rsdt = tables->table_data->len;
- build_rsdt(tables->table_data, tables->linker, table_offsets);
+ rsdt = tables->table_data.buf->len;
+ build_rsdt(tables->table_data.buf, tables->linker, table_offsets);
/* RSDP is in FSEG memory, so allocate it separately */
build_rsdp(tables->rsdp, tables->linker, rsdt);
@@ -1443,23 +1444,23 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables)
guest_info->legacy_acpi_table_size +
ACPI_BUILD_LEGACY_CPU_AML_SIZE * max_cpus;
int legacy_table_size =
- ROUND_UP(tables->table_data->len - aml_len + legacy_aml_len,
+ ROUND_UP(tables->table_data.buf->len - aml_len + legacy_aml_len,
ACPI_BUILD_ALIGN_SIZE);
- if (tables->table_data->len > legacy_table_size) {
+ if (tables->table_data.buf->len > legacy_table_size) {
/* Should happen only with PCI bridges and -M pc-i440fx-2.0. */
error_report("Warning: migration may not work.");
}
- g_array_set_size(tables->table_data, legacy_table_size);
+ g_array_set_size(tables->table_data.buf, legacy_table_size);
} else {
/* Make sure we have a buffer in case we need to resize the tables. */
- if (tables->table_data->len > ACPI_BUILD_TABLE_SIZE / 2) {
+ if (tables->table_data.buf->len > ACPI_BUILD_TABLE_SIZE / 2) {
/* As of QEMU 2.1, this fires with 160 VCPUs and 255 memory slots. */
error_report("Warning: ACPI tables are larger than 64k.");
error_report("Warning: migration may not work.");
error_report("Warning: please remove CPUs, NUMA nodes, "
"memory slots or PCI bridges.");
}
- acpi_align_size(tables->table_data, ACPI_BUILD_TABLE_SIZE);
+ acpi_align_size(tables->table_data.buf, ACPI_BUILD_TABLE_SIZE);
}
acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE);
@@ -1483,8 +1484,8 @@ static void acpi_build_update(void *build_opaque, uint32_t offset)
acpi_build(build_state->guest_info, &tables);
- assert(acpi_data_len(tables.table_data) == build_state->table_size);
- memcpy(qemu_get_ram_ptr(build_state->table_ram), tables.table_data->data,
+ assert(acpi_data_len(tables.table_data.buf) == build_state->table_size);
+ memcpy(qemu_get_ram_ptr(build_state->table_ram), tables.table_data.buf->data,
build_state->table_size);
cpu_physical_memory_set_dirty_range_nocode(build_state->table_ram,
@@ -1546,10 +1547,10 @@ void acpi_setup(PcGuestInfo *guest_info)
acpi_build(build_state->guest_info, &tables);
/* Now expose it all to Guest */
- build_state->table_ram = acpi_add_rom_blob(build_state, tables.table_data,
- ACPI_BUILD_TABLE_FILE);
+ build_state->table_ram = acpi_add_rom_blob(build_state,
+ tables.table_data.buf, ACPI_BUILD_TABLE_FILE);
assert(build_state->table_ram != RAM_ADDR_MAX);
- build_state->table_size = acpi_data_len(tables.table_data);
+ build_state->table_size = acpi_data_len(tables.table_data.buf);
acpi_add_rom_blob(NULL, tables.linker, "etc/table-loader");
--
1.8.3.1
next prev parent reply other threads:[~2014-12-19 2:04 UTC|newest]
Thread overview: 58+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-12-19 2:01 [Qemu-devel] [RFC 00/47] ACPI refactoring: replace template patching with C ASL API Igor Mammedov
2014-12-19 2:01 ` [Qemu-devel] [RFC 01/47] acpi: introduce AML composer aml_append() Igor Mammedov
2014-12-19 2:01 ` [Qemu-devel] [RFC 02/47] acpi: add acpi_scope() term Igor Mammedov
2014-12-19 2:01 ` [Qemu-devel] [RFC 03/47] acpi: add acpi_device() term Igor Mammedov
2014-12-19 2:01 ` [Qemu-devel] [RFC 04/47] acpi: add acpi_method() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 05/47] acpi: add acpi_if() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 06/47] acpi: add acpi_name() & acpi_name_decl() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 07/47] acpi: factor out ACPI const int packing out build_append_value() Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 08/47] acpi: extend build_append_{value|int}() to support 64-bit values Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 09/47] acpi: add acpi_int() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 10/47] acpi: add acpi_return() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 11/47] acpi: add acpi_arg0(), acpi_arg1(), acpi_arg2(), acpi_arg3() terms Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 12/47] acpi: add acpi_store() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 13/47] acpi: add acpi_and() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 14/47] acpi: add acpi_notify() term Igor Mammedov
2015-01-19 12:32 ` Paolo Bonzini
2015-01-20 9:40 ` Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 15/47] acpi: add acpi_call1(), acpi_call2(), acpi_call3(), acpi_call4() helpers Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 16/47] pc: acpi-build: drop template patching and create PCI bus tree dinamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 17/47] acpi: add acpi_package() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 18/47] pc: acpi-build: drop unsupported PM1b_CNT.SLP_TYP Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 19/47] pc: acpi-build: generate _S[345] packages dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 20/47] acpi: add acpi_buffer() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 21/47] acpi: add acpi_resource_template() helper Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 22/47] acpi: add acpi_io() helper Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 23/47] acpi: include PkgLength size only when requested Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 24/47] acpi: add acpi_operation_region() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 25/47] acpi: add acpi_field() & acpi_named_field() terms Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 26/47] acpi: add acpi_local0() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 27/47] acpi: add acpi_string() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 28/47] pc: acpi-build: generate pvpanic device description dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 29/47] acpi: add acpi_varpackage() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 30/47] acpi: add acpi_equal() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 31/47] acpi: add acpi_processor() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 32/47] acpi: add acpi_eisaid() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 33/47] pc: acpi-build: drop template patching and CPU hotplug objects dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 34/47] pc: acpi-build: create CPU hotplug IO region dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 35/47] acpi: add acpi_reserved_field() term Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 36/47] pc: acpi-build: drop template patching and memory hotplug objects dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 37/47] pc: acpi-build: create memory hotplug IO region dynamically Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 38/47] acpi: add acpi_word_bus_number(), acpi_word_io(), acpi_dword_memory(), acpi_qword_memory() terms Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 39/47] pc: pcihp: expose MMIO base and len as properties Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 40/47] pc: acpi-build: reserve PCIHP MMIO resources Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 41/47] pc: acpi-build: create PCI0._CRS dynamically Igor Mammedov
2015-01-19 12:42 ` Paolo Bonzini
2015-01-19 21:55 ` Michael S. Tsirkin
2015-01-20 9:37 ` Marcel Apfelbaum
2015-01-20 9:42 ` Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 42/47] acpi: make tables linker-loader available to other targets Igor Mammedov
2015-01-19 12:36 ` Paolo Bonzini
2015-01-19 21:54 ` Michael S. Tsirkin
2015-01-19 22:05 ` Michael S. Tsirkin
2015-01-20 9:43 ` Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 43/47] acpi: add acpi_def_block() term Igor Mammedov
2014-12-19 2:02 ` Igor Mammedov [this message]
2014-12-19 2:02 ` [Qemu-devel] [RFC 45/47] pc: acpi-build: drop remaining ssdt_misc template and use acpi_def_block() Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 46/47] pc: acpi: update DSTD blobs Igor Mammedov
2014-12-19 2:02 ` [Qemu-devel] [RFC 47/47] tests: acpi: update reference DSDT/SSDT tables Igor Mammedov
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=1418954562-13716-45-git-send-email-imammedo@redhat.com \
--to=imammedo@redhat.com \
--cc=claudio.fontana@huawei.com \
--cc=drjones@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.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).