From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60483) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muK-0000vw-4T for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:14 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1mu8-0002aj-M8 for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:08 -0500 Received: from mx1.redhat.com ([209.132.183.28]:44416) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mu8-0002Zz-ES for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:02:56 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:01:57 +0000 Message-Id: <1418954562-13716-3-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 02/47] acpi: add acpi_scope() term 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 | 18 ++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index c9050ef..56b69dd 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -281,3 +281,21 @@ void aml_append(AcpiAml *parent_ctx, AcpiAml child) build_append_array(parent_ctx->buf, child.buf); build_free_array(child.buf); } + +static AcpiAml aml_allocate_internal(uint8_t op, AcpiBlockFlags flags) +{ + AcpiAml var = { .op = op, .block_flags = flags }; + var.buf = build_alloc_array(); + return var; +} + +/* ACPI 5.0: 20.2.5.1 Namespace Modifier Objects Encoding: DefScope */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...) +{ + va_list ap; + AcpiAml var = aml_allocate_internal(0x10 /* ScopeOp */, PACKAGE); + va_start(ap, name_format); + build_append_namestringv(var.buf, name_format, ap); + va_end(ap); + return var; +} diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index 64e7ec3..bbb786b 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -21,6 +21,10 @@ typedef struct AcpiAml { void aml_append(AcpiAml *parent_ctx, AcpiAml child); +/* Block ASL object primitives */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...); + +/* other helpers */ GArray *build_alloc_array(void); void build_free_array(GArray *array); void build_prepend_byte(GArray *array, uint8_t val); -- 1.8.3.1