From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38040) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6dp-00045e-Nf for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:22 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zb6dl-0000En-QU for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:59770) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zb6dl-0000ED-IC for qemu-devel@nongnu.org; Sun, 13 Sep 2015 08:44:17 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (Postfix) with ESMTPS id 44444550CC for ; Sun, 13 Sep 2015 12:44:17 +0000 (UTC) From: Laszlo Ersek Date: Sun, 13 Sep 2015 14:43:43 +0200 Message-Id: <1442148227-17343-10-git-send-email-lersek@redhat.com> In-Reply-To: <1442148227-17343-1-git-send-email-lersek@redhat.com> References: <55F5647C.6030901@redhat.com> <1442148227-17343-1-git-send-email-lersek@redhat.com> Subject: [Qemu-devel] [PATCH FYI 09/13] hw/acpi: expose more parameters for aml_method() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Gal Hammer , Paolo Bonzini , "Michael S. Tsirkin" , Igor Mammedov ACPI 1.0b defines the SerializeFlag in MethodFlags. We have not exposed this until now, but serializing methods that create named objects is warmly recommended by (recent versions of) the ACPI spec, and recent iasl actually warns about it. Therefore expose SerializeFlag in a new function. The old aml_method() function is preserved for old callers' sake. While at it, expose the SyncLevel bitfield of MethodFlags as well. Because that was introduced in ACPI 2.0, add a separate function for it. This allows us to provide one comprehensive DefMethod implementation. Cc: Paolo Bonzini Cc: Gal Hammer Cc: Igor Mammedov Cc: "Michael S. Tsirkin" Signed-off-by: Laszlo Ersek --- include/hw/acpi/aml-build.h | 3 +++ hw/acpi/aml-build.c | 26 +++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index ee54242..f8f96ec 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -266,6 +266,9 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, Aml *aml_scope(const char *name_format, ...) GCC_FMT_ATTR(1, 2); Aml *aml_device(const char *name_format, ...) GCC_FMT_ATTR(1, 2); Aml *aml_method(const char *name, int arg_count); +Aml *aml_method_serialized(const char *name, int arg_count, bool serialized); +Aml *aml_method_flags(const char *name, int arg_count, bool serialized, + int sync_level); Aml *aml_if(Aml *predicate); Aml *aml_else(void); Aml *aml_while(Aml *predicate); diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 7d58483..a0f187e 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -698,9 +698,33 @@ Aml *aml_while(Aml *predicate) /* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */ Aml *aml_method(const char *name, int arg_count) { + return aml_method_serialized(name, arg_count, false); +} + +/* ACPI 1.0b: 16.2.5.2 Named Objects Encoding: DefMethod */ +Aml *aml_method_serialized(const char *name, int arg_count, bool serialized) +{ + return aml_method_flags(name, arg_count, serialized, 0); +} + +/* ACPI 2.0: 17.2.4.2 Named Objects Encoding: DefMethod */ +Aml *aml_method_flags(const char *name, int arg_count, bool serialized, + int sync_level) +{ Aml *var = aml_bundle(0x14 /* MethodOp */, AML_PACKAGE); build_append_namestring(var->buf, "%s", name); - build_append_byte(var->buf, arg_count); /* MethodFlags: ArgCount */ + + assert(arg_count >= 0); + assert(arg_count <= 7); + if (serialized) { + assert(sync_level >= 0x00); + assert(sync_level <= 0x0f); + } else { + assert(sync_level == 0); + } + + build_append_byte(var->buf, + arg_count | (serialized << 3) | (sync_level << 4)); return var; } -- 1.8.3.1