From: Igor Mammedov <imammedo@redhat.com>
To: Sunil V L <sunilvl@ventanamicro.com>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org,
qemu-riscv@nongnu.org, "Michael S . Tsirkin" <mst@redhat.com>,
Ani Sinha <anisinha@redhat.com>,
Peter Maydell <peter.maydell@linaro.org>,
Shannon Zhao <shannon.zhaosl@gmail.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Palmer Dabbelt <palmer@dabbelt.com>,
Alistair Francis <alistair.francis@wdc.com>,
Bin Meng <bin.meng@windriver.com>,
Weiwei Li <liweiwei@iscas.ac.cn>,
Daniel Henrique Barboza <dbarboza@ventanamicro.com>,
Liu Zhiwei <zhiwei_liu@linux.alibaba.com>,
Andrew Jones <ajones@ventanamicro.com>,
Anup Patel <apatel@ventanamicro.com>
Subject: Re: [PATCH 01/10] hw/arm/virt-acpi-build.c: Move fw_cfg and virtio to common location
Date: Mon, 24 Jul 2023 17:18:59 +0200 [thread overview]
Message-ID: <20230724171859.212fec62@imammedo.users.ipa.redhat.com> (raw)
In-Reply-To: <20230712163943.98994-2-sunilvl@ventanamicro.com>
On Wed, 12 Jul 2023 22:09:34 +0530
Sunil V L <sunilvl@ventanamicro.com> wrote:
> The functions which add fw_cfg and virtio to DSDT are same for ARM
> and RISC-V. So, instead of duplicating in RISC-V, move them from
> hw/arm/virt-acpi-build.c to common aml-build.c.
>
> Signed-off-by: Sunil V L <sunilvl@ventanamicro.com>
> ---
> hw/acpi/aml-build.c | 41 ++++++++++++++++++++++++++++++++++++
> hw/arm/virt-acpi-build.c | 42 -------------------------------------
> hw/riscv/virt-acpi-build.c | 16 --------------
> include/hw/acpi/aml-build.h | 6 ++++++
> 4 files changed, 47 insertions(+), 58 deletions(-)
>
> diff --git a/hw/acpi/aml-build.c b/hw/acpi/aml-build.c
patch looks fine modulo,
I'd put these into respective device files instead of generic
aml-build.c which was intended for basic AML primitives
(it 's got polluted over time with device specific functions
but that's not the reason to continue doing that).
Also having those functions along with devices models
goes along with self enumerating ACPI devices (currently
it works for x86 PCI/ISA device but there is no reason
that it can't work with other types as well when
I get there)
> index ea331a20d1..eeb1263c8c 100644
> --- a/hw/acpi/aml-build.c
> +++ b/hw/acpi/aml-build.c
> @@ -2467,3 +2467,44 @@ Aml *aml_i2c_serial_bus_device(uint16_t address, const char *resource_source)
>
> return var;
> }
> +
> +void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap)
> +{
> + Aml *dev = aml_device("FWCF");
> + aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
> + /* device present, functioning, decoding, not shown in UI */
> + aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
> + aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
> +
> + Aml *crs = aml_resource_template();
> + aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base,
> + fw_cfg_memmap->size, AML_READ_WRITE));
> + aml_append(dev, aml_name_decl("_CRS", crs));
> + aml_append(scope, dev);
> +}
> +
> +void acpi_dsdt_add_virtio(Aml *scope,
> + const MemMapEntry *virtio_mmio_memmap,
> + uint32_t mmio_irq, int num)
> +{
> + hwaddr base = virtio_mmio_memmap->base;
> + hwaddr size = virtio_mmio_memmap->size;
> + int i;
> +
> + for (i = 0; i < num; i++) {
> + uint32_t irq = mmio_irq + i;
> + Aml *dev = aml_device("VR%02u", i);
> + aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
> + aml_append(dev, aml_name_decl("_UID", aml_int(i)));
> + aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
> +
> + Aml *crs = aml_resource_template();
> + aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE));
> + aml_append(crs,
> + aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
> + AML_EXCLUSIVE, &irq, 1));
> + aml_append(dev, aml_name_decl("_CRS", crs));
> + aml_append(scope, dev);
> + base += size;
> + }
> +}
> diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c
> index 6b674231c2..fdedb68e2b 100644
> --- a/hw/arm/virt-acpi-build.c
> +++ b/hw/arm/virt-acpi-build.c
> @@ -35,7 +35,6 @@
> #include "target/arm/cpu.h"
> #include "hw/acpi/acpi-defs.h"
> #include "hw/acpi/acpi.h"
> -#include "hw/nvram/fw_cfg.h"
> #include "hw/acpi/bios-linker-loader.h"
> #include "hw/acpi/aml-build.h"
> #include "hw/acpi/utils.h"
> @@ -94,21 +93,6 @@ static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap,
> aml_append(scope, dev);
> }
>
> -static void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap)
> -{
> - Aml *dev = aml_device("FWCF");
> - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
> - /* device present, functioning, decoding, not shown in UI */
> - aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
> - aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
> -
> - Aml *crs = aml_resource_template();
> - aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base,
> - fw_cfg_memmap->size, AML_READ_WRITE));
> - aml_append(dev, aml_name_decl("_CRS", crs));
> - aml_append(scope, dev);
> -}
> -
> static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
> {
> Aml *dev, *crs;
> @@ -133,32 +117,6 @@ static void acpi_dsdt_add_flash(Aml *scope, const MemMapEntry *flash_memmap)
> aml_append(scope, dev);
> }
>
> -static void acpi_dsdt_add_virtio(Aml *scope,
> - const MemMapEntry *virtio_mmio_memmap,
> - uint32_t mmio_irq, int num)
> -{
> - hwaddr base = virtio_mmio_memmap->base;
> - hwaddr size = virtio_mmio_memmap->size;
> - int i;
> -
> - for (i = 0; i < num; i++) {
> - uint32_t irq = mmio_irq + i;
> - Aml *dev = aml_device("VR%02u", i);
> - aml_append(dev, aml_name_decl("_HID", aml_string("LNRO0005")));
> - aml_append(dev, aml_name_decl("_UID", aml_int(i)));
> - aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
> -
> - Aml *crs = aml_resource_template();
> - aml_append(crs, aml_memory32_fixed(base, size, AML_READ_WRITE));
> - aml_append(crs,
> - aml_interrupt(AML_CONSUMER, AML_LEVEL, AML_ACTIVE_HIGH,
> - AML_EXCLUSIVE, &irq, 1));
> - aml_append(dev, aml_name_decl("_CRS", crs));
> - aml_append(scope, dev);
> - base += size;
> - }
> -}
> -
> static void acpi_dsdt_add_pci(Aml *scope, const MemMapEntry *memmap,
> uint32_t irq, VirtMachineState *vms)
> {
> diff --git a/hw/riscv/virt-acpi-build.c b/hw/riscv/virt-acpi-build.c
> index 7331248f59..01843e4509 100644
> --- a/hw/riscv/virt-acpi-build.c
> +++ b/hw/riscv/virt-acpi-build.c
> @@ -97,22 +97,6 @@ static void acpi_dsdt_add_cpus(Aml *scope, RISCVVirtState *s)
> }
> }
>
> -static void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap)
> -{
> - Aml *dev = aml_device("FWCF");
> - aml_append(dev, aml_name_decl("_HID", aml_string("QEMU0002")));
> -
> - /* device present, functioning, decoding, not shown in UI */
> - aml_append(dev, aml_name_decl("_STA", aml_int(0xB)));
> - aml_append(dev, aml_name_decl("_CCA", aml_int(1)));
> -
> - Aml *crs = aml_resource_template();
> - aml_append(crs, aml_memory32_fixed(fw_cfg_memmap->base,
> - fw_cfg_memmap->size, AML_READ_WRITE));
> - aml_append(dev, aml_name_decl("_CRS", crs));
> - aml_append(scope, dev);
> -}
> -
> /* RHCT Node[N] starts at offset 56 */
> #define RHCT_NODE_ARRAY_OFFSET 56
>
> diff --git a/include/hw/acpi/aml-build.h b/include/hw/acpi/aml-build.h
> index d1fb08514b..c4a8967310 100644
> --- a/include/hw/acpi/aml-build.h
> +++ b/include/hw/acpi/aml-build.h
> @@ -3,6 +3,7 @@
>
> #include "hw/acpi/acpi-defs.h"
> #include "hw/acpi/bios-linker-loader.h"
> +#include "hw/nvram/fw_cfg.h"
>
> #define ACPI_BUILD_APPNAME6 "BOCHS "
> #define ACPI_BUILD_APPNAME8 "BXPC "
> @@ -497,4 +498,9 @@ void build_fadt(GArray *tbl, BIOSLinker *linker, const AcpiFadtData *f,
>
> void build_tpm2(GArray *table_data, BIOSLinker *linker, GArray *tcpalog,
> const char *oem_id, const char *oem_table_id);
> +
> +void acpi_dsdt_add_fw_cfg(Aml *scope, const MemMapEntry *fw_cfg_memmap);
> +void acpi_dsdt_add_virtio(Aml *scope, const MemMapEntry *virtio_mmio_memmap,
> + uint32_t mmio_irq, int num);
> +
> #endif
next prev parent reply other threads:[~2023-07-24 15:19 UTC|newest]
Thread overview: 34+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-12 16:39 [PATCH 00/10] RISC-V: ACPI: Enable AIA and update RHC Sunil V L
2023-07-12 16:39 ` [PATCH 01/10] hw/arm/virt-acpi-build.c: Move fw_cfg and virtio to common location Sunil V L
2023-07-12 19:06 ` Daniel Henrique Barboza
2023-07-23 23:40 ` Alistair Francis
2023-07-24 15:18 ` Igor Mammedov [this message]
2023-07-25 16:50 ` Sunil V L
2023-07-26 8:25 ` Igor Mammedov
2023-08-16 18:51 ` Daniel Henrique Barboza
2023-08-17 3:30 ` Sunil V L
2023-07-12 16:39 ` [PATCH 02/10] hw/riscv: virt: Add PCI bus reference in RISCVVirtState Sunil V L
2023-07-12 20:18 ` Daniel Henrique Barboza
2023-07-23 23:45 ` Alistair Francis
2023-07-12 16:39 ` [PATCH 03/10] hw/riscv: virt: Make few IMSIC macros and functions public Sunil V L
2023-07-12 20:21 ` Daniel Henrique Barboza
2023-07-24 1:53 ` Alistair Francis
2023-07-12 16:39 ` [PATCH 04/10] hw/riscv: virt: Add PCIe HIGHMEM in memmap Sunil V L
2023-07-18 20:05 ` Daniel Henrique Barboza
2023-07-19 3:37 ` Sunil V L
2023-07-24 15:32 ` Igor Mammedov
2023-07-27 10:59 ` Sunil V L
2023-07-27 12:04 ` Igor Mammedov
2023-07-27 12:32 ` Sunil V L
2023-07-12 16:39 ` [PATCH 05/10] hw/riscv/virt-acpi-build.c: Add AIA support in RINTC Sunil V L
2023-07-18 20:06 ` Daniel Henrique Barboza
2023-07-12 16:39 ` [PATCH 06/10] hw/riscv/virt-acpi-build.c: Add IMSIC in the MADT Sunil V L
2023-07-18 20:06 ` Daniel Henrique Barboza
2023-07-12 16:39 ` [PATCH 07/10] hw/riscv/virt-acpi-build.c: Add APLIC " Sunil V L
2023-07-18 20:10 ` Daniel Henrique Barboza
2023-07-12 16:39 ` [PATCH 08/10] hw/riscv/virt-acpi-build.c: Add CMO information in RHCT Sunil V L
2023-07-18 20:10 ` Daniel Henrique Barboza
2023-07-12 16:39 ` [PATCH 09/10] hw/riscv/virt-acpi-build.c: Add MMU node " Sunil V L
2023-07-18 20:12 ` Daniel Henrique Barboza
2023-07-12 16:39 ` [PATCH 10/10] hw/riscv/virt-acpi-build.c: Add IO controllers and devices Sunil V L
2023-07-18 20:13 ` Daniel Henrique Barboza
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230724171859.212fec62@imammedo.users.ipa.redhat.com \
--to=imammedo@redhat.com \
--cc=ajones@ventanamicro.com \
--cc=alistair.francis@wdc.com \
--cc=anisinha@redhat.com \
--cc=apatel@ventanamicro.com \
--cc=bin.meng@windriver.com \
--cc=dbarboza@ventanamicro.com \
--cc=liweiwei@iscas.ac.cn \
--cc=mst@redhat.com \
--cc=palmer@dabbelt.com \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=qemu-riscv@nongnu.org \
--cc=shannon.zhaosl@gmail.com \
--cc=sunilvl@ventanamicro.com \
--cc=zhiwei_liu@linux.alibaba.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).