diff options
| author | Eric Auger <eric.auger@redhat.com> | 2025-07-14 10:05:14 +0200 |
|---|---|---|
| committer | Michael S. Tsirkin <mst@redhat.com> | 2025-07-15 02:56:40 -0400 |
| commit | 1a102856652268cf2ec4cbd2cb9b229ef920c31d (patch) | |
| tree | 2c1b8679b8c8325f6458f8e7c32000c067fcf1dc /hw/core | |
| parent | 745315784db4315644421f5def482ff1324503bd (diff) | |
| download | focaccia-qemu-1a102856652268cf2ec4cbd2cb9b229ef920c31d.tar.gz focaccia-qemu-1a102856652268cf2ec4cbd2cb9b229ef920c31d.zip | |
hw/core/sysbus: Introduce sysbus_mmio_map_name() helper
Some sysbus devices have conditional mmio regions. This happens for instance with the hw/acpi/ged device. In that case it becomes difficult to predict which index a specific MMIO region corresponds to when one needs to mmio map the region. Introduce a new helper that takes the name of the region instead of its index. If the region is not found this returns -1. Otherwise it maps the corresponding index and returns this latter. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Igor Mammedov <imammedo@redhat.com> Message-Id: <20250714080639.2525563-31-eric.auger@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Diffstat (limited to 'hw/core')
| -rw-r--r-- | hw/core/sysbus.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/hw/core/sysbus.c b/hw/core/sysbus.c index e71367adfb..ec69e877a2 100644 --- a/hw/core/sysbus.c +++ b/hw/core/sysbus.c @@ -151,6 +151,17 @@ void sysbus_mmio_map(SysBusDevice *dev, int n, hwaddr addr) sysbus_mmio_map_common(dev, n, addr, false, 0); } +int sysbus_mmio_map_name(SysBusDevice *dev, const char *name, hwaddr addr) +{ + for (int i = 0; i < dev->num_mmio; i++) { + if (!strcmp(dev->mmio[i].memory->name, name)) { + sysbus_mmio_map(dev, i, addr); + return i; + } + } + return -1; +} + void sysbus_mmio_map_overlap(SysBusDevice *dev, int n, hwaddr addr, int priority) { |