From patchwork Fri Dec 19 02:02:27 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 422718 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 230AF1400A0 for ; Fri, 19 Dec 2014 13:21:16 +1100 (AEDT) Received: from localhost ([::1]:56451 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1nBq-0007Ku-8y for incoming@patchwork.ozlabs.org; Thu, 18 Dec 2014 21:21:14 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60870) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mut-0001xN-Kv for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1mun-0002yG-FR for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34461) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1mun-0002y6-6g for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:37 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id sBJ23Xge018007 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 18 Dec 2014 21:03:33 -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-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id sBJ22lIN015753; Thu, 18 Dec 2014 21:03:32 -0500 From: Igor Mammedov To: qemu-devel@nongnu.org Date: Fri, 19 Dec 2014 02:02:27 +0000 Message-Id: <1418954562-13716-33-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> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 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, claudio.fontana@huawei.com, mst@redhat.com Subject: [Qemu-devel] [RFC 32/47] acpi: add acpi_eisaid() 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_gen_utils.c | 31 +++++++++++++++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 1 + 2 files changed, 32 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index 4606d1e..68d1855 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -2,7 +2,9 @@ #include #include #include +#include #include "hw/acpi/acpi_gen_utils.h" +#include "qemu/bswap.h" GArray *build_alloc_array(void) { @@ -633,3 +635,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_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index 753171f..02d5aa8 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_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);