[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 04/13] acpi: make AcpiAml an OQM object
From: |
Igor Mammedov |
Subject: |
[Qemu-devel] [PATCH 04/13] acpi: make AcpiAml an OQM object |
Date: |
Wed, 28 Jan 2015 10:03:28 +0000 |
it allows to build table tree by assigning
child AML objects to parent AML object and
reuse the same AML objects multiple times.
When table is build and added to ACPI
tables blob, it will create the same
parent->child relation, and when ACPI tables
blob is destroyed (object_unref()), it will
automatically cleanup all children AML objects
that has been created for it.
Signed-off-by: Igor Mammedov <address@hidden>
---
hw/acpi/acpi-build-utils.c | 31 +++++++++++++++++++++++++++++++
include/hw/acpi/acpi-build-utils.h | 13 +++++++++++++
2 files changed, 44 insertions(+)
diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c
index 5bfb74d..1041865 100644
--- a/hw/acpi/acpi-build-utils.c
+++ b/hw/acpi/acpi-build-utils.c
@@ -27,6 +27,7 @@
#include "hw/acpi/acpi-build-utils.h"
#include "qemu/bswap.h"
#include "hw/acpi/bios-linker-loader.h"
+#include "qemu/module.h"
GArray *build_alloc_array(void)
{
@@ -910,3 +911,33 @@ AcpiAml *acpi_def_block(const char *signature, uint8_t
revision,
return var;
}
+
+static void aml_object_initfn(Object *obj) {
+ AcpiAml *aml = AML_OBJECT(obj);
+
+ aml->buf = build_alloc_array();
+}
+
+static void aml_object_finalize(Object *obj) {
+ AcpiAml *aml = AML_OBJECT(obj);
+
+ build_free_array(aml->buf);
+ memset(aml, 0, sizeof(*aml));
+}
+
+static const TypeInfo aml_object_type_info = {
+ .name = TYPE_AML_OBJECT,
+ .parent = TYPE_UNOWNED_OBJECT,
+ .instance_size = sizeof(AcpiAml),
+ .instance_init = aml_object_initfn,
+ .instance_finalize = aml_object_finalize,
+ .abstract = false,
+ .class_size = sizeof(AcpiAmlClass),
+};
+
+static void aml_register_types(void)
+{
+ type_register_static(&aml_object_type_info);
+}
+
+type_init(aml_register_types)
diff --git a/include/hw/acpi/acpi-build-utils.h
b/include/hw/acpi/acpi-build-utils.h
index 0e068f1..c36ddb6 100644
--- a/include/hw/acpi/acpi-build-utils.h
+++ b/include/hw/acpi/acpi-build-utils.h
@@ -4,6 +4,7 @@
#include <stdint.h>
#include <glib.h>
#include "qemu/compiler.h"
+#include "qom/object.h"
typedef enum {
NON_BLOCK,
@@ -17,13 +18,25 @@ typedef enum {
#define ACPI_BUILD_TABLE_FILE "etc/acpi/tables"
#define ACPI_BUILD_APPNAME4 "BXPC"
+#define TYPE_AML_OBJECT "aml-object"
+#define AML_OBJECT(obj) OBJECT_CHECK(AcpiAml, (obj), TYPE_AML_OBJECT)
+#define AML_OBJECT_CLASS(klass) \
+ OBJECT_CLASS_CHECK(AcpiAmlClass, (klass), TYPE_AML_OBJECT)
+#define AML_OBJECT_GET_CLASS \
+ OBJECT_GET_CLASS(AcpiAmlClass, (obj), TYPE_AML_OBJECT)
+
typedef struct AcpiAml {
+ Object parent_obj;
GArray *buf;
uint8_t op;
AcpiBlockFlags block_flags;
GArray *linker;
} AcpiAml;
+typedef struct AcpiAmlClass {
+ ObjectClass parent_class;
+} AcpiAmlClass;
+
typedef enum {
acpi_decode10 = 0,
acpi_decode16 = 1,
--
1.8.3.1
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), (continued)
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Michael S. Tsirkin, 2015/01/24
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Igor Mammedov, 2015/01/26
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Michael S. Tsirkin, 2015/01/26
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Igor Mammedov, 2015/01/26
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Andrew Jones, 2015/01/26
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Michael S. Tsirkin, 2015/01/26
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Igor Mammedov, 2015/01/27
- Re: [Qemu-devel] [PATCH v2 01/47] acpi: introduce AML composer aml_append(), Michael S. Tsirkin, 2015/01/28
- [Qemu-devel] [PATCH 00/13] convert AML API to QOM, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 02/13] make toplevel ACPI tables blob a pointer, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 04/13] acpi: make AcpiAml an OQM object,
Igor Mammedov <=
- [Qemu-devel] [PATCH 03/13] qom: add support for weak referenced object: aka UnownedObject, Igor Mammedov, 2015/01/28
- Re: [Qemu-devel] [PATCH 03/13] qom: add support for weak referenced object: aka UnownedObject, Paolo Bonzini, 2015/01/28
- Re: [Qemu-devel] [PATCH 03/13] qom: add support for weak referenced object: aka UnownedObject, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 05/13] acpi: use TYPE_AML_OBJECT inside of AML API, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 09/13] acpi: add aml_blob() helper, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 08/13] i386: acpi: hack not yet converted tables calls to deal with table_data being a pointer, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 01/13] convert to passing AcpiAml by pointers, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 10/13] i386: acpi: add DSDT table using AML API, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 07/13] acpi: make toplevel ACPI tables blob a dedicated object, Igor Mammedov, 2015/01/28
- [Qemu-devel] [PATCH 11/13] acpi: acpi_add_table() to common cross target file, Igor Mammedov, 2015/01/28