From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40977) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdbnU-00040E-Vj for qemu-devel@nongnu.org; Thu, 02 Apr 2015 05:52:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdbnQ-0007Ui-BY for qemu-devel@nongnu.org; Thu, 02 Apr 2015 05:52:24 -0400 Received: from [59.151.112.132] (port=29151 helo=heian.cn.fujitsu.com) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdbnO-0007S2-Rr for qemu-devel@nongnu.org; Thu, 02 Apr 2015 05:52:20 -0400 From: Zhu Guihua Date: Thu, 2 Apr 2015 17:50:21 +0800 Message-ID: In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v6 5/8] acpi: extend aml_field() to support UpdateRule List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org, imammedo@redhat.com, mst@redhat.com, pbonzini@redhat.com Cc: guz.fnst@cn.fujitsu.com, izumi.taku@jp.fujitsu.com, Zhu Guihua , tangchen@cn.fujitsu.com The flags field is declared with default update rule 'Preserve', this patch extends aml_field() to support UpdateRule so that we can specify different values per field. Signed-off-by: Zhu Guihua --- hw/acpi/aml-build.c | 4 +++- hw/i386/acpi-build.c | 13 ++++++++----- include/hw/acpi/aml-build.h | 10 ++++++++-- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index d7945f6..f926c9a 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -635,9 +635,11 @@ Aml *aml_reserved_field(unsigned length) } /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefField */ -Aml *aml_field(const char *name, AmlFieldFlags flags) +Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule) { Aml *var = aml_bundle(0x81 /* FieldOp */, AML_EXT_PACKAGE); + uint8_t flags = rule << 5 | type; + build_append_namestring(var->buf, "%s", name); build_append_byte(var->buf, flags); return var; diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index e761005..dc1b8e8 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -798,7 +798,7 @@ build_ssdt(GArray *table_data, GArray *linker, aml_append(dev, aml_operation_region("PEOR", aml_system_io, misc->pvpanic_port, 1)); - field = aml_field("PEOR", aml_byte_acc); + field = aml_field("PEOR", aml_byte_acc, aml_preserve); aml_append(field, aml_named_field("PEPT", 8)); aml_append(dev, field); @@ -835,7 +835,7 @@ build_ssdt(GArray *table_data, GArray *linker, /* declare CPU hotplug MMIO region and PRS field to access it */ aml_append(sb_scope, aml_operation_region( "PRST", aml_system_io, pm->cpu_hp_io_base, pm->cpu_hp_io_len)); - field = aml_field("PRST", aml_byte_acc); + field = aml_field("PRST", aml_byte_acc, aml_preserve); aml_append(field, aml_named_field("PRS", 256)); aml_append(sb_scope, field); @@ -909,7 +909,8 @@ build_ssdt(GArray *table_data, GArray *linker, pm->mem_hp_io_base, pm->mem_hp_io_len) ); - field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_dword_acc); + field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_dword_acc, + aml_preserve); aml_append(field, /* read only */ aml_named_field(stringify(MEMORY_SLOT_ADDR_LOW), 32)); aml_append(field, /* read only */ @@ -922,7 +923,8 @@ build_ssdt(GArray *table_data, GArray *linker, aml_named_field(stringify(MEMORY_SLOT_PROXIMITY), 32)); aml_append(scope, field); - field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_byte_acc); + field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_byte_acc, + aml_preserve); aml_append(field, aml_reserved_field(160 /* bits, Offset(20) */)); aml_append(field, /* 1 if enabled, read only */ aml_named_field(stringify(MEMORY_SLOT_ENABLED), 1)); @@ -931,7 +933,8 @@ build_ssdt(GArray *table_data, GArray *linker, aml_named_field(stringify(MEMORY_SLOT_INSERT_EVENT), 1)); aml_append(scope, field); - field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_dword_acc); + field = aml_field(stringify(MEMORY_HOTPLUG_IO_REGION), aml_dword_acc, + aml_preserve); aml_append(field, /* DIMM selector, write only */ aml_named_field(stringify(MEMORY_SLOT_SLECTOR), 32)); aml_append(field, /* _OST event code, write only */ diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 17d3beb..5aa5e7a 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -35,7 +35,13 @@ typedef enum { aml_dword_acc = 3, aml_qword_acc = 4, aml_buffer_acc = 5, -} AmlFieldFlags; +} AmlAccessType; + +typedef enum { + aml_preserve = 0, + aml_write_as_ones = 1, + aml_write_as_zeros = 2, +} AmlUpdateRule; typedef enum { aml_system_memory = 0x00, @@ -185,7 +191,7 @@ Aml *aml_if(Aml *predicate); Aml *aml_package(uint8_t num_elements); Aml *aml_buffer(void); Aml *aml_resource_template(void); -Aml *aml_field(const char *name, AmlFieldFlags flags); +Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule); Aml *aml_varpackage(uint32_t num_elements); #endif -- 1.9.3