From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40583) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGPTp-00045y-OU for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:04:18 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGPTj-00029L-Je for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:04:13 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56555) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGPTj-00029G-D5 for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:04:07 -0500 From: Igor Mammedov Date: Wed, 28 Jan 2015 10:03:36 +0000 Message-Id: <1422439417-5031-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1422439417-5031-1-git-send-email-imammedo@redhat.com> References: <20150128072757.GA12987@redhat.com> <1422439417-5031-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH 12/13] acpi: prepare for API internal collection of RSDT entries List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, zhaoshenglong@huawei.com, claudio.fontana@huawei.com, marcel.a@redhat.com Signed-off-by: Igor Mammedov --- hw/acpi/acpi-build-utils.c | 19 +++++++++++++++++++ hw/i386/acpi-build.c | 16 ++++++++++------ include/hw/acpi/acpi-build-utils.h | 2 ++ 3 files changed, 31 insertions(+), 6 deletions(-) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index fe598ff..ae62da6 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -328,6 +328,10 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml *child) uint32_t le32_len = cpu_to_le32(child->buf->len); AcpiAmlTablesBlob *tables_blob = AML_TABLES_BLOB(parent_ctx); + if (child->has_rsdt_entry) { + acpi_add_table(tables_blob->rsdt_entries, parent_ctx->buf); + } + /* create linker entry for the DefinitionBlock */ bios_linker_loader_add_checksum(tables_blob->linker, ACPI_BUILD_TABLE_FILE, @@ -963,10 +967,25 @@ static const TypeInfo aml_object_type_info = { .class_size = sizeof(AcpiAmlClass), }; +static void aml_tables_blob_initfn(Object *obj) { + AcpiAmlTablesBlob *tbobj = AML_TABLES_BLOB(obj); + + tbobj->rsdt_entries = g_array_new(false, true /* clear */, + sizeof(uint32_t)); +} + +static void aml_tables_blob_finalize(Object *obj) { + AcpiAmlTablesBlob *tbobj = AML_TABLES_BLOB(obj); + + g_array_free(tbobj->rsdt_entries, true); +} + static const TypeInfo aml_tables_blob_type_info = { .name = TYPE_AML_TABLES_BLOB, .parent = TYPE_AML_OBJECT, .instance_size = sizeof(AcpiAmlTablesBlob), + .instance_init = aml_tables_blob_initfn, + .instance_finalize = aml_tables_blob_finalize, .abstract = false, .class_size = sizeof(AcpiAmlTablesBlobClass), }; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index d923ac2..d7d2590 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1270,11 +1270,17 @@ struct AcpiBuildTables { static inline void acpi_build_tables_init(AcpiBuildTables *tables) { + AcpiAmlTablesBlob *tables_blob_obj; + tables->rsdp = g_array_new(false, true /* clear */, 1); + tables->table_data = AML_OBJECT(object_new(TYPE_AML_OBJECT)); tables->tcpalog = g_array_new(false, true /* clear */, 1); tables->linker = bios_linker_loader_init(); tables->table_data = AML_OBJECT(object_new(TYPE_AML_TABLES_BLOB)); - AML_TABLES_BLOB(tables->table_data)->linker = tables->linker; + tables_blob_obj = AML_TABLES_BLOB(tables->table_data); + tables_blob_obj->linker = tables->linker; + tables_blob_obj->rsdt_entries = g_array_new(false, true /* clear */, + sizeof(uint32_t)); } static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre) @@ -1282,6 +1288,8 @@ 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); + + /* Cleanup memory that's no longer used. */ object_unref(OBJECT(tables->table_data)); g_array_free(tables->tcpalog, mfre); } @@ -1349,8 +1357,7 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) acpi_get_misc_info(&misc); acpi_get_pci_info(&pci); - table_offsets = g_array_new(false, true /* clear */, - sizeof(uint32_t)); + table_offsets = AML_TABLES_BLOB(tables->table_data)->rsdt_entries; ACPI_BUILD_DPRINTF("init ACPI tables\n"); bios_linker_loader_alloc(tables->linker, ACPI_BUILD_TABLE_FILE, @@ -1473,9 +1480,6 @@ void acpi_build(PcGuestInfo *guest_info, AcpiBuildTables *tables) } acpi_align_size(tables->linker, ACPI_BUILD_ALIGN_SIZE); - - /* Cleanup memory that's no longer used. */ - g_array_free(table_offsets, true); } static void acpi_build_update(void *build_opaque, uint32_t offset) diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index 4bbe6b5..6a0c9a1 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -30,6 +30,7 @@ typedef struct AcpiAml { GArray *buf; uint8_t op; AcpiBlockFlags block_flags; + bool has_rsdt_entry; } AcpiAml; typedef struct AcpiAmlClass { @@ -46,6 +47,7 @@ typedef struct AcpiAmlClass { typedef struct AcpiAmlTablesBlob { AcpiAml parent_obj; GArray *linker; + GArray *rsdt_entries; } AcpiAmlTablesBlob; typedef struct AcpiAmlTablesBlobClass { -- 1.8.3.1