On 27/11/23 06:20, Gustavo Romero wrote:
Add a new device, ivshmem-flat, which is similar to the ivshmem PCI but
does not require a PCI bus. It's meant to be used on machines like those
with Cortex-M MCUs, which usually lack a PCI/PCIe bus, e.g. lm3s6965evb
and mps2-an385.
The device currently only supports the sysbus bus.
The following is an example on how to create the ivshmem-flat device on
a Stellaris machine:
$ qemu-system-arm -cpu cortex-m3 -machine lm3s6965evb -nographic
-net none -chardev stdio,id=con,mux=on
-serial chardev:con -mon chardev=con,mode=readline
-chardev socket,path=/tmp/ivshmem_socket,id=ivf
-device
ivshmem-flat,x-irq-qompath=/machine/unattached/device[1]/nvic/unnamed-gpio-in[0],x-bus-qompath="/sysbus",chardev=ivf
-kernel zephyr_qemu.elf
The new device, just like the ivshmem PCI device, supports both peer
notification via hardware interrupts and shared memory.
The IRQ QOM path for the target machine can be determined by creating
the VM without the ivshmem-flat device, going to the QEMU console and
listing the QOM nodes with 'info qom-tree'. In the Stellaris example
above the input IRQ is in the NVIC IC.
The MMRs for status and control (notification) are mapped to the MMIO
region at 0x400FF000 (default), whilst the shared memory region start
is mapped at addr. 0x40100000 (default), but both addresses can be set
when creating the device by using 'x-bus-address-{mmr,shmem}' options,
respectively.
The device shared memory size can be set using the 'shmem-size' option
and it defaults to 4 MiB, which is the default size of shmem allocated
by the ivshmem server.
Per https://gitlab.com/qemu-project/qemu/-/issues/1134#note_1667709336:
Resolves: https://gitlab.com/qemu-project/qemu/-/issues/1134
Signed-off-by: Gustavo Romero <gustavo.rom...@linaro.org>
---
docs/system/devices/ivshmem-flat.rst | 89 +++++
hw/arm/mps2.c | 2 +
hw/arm/stellaris.c | 5 +-
hw/arm/virt.c | 2 +
hw/core/sysbus-fdt.c | 1 +
hw/misc/Kconfig | 5 +
hw/misc/ivshmem-flat.c | 477 +++++++++++++++++++++++++++
hw/misc/meson.build | 2 +
hw/misc/trace-events | 18 +
include/hw/misc/ivshmem-flat.h | 72 ++++
10 files changed, 672 insertions(+), 1 deletion(-)
create mode 100644 docs/system/devices/ivshmem-flat.rst
create mode 100644 hw/misc/ivshmem-flat.c
create mode 100644 include/hw/misc/ivshmem-flat.h