From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muL-0000w4-L9 for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1muC-0002eT-Po for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:09 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54001) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muC-0002eI-GY for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:00 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:02:01 +0000 Message-Id: <1418954562-13716-7-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 06/47] acpi: add acpi_name() & acpi_name_decl() 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 | 24 ++++++++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index 7bb41ce..cfccb42 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -289,6 +289,30 @@ static AcpiAml aml_allocate_internal(uint8_t op, AcpiBlockFlags flags) return var; } +/* + * help to construct NameString, which return AcpiAml object + * for using with other aml_append or other acpi_* terms + */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_name(const char *name_format, ...) +{ + va_list ap; + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + va_start(ap, name_format); + build_append_namestringv(var.buf, name_format, ap); + va_end(ap); + return var; +} + +/* ACPI 5.0: 20.2.5.1 Namespace Modifier Objects Encoding: DefName */ +AcpiAml acpi_name_decl(const char *name, AcpiAml val) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x08); + build_append_namestring(var.buf, "%s", name); + aml_append(&var, val); + return var; +} + /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ AcpiAml acpi_if(AcpiAml predicate) { diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index 177f9ed..868cfa5 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -21,6 +21,9 @@ typedef struct AcpiAml { void aml_append(AcpiAml *parent_ctx, AcpiAml child); +/* non block ASL object primitives */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_name(const char *name_format, ...); +AcpiAml acpi_name_decl(const char *name, AcpiAml val); /* Block ASL object primitives */ AcpiAml acpi_if(AcpiAml predicate); AcpiAml acpi_method(const char *name, int arg_count); -- 1.8.3.1