From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60621) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muW-0001Dm-Ix for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:28 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1muP-0002nA-3u for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:20 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54092) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muO-0002mr-ST for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:13 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:02:10 +0000 Message-Id: <1418954562-13716-16-git-send-email-imammedo@redhat.com> In-Reply-To: <1418954562-13716-1-git-send-email-imammedo@redhat.com> References: <1418954562-13716-1-git-send-email-imammedo@redhat.com> Subject: [Qemu-devel] [RFC 15/47] acpi: add acpi_call1(), acpi_call2(), acpi_call3(), acpi_call4() helpers List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, drjones@redhat.com, claudio.fontana@huawei.com, mst@redhat.com Signed-off-by: Igor Mammedov --- hw/acpi/acpi_gen_utils.c | 43 ++++++++++++++++++++++++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 6 ++++++ 2 files changed, 49 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index d6bdc16..33478ef 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -386,6 +386,49 @@ AcpiAml acpi_notify(AcpiAml arg1, AcpiAml arg2) return var; } +/* helper to call method with 1 argument */ +AcpiAml acpi_call1(const char *method, AcpiAml arg1) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_namestring(var.buf, "%s", method); + aml_append(&var, arg1); + return var; +} + +/* helper to call method with 2 arguments */ +AcpiAml acpi_call2(const char *method, AcpiAml arg1, AcpiAml arg2) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_namestring(var.buf, "%s", method); + aml_append(&var, arg1); + aml_append(&var, arg2); + return var; +} + +/* helper to call method with 3 arguments */ +AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2, AcpiAml arg3) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_namestring(var.buf, "%s", method); + aml_append(&var, arg1); + aml_append(&var, arg2); + aml_append(&var, arg3); + return var; +} + +/* helper to call method with 4 arguments */ +AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2, + AcpiAml arg3, AcpiAml arg4) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_namestring(var.buf, "%s", method); + aml_append(&var, arg1); + aml_append(&var, arg2); + aml_append(&var, arg3); + aml_append(&var, arg4); + return var; +} + /* ACPI 5.0: 20.2.5.3 Type 1 Opcodes Encoding: DefIfElse */ AcpiAml acpi_if(AcpiAml predicate) { diff --git a/include/hw/acpi/acpi_gen_utils.h b/include/hw/acpi/acpi_gen_utils.h index 1395b32..473589d 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -33,6 +33,12 @@ AcpiAml acpi_arg3(void); AcpiAml acpi_store(AcpiAml val, AcpiAml target); AcpiAml acpi_and(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); +AcpiAml acpi_call3(const char *method, AcpiAml arg1, AcpiAml arg2, + AcpiAml arg3); +AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2, + AcpiAml arg3, AcpiAml arg4); /* Block ASL object primitives */ AcpiAml acpi_if(AcpiAml predicate); -- 1.8.3.1