From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60762) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muj-0001bG-WF for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:40 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1mud-0002uI-PS for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:33 -0500 Received: from mx1.redhat.com ([209.132.183.28]:56663) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mud-0002tf-GS for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:27 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:02:20 +0000 Message-Id: <1418954562-13716-26-git-send-email-imammedo@redhat.com> In-Reply-To: <1418954562-13716-1-git-send-email-imammedo@redhat.com> References: <1418954562-13716-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [RFC 25/47] acpi: add acpi_field() & acpi_named_field() terms List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Signed-off-by: Igor Mammedov --- hw/acpi/acpi_gen_utils.c | 27 +++++++++++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 6 ++++++ 2 files changed, 33 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index c69c708..acb40fb 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -200,6 +200,15 @@ build_prepend_package_length(GArray *package, unsigned length, bool incl_self) build_prepend_byte(package, byte); } +static void build_append_pkg_length(GArray *array, unsigned length, bool incl_self) +{ + GArray *tmp = build_alloc_array(); + + build_prepend_package_length(tmp, length, incl_self); + build_append_array(array, tmp); + build_free_array(tmp); +} + void build_package(GArray *package, uint8_t op) { build_prepend_package_length(package, package->len, true); @@ -533,3 +542,21 @@ AcpiAml acpi_operation_region(const char *name, acpiRegionSpace rs, build_append_int(var.buf, len); return var; } + +/* ACPI 5.0: 20.2.5.2 Named Objects Encoding: NamedField */ +AcpiAml acpi_named_field(const char *name, unsigned length) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_nameseg(var.buf, "%s", name); + build_append_pkg_length(var.buf, length, false); + return var; +} + +/* ACPI 5.0: 20.2.5.2 Named Objects Encoding: DefField */ +AcpiAml acpi_field(const char *name, acpiFieldFlags flags) +{ + AcpiAml var = aml_allocate_internal(0x81 /* FieldOp */, EXT_PACKAGE); + build_append_namestring(var.buf, "%s", name); + build_append_byte(var.buf, flags); + return var; +} diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index cb45129..b94098a 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -25,6 +25,10 @@ typedef enum { } acpiIODecode; typedef enum { + acpi_byte_acc = 1, +} acpiFieldFlags; + +typedef enum { acpi_system_memory = 0x00, acpi_system_io = 0x01, } acpiRegionSpace; @@ -53,6 +57,7 @@ AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base, uint8_t aln, uint8_t len); AcpiAml acpi_operation_region(const char *name, acpiRegionSpace rs, uint32_t offset, uint32_t len); +AcpiAml acpi_named_field(const char *name, unsigned length); /* Block ASL object primitives */ AcpiAml acpi_if(AcpiAml predicate); @@ -62,6 +67,7 @@ AcpiAml GCC_FMT_ATTR(1, 2) acpi_device(const char *name_format, ...); AcpiAml acpi_buffer(void); AcpiAml acpi_resource_template(void); AcpiAml acpi_package(uint8_t num_elements); +AcpiAml acpi_field(const char *name, acpiFieldFlags flags); /* other helpers */ GArray *build_alloc_array(void); -- 1.8.3.1