From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51224) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlzK-0003fT-Si for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:53 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKlzE-0000UU-OP for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:46 -0500 Received: from mx1.redhat.com ([209.132.183.28]:58903) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlzE-0000UM-CG for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:54:40 -0500 From: Igor Mammedov Date: Mon, 9 Feb 2015 10:53:34 +0000 Message-Id: <1423479254-15342-13-git-send-email-imammedo@redhat.com> In-Reply-To: <1423479254-15342-1-git-send-email-imammedo@redhat.com> References: <1423479254-15342-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [PATCH v3 12/52] acpi: add aml_name() & aml_name_decl() term List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com, zhaoshenglong@huawei.com Signed-off-by: Igor Mammedov --- hw/acpi/aml-build.c | 32 ++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 4 ++++ 2 files changed, 36 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 9f43fef..5d6553c 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -259,6 +259,15 @@ static Aml *aml_alloc(void) return var; } +static Aml *aml_opcode(uint8_t op) +{ + Aml *var = aml_alloc(); + + var->op = op; + var->block_flags = AML_NON_BLOCK; + return var; +} + static Aml *aml_bundle(uint8_t op, AmlBlockFlags flags) { Aml *var = aml_alloc(); @@ -383,6 +392,29 @@ Aml *aml_def_block(const char *signature, uint8_t revision, return var; } +/* + * helper to construct NameString, which returns Aml object + * for using with aml_append or other aml_* terms + */ +Aml *aml_name(const char *name_format, ...) +{ + va_list ap; + Aml *var = aml_alloc(); + va_start(ap, name_format); + build_append_namestringv(var->buf, name_format, ap); + va_end(ap); + return var; +} + +/* ACPI 1.0b: 16.2.5.1 Namespace Modifier Objects Encoding: DefName */ +Aml *aml_name_decl(const char *name, Aml *val) +{ + Aml *var = aml_opcode(0x08 /* NameOp */); + build_append_namestring(var->buf, "%s", name); + aml_append(var, val); + return var; +} + /* ACPI 1.0b: 16.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ Aml *aml_if(Aml *predicate) { diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 7cd1f51..d5d8c11 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -69,6 +69,10 @@ void free_aml_allocator(void); */ void aml_append(Aml *parent_ctx, Aml *child); +/* non block AML object primitives */ +Aml *aml_name(const char *name_format, ...) GCC_FMT_ATTR(1, 2); +Aml *aml_name_decl(const char *name, Aml *val); + /* Block AML object primitives */ Aml *aml_def_block(const char *signature, uint8_t revision, const char *oem_id, const char *oem_table_id, -- 1.8.3.1