From patchwork Sat Jan 24 09:21:18 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shannon Zhao X-Patchwork-Id: 432392 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 7FEB31402A1 for ; Sat, 24 Jan 2015 20:24:47 +1100 (AEDT) Received: from localhost ([::1]:34429 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwxQ-0000Gu-Eu for incoming@patchwork.ozlabs.org; Sat, 24 Jan 2015 04:24:44 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50712) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwwp-0007XQ-LQ for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YEwwm-0004ba-Kr for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:07 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:40123) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YEwwl-0004b3-Ti for qemu-devel@nongnu.org; Sat, 24 Jan 2015 04:24:04 -0500 Received: from 172.24.2.119 (EHLO szxeml427-hub.china.huawei.com) ([172.24.2.119]) by szxrg03-dlp.huawei.com (MOS 4.4.3-GA FastPath queued) with ESMTP id BAW28210; Sat, 24 Jan 2015 17:23:44 +0800 (CST) Received: from HGHY1Z002260041.china.huawei.com (10.177.16.142) by szxeml427-hub.china.huawei.com (10.82.67.182) with Microsoft SMTP Server id 14.3.158.1; Sat, 24 Jan 2015 17:23:37 +0800 From: Shannon Zhao To: , , , , , , , , , Date: Sat, 24 Jan 2015 17:21:18 +0800 Message-ID: <1422091280-14532-10-git-send-email-zhaoshenglong@huawei.com> X-Mailer: git-send-email 1.9.0.msysgit.0 In-Reply-To: <1422091280-14532-1-git-send-email-zhaoshenglong@huawei.com> References: <1422091280-14532-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.0A020204.54C364A0.00F4, 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: 4d88d52e372dd940aa4897bb5b91e827 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: wanghaibin.wang@huawei.com, hangaohuai@huawei.com, peter.huangpeng@huawei.com, zhaoshenglong@huawei.com Subject: [Qemu-devel] [RFC PATCH 09/11] hw/acpi/acpi-build-utils: Add acpi_fixed_memory32() and acpi_extended_irq() 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 Add acpi_fixed_memory32() for describing device mmio region in resource template. Add acpi_extended_irq() for describing device interrupt in resource template. These can be used to generating DSDT table for ACPI on ARM. Signed-off-by: Shannon Zhao --- hw/acpi/acpi-build-utils.c | 42 ++++++++++++++++++++++++++++++++++++ include/hw/acpi/acpi-build-utils.h | 2 + 2 files changed, 44 insertions(+), 0 deletions(-) diff --git a/hw/acpi/acpi-build-utils.c b/hw/acpi/acpi-build-utils.c index 59873e3..211c4d3 100644 --- a/hw/acpi/acpi-build-utils.c +++ b/hw/acpi/acpi-build-utils.c @@ -493,6 +493,48 @@ AcpiAml acpi_call4(const char *method, AcpiAml arg1, AcpiAml arg2, } /* + * ACPI 5.1: 19.5.80 Memory32Fixed (Memory Resource Descriptor Macro) + * 6.4.2 Small Resource Data Type + */ +AcpiAml acpi_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x86); /* Extended irq descriptor */ + build_append_byte(var.buf, 9); + build_append_byte(var.buf, 0); + build_append_byte(var.buf, rw_flag); + build_append_byte(var.buf, addr & 0xff); + build_append_byte(var.buf, (addr >> 8) & 0xff); + build_append_byte(var.buf, (addr >> 16) & 0xff); + build_append_byte(var.buf, (addr >> 24) & 0xff); + + build_append_byte(var.buf, size & 0xff); + build_append_byte(var.buf, (size >> 8) & 0xff); + build_append_byte(var.buf, (size >> 16) & 0xff); + build_append_byte(var.buf, (size >> 24) & 0xff); + return var; +} + +/* + * ACPI 5.1: 19.5.61 Interrupt (Interrupt Resource Descriptor Macro) + * 6.4.2 Small Resource Data Type + */ +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq) +{ + AcpiAml var = aml_allocate_internal(0, NON_BLOCK); + build_append_byte(var.buf, 0x89); /* Extended irq descriptor */ + build_append_byte(var.buf, 6); + build_append_byte(var.buf, 0); + build_append_byte(var.buf, irq_flags); + build_append_byte(var.buf, 0x01); + build_append_byte(var.buf, irq & 0xff); + build_append_byte(var.buf, (irq >> 8) & 0xff); + build_append_byte(var.buf, (irq >> 16) & 0xff); + build_append_byte(var.buf, (irq >> 24) & 0xff); + return var; +} + +/* * ACPI 5.0: 19.5.62 IO (IO Resource Descriptor Macro) * 6.4.2 Small Resource Data Type */ diff --git a/include/hw/acpi/acpi-build-utils.h b/include/hw/acpi/acpi-build-utils.h index d39b5b1..bfed546 100644 --- a/include/hw/acpi/acpi-build-utils.h +++ b/include/hw/acpi/acpi-build-utils.h @@ -115,6 +115,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_fixed_memory32(uint64_t addr, uint64_t size, uint8_t rw_flag); +AcpiAml acpi_extended_irq(uint8_t irq_flags, int irq); AcpiAml acpi_io(acpiIODecode dec, uint16_t min_base, uint16_t max_base, uint8_t aln, uint8_t len); AcpiAml acpi_iqr_no_flags(uint8_t irq);