From patchwork Mon Feb 16 09:54:01 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marcel Apfelbaum X-Patchwork-Id: 440006 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 25A33140119 for ; Mon, 16 Feb 2015 21:04:02 +1100 (AEDT) Received: from localhost ([::1]:38538 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNIX2-0002az-9u for incoming@patchwork.ozlabs.org; Mon, 16 Feb 2015 05:04:00 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34764) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNISt-0003C2-KI for qemu-devel@nongnu.org; Mon, 16 Feb 2015 04:59:49 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YNISp-0004LM-5U for qemu-devel@nongnu.org; Mon, 16 Feb 2015 04:59:43 -0500 Received: from mx1.redhat.com ([209.132.183.28]:48834) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YNISo-0004Ky-N4; Mon, 16 Feb 2015 04:59:39 -0500 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t1G9sTiM023850 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 16 Feb 2015 04:54:29 -0500 Received: from work.redhat.com (vpn1-4-121.ams2.redhat.com [10.36.4.121]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t1G9sI0j006518; Mon, 16 Feb 2015 04:54:24 -0500 From: Marcel Apfelbaum To: qemu-devel@nongnu.org Date: Mon, 16 Feb 2015 11:54:01 +0200 Message-Id: <1424080457-13752-2-git-send-email-marcel@redhat.com> In-Reply-To: <1424080457-13752-1-git-send-email-marcel@redhat.com> References: <1424080457-13752-1-git-send-email-marcel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: seabios@seabios.org, kraxel@redhat.com, mst@redhat.com, quintela@redhat.com, agraf@suse.de, marcel@redhat.com, alex.williamson@redhat.com, kevin@koconnor.net, qemu-ppc@nongnu.org, hare@suse.de, imammedo@redhat.com, amit.shah@redhat.com, pbonzini@redhat.com, leon.alrae@imgtec.com, aurelien@aurel32.net, rth@twiddle.net Subject: [Qemu-devel] [PATCH RFC V2 01/17] acpi: added needed acpi constructs 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 Signed-off-by: Marcel Apfelbaum --- hw/acpi/acpi-build-utils.c | 107 +++++++++++++++++++++++++++++++++++-- include/hw/acpi/acpi-build-utils.h | 12 +++++ 2 files changed, 116 insertions(+), 3 deletions(-) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index 58f88cd..19cd146 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -439,6 +439,26 @@ AcpiAml acpi_and(AcpiAml arg1, AcpiAml arg2) return var; } +AcpiAml acpi_or(AcpiAml arg1, AcpiAml arg2) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x7D); /* AndOp */ + aml_append(&var, arg1); + aml_append(&var, arg2); + build_append_int(var.buf, 0x00); /* NullNameOp */ + return var; +} + +AcpiAml acpi_add(AcpiAml arg1, AcpiAml arg2) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x72); /* AddOp */ + aml_append(&var, arg1); + aml_append(&var, arg2); + build_append_int(var.buf, 0x00); /* NullNameOp */ + return var; +} + /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefNotify */ AcpiAml acpi_notify(AcpiAml arg1, AcpiAml arg2) { @@ -518,6 +538,53 @@ AcpiAml acpi_equal(AcpiAml arg1, AcpiAml arg2) build_append_byte(var.buf, 0x93); /* LequalOp */ aml_append(&var, arg1); aml_append(&var, arg2); + return var; +} + +AcpiAml acpi_increment(AcpiAml arg1) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x75); /* LequalOp */ + aml_append(&var, arg1); + return var; +} + +AcpiAml acpi_lless(AcpiAml arg1, AcpiAml arg2) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x95); /* LequalOp */ + aml_append(&var, arg1); + aml_append(&var, arg2); +// build_append_int(var.buf, 0x00); /* NullNameOp */ + return var; +} + +AcpiAml acpi_shiftright(AcpiAml arg1, int count) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x7A); /* RightShiftOp */ + aml_append(&var, arg1); + aml_append(&var, acpi_int(count)); + build_append_int(var.buf, 0x00); /* NullNameOp */ + return var; +} + +AcpiAml acpi_shiftleft(AcpiAml arg1, int count) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x79); /* RightLeftOp */ + aml_append(&var, arg1); + aml_append(&var, acpi_int(count)); + build_append_int(var.buf, 0x00); /* NullNameOp */ + return var; +} + +AcpiAml acpi_index(AcpiAml arg1, AcpiAml idx) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x88); /* IndexOp */ + aml_append(&var, arg1); + aml_append(&var, idx); build_append_int(var.buf, 0x00); /* NullNameOp */ return var; } @@ -530,6 +597,13 @@ AcpiAml acpi_if(AcpiAml predicate) return var; } +AcpiAml acpi_while(AcpiAml predicate) +{ + AcpiAml var = aml_allocate_internal(0xA2 /* WhileOp */, PACKAGE); + aml_append(&var, predicate); + return var; +} + /* ACPI 5.0: 20.2.5.2 Named Objects Encoding: DefMethod */ AcpiAml acpi_method(const char *name, int arg_count) { @@ -652,14 +726,41 @@ AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char *name_format, ...) return var; } -/* ACPI 5.0: 20.2.6.2 Local Objects Encoding: Local0Op */ -AcpiAml acpi_local0(void) +/* ACPI 5.0: 20.2.6.2 Local Objects Encoding: LocalXOp */ +static AcpiAml acpi_local(uint8_t index) { AcpiAml var = aml_allocate_internal(0, NON_BLOCK); - build_append_byte(var.buf, 0x60); /* Local0Op */ + + assert(index < 8); + build_append_byte(var.buf, 0x60 + index); /* Local0Op */ return var; } +AcpiAml acpi_local0(void) +{ + return acpi_local(0); +} + +AcpiAml acpi_local1(void) +{ + return acpi_local(1); +} + +AcpiAml acpi_local2(void) +{ + return acpi_local(2); +} + +AcpiAml acpi_local3(void) +{ + return acpi_local(3); +} + +AcpiAml acpi_local4(void) +{ + return acpi_local(4); +} + /* ACPI 5.0: 20.2.5.4 Type 2 Opcodes Encoding: DefVarPackage */ AcpiAml acpi_varpackage(uint32_t num_elements) { diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index 868d439..e39a82d 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -108,6 +108,8 @@ AcpiAml acpi_arg2(void); AcpiAml acpi_arg3(void); AcpiAml acpi_store(AcpiAml val, AcpiAml target); AcpiAml acpi_and(AcpiAml arg1, AcpiAml arg2); +AcpiAml acpi_or(AcpiAml arg1, AcpiAml arg2); +AcpiAml acpi_add(AcpiAml arg1, AcpiAml arg2); AcpiAml acpi_notify(AcpiAml arg1, AcpiAml arg2); AcpiAml acpi_call1(const char *method, AcpiAml arg1); AcpiAml acpi_call2(const char *method, AcpiAml arg1, AcpiAml arg2); @@ -123,7 +125,16 @@ AcpiAml acpi_named_field(const char *name, unsigned length); AcpiAml acpi_reserved_field(unsigned length); AcpiAml GCC_FMT_ATTR(1, 2) acpi_string(const char *name_format, ...); AcpiAml acpi_local0(void); +AcpiAml acpi_local1(void); +AcpiAml acpi_local2(void); +AcpiAml acpi_local3(void); +AcpiAml acpi_local4(void); +AcpiAml acpi_increment(AcpiAml arg1); AcpiAml acpi_equal(AcpiAml arg1, AcpiAml arg2); +AcpiAml acpi_lless(AcpiAml arg1, AcpiAml arg2); +AcpiAml acpi_index(AcpiAml arg1, AcpiAml idx); +AcpiAml acpi_shiftright(AcpiAml arg1, int count); +AcpiAml acpi_shiftleft(AcpiAml arg1, int count); AcpiAml GCC_FMT_ATTR(4, 5) acpi_processor(uint8_t proc_id, uint32_t pblk_addr, uint8_t pblk_len, const char *name_format, ...); @@ -155,6 +166,7 @@ AcpiAml acpi_def_block(const char *signature, uint8_t revision, const char *oem_id, const char *oem_table_id, uint32_t oem_revision); AcpiAml acpi_if(AcpiAml predicate); +AcpiAml acpi_while(AcpiAml predicate); AcpiAml acpi_method(const char *name, int arg_count); AcpiAml GCC_FMT_ATTR(1, 2) acpi_scope(const char *name_format, ...); AcpiAml GCC_FMT_ATTR(1, 2) acpi_device(const char *name_format, ...);