From patchwork Thu May 7 09:29:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48100 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-la0-f72.google.com (mail-la0-f72.google.com [209.85.215.72]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id AA9B820553 for ; Thu, 7 May 2015 09:40:34 +0000 (UTC) Received: by labgx2 with SMTP id gx2sf11809003lab.1 for ; Thu, 07 May 2015 02:40:33 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:mime-version:content-type:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=k2VrcLR8itXW6hNdm1vo2a2mbY4fHnjRxOB64fm5OPU=; b=a2P+CzGmINwebJh5pduhP7gzHAsIlP5Y70wRCwqETN5fQhuU6VINgJhlHUPdK9dbi8 7cpivOclVwE1hcYNq5m2NL9gRRkA0l8aSk1ZK/7TafX61rmD4qT1uZJJOxNO9IRe8eSk Ou5/+1sxdb8QobjdQr77vbFUsr98ZGSfCdkm8Zq55KXzzDBvcJj9e/d/imodnyuFObuf t9bCmG6PMBCHfkGOCrRDEi6CQscJN6+rW+ZWp/Dsqi5MGauQdG8IbJ+mUsaxgh41Cgo5 uSIoYqEg/HRwZ2pn5vYvm73v4efrWzri37dNsDwuP1WazhxZXukKNLxqG5Eiiet2wgx4 ZZ1w== X-Gm-Message-State: ALoCoQkpuVQfA7hBfCKUvmWSkdMsV0DVfbT7HDf2knwzwTLWlG4N1h5beaPnv2dfi0CP8Sc1nrH9 X-Received: by 10.180.96.6 with SMTP id do6mr1633274wib.4.1430991633554; Thu, 07 May 2015 02:40:33 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.23.197 with SMTP id o5ls162162laf.66.gmail; Thu, 07 May 2015 02:40:33 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr2359417lbc.19.1430991633420; Thu, 07 May 2015 02:40:33 -0700 (PDT) Received: from mail-la0-f46.google.com (mail-la0-f46.google.com. [209.85.215.46]) by mx.google.com with ESMTPS id an10si921138lac.169.2015.05.07.02.40.33 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 May 2015 02:40:33 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) client-ip=209.85.215.46; Received: by laat2 with SMTP id t2so26427588laa.1 for ; Thu, 07 May 2015 02:40:33 -0700 (PDT) X-Received: by 10.152.206.75 with SMTP id lm11mr2297646lac.41.1430991633140; Thu, 07 May 2015 02:40:33 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.67.65 with SMTP id l1csp3331581lbt; Thu, 7 May 2015 02:40:32 -0700 (PDT) X-Received: by 10.55.53.8 with SMTP id c8mr6079678qka.63.1430991631803; Thu, 07 May 2015 02:40:31 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n21si1416986qha.111.2015.05.07.02.40.31 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 07 May 2015 02:40:31 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:49719 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqIIB-0003IZ-0j for patch@linaro.org; Thu, 07 May 2015 05:40:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56902) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqIAJ-0007pw-DP for qemu-devel@nongnu.org; Thu, 07 May 2015 05:32:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YqIAG-0001uI-EQ for qemu-devel@nongnu.org; Thu, 07 May 2015 05:32:23 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:42299) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YqIAF-0001tM-LA for qemu-devel@nongnu.org; Thu, 07 May 2015 05:32:20 -0400 Received: from 172.24.2.119 (EHLO szxeml426-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CNI17470; Thu, 07 May 2015 17:32:05 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.158.1; Thu, 7 May 2015 17:31:33 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Thu, 7 May 2015 17:29:16 +0800 Message-ID: <1430990964-10528-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1430990964-10528-1-git-send-email-zhaoshenglong@huawei.com> References: <1430990964-10528-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 58.251.152.64 Cc: hangaohuai@huawei.com, zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v6 14/22] hw/acpi/aml-build: Add ToUUID macro 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: patch@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.46 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Shannon Zhao Add ToUUID macro, this is useful for generating PCIe ACPI table. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 46 +++++++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 47 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index a38a536..d9c9876 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -961,6 +961,52 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, addr_trans, len, flags); } +static uint8_t Hex2Byte(const char *src) +{ + int hi = Hex2Digit(*src++); + int lo = Hex2Digit(*src); + + g_assert(((hi >= 0) && (hi <= 15)) && ((lo >= 0) && (lo <= 15))); + return (hi << 4) | lo; +} + +/* + * ACPI 3.0: 17.5.124 ToUUID (Convert String to UUID Macro) + * e.g. UUID: aabbccdd-eeff-gghh-iijj-kkllmmnnoopp + * call aml_touuid("aabbccdd-eeff-gghh-iijj-kkllmmnnoopp"); + */ +Aml *aml_touuid(const char *uuid) +{ + Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER); + + /* format: aabbccdd-eeff-gghh-iijj-kkllmmnnoopp */ + g_assert((strlen(uuid) == 36) && (uuid[8] == '-') && (uuid[13] == '-') + && (uuid[18] == '-') && (uuid[23] == '-')); + + build_append_byte(var->buf, Hex2Byte(uuid + 6)); /* dd - at offset 00 */ + build_append_byte(var->buf, Hex2Byte(uuid + 4)); /* cc - at offset 01 */ + build_append_byte(var->buf, Hex2Byte(uuid + 2)); /* bb - at offset 02 */ + build_append_byte(var->buf, Hex2Byte(uuid + 0)); /* aa - at offset 03 */ + + build_append_byte(var->buf, Hex2Byte(uuid + 11)); /* ff - at offset 04 */ + build_append_byte(var->buf, Hex2Byte(uuid + 9)); /* ee - at offset 05 */ + + build_append_byte(var->buf, Hex2Byte(uuid + 16)); /* hh - at offset 06 */ + build_append_byte(var->buf, Hex2Byte(uuid + 14)); /* gg - at offset 07 */ + + build_append_byte(var->buf, Hex2Byte(uuid + 19)); /* ii - at offset 08 */ + build_append_byte(var->buf, Hex2Byte(uuid + 21)); /* jj - at offset 09 */ + + build_append_byte(var->buf, Hex2Byte(uuid + 24)); /* kk - at offset 10 */ + build_append_byte(var->buf, Hex2Byte(uuid + 26)); /* ll - at offset 11 */ + build_append_byte(var->buf, Hex2Byte(uuid + 28)); /* mm - at offset 12 */ + build_append_byte(var->buf, Hex2Byte(uuid + 30)); /* nn - at offset 13 */ + build_append_byte(var->buf, Hex2Byte(uuid + 32)); /* oo - at offset 14 */ + build_append_byte(var->buf, Hex2Byte(uuid + 34)); /* pp - at offset 15 */ + + return var; +} + void build_header(GArray *linker, GArray *table_data, AcpiTableHeader *h, const char *sig, int len, uint8_t rev) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 69d7813..7399f04 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -259,6 +259,7 @@ Aml *aml_buffer(int buffer_size, uint8_t *byte_list); Aml *aml_resource_template(void); Aml *aml_field(const char *name, AmlFieldFlags flags); Aml *aml_varpackage(uint32_t num_elements); +Aml *aml_touuid(const char *uuid); void build_header(GArray *linker, GArray *table_data,