From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48692) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6k-0003nY-0n for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEJ6b-0003iL-T0 for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:41 -0500 Received: from mx1.redhat.com ([209.132.183.28]:39279) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEJ6b-0003i7-LP for qemu-devel@nongnu.org; Thu, 22 Jan 2015 09:51:33 -0500 From: Igor Mammedov Date: Thu, 22 Jan 2015 14:50:16 +0000 Message-Id: <1421938231-25698-33-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> Subject: [Qemu-devel] [PATCH v2 32/47] acpi: add acpi_eisaid() 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, marcel.a@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Signed-off-by: Igor Mammedov --- hw/acpi/acpi-build-utils.c | 31 +++++++++++++++++++++++++++++++ include/hw/acpi/acpi-build-utils.h | 1 + 2 files changed, 32 insertions(+) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index e51196b..cbc1241 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -23,7 +23,9 @@ #include #include #include +#include #include "hw/acpi/acpi-build-utils.h" +#include "qemu/bswap.h" GArray *build_alloc_array(void) { @@ -659,3 +661,32 @@ acpi_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len, build_append_byte(var.buf, pblk_len); /* PblkLen */ return var; } + +static uint8_t Hex2Digit(char c) +{ + if (c >= 'A') { + return c - 'A' + 10; + } + + return c - '0'; +} + +/* ACPI 5.0: 19.5.36 EISAID (EISA ID String To Integer Conversion Macro) */ +AcpiAml acpi_eisaid(const char *str) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + uint32_t id; + + g_assert(strlen(str) == 7); + id = (str[0] - 0x40) << 26 | + (str[1] - 0x40) << 21 | + (str[2] - 0x40) << 16 | + Hex2Digit(str[3]) << 12 | + Hex2Digit(str[4]) << 8 | + Hex2Digit(str[5]) << 4 | + Hex2Digit(str[6]); + + build_append_byte(var.buf, 0x0C); /* DWordPrefix */ + build_append_value(var.buf, bswap32(id), sizeof(id)); + return var; +} diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index 753171f..02d5aa8 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -64,6 +64,7 @@ AcpiAml acpi_equal(AcpiAml arg1, AcpiAml arg2); AcpiAml GCC_FMT_ATTR(4, 5) acpi_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len, const char *name_format, ...); +AcpiAml acpi_eisaid(const char *str); /* Block ASL object primitives */ AcpiAml acpi_if(AcpiAml predicate); -- 1.8.3.1