From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51650) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKm00-00050q-Ct for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:55:29 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YKlzx-0001Bd-6E for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:55:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:47074) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YKlzw-0001BV-Ux for qemu-devel@nongnu.org; Mon, 09 Feb 2015 05:55:25 -0500 From: Igor Mammedov Date: Mon, 9 Feb 2015 10:53:59 +0000 Message-Id: <1423479254-15342-38-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 37/52] acpi: add aml_eisaid() 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 | 29 +++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 30 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index aa5ef59..90c1272 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -716,3 +716,32 @@ Aml *aml_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 1.0b: 15.2.3.6.4.1 EISAID Macro - Convert EISA ID String To Integer */ +Aml *aml_eisaid(const char *str) +{ + Aml *var = aml_alloc(); + 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/aml-build.h b/include/hw/acpi/aml-build.h index 3cf9fbb..84fe4db 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -106,6 +106,7 @@ Aml *aml_string(const char *name_format, ...) GCC_FMT_ATTR(1, 2); Aml *aml_equal(Aml *arg1, Aml *arg2); Aml *aml_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len, const char *name_format, ...) GCC_FMT_ATTR(4, 5); +Aml *aml_eisaid(const char *str); /* Block AML object primitives */ Aml *aml_def_block(const char *signature, uint8_t revision, -- 1.8.3.1