m68k: add Virtual M68k Machine
v4 cover m68k: add Virtual M68k Machine
The Quadra 800 machine is very limited to run linux, it manages only 1 GiB of memory and only some specific interfaces.
The Virtual M68k Machine is based on Goldfish interfaces defined by Google for Android simulator. It uses Goldfish-rtc (timer and RTC), Goldfish-pic (PIC) and Goldfish-tty (for serial port and early tty).
https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFIS=
H-VIRTUAL-HARDWARE.TXT
The machine is created with 128 virtio-mmio busses, and they can be used to add serial console, GPU, disk, NIC, HID, ...
This series re-use the goldfish-rtc implemented for RISCV, and adds the two others based on the goldfish specs, the kernel driver and android simulator ones.
The machine can manage up to 3.2 GiB of memory, not because of an hardware limitation but because the kernel crashes after this value.
Simply configure qemu with:
.../configure --target-list=3Dm68k-softmmu
To run the machine you need a modified kernel you can find here:
https://github.com/vivier/linux/tree/m68k-virt
You need to compile the kernel with:
make virt_defconfig
make vmlinux
The disk must be installed using the q800 machine because the debian installer doesn't want to be used with a kernel that is not the one on the ISO.
And then you can run the machine with something like:
qemu-system-m68k -M virt \
-m 3399672K \
-chardev stdio,signal=3Doff,mux=3Don,id=3Dchar0 \
-mon chardev=3Dchar0,mode=3Dreadline \
-kernel vmlinux \
-append "console=3Dhvc0 root=3D/dev/vda2" \
-blockdev node-name=3Dsystem,driver=3Dfile,filename=3Ddebian-10.0.qcow2 \
-blockdev node-name=3Ddrive0,driver=3Dqcow2,file=3Dsystem \
-device virtio-blk-device,drive=3Ddrive0 \
-serial chardev:char0 \
-device virtio-net-device,netdev=3Dhostnet0 \
-netdev bridge,id=3Dhostnet0,br=3Dvirbr0 \
-device virtio-rng-device \
-device virtio-serial-device \
-device virtio-gpu-device \
-device virtconsole,chardev=3Dchar0 \
-device virtio-keyboard-device \
-device virtio-mouse-device
if you want to use Goldfish-tty for the console rather than virtconsole, you can add "console=3DttyGF".
To start the debian-installer, you can try by adding:
-device virtio-scsi-device \
-blockdev node-name=3Ddebian10,driver=3Dfile,filename=3Ddebian-10.0.0-m68k-=
NETINST-1.iso \
-blockdev node-name=3Dcdrom0,driver=3Draw,file=3Ddebian10 \
-device scsi-cd,drive=3Dcdrom0 \
-initrd installer-m68k/20200315/images/cdrom/initrd.gz
ISO: https://cdimage.debian.org/cdimage/ports/snapshots/2020-10-12/debian-=
10.0.0-m68k-NETINST-1.iso
initrd: https://cdimage.debian.org/cdimage/ports/debian-installer/2020-10-12/=
m68k/debian-installer-images_20200315_m68k.tar.gz
v4:
goldfish-tty:
Use fifo8 for the data_in buffer
Remove the data_out buffer from the struct and put it directly in the function. We don't need to use the fifo8 type because we can't bufferize the data as we can't stop the tx queue when the buffer is full. We rely on qemu_chr_fe_write_all() that blocks the thread for that.
goldfish-pic:
Add DEFINE_PROP_UINT8() for the index
Add .impl.min_access_size
v3:
Add some #define for the interrupt controller (and fix the number of IRQs) Add some comments
Update MAINTAINERS
Remove "goldfish_rtc: re-arm the alarm after migration" that will be merged via the RISC-V branch.
v2:
Add an interrupt controller to replace the Q800 GLUE Add a system controller to shutdown the machine
Add a fix for goldfish_rtc (already sent alone)
Add statistics in goldfish-pic
Add versionned machine type
Use two goldfish-rtc rather than only one (for timer and RTC)
Laurent Vivier (5):
char: add goldfish-tty
intc: add goldfish-pic
m68k: add an interrupt controller
m68k: add a system controller
m68k: add Virtual M68k Machine
default-configs/devices/m68k-softmmu.mak | 1 + include/hw/char/goldfish_tty.h | 35 ++ include/hw/intc/goldfish_pic.h | 33 ++ include/hw/intc/m68k_irqc.h | 41 +++ include/hw/misc/m68k_virt_ctrl.h | 22 ++ .../standard-headers/asm-m68k/bootinfo-virt.h | 18 + hw/char/goldfish_tty.c | 272 +++++++++++++++ hw/intc/goldfish_pic.c | 219 ++++++++++++ hw/intc/m68k_irqc.c | 119 +++++++ hw/m68k/virt.c | 313 ++++++++++++++++++ hw/misc/m68k_virt_ctrl.c | 152 +++++++++ MAINTAINERS | 13 + hw/char/Kconfig | 3 + hw/char/meson.build | 2 + hw/char/trace-events | 10 + hw/intc/Kconfig | 6 + hw/intc/meson.build | 2 + hw/intc/trace-events | 8 + hw/m68k/Kconfig | 10 + hw/m68k/meson.build | 1 + hw/misc/Kconfig | 3 + hw/misc/meson.build | 3 + hw/misc/trace-events | 7 + 23 files changed, 1293 insertions(+) create mode 100644 include/hw/char/goldfish_tty.h create mode 100644 include/hw/intc/goldfish_pic.h create mode 100644 include/hw/intc/m68k_irqc.h create mode 100644 include/hw/misc/m68k_virt_ctrl.h create mode 100644 include/standard-headers/asm-m68k/bootinfo-virt.h create mode 100644 hw/char/goldfish_tty.c create mode 100644 hw/intc/goldfish_pic.c create mode 100644 hw/intc/m68k_irqc.c create mode 100644 hw/m68k/virt.c create mode 100644 hw/misc/m68k_virt_ctrl.c
--=20
2.29.2
PATCH v4 1/5 char: add goldfish-tty
Implement the goldfish tty device as defined in
https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT
and based on the kernel driver code:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/goldfish.c
--- include/hw/char/goldfish_tty.h | 35 +++++ hw/char/goldfish_tty.c | 272 +++++++++++++++++++++++++++++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 2 + hw/char/trace-events | 10 ++ 5 files changed, 322 insertions(+) create mode 100644 include/hw/char/goldfish_tty.h create mode 100644 hw/char/goldfish_tty.c
include/hw/char/goldfish_tty.h new file +35 -0
@@ -0,0 +1,35 @@ +/* +* SPDX-License-Identifer: GPL-2.0-or-later +* +* Goldfish TTY +* +* (c) 2020 Laurent Vivier <[email protected]> +* +*/ + +#ifndef HW_CHAR_GOLDFISH_TTY_H +#define HW_CHAR_GOLDFISH_TTY_H + +#include "qemu/fifo8.h" +#include "chardev/char-fe.h" + +#define TYPE_GOLDFISH_TTY "goldfish_tty" +OBJECT_DECLARE_SIMPLE_TYPE(GoldfishTTYState, GOLDFISH_TTY) + +#define GOLFISH_TTY_BUFFER_SIZE 128 + +struct GoldfishTTYState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +qemu_irq irq; +CharBackend chr; + +uint32_t data_len; +uint64_t data_ptr; +bool int_enabled; + +Fifo8 rx_fifo; +}; + +#endif
hw/char/goldfish_tty.c new file +272 -0
272 lines not on this page · raw message
hw/char/Kconfig +3 -0
@@ -61,3 +61,6 @@ config MCHP_PFSOC_MMUART config SIFIVE_UART bool + +config GOLDFISH_TTY + bool
hw/char/meson.build +2 -0
@@ -39,3 +39,5 @@ specific_ss.add(when: 'CONFIG_HTIF', if_true: files('riscv_htif.c')) specific_ss.add(when: 'CONFIG_TERMINAL3270', if_true: files('terminal3270.c')) specific_ss.add(when: 'CONFIG_VIRTIO', if_true: files('virtio-serial-bus.c')) specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('spapr_vty.c')) + +specific_ss.add(when: 'CONFIG_GOLDFISH_TTY', if_true: files('goldfish_tty.c'))
hw/char/trace-events +10 -0
@@ -20,6 +20,16 @@ virtio_console_flush_buf(unsigned int port, size_t len, ssize_t ret) "port %u, i virtio_console_chr_read(unsigned int port, int size) "port %u, size %d" virtio_console_chr_event(unsigned int port, int event) "port %u, event %d" +# goldfish_tty.c +goldfish_tty_read(void *dev, unsigned int addr, unsigned int size, uint64_t value) "tty: %p reg: 0x%02x size: %d value: 0x%"PRIx64 +goldfish_tty_write(void *dev, unsigned int addr, unsigned int size, uint64_t value) "tty: %p reg: 0x%02x size: %d value: 0x%"PRIx64 +goldfish_tty_can_receive(void *dev, unsigned int available) "tty: %p available: %u" +goldfish_tty_receive(void *dev, unsigned int size) "tty: %p size: %u" +goldfish_tty_reset(void *dev) "tty: %p" +goldfish_tty_realize(void *dev) "tty: %p" +goldfish_tty_unrealize(void *dev) "tty: %p" +goldfish_tty_instance_init(void *dev) "tty: %p" + # grlib_apbuart.c grlib_apbuart_event(int event) "event:%d" grlib_apbuart_writel_unknown(uint64_t addr, uint32_t value) "addr 0x%"PRIx64" value 0x%x"
Signature · 1 line
2.29.2
Re: [PATCH v4 1/5] char: add goldfish-tty
Quoted 21 lines · Laurent Vivier
Implement the goldfish tty device as defined in
https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT
and based on the kernel driver code:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/goldfish.c
Signed-off-by Laurent Vivier <[email protected]>--- include/hw/char/goldfish_tty.h | 35 +++++ hw/char/goldfish_tty.c | 272 +++++++++++++++++++++++++++++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 2 + hw/char/trace-events | 10 ++ 5 files changed, 322 insertions(+) create mode 100644 include/hw/char/goldfish_tty.h create mode 100644 hw/char/goldfish_tty.chw/char/goldfish_tty.c new file +2
-0+static void goldfish_tty_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size)
hw/char/goldfish_tty.c line 125
Quoted 10 lines
hw/char/goldfish_tty.c new file +10
-0+{ +GoldfishTTYState *s = opaque; +unsigned char c; + +trace_goldfish_tty_write (s, addr, size, value); + +switch (addr) { +case REG_PUT_CHAR : + c = value; +qemu_chr_fe_write_all (&s->chr, &c,sizeof (c));
No IRQ here described in the spec... So this is correct.
hw/char/goldfish_tty.c line 134
Quoted 9 lines
hw/char/goldfish_tty.c new file +9
-0+break ; +case REG_CMD : +goldfish_tty_cmd (s, value); +break ; +case REG_DATA_PTR : + s->data_ptr = value; +break ; +case REG_DATA_PTR_HIGH : + s->data_ptr = (value <<32 ) | (uint32_t )s->data_ptr;
Matter of taste, I find it easier to review as:
s->data_ptr = deposit64(s->data_ptr, value, 32, 32);
The spec says this register is only available on 64-bit targets.
Should we restrict this "#if TARGET_LONG_SIZE == 8"? else log_mask(GUEST_ERROR)...
This seems overkill to me but that would respect the spec.
Quoted 7 lines
hw/char/goldfish_tty.c new file +7
-0+break ; +case REG_DATA_LEN : + s->data_len = value; +break ; +default : + qemu_log_mask(LOG_UNIMP, + "%s: unimplemented register write 0x%02"HWADDR_PRIx"\n",
hw/char/goldfish_tty.c line 151
Quoted 10 lines
hw/char/goldfish_tty.c new file +10
-0+ __func__, addr); +break ; + } +} + +static const MemoryRegionOps goldfish_tty_ops = { + .read = goldfish_tty_read, + .write = goldfish_tty_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid.max_access_size =4 ,
Again, I think you also want:
.impl.min_access_size = 4,
hw/char/goldfish_tty.c line 153
Quoted 2 lines
hw/char/goldfish_tty.c new file +2
-0+ .impl.max_access_size = 4, +};
With min_access_size:
Re: [PATCH v4 1/5] char: add goldfish-tty
Le 07/03/2021 à 20:24, Philippe Mathieu-Daudé a écrit :
Quoted 45 lines · Laurent Vivier
Quoted 21 lines
Implement the goldfish tty device as defined in
https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT
and based on the kernel driver code:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/tty/goldfish.c
Signed-off-by Laurent Vivier <[email protected]>--- include/hw/char/goldfish_tty.h | 35 +++++ hw/char/goldfish_tty.c | 272 +++++++++++++++++++++++++++++++++ hw/char/Kconfig | 3 + hw/char/meson.build | 2 + hw/char/trace-events | 10 ++ 5 files changed, 322 insertions(+) create mode 100644 include/hw/char/goldfish_tty.h create mode 100644 hw/char/goldfish_tty.chw/char/goldfish_tty.c new file +2
-0+static void goldfish_tty_write (void *opaque,hwaddr addr, +uint64_t value,unsigned size)hw/char/goldfish_tty.c line 125
Quoted 10 lines
hw/char/goldfish_tty.c new file +10
-0+{ +GoldfishTTYState *s = opaque; +unsigned char c; + +trace_goldfish_tty_write (s, addr, size, value); + +switch (addr) { +case REG_PUT_CHAR : + c = value; +qemu_chr_fe_write_all (&s->chr, &c,sizeof (c));No IRQ here described in the spec... So this is correct.
hw/char/goldfish_tty.c line 134
Quoted 9 lines
hw/char/goldfish_tty.c new file +9
-0+break ; +case REG_CMD : +goldfish_tty_cmd (s, value); +break ; +case REG_DATA_PTR : + s->data_ptr = value; +break ; +case REG_DATA_PTR_HIGH : + s->data_ptr = (value <<32 ) | (uint32_t )s->data_ptr;
Quoted 3 lines
Matter of taste, I find it easier to review as:
s->data_ptr = deposit64(s->data_ptr, value, 32, 32);
I agree.
Quoted 7 lines
The spec says this register is only available on 64-bit targets.
Should we restrict this "#if
TARGET_LONG_SIZE== 8"? elselog_mask(GUEST_ERROR)...This seems overkill to me but that would respect the spec.
TARGET_LONG_SIZE depends on CPU, I don't think we can use it here.
Quoted 20 lines
Quoted 7 lines
hw/char/goldfish_tty.c new file +7
-0+break ; +case REG_DATA_LEN : + s->data_len = value; +break ; +default : + qemu_log_mask(LOG_UNIMP, + "%s: unimplemented register write 0x%02"HWADDR_PRIx"\n",hw/char/goldfish_tty.c line 151
Quoted 10 lines
hw/char/goldfish_tty.c new file +10
-0+ __func__, addr); +break ; + } +} + +static const MemoryRegionOps goldfish_tty_ops = { + .read = goldfish_tty_read, + .write = goldfish_tty_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .valid.max_access_size =4 ,Again, I think you also want:
Quoted 4 lines
.impl.min_access_size = 4,Quoted 2 lines
hw/char/goldfish_tty.c new file +2
-0+ .impl.max_access_size = 4, +};
OK
Quoted 4 lines
With
min_access_size:Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Thanks,
Laurent
Re: [PATCH v4 1/5] char: add goldfish-tty
Quoted 9 lines · Laurent Vivier
Le 07/03/2021 à 20:24, Philippe Mathieu-Daudé a écrit :
Quoted 6 lines
The spec says this register is only available on 64-bit targets.
Should we restrict this "#if
TARGET_LONG_SIZE== 8"? elselog_mask(GUEST_ERROR)...This seems overkill to me but that would respect the spec.
TARGET_LONG_SIZEdepends on CPU, I don't think we can use it here.
TARGET_LONG_BITS is in fact poisoned -- you can't use it here.
r~
PATCH v4 2/5 intc: add goldfish-pic
In reply to Laurent VivierImplement the goldfish pic device as defined in
https://android.googlesource.com/platform/external/qemu/+/master/docs/GOLDFISH-VIRTUAL-HARDWARE.TXT
--- include/hw/intc/goldfish_pic.h | 33 +++++ hw/intc/goldfish_pic.c | 219 +++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 1 + hw/intc/trace-events | 8 ++ 5 files changed, 264 insertions(+) create mode 100644 include/hw/intc/goldfish_pic.h create mode 100644 hw/intc/goldfish_pic.c
include/hw/intc/goldfish_pic.h new file +33 -0
@@ -0,0 +1,33 @@ +/* +* SPDX-License-Identifer: GPL-2.0-or-later +* +* Goldfish PIC +* +* (c) 2020 Laurent Vivier <[email protected]> +* +*/ + +#ifndef HW_INTC_GOLDFISH_PIC_H +#define HW_INTC_GOLDFISH_PIC_H + +#define TYPE_GOLDFISH_PIC "goldfish_pic" +OBJECT_DECLARE_SIMPLE_TYPE(GoldfishPICState, GOLDFISH_PIC) + +#define GOLDFISH_PIC_IRQ_NB 32 + +struct GoldfishPICState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +qemu_irq irq; + +uint32_t pending; +uint32_t enabled; + +/* statistics */ +uint64_t stats_irq_count[32 ]; +/* for tracing */ +uint8_t idx; +}; + +#endif
hw/intc/goldfish_pic.c new file +219 -0
219 lines not on this page · raw message
hw/intc/Kconfig +3 -0
@@ -64,3 +64,6 @@ config SIFIVE_CLINT config SIFIVE_PLIC bool + +config GOLDFISH_PIC + bool
hw/intc/meson.build +1 -0
@@ -57,3 +57,4 @@ specific_ss.add(when: 'CONFIG_PSERIES', if_true: files('xics_spapr.c', 'spapr_xi specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) +specific_ss.add(when: 'CONFIG_GOLDFISH_PIC', if_true: files('goldfish_pic.c'))
hw/intc/trace-events +8 -0
@@ -239,3 +239,11 @@ xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x # pnv_xive.c pnv_xive_ic_hw_trigger(uint64_t addr, uint64_t val) "@0x%"PRIx64" val=0x%"PRIx64 + +# goldfish_pic.c +goldfish_irq_request(void *dev, int idx, int irq, int level) "pic: %p goldfish-irq.%d irq: %d level: %d" +goldfish_pic_read(void *dev, int idx, unsigned int addr, unsigned int size, uint64_t value) "pic: %p goldfish-irq.%d reg: 0x%02x size: %d value: 0x%"PRIx64 +goldfish_pic_write(void *dev, int idx, unsigned int addr, unsigned int size, uint64_t value) "pic: %p goldfish-irq.%d reg: 0x%02x size: %d value: 0x%"PRIx64 +goldfish_pic_reset(void *dev, int idx) "pic: %p goldfish-irq.%d" +goldfish_pic_realize(void *dev, int idx) "pic: %p goldfish-irq.%d" +goldfish_pic_instance_init(void *dev) "pic: %p goldfish-irq"
Signature · 1 line
2.29.2
PATCH v4 3/5 m68k: add an interrupt controller
In reply to Laurent VivierA (generic) copy of the GLUE device we already have for q800 to use with the m68k-virt machine.
The q800 one would disappear in the future as q800 uses actually the djMEMC controller.
--- include/hw/intc/m68k_irqc.h | 41 +++++++++++++ hw/intc/m68k_irqc.c | 119 ++++++++++++++++++++++++++++++++++++ hw/intc/Kconfig | 3 + hw/intc/meson.build | 1 + 4 files changed, 164 insertions(+) create mode 100644 include/hw/intc/m68k_irqc.h create mode 100644 hw/intc/m68k_irqc.c
include/hw/intc/m68k_irqc.h new file +41 -0
@@ -0,0 +1,41 @@ +/* +* SPDX-License-Identifer: GPL-2.0-or-later +* +* QEMU Motorola 680x0 IRQ Controller +* +* (c) 2020 Laurent Vivier <[email protected]> +* +*/ + +#ifndef M68K_IRQC_H +#define M68K_IRQC_H + +#include "hw/sysbus.h" + +#define TYPE_M68K_IRQC "m68k-irq-controller" +#define M68K_IRQC (obj) OBJECT_CHECK(M68KIRQCState, (obj), \ + TYPE_M68K_IRQC) + +#define M68K_IRQC_AUTOVECTOR_BASE 25 + +enum { +M68K_IRQC_LEVEL_1 =0 , +M68K_IRQC_LEVEL_2 , +M68K_IRQC_LEVEL_3 , +M68K_IRQC_LEVEL_4 , +M68K_IRQC_LEVEL_5 , +M68K_IRQC_LEVEL_6 , +M68K_IRQC_LEVEL_7 , +}; +#define M68K_IRQC_LEVEL_NUM (M68K_IRQC_LEVEL_7 - M68K_IRQC_LEVEL_1 + 1) + +typedef struct M68KIRQCState { +SysBusDevice parent_obj; + +uint8_t ipr; + +/* statistics */ +uint64_t stats_irq_count[M68K_IRQC_LEVEL_NUM ]; +}M68KIRQCState ; + +#endif
hw/intc/m68k_irqc.c new file +119 -0
119 lines not on this page · raw message
hw/intc/Kconfig +3 -0
@@ -67,3 +67,6 @@ config SIFIVE_PLIC config GOLDFISH_PIC bool + +config M68K_IRQC + bool
hw/intc/meson.build +1 -0
@@ -58,3 +58,4 @@ specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c')) specific_ss.add(when: ['CONFIG_KVM', 'CONFIG_XIVE'], if_true: files('spapr_xive_kvm.c')) specific_ss.add(when: 'CONFIG_GOLDFISH_PIC', if_true: files('goldfish_pic.c')) +specific_ss.add(when: 'CONFIG_M68K_IRQC', if_true: files('m68k_irqc.c'))
Signature · 1 line
2.29.2
PATCH v4 4/5 m68k: add a system controller
In reply to Laurent VivierAdd a system controller for the m68k-virt machine.
This controller allows the kernel to power off or reset the machine.
--- include/hw/misc/m68k_virt_ctrl.h | 22 +++++ hw/misc/m68k_virt_ctrl.c | 152 +++++++++++++++++++++++++++++++ hw/misc/Kconfig | 3 + hw/misc/meson.build | 3 + hw/misc/trace-events | 7 ++ 5 files changed, 187 insertions(+) create mode 100644 include/hw/misc/m68k_virt_ctrl.h create mode 100644 hw/misc/m68k_virt_ctrl.c
include/hw/misc/m68k_virt_ctrl.h new file +22 -0
@@ -0,0 +1,22 @@ +/* +* SPDX-License-Identifer: GPL-2.0-or-later +* +* Virt m68k system Controller +*/ + +#ifndef M68K_VIRT_CTRL_H +#define M68K_VIRT_CTRL_H + +#define TYPE_M68K_VIRT_CTRL "m68k-virt-ctrl" +OBJECT_DECLARE_SIMPLE_TYPE(M68KVirtCtrlState, M68K_VIRT_CTRL) + +struct M68KVirtCtrlState { +SysBusDevice parent_obj; + +MemoryRegion iomem; +qemu_irq irq; + +uint32_t irq_enabled; +}; + +#endif
hw/misc/m68k_virt_ctrl.c new file +152 -0
152 lines not on this page · raw message
hw/misc/Kconfig +3 -0
@@ -174,4 +174,7 @@ config SIFIVE_U_OTP config SIFIVE_U_PRCI bool +config M68K_VIRT_CTRL + bool + source macio/Kconfig
hw/misc/meson.build +3 -0
@@ -24,6 +24,9 @@ softmmu_ss.add(when: 'CONFIG_ARM11SCU', if_true: files('arm11scu.c')) # Mac devices softmmu_ss.add(when: 'CONFIG_MOS6522', if_true: files('mos6522.c')) +# virt m68k devices +softmmu_ss.add(when: 'CONFIG_M68K_VIRT_CTRL', if_true: files('m68k_virt_ctrl.c')) + # RISC-V devices softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_DMC', if_true: files('mchp_pfsoc_dmc.c')) softmmu_ss.add(when: 'CONFIG_MCHP_PFSOC_IOSCB', if_true: files('mchp_pfsoc_ioscb.c'))
hw/misc/trace-events +7 -0
@@ -243,3 +243,10 @@ pca955x_gpio_change(const char *description, unsigned id, unsigned prev_state, u bcm2835_cprman_read(uint64_t offset, uint64_t value) "offset:0x%" PRIx64 " value:0x%" PRIx64 bcm2835_cprman_write(uint64_t offset, uint64_t value) "offset:0x%" PRIx64 " value:0x%" PRIx64 bcm2835_cprman_write_invalid_magic(uint64_t offset, uint64_t value) "offset:0x%" PRIx64 " value:0x%" PRIx64 + +# m68k_virt_ctrl.c +m68k_virt_ctrl_read(void *dev, unsigned int addr, unsigned int size, uint64_t value) "ctrl: %p reg: 0x%02x size: %d value: 0x%"PRIx64 +m68k_virt_ctrl_write(void *dev, unsigned int addr, unsigned int size, uint64_t value) "ctrl: %p reg: 0x%02x size: %d value: 0x%"PRIx64 +m68k_virt_ctrl_reset(void *dev) "ctrl: %p" +m68k_virt_ctrl_realize(void *dev) "ctrl: %p" +m68k_virt_ctrl_instance_init(void *dev) "ctrl: %p"
Signature · 1 line
2.29.2
Re: [PATCH v4 4/5] m68k: add a system controller
Quoted 8 lines · Laurent Vivier
Add a system controller for the m68k-virt machine.
This controller allows the kernel to power off or reset the machine.Signed-off-by Laurent Vivier <[email protected]>Reviewed-by Richard Henderson <[email protected]>--- include/hw/misc/m68k_virt_ctrl.h | 22 +++++ hw/misc/m68k_virt_ctrl.c | 152 +++++++++++++++++++++++++++++++
Wouldn't it make more sense to place this in hw/m68k than hw/misc ?
Thomas
PATCH v4 5/5 m68k: add Virtual M68k Machine
In reply to Laurent VivierThe machine is based on Goldfish interfaces defined by Google for Android simulator. It uses Goldfish-rtc (timer and RTC), Goldfish-pic (PIC) and Goldfish-tty (for serial port and early tty).
The machine is created with 128 virtio-mmio bus, and they can be used to use serial console, GPU, disk, NIC, HID, ...
--- default-configs/devices/m68k-softmmu.mak | 1 + .../standard-headers/asm-m68k/bootinfo-virt.h | 18 + hw/m68k/virt.c | 313 ++++++++++++++++++ MAINTAINERS | 13 + hw/m68k/Kconfig | 10 + hw/m68k/meson.build | 1 + 6 files changed, 356 insertions(+) create mode 100644 include/standard-headers/asm-m68k/bootinfo-virt.h create mode 100644 hw/m68k/virt.c
default-configs/devices/m68k-softmmu.mak +1 -0
@@ -8,3 +8,4 @@ CONFIG_AN5206=y CONFIG_MCF5208=y CONFIG_NEXTCUBE=y CONFIG_Q800=y +CONFIG_M68K_VIRT=y
include/standard-headers/asm-m68k/bootinfo-virt.h new file +18 -0
@@ -0,0 +1,18 @@ +/* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */ +/* +** asm/bootinfo-virt.h -- Virtual-m68k-specific boot information definitions +*/ + +#ifndef _UAPI_ASM_M68K_BOOTINFO_VIRT_H +#define _UAPI_ASM_M68K_BOOTINFO_VIRT_H + +#define BI_VIRT_QEMU_VERSION 0x8000 +#define BI_VIRT_GF_PIC_BASE 0x8001 +#define BI_VIRT_GF_RTC_BASE 0x8002 +#define BI_VIRT_GF_TTY_BASE 0x8003 +#define BI_VIRT_VIRTIO_BASE 0x8004 +#define BI_VIRT_CTRL_BASE 0x8005 + +#define VIRT_BOOTI_VERSION MK_BI_VERSION(2, 0) + +#endif /* _UAPI_ASM_M68K_BOOTINFO_MAC_H */
hw/m68k/virt.c new file +313 -0
313 lines not on this page · raw message
MAINTAINERS +13 -0
@@ -1123,6 +1123,19 @@ F: include/hw/nubus/* F: include/hw/display/macfb.h F: include/hw/block/swim.h +virt +M: Laurent Vivier <[email protected]> +S: Maintained +F: hw/m68k/virt.c +F: hw/char/goldfish_tty.c +F: hw/intc/goldfish_pic.c +F: hw/intc/m68k_irqc.c +F: hw/misc/m68k_virt_ctrl.c +F: include/hw/char/goldfish_tty.h +F: include/hw/intc/goldfish_pic.h +F: include/hw/intc/m68k_irqc.h +F: include/hw/misc/m68k_virt_ctrl.h + MicroBlaze Machines ------------------- petalogix_s3adsp1800
hw/m68k/Kconfig +10 -0
@@ -23,3 +23,13 @@ config Q800 select ESP select DP8393X select OR_IRQ + +config M68K_VIRT + bool + select M68K_IRQC + select M68K_VIRT_CTRL + select GOLDFISH_PIC + select GOLDFISH_TTY + select GOLDFISH_RTC + select VIRTIO + select VIRTIO_MMIO
hw/m68k/meson.build +1 -0
@@ -3,5 +3,6 @@ m68k_ss.add(when: 'CONFIG_AN5206', if_true: files('an5206.c', 'mcf5206.c')) m68k_ss.add(when: 'CONFIG_MCF5208', if_true: files('mcf5208.c', 'mcf_intc.c')) m68k_ss.add(when: 'CONFIG_NEXTCUBE', if_true: files('next-kbd.c', 'next-cube.c')) m68k_ss.add(when: 'CONFIG_Q800', if_true: files('q800.c')) +m68k_ss.add(when: 'CONFIG_M68K_VIRT', if_true: files('virt.c')) hw_arch += {'m68k': m68k_ss}
Signature · 1 line
2.29.2