From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40517) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGPTi-0003pH-2Z for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:04:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YGPTb-00027L-U9 for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:04:06 -0500 Received: from mx1.redhat.com ([209.132.183.28]:41075) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YGPTb-00027H-Nw for qemu-devel@nongnu.org; Wed, 28 Jan 2015 05:03:59 -0500 From: Igor Mammedov Date: Wed, 28 Jan 2015 10:03:31 +0000 Message-Id: <1422439417-5031-8-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 07/13] acpi: make toplevel ACPI tables blob a dedicated object 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 it will help to generalize and reuse blob intitalization/ destruction code. Signed-off-by: Igor Mammedov --- hw/acpi/acpi-build-utils.c | 12 +++++++++++- hw/i386/acpi-build.c | 4 ++-- include/hw/acpi/acpi-build-utils.h | 17 ++++++++++++++++- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index 02f60d7..bffad1e 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -320,9 +320,10 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml *child) uint8_t *start = (uint8_t *)parent_ctx->buf->data + parent_ctx->buf->len; uint32_t le32_len = cpu_to_le32(child->buf->len); + AcpiAmlTablesBlob *tables_blob = AML_TABLES_BLOB(parent_ctx); /* create linker entry for the DefinitionBlock */ - bios_linker_loader_add_checksum(parent_ctx->linker, + bios_linker_loader_add_checksum(tables_blob->linker, ACPI_BUILD_TABLE_FILE, parent_ctx->buf->data, start, child->buf->len, start + 9 /* checksum offset */); @@ -948,9 +949,18 @@ static const TypeInfo aml_object_type_info = { .class_size = sizeof(AcpiAmlClass), }; +static const TypeInfo aml_tables_blob_type_info = { + .name = TYPE_AML_TABLES_BLOB, + .parent = TYPE_AML_OBJECT, + .instance_size = sizeof(AcpiAmlTablesBlob), + .abstract = false, + .class_size = sizeof(AcpiAmlTablesBlobClass), +}; + static void aml_register_types(void) { type_register_static(&aml_object_type_info); + type_register_static(&aml_tables_blob_type_info); } type_init(aml_register_types) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index f456f53..624c903 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1279,10 +1279,10 @@ struct AcpiBuildTables { static inline void acpi_build_tables_init(AcpiBuildTables *tables) { 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->linker = tables->linker; + tables->table_data = AML_OBJECT(object_new(TYPE_AML_TABLES_BLOB)); + AML_TABLES_BLOB(tables->table_data)->linker = tables->linker; } static inline void acpi_build_tables_cleanup(AcpiBuildTables *tables, bool mfre) diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index c36ddb6..b2d023e 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -30,13 +30,28 @@ typedef struct AcpiAml { GArray *buf; uint8_t op; AcpiBlockFlags block_flags; - GArray *linker; } AcpiAml; typedef struct AcpiAmlClass { ObjectClass parent_class; } AcpiAmlClass; +#define TYPE_AML_TABLES_BLOB "aml-tables-blob" +#define AML_TABLES_BLOB(obj) OBJECT_CHECK(AcpiAmlTablesBlob, (obj), TYPE_AML_TABLES_BLOB) +#define AML_TABLES_BLOB_CLASS(klass) \ + OBJECT_CLASS_CHECK(AcpiAmlTablesBlobClass, (klass), TYPE_AML_TABLES_BLOB) +#define AML_TABLES_BLOB_GET_CLASS \ + OBJECT_GET_CLASS(AcpiAmlTablesBlobClass, (obj), TYPE_AML_TABLES_BLOB) + +typedef struct AcpiAmlTablesBlob { + AcpiAml parent_obj; + GArray *linker; +} AcpiAmlTablesBlob; + +typedef struct AcpiAmlTablesBlobClass { + AcpiAmlClass parent_class; +} AcpiAmlTablesBlobClass; + typedef enum { acpi_decode10 = 0, acpi_decode16 = 1, -- 1.8.3.1