From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muw-00020N-3p for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:52 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1mup-0002yv-UU for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34478) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mup-0002yj-LS for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:39 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:02:22 +0000 Message-Id: <1418954562-13716-28-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 27/47] acpi: add acpi_string() 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 | 26 ++++++++++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index 6bd7974..920d8c2 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -561,6 +561,32 @@ AcpiAml acpi_field(const char *name, acpiFieldFlags flags) return var; } +/* ACPI 5.0: 20.2.3 Data Objects Encoding: String */ +AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char *name_format, ...) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + va_list ap, va_len; + char *s; + int len; + + va_start(ap, name_format); + va_copy(va_len, ap); + len = vsnprintf(NULL, 0, name_format, va_len); + va_end(va_len); + len += 1; + s = g_new(typeof(*s), len); + + len = vsnprintf(s, len, name_format, ap); + va_end(ap); + + build_append_byte(var.buf, 0x0D); /* StringPrefix */ + g_array_append_vals(var.buf, s, len); + build_append_byte(var.buf, 0x0); /* NullChar */ + g_free(s); + + return var; +} + /* ACPI 5.0: 20.2.6.2 Local Objects Encoding: Local0Op */ AcpiAml acpi_local0(void) { diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index 8261ee5..c823fb8 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -58,6 +58,7 @@ AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base, AcpiAml acpi_operation_region(const char *name, acpiRegionSpace rs, uint32_t offset, uint32_t len); AcpiAml acpi_named_field(const char *name, unsigned length); +AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char *name_format, ...); AcpiAml acpi_local0(void); /* Block ASL object primitives */ -- 1.8.3.1