From patchwork Thu May 21 02:28:41 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48821 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f70.google.com (mail-wg0-f70.google.com [74.125.82.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 2620E2121F for ; Thu, 21 May 2015 02:31:57 +0000 (UTC) Received: by wgcz3 with SMTP id z3sf16590993wgc.3 for ; Wed, 20 May 2015 19:31:56 -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=BJy2Zsqa3Jqel0/xGuuuqvTljylXsIMC1MBTR21sFHM=; b=DnFBKRLiJuo6S5LHIJZ8/3OOTxaaNnhrk23fOZcqiM97frvrFJqx+EJ4HJYdTp8dfE xpEv4ZfVwvBxmrB26bMk6h0A1QQHkIIjav+x+gmxaMxMa9YScwZ4VmDE9qbjgGTJwd3l HfXLCu0ON9nWZiwSrVb7MK0ixxpSEtpGYEeXIslMNFKXKTPUgQEIBuweexQ2e0T2oAtC LXSYbaQ86KPA8FzOncmIWtV8+GmrgrdzEC3VbxNz4ytgU1zrrLA9yGCPab7IGYt2mguJ No3GpEv/N5b+t3dzvB50H1zBwqrovQVVyth1J+tulIY1Sc95qiTHknS5d4jGE+BpqGH9 HI9Q== X-Gm-Message-State: ALoCoQlqeDjOCTB68R95cx5+SCebcLX8YLQ+VWFxbVdcFfeIfcCjyn4cOi/rbow+6T8AwXmH2CXR X-Received: by 10.194.142.205 with SMTP id ry13mr462893wjb.2.1432175516399; Wed, 20 May 2015 19:31:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.205.70 with SMTP id le6ls287607lac.50.gmail; Wed, 20 May 2015 19:31:56 -0700 (PDT) X-Received: by 10.112.162.38 with SMTP id xx6mr315325lbb.110.1432175516257; Wed, 20 May 2015 19:31:56 -0700 (PDT) Received: from mail-la0-f44.google.com (mail-la0-f44.google.com. [209.85.215.44]) by mx.google.com with ESMTPS id g10si12323126lam.78.2015.05.20.19.31.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 20 May 2015 19:31:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.44 as permitted sender) client-ip=209.85.215.44; Received: by labbd9 with SMTP id bd9so93301180lab.2 for ; Wed, 20 May 2015 19:31:56 -0700 (PDT) X-Received: by 10.112.198.74 with SMTP id ja10mr306438lbc.19.1432175516157; Wed, 20 May 2015 19:31:56 -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.108.230 with SMTP id hn6csp228211lbb; Wed, 20 May 2015 19:31:55 -0700 (PDT) X-Received: by 10.140.94.246 with SMTP id g109mr491747qge.101.1432175514814; Wed, 20 May 2015 19:31:54 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id t20si8536102qge.112.2015.05.20.19.31.54 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 20 May 2015 19:31:54 -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]:54558 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvGH3-0001m5-Lu for patch@linaro.org; Wed, 20 May 2015 22:31:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45971) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvGFy-0000KO-Sm for qemu-devel@nongnu.org; Wed, 20 May 2015 22:30:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YvGFu-0005Es-JA for qemu-devel@nongnu.org; Wed, 20 May 2015 22:30:46 -0400 Received: from szxga01-in.huawei.com ([58.251.152.64]:36249) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YvGFt-0005EZ-Iq for qemu-devel@nongnu.org; Wed, 20 May 2015 22:30:42 -0400 Received: from 172.24.2.119 (EHLO szxeml434-hub.china.huawei.com) ([172.24.2.119]) by szxrg01-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id COD16470; Thu, 21 May 2015 10:30:30 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml434-hub.china.huawei.com (10.82.67.225) with Microsoft SMTP Server id 14.3.158.1; Thu, 21 May 2015 10:30:17 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Thu, 21 May 2015 10:28:41 +0800 Message-ID: <1432175331-12548-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1432175331-12548-1-git-send-email-zhaoshenglong@huawei.com> References: <1432175331-12548-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 v8 14/24] hw/acpi/aml-build: Make aml_buffer() definition consistent with the spec 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.44 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 According to ACPI spec, DefBuffer can take two parameters: BufferSize and ByteList. Make it consistent with the spec. Uninitialized buffer could be requested by passing ByteList as NULL to reserve space. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 16 ++++++++++++++-- include/hw/acpi/aml-build.h | 2 +- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index de19c63..22478c2 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -642,10 +642,22 @@ Aml *aml_resource_template(void) return var; } -/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefBuffer */ -Aml *aml_buffer(void) +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefBuffer + * Pass byte_list as NULL to request uninitialized buffer to reserve space. + */ +Aml *aml_buffer(int buffer_size, uint8_t *byte_list) { + int i; Aml *var = aml_bundle(0x11 /* BufferOp */, AML_BUFFER); + + for (i = 0; i < buffer_size; i++) { + if (byte_list == NULL) { + build_append_byte(var->buf, 0x0); + } else { + build_append_byte(var->buf, byte_list[i]); + } + } + return var; } diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index f4e678f..fac70ea 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -253,7 +253,7 @@ Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2); Aml *aml_method(const char *name, int arg_count); Aml *aml_if(Aml *predicate); Aml *aml_package(uint8_t num_elements); -Aml *aml_buffer(void); +Aml *aml_buffer(int buffer_size, uint8_t *byte_list); Aml *aml_resource_template(void); Aml *aml_field(const char *name, AmlAccessType type, AmlUpdateRule rule); Aml *aml_varpackage(uint32_t num_elements);