From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muf-0001RI-0L for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:35 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Y1muY-0002sH-OZ for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:28 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34969) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Y1muY-0002s6-EB for qemu-devel@nongnu.org; Thu, 18 Dec 2014 21:03:22 -0500 From: Igor Mammedov Date: Fri, 19 Dec 2014 02:02:17 +0000 Message-Id: <1418954562-13716-23-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 22/47] acpi: add acpi_io() helper 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 | 19 +++++++++++++++++++ include/hw/acpi/acpi_gen_utils.h | 7 +++++++ 2 files changed, 26 insertions(+) diff --git a/hw/acpi/acpi_gen_utils.c b/hw/acpi/acpi_gen_utils.c index 01d5c77..e9b2606 100644 --- a/hw/acpi/acpi_gen_utils.c +++ b/hw/acpi/acpi_gen_utils.c @@ -429,6 +429,25 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2, return var; } +/* + * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro) + * 6.4.2 Small Resource Data Type +*/ +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base, + uint8_t aln, uint8_t len) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x47); /* IO port descriptor */ + build_append_byte(var.buf, dec); + build_append_byte(var.buf, min_base & 0xff); + build_append_byte(var.buf, (min_base >> 8) & 0xff); + build_append_byte(var.buf, max_base & 0xff); + build_append_byte(var.buf, (max_base >> 8) & 0xff); + build_append_byte(var.buf, aln); + build_append_byte(var.buf, len); + 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 594fae7..91575f1 100644 --- a/include/hw/acpi/acpi_gen_utils.h +++ b/include/hw/acpi/acpi_gen_utils.h @@ -19,6 +19,11 @@ typedef struct AcpiAml { AcpiBlockFlags block_flags; } AcpiAml; +typedef enum { + acpi_decode10 = 0, + acpi_decode16 = 1, +} acpiIODecode; + void aml_append(AcpiAml *parent_ctx, AcpiAml child); /* non block ASL object primitives */ @@ -39,6 +44,8 @@ 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); +AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base, + uint8_t aln, uint8_t len); /* Block ASL object primitives */ AcpiAml acpi_if(AcpiAml predicate); -- 1.8.3.1