From patchwork Thu Jan 22 14:50:11 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 431875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BFCC31400B6 for ; Fri, 23 Jan 2015 02:13:59 +1100 (AEDT) Received: from localhost ([::1]:53983 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJSH-0000Cy-UG for incoming@patchwork.ozlabs.org; Thu, 22 Jan 2015 10:13:57 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48619) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6e-0003fk-UC for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6a-0003hT-6G for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:36 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39270) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6Z-0003hK-Tu for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:32 -0500 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEpI8C019461 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 22 Jan 2015 09:51:19 -0500 Received: from dell-pet610-01.lab.eng.brq.redhat.com (dell-pet610-01.lab.eng.brq.redhat.com [10.34.42.20]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t0MEoYdq030524; Thu, 22 Jan 2015 09:51:17 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Thu, 22 Jan 2015 14:50:11 +0000 Message-Id: <1421938231-25698-28-git-send-email-imammedo@redhat.com> In-Reply-To: <1421938231-25698-1-git-send-email-imammedo@redhat.com> References: <1421938231-25698-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: pbonzini@redhat.com, drjones@redhat.com, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Subject: [Qemu-devel] [PATCH v2 27/47] acpi: add acpi_string() term X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Signed-off-by: Igor Mammedov --- hw/acpi/acpi-build-utils.c | 26 ++++++++++++++++++++++++++ include/hw/acpi/acpi-build-utils.h | 1 + 2 files changed, 27 insertions(+) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index 1affed2..fedf871 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -587,6 +587,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-build-utils.h b/include/hw/acpi/acpi-build-utils.h index 8261ee5..c823fb8 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-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 */