From patchwork Wed Aug 8 15:15:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Igor Mammedov X-Patchwork-Id: 955091 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com 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 41lw4s2ZGbz9s0n for ; Thu, 9 Aug 2018 01:18:21 +1000 (AEST) Received: from localhost ([::1]:44282 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnQE6-0006tx-VF for incoming@patchwork.ozlabs.org; Wed, 08 Aug 2018 11:18:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:51457) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fnQBx-0005pG-TB for qemu-devel@nongnu.org; Wed, 08 Aug 2018 11:16:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fnQBu-0002gc-4k for qemu-devel@nongnu.org; Wed, 08 Aug 2018 11:16:05 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:56706 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fnQBt-0002g6-Vy for qemu-devel@nongnu.org; Wed, 08 Aug 2018 11:16:02 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id E4AA5402315B for ; Wed, 8 Aug 2018 15:16:00 +0000 (UTC) Received: from dell-r430-03.lab.eng.brq.redhat.com (dell-r430-03.lab.eng.brq.redhat.com [10.37.153.18]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C242104949D; Wed, 8 Aug 2018 15:16:00 +0000 (UTC) From: Igor Mammedov To: qemu-devel@nongnu.org Date: Wed, 8 Aug 2018 17:15:46 +0200 Message-Id: <1533741349-199141-2-git-send-email-imammedo@redhat.com> In-Reply-To: <1533741349-199141-1-git-send-email-imammedo@redhat.com> References: <1533741349-199141-1-git-send-email-imammedo@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 08 Aug 2018 15:16:00 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.6]); Wed, 08 Aug 2018 15:16:00 +0000 (UTC) for IP:'10.11.54.3' DOMAIN:'int-mx03.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'imammedo@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [RFC PATCH 1/4] acpi: aml: add aml_register() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "Michael S. Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Michael S. Tsirkin" Based on a patch by Igor Mammedov. Signed-off-by: Igor Mammedov Signed-off-by: Michael S. Tsirkin --- include/hw/acpi/aml-build.h | 5 +++++ hw/acpi/aml-build.c | 21 +++++++++++++++++++++ 2 files changed, 26 insertions(+) diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h index 6c36903..10c7946 100644 --- a/include/hw/acpi/aml-build.h +++ b/include/hw/acpi/aml-build.h @@ -346,6 +346,11 @@ Aml *aml_qword_memory(AmlDecode dec, AmlMinFixed min_fixed, uint64_t len); Aml *aml_dma(AmlDmaType typ, AmlDmaBusMaster bm, AmlTransferSize sz, uint8_t channel); +Aml *aml_register(AmlAddressSpace as, + uint8_t bit_width, + uint8_t bit_offset, + uint64_t address, + uint8_t access_size); Aml *aml_sleep(uint64_t msec); /* Block AML object primitives */ diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c index 1e43cd7..def62b3 100644 --- a/hw/acpi/aml-build.c +++ b/hw/acpi/aml-build.c @@ -874,6 +874,27 @@ Aml *aml_irq_no_flags(uint8_t irq) return var; } +/* + * ACPI: 2.0: 16.2.4.16 ASL Macro for Generic Register Descriptor + * + * access_size comes from: + * ACPI 3.0: 17.5.98 Register (Generic Register Resource Descriptor Macro) + */ +Aml *aml_register(AmlAddressSpace as, + uint8_t bit_width, + uint8_t bit_offset, + uint64_t address, + uint8_t access_size) +{ + Aml *var = aml_alloc(); + + build_append_byte(var->buf, 0x82); /* Generic Register Descriptor */ + build_append_byte(var->buf, 0x0C); /* Length, bits[7:0] */ + build_append_byte(var->buf, 0x0); /* Length, bits[15:8] */ + build_append_gas(var->buf, as, bit_width, bit_offset, access_size, address); + return var; +} + /* ACPI 1.0b: 16.2.5.4 Type 2 Opcodes Encoding: DefLNot */ Aml *aml_lnot(Aml *arg) {