From patchwork Fri Apr 3 10:03:46 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 457927 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 1991F1400A0 for ; Fri, 3 Apr 2015 21:13:16 +1100 (AEDT) Received: from localhost ([::1]:33337 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdybC-0005c5-54 for incoming@patchwork.ozlabs.org; Fri, 03 Apr 2015 06:13:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38464) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdyUs-0002XR-4G for qemu-devel@nongnu.org; Fri, 03 Apr 2015 06:06:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YdyUn-0006ko-Ox for qemu-devel@nongnu.org; Fri, 03 Apr 2015 06:06:42 -0400 Received: from szxga03-in.huawei.com ([119.145.14.66]:9711) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YdyUn-0006ey-6I for qemu-devel@nongnu.org; Fri, 03 Apr 2015 06:06:37 -0400 Received: from 172.24.2.119 (EHLO szxeml425-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BDZ47799; Fri, 03 Apr 2015 18:05:59 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.158.1; Fri, 3 Apr 2015 18:05:50 +0800 From: Shannon Zhao To: , , , , , , , , , , Date: Fri, 3 Apr 2015 18:03:46 +0800 Message-ID: <1428055432-12120-15-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1428055432-12120-1-git-send-email-zhaoshenglong@huawei.com> References: <1428055432-12120-1-git-send-email-zhaoshenglong@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.16.142] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020201.551E6607.01A0, ss=1, re=0.001, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-05-26 15:14:31, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: b01ac80a9dc0a5b0ef66f98953022432 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.66 Cc: hangaohuai@huawei.com, shannon.zhao@linaro.org, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [PATCH v4 14/20] hw/acpi/aml-build: Add aml_or() term 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Shannon Zhao Add aml_or() term and make aml_and can take three args. Expose build_append_int_noprefix as it wiil be used by creating a buffer. Signed-off-by: Shannon Zhao Signed-off-by: Shannon Zhao --- hw/acpi/aml-build.c | 24 +++++++++++++++++++++--- hw/i386/acpi-build.c | 2 +- include/hw/acpi/aml-build.h | 4 +++- 3 files changed, 25 insertions(+), 5 deletions(-) diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 5a94fc9..312afb6 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -240,7 +240,7 @@ static void build_extop_package(GArray *package, uint8_t op) build_prepend_byte(package, 0x5B); /* ExtOpPrefix */ } -static void build_append_int_noprefix(GArray *table, uint64_t value, int size) +void build_append_int_noprefix(GArray *table, uint64_t value, int size) { int i; @@ -445,12 +445,30 @@ Aml *aml_store(Aml *val, Aml *target) } /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefAnd */ -Aml *aml_and(Aml *arg1, Aml *arg2) +Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3) { Aml *var = aml_opcode(0x7B /* AndOp */); aml_append(var, arg1); aml_append(var, arg2); - build_append_byte(var->buf, 0x00 /* NullNameOp */); + if (arg3 == NULL) { + build_append_byte(var->buf, 0x00 /* NullNameOp */); + } else { + aml_append(var, arg3); + } + return var; +} + +/* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefOr */ +Aml *aml_or(Aml *arg1, Aml *arg2, Aml *arg3) +{ + Aml *var = aml_opcode(0x7D /* OrOp */); + aml_append(var, arg1); + aml_append(var, arg2); + if (arg3 == NULL) { + build_append_byte(var->buf, 0x00 /* NullNameOp */); + } else { + aml_append(var, arg3); + } return var; } diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 7b5210e..133685e 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -452,7 +452,7 @@ static void build_append_pcihp_notify_entry(Aml *method, int slot) Aml *if_ctx; int32_t devfn = PCI_DEVFN(slot, 0); - if_ctx = aml_if(aml_and(aml_arg(0), aml_int(0x1U << slot))); + if_ctx = aml_if(aml_and(aml_arg(0), aml_int(0x1U << slot), NULL)); aml_append(if_ctx, aml_notify(aml_name("S%.02X", devfn), aml_arg(1))); aml_append(method, if_ctx); } diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 942d986..3473d6e 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -156,7 +156,8 @@ Aml *aml_return(Aml *val); Aml *aml_int(const uint64_t val); Aml *aml_arg(int pos); Aml *aml_store(Aml *val, Aml *target); -Aml *aml_and(Aml *arg1, Aml *arg2); +Aml *aml_and(Aml *arg1, Aml *arg2, Aml *arg3); +Aml *aml_or(Aml *arg1, Aml *arg2, Aml *arg3); Aml *aml_notify(Aml *arg1, Aml *arg2); Aml *aml_call1(const char *method, Aml *arg1); Aml *aml_call2(const char *method, Aml *arg1, Aml *arg2); @@ -211,6 +212,7 @@ Aml *aml_field(const char *name, AmlFieldFlags flags); Aml *aml_varpackage(uint32_t num_elements); Aml *aml_touuid(int32_t val1, int16_t val2, int16_t val3, int16_t val4, int64_t val5); +void build_append_int_noprefix(GArray *table, uint64_t value, int size); void build_header(GArray *linker, GArray *table_data,