From patchwork Wed Apr 15 13:25:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 47179 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 1DF6D20553 for ; Wed, 15 Apr 2015 13:30:22 +0000 (UTC) Received: by layy10 with SMTP id y10sf10005355lay.0 for ; Wed, 15 Apr 2015 06:30:20 -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=0pojyORClAvre6vKXoniXsvc1pVN1Q4SV9Dzu6ujUV8=; b=U4bQ9nw3loWWpaiDuPUfvjJa+pNX7SPFowa22Mg5PmxaCyGNtBn9w7NFX8iAH/THwE rng2J5w1PGQ8W88EzUWuTJsUDhN9hYKZ6/lLOKA2oVbitYRK3tKCHAOHM2IlDx0BkcEQ M2zRiKRroJqQRy0EaAIcT126z1OqGPbgVXyitP0rsVIoQkPqm7IIlHcGj1tda2OTdodg nFq10UhcQ2QWsjULVqqWSMIVVOV1A3uSjzkfKUe+eVL7P/Xky7TRQA1nlolbIdHB7/YE bYHitBumVh3CmySMXNZpZU0JZvL90KBOnWpjpbQbQajZInnU9Y1nnBvZoTm9BCx35Fbb 0aPg== X-Gm-Message-State: ALoCoQn+HAT+EYJP2cPqDcKOATav5kK0hyqq2PAm2LYx21ebymb5GnOWMvaCgfOtgHY0U6JOXmQV X-Received: by 10.180.97.9 with SMTP id dw9mr4809697wib.2.1429104620951; Wed, 15 Apr 2015 06:30:20 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.227 with SMTP id t3ls188763laj.72.gmail; Wed, 15 Apr 2015 06:30:20 -0700 (PDT) X-Received: by 10.112.210.230 with SMTP id mx6mr23975007lbc.64.1429104620822; Wed, 15 Apr 2015 06:30:20 -0700 (PDT) Received: from mail-la0-f42.google.com (mail-la0-f42.google.com. [209.85.215.42]) by mx.google.com with ESMTPS id ys9si3918993lab.63.2015.04.15.06.30.20 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 15 Apr 2015 06:30:20 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.42 as permitted sender) client-ip=209.85.215.42; Received: by laat2 with SMTP id t2so32718971laa.1 for ; Wed, 15 Apr 2015 06:30:20 -0700 (PDT) X-Received: by 10.152.234.169 with SMTP id uf9mr23878748lac.88.1429104620547; Wed, 15 Apr 2015 06:30:20 -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 l1csp2514354lbt; Wed, 15 Apr 2015 06:30:19 -0700 (PDT) X-Received: by 10.140.144.67 with SMTP id 64mr11437649qhq.40.1429104619174; Wed, 15 Apr 2015 06:30:19 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id l135si4627489qhl.16.2015.04.15.06.30.18 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 15 Apr 2015 06:30:19 -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]:60497 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNOU-0002R1-BL for patch@linaro.org; Wed, 15 Apr 2015 09:30:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNLO-0006HI-Hz for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YiNLL-0004un-Bz for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:06 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:41904) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YiNLK-0004sM-4o for qemu-devel@nongnu.org; Wed, 15 Apr 2015 09:27:03 -0400 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CME19610; Wed, 15 Apr 2015 21:26:42 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Wed, 15 Apr 2015 21:26:32 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Wed, 15 Apr 2015 21:25:02 +0800 Message-ID: <1429104309-3844-14-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1429104309-3844-1-git-send-email-zhaoshenglong@huawei.com> References: <1429104309-3844-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, shannon.zhao@linaro.org, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH v5 13/20] 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.42 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 | 40 ++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/aml-build.h | 1 + 2 files changed, 41 insertions(+) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index b99bb13..316d5a5 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -25,6 +25,7 @@ #include #include #include "hw/acpi/aml-build.h" +#include "qemu-common.h" #include "qemu/bswap.h" #include "qemu/bitops.h" #include "hw/acpi/bios-linker-loader.h" @@ -948,6 +949,45 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, addr_trans, len, flags); } +/* + * ACPI 3.0: 17.5.124 ToUUID (Convert String to UUID Macro) + * e.g. UUID: E5C937D0-3553-4d7a-9117-EA4D19C3434D + * call aml_touuid("E5C937D0-3553-4d7a-9117-EA4D19C3434D"); + */ +Aml *aml_touuid(const char *uuid) +{ + int i; + long int val; + char *end; + const char *start = uuid; + Aml *UUID = aml_buffer(); + + val = strtol(start, &end, 16); + g_assert((end - start) == 8); + build_append_int_noprefix(UUID->buf, val, 4); + start = end + 1; + val = strtol(start, &end, 16); + g_assert((end - start) == 4); + build_append_int_noprefix(UUID->buf, val, 2); + start = end + 1; + val = strtol(start, &end, 16); + g_assert((end - start) == 4); + build_append_int_noprefix(UUID->buf, val, 2); + start = end + 1; + val = strtol(start, &end, 16); + g_assert((end - start) == 4); + build_append_int_noprefix(UUID->buf, (val >> 8) & 0xFF, 1); + build_append_int_noprefix(UUID->buf, val & 0xFF, 1); + start = end + 1; + val = strtol(start, &end, 16); + g_assert((end - start) == 12); + for (i = 40; i >= 0; i -= 8) { + build_append_int_noprefix(UUID->buf, (val >> i) & 0xFF, 1); + } + + return UUID; +} + 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 d1b9fe7..b41fd0c 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -259,6 +259,7 @@ Aml *aml_buffer(void); 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,