From patchwork Thu May 14 09:19:32 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 48496 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 38C102121F for ; Thu, 14 May 2015 09:30:57 +0000 (UTC) Received: by wgin8 with SMTP id n8sf17233648wgi.0 for ; Thu, 14 May 2015 02:30: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=lNEc/2lQNRLzEhpndH/d2jqr7e86qat7kPdhJGTy0CI=; b=N92p4xMb65B4NidOoQLvd3bADyi2N79QxCi9qXQ+lmTMH8/54qU44wlexCl7B2SgL9 JVgzxJG612VWhrb1nM+1whul3fKGoJ99Y4tFoziw6tYvQ/nGP69F1va2EbhFJak1WuoD Cbhp4H4Wd+atEr5KwIy3//B1GOjMXOKuP7df6zHEEJmQVhWogVv0jjJ2aaRjFS/bxp1J VfIX8NSSLXvabFxWMHttH1DpyQezgtBjfTJ7WvkIR2sVND2hkGJBMYlHUHHyuwj4ohTx O3PHK57CbmUaA7BoHgNbDz7MEbdRVziXzOu5oMj8liXvvLGeXYCyzJqbNpBUeKBKQ3dD pB7g== X-Gm-Message-State: ALoCoQkV4v7VyNS0DFKGMJYN9qilUXHNnTvp6pYMqZFgwG8JUDe/uMx4iLcfQ0uIQdl5cZ31zEYe X-Received: by 10.112.55.104 with SMTP id r8mr2421462lbp.18.1431595856255; Thu, 14 May 2015 02:30:56 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.4.73 with SMTP id i9ls384656lai.100.gmail; Thu, 14 May 2015 02:30:56 -0700 (PDT) X-Received: by 10.112.198.8 with SMTP id iy8mr2469728lbc.44.1431595856077; Thu, 14 May 2015 02:30:56 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com. [209.85.215.49]) by mx.google.com with ESMTPS id lk5si14110277lac.170.2015.05.14.02.30.56 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 14 May 2015 02:30:56 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by lagv1 with SMTP id v1so59140216lag.3 for ; Thu, 14 May 2015 02:30:56 -0700 (PDT) X-Received: by 10.152.9.66 with SMTP id x2mr2478819laa.36.1431595855982; Thu, 14 May 2015 02:30:55 -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 hn6csp1118291lbb; Thu, 14 May 2015 02:30:55 -0700 (PDT) X-Received: by 10.229.249.6 with SMTP id mi6mr614614qcb.24.1431595854583; Thu, 14 May 2015 02:30:54 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id 47si1754383qgf.38.2015.05.14.02.30.53 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Thu, 14 May 2015 02:30: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]:53331 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YspTh-0006fv-Jy for patch@linaro.org; Thu, 14 May 2015 05:30:53 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48425) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YspNh-0005Yp-3l for qemu-devel@nongnu.org; Thu, 14 May 2015 05:24:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YspNe-0001Rs-TX for qemu-devel@nongnu.org; Thu, 14 May 2015 05:24:41 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:32521) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YspNe-0001O0-9M for qemu-devel@nongnu.org; Thu, 14 May 2015 05:24:38 -0400 Received: from 172.24.2.119 (EHLO szxeml430-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id CLJ60796; Thu, 14 May 2015 17:21:15 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.158.1; Thu, 14 May 2015 17:20:59 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Thu, 14 May 2015 17:19:32 +0800 Message-ID: <1431595182-7552-14-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1431595182-7552-1-git-send-email-zhaoshenglong@huawei.com> References: <1431595182-7552-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: 119.145.14.65 Cc: hangaohuai@huawei.com, zhaoshenglong@huawei.com, peter.huangpeng@huawei.com, shannon.zhao@linaro.org Subject: [Qemu-devel] [PATCH v7 13/23] 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.49 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. If we want to request uninitialized buffer, pass ByteList as NULL to aml_buffer() to reserve spaces. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 15 ++++++++++++++- include/hw/acpi/aml-build.h | 2 +- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index b0e1dbc..6197896 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -636,9 +636,22 @@ Aml *aml_resource_template(void) } /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefBuffer */ -Aml *aml_buffer(void) +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++) { + /* (byte_list == NULL) means requesting uninitialized buffer, only + * need to reserve spaces. + */ + 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 dd3b317..615f3c1 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -261,7 +261,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);