From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45582) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuNaz-0007oi-Dw for qemu-devel@nongnu.org; Mon, 18 May 2015 12:08:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YuNav-0006Ci-4d for qemu-devel@nongnu.org; Mon, 18 May 2015 12:08:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37800) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YuNau-0006CX-VY for qemu-devel@nongnu.org; Mon, 18 May 2015 12:08:45 -0400 Date: Mon, 18 May 2015 18:08:39 +0200 From: "Michael S. Tsirkin" Message-ID: <20150518180744-mutt-send-email-mst@redhat.com> References: <1431595182-7552-1-git-send-email-zhaoshenglong@huawei.com> <1431595182-7552-14-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1431595182-7552-14-git-send-email-zhaoshenglong@huawei.com> Subject: Re: [Qemu-devel] [PATCH v7 13/23] hw/acpi/aml-build: Make aml_buffer() definition consistent with the spec List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Shannon Zhao Cc: peter.maydell@linaro.org, hangaohuai@huawei.com, a.spyridakis@virtualopensystems.com, claudio.fontana@huawei.com, qemu-devel@nongnu.org, peter.huangpeng@huawei.com, alex.bennee@linaro.org, hanjun.guo@linaro.org, imammedo@redhat.com, pbonzini@redhat.com, lersek@redhat.com, christoffer.dall@linaro.org, shannon.zhao@linaro.org On Thu, May 14, 2015 at 05:19:32PM +0800, Shannon Zhao wrote: > 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. > + */ This comment documents API, belongs at top of function, not here. > + if (byte_list == NULL) { > + build_append_byte(var->buf, 0x0); > + } else { > + build_append_byte(var->buf, *(byte_list + i)); byte_list[i] would be clearer. > + } > + } > + > 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); > -- > 2.1.0 >