Skip to contentSkip to conversation

m68k: add Virtual M68k Machine

PATCH Applied Laurent Vivier 3 participants 20 messages Dec 20, 2020 – Feb 12, 2021 Arm/Amlogic Meson SoC support

v2 of 16 Applied Latest is v16 →

lore
Share & tools
lore
#0 lore raw

v2 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

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 (7):
m68k: import bootinfo headers from linux
char: add goldfish-tty
intc: add goldfish-pic
m68k: add an interrupt controller
m68k: add a system controller
goldfish_rtc: re-arm the alarm after migration
m68k: add Virtual M68k Machine

 default-configs/devices/m68k-softmmu.mak      |   1 +
 hw/m68k/bootinfo.h                            |  55 ---
 include/hw/char/goldfish_tty.h                |  36 ++
 include/hw/intc/goldfish_pic.h                |  33 ++
 include/hw/intc/m68k_irqc.h                   |  28 ++
 include/hw/misc/m68k_virt_ctrl.h              |  22 ++
 .../standard-headers/asm-m68k/bootinfo-mac.h  | 120 +++++++
 .../standard-headers/asm-m68k/bootinfo-virt.h |  18 +
 include/standard-headers/asm-m68k/bootinfo.h  | 166 ++++++++++
 hw/char/goldfish_tty.c                        | 266 +++++++++++++++
 hw/intc/goldfish_pic.c                        | 214 ++++++++++++
 hw/intc/m68k_irqc.c                           | 120 +++++++
 hw/m68k/q800.c                                |  20 +-
 hw/m68k/virt.c                                | 312 ++++++++++++++++++
 hw/misc/m68k_virt_ctrl.c                      | 152 +++++++++
 hw/rtc/goldfish_rtc.c                         |   2 +
 MAINTAINERS                                   |  11 +
 hw/char/Kconfig                               |   3 +
 hw/char/meson.build                           |   2 +
 hw/char/trace-events                          |   9 +
 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 +
 28 files changed, 1562 insertions(+), 68 deletions(-)
 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-mac.h
 create mode 100644 include/standard-headers/asm-m68k/bootinfo-virt.h
 create mode 100644 include/standard-headers/asm-m68k/bootinfo.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

#1 lore raw

PATCH v2 1/7 m68k: import bootinfo headers from linux

Copy bootinfo.h and bootinfo-mac.h from arch/m68k/include/uapi/asm/ to include/standard-headers/asm-m68k/

Imported from linux v5.9 but didn't change since v4.14 (header update) and since v4.10 (content update).

---
 hw/m68k/bootinfo.h                            |  55 ------
 .../standard-headers/asm-m68k/bootinfo-mac.h  | 120 +++++++++++++
 include/standard-headers/asm-m68k/bootinfo.h  | 166 ++++++++++++++++++
 hw/m68k/q800.c                                |  20 +--
 MAINTAINERS                                   |   2 +
 5 files changed, 295 insertions(+), 68 deletions(-)
 create mode 100644 include/standard-headers/asm-m68k/bootinfo-mac.h
 create mode 100644 include/standard-headers/asm-m68k/bootinfo.h
hw/m68k/bootinfo.h +0 -55
index c954270aad6c..adbf0c5521e5 100644
@@ -11,61 +11,6 @@
 
 #ifndef HW_M68K_BOOTINFO_H
 #define HW_M68K_BOOTINFO_H
-struct bi_record {
-    uint16_t tag;        /* tag ID */
-    uint16_t size;       /* size of record */
-    uint32_t data[];     /* data */
-};
-
-/* machine independent tags */
-
-#define BI_LAST         0x0000 /* last record */
-#define BI_MACHTYPE     0x0001 /* machine type (u_long) */
-#define BI_CPUTYPE      0x0002 /* cpu type (u_long) */
-#define BI_FPUTYPE      0x0003 /* fpu type (u_long) */
-#define BI_MMUTYPE      0x0004 /* mmu type (u_long) */
-#define BI_MEMCHUNK     0x0005 /* memory chunk address and size */
-                               /* (struct mem_info) */
-#define BI_RAMDISK      0x0006 /* ramdisk address and size */
-                               /* (struct mem_info) */
-#define BI_COMMAND_LINE 0x0007 /* kernel command line parameters */
-                               /* (string) */
-
-/*  Macintosh-specific tags (all u_long) */
-
-#define BI_MAC_MODEL    0x8000  /* Mac Gestalt ID (model type) */
-#define BI_MAC_VADDR    0x8001  /* Mac video base address */
-#define BI_MAC_VDEPTH   0x8002  /* Mac video depth */
-#define BI_MAC_VROW     0x8003  /* Mac video rowbytes */
-#define BI_MAC_VDIM     0x8004  /* Mac video dimensions */
-#define BI_MAC_VLOGICAL 0x8005  /* Mac video logical base */
-#define BI_MAC_SCCBASE  0x8006  /* Mac SCC base address */
-#define BI_MAC_BTIME    0x8007  /* Mac boot time */
-#define BI_MAC_GMTBIAS  0x8008  /* Mac GMT timezone offset */
-#define BI_MAC_MEMSIZE  0x8009  /* Mac RAM size (sanity check) */
-#define BI_MAC_CPUID    0x800a  /* Mac CPU type (sanity check) */
-#define BI_MAC_ROMBASE  0x800b  /* Mac system ROM base address */
-
-/*  Macintosh hardware profile data */
-
-#define BI_MAC_VIA1BASE 0x8010  /* Mac VIA1 base address (always present) */
-#define BI_MAC_VIA2BASE 0x8011  /* Mac VIA2 base address (type varies) */
-#define BI_MAC_VIA2TYPE 0x8012  /* Mac VIA2 type (VIA, RBV, OSS) */
-#define BI_MAC_ADBTYPE  0x8013  /* Mac ADB interface type */
-#define BI_MAC_ASCBASE  0x8014  /* Mac Apple Sound Chip base address */
-#define BI_MAC_SCSI5380 0x8015  /* Mac NCR 5380 SCSI (base address, multi) */
-#define BI_MAC_SCSIDMA  0x8016  /* Mac SCSI DMA (base address) */
-#define BI_MAC_SCSI5396 0x8017  /* Mac NCR 53C96 SCSI (base address, multi) */
-#define BI_MAC_IDETYPE  0x8018  /* Mac IDE interface type */
-#define BI_MAC_IDEBASE  0x8019  /* Mac IDE interface base address */
-#define BI_MAC_NUBUS    0x801a  /* Mac Nubus type (none, regular, pseudo) */
-#define BI_MAC_SLOTMASK 0x801b  /* Mac Nubus slots present */
-#define BI_MAC_SCCTYPE  0x801c  /* Mac SCC serial type (normal, IOP) */
-#define BI_MAC_ETHTYPE  0x801d  /* Mac builtin ethernet type (Sonic, MACE */
-#define BI_MAC_ETHBASE  0x801e  /* Mac builtin ethernet base address */
-#define BI_MAC_PMU      0x801f  /* Mac power management / poweroff hardware */
-#define BI_MAC_IOP_SWIM 0x8020  /* Mac SWIM floppy IOP */
-#define BI_MAC_IOP_ADB  0x8021  /* Mac ADB IOP */
 
 #define BOOTINFO0(as, base, id) \
     do { \
include/standard-headers/asm-m68k/bootinfo-mac.h new file +120 -0

120 lines not on this page · raw message

include/standard-headers/asm-m68k/bootinfo.h new file +166 -0

166 lines not on this page · raw message

hw/m68k/q800.c +7 -13
index 2af0e2532eb2..d4eca467671b 100644
@@ -37,6 +37,8 @@
 #include "hw/char/escc.h"
 #include "hw/sysbus.h"
 #include "hw/scsi/esp.h"
+#include "standard-headers/asm-m68k/bootinfo.h"
+#include "standard-headers/asm-m68k/bootinfo-mac.h"
 #include "bootinfo.h"
 #include "hw/misc/mac_via.h"
 #include "hw/input/adb.h"
@@ -55,14 +57,6 @@
 
 #define MACROM_FILENAME "MacROM.bin"
 
-#define Q800_MACHINE_ID 35
-#define Q800_CPU_ID (1 << 2)
-#define Q800_FPU_ID (1 << 2)
-#define Q800_MMU_ID (1 << 2)
-
-#define MACH_MAC        3
-#define Q800_MAC_CPU_ID 2
-
 #define IO_BASE               0x50000000
 #define IO_SLICE              0x00040000
 #define IO_SIZE               0x04000000
@@ -415,11 +409,11 @@ static void q800_init(MachineState *machine)
         parameters_base = (high + 1) & ~1;
 
         BOOTINFO1(cs->as, parameters_base, BI_MACHTYPE, MACH_MAC);
-        BOOTINFO1(cs->as, parameters_base, BI_FPUTYPE, Q800_FPU_ID);
-        BOOTINFO1(cs->as, parameters_base, BI_MMUTYPE, Q800_MMU_ID);
-        BOOTINFO1(cs->as, parameters_base, BI_CPUTYPE, Q800_CPU_ID);
-        BOOTINFO1(cs->as, parameters_base, BI_MAC_CPUID, Q800_MAC_CPU_ID);
-        BOOTINFO1(cs->as, parameters_base, BI_MAC_MODEL, Q800_MACHINE_ID);
+        BOOTINFO1(cs->as, parameters_base, BI_FPUTYPE, FPU_68040);
+        BOOTINFO1(cs->as, parameters_base, BI_MMUTYPE, MMU_68040);
+        BOOTINFO1(cs->as, parameters_base, BI_CPUTYPE, CPU_68040);
+        BOOTINFO1(cs->as, parameters_base, BI_MAC_CPUID, CPUB_68040);
+        BOOTINFO1(cs->as, parameters_base, BI_MAC_MODEL, MAC_MODEL_Q800);
         BOOTINFO1(cs->as, parameters_base,
                   BI_MAC_MEMSIZE, ram_size >> 20); /* in MB */
         BOOTINFO2(cs->as, parameters_base, BI_MEMCHUNK, 0, ram_size);
MAINTAINERS +2 -0
index 1e7c8f04885d..7640dfb5f0fc 100644
@@ -1098,6 +1098,8 @@ F: hw/nubus/*
 F: hw/display/macfb.c
 F: hw/block/swim.c
 F: hw/m68k/bootinfo.h
+F: include/standard-headers/asm-m68k/bootinfo.h
+F: include/standard-headers/asm-m68k/bootinfo-mac.h
 F: include/hw/misc/mac_via.h
 F: include/hw/nubus/*
 F: include/hw/display/macfb.h
Signature · 1 line
2.29.2
#2 lore raw

PATCH v2 2/7 char: add goldfish-tty

In reply to Laurent Vivier
---
 include/hw/char/goldfish_tty.h |  36 +++++
 hw/char/goldfish_tty.c         | 266 +++++++++++++++++++++++++++++++++
 hw/char/Kconfig                |   3 +
 hw/char/meson.build            |   2 +
 hw/char/trace-events           |   9 ++
 5 files changed, 316 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 +36 -0
new file mode 100644
index 000000000000..84d78f8cff54
@@ -0,0 +1,36 @@
+/*
+ * 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 "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;
+
+    uint32_t data_in_count;
+    uint8_t data_in[GOLFISH_TTY_BUFFER_SIZE];
+    uint8_t data_out[GOLFISH_TTY_BUFFER_SIZE];
+};
+
+#endif
hw/char/goldfish_tty.c new file +266 -0

266 lines not on this page · raw message

hw/char/Kconfig +3 -0
index 939bc4475883..a8bf0c6a7708 100644
@@ -61,3 +61,6 @@ config MCHP_PFSOC_MMUART
 
 config SIFIVE_UART
     bool
+
+config GOLDFISH_TTY
+    bool
hw/char/meson.build +2 -0
index 196ac91fa29a..69d974873606 100644
@@ -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 +9 -0
index 81026f661277..dc7fb717e13b 100644
@@ -20,6 +20,15 @@ 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_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
Reviewed-by on v2 2/7
#3 lore raw

Re: [PATCH v2 2/7] char: add goldfish-tty

Quoted 10 lines · Laurent Vivier
---
 include/hw/char/goldfish_tty.h |  36 +++++
 hw/char/goldfish_tty.c         | 266 +++++++++++++++++++++++++++++++++
 hw/char/Kconfig                |   3 +
 hw/char/meson.build            |   2 +
 hw/char/trace-events           |   9 ++
 5 files changed, 316 insertions(+)
 create mode 100644 include/hw/char/goldfish_tty.h
 create mode 100644 hw/char/goldfish_tty.c

...

Quoted 20 lines
hw/char/goldfish_tty.c new file +20 -0
+static void goldfish_tty_cmd(GoldfishTTYState *s, uint32_t cmd)
+{
+    int to_copy;
+
+    switch (cmd) {
+    case CMD_INT_DISABLE:
+        if (s->int_enabled) {
+            if (s->data_in_count) {
+                qemu_set_irq(s->irq, 0);
+            }
+            s->int_enabled = false;
+        }
+        break;
+    case CMD_INT_ENABLE:
+        if (!s->int_enabled) {
+            if (s->data_in_count) {
+                qemu_set_irq(s->irq, 1);
+            }
+            s->int_enabled = true;
+        }

hw/char/goldfish_tty.c line 96

Quoted 10 lines
hw/char/goldfish_tty.c new file +10 -0
+        break;
+    case CMD_WRITE_BUFFER:
+        to_copy = s->data_len;
+        while (to_copy) {
+            int len;
+
+            len = MIN(GOLFISH_TTY_BUFFER_SIZE, to_copy);
+
+            address_space_rw(&address_space_memory, s->data_ptr,
+                             MEMTXATTRS_UNSPECIFIED, s->data_out, len, 0);

Could this fail, no need to check return value?

hw/char/goldfish_tty.c line 104

Quoted 8 lines
hw/char/goldfish_tty.c new file +8 -0
+            to_copy -= len;
+            qemu_chr_fe_write_all(&s->chr, s->data_out, len);
+        }
+        break;
+    case CMD_READ_BUFFER:
+        to_copy = MIN(s->data_len, s->data_in_count);
+        address_space_rw(&address_space_memory, s->data_ptr,
+                         MEMTXATTRS_UNSPECIFIED, s->data_in, to_copy, 1);

Ditto.

Quoted 38 lines
hw/char/goldfish_tty.c new file +38 -0
+        s->data_in_count -= to_copy;
+        memmove(s->data_in, s->data_in + to_copy, s->data_in_count);
+        if (s->int_enabled && !s->data_in_count) {
+            qemu_set_irq(s->irq, 0);
+        }
+        break;
+    }
+}
+
+static void goldfish_tty_write(void *opaque, hwaddr addr,
+                               uint64_t value, unsigned size)
+{
+    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));
+        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;
+        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",
+                      __func__, addr);

hw/char/goldfish_tty.c line 152

Quoted 10 lines
hw/char/goldfish_tty.c new file +10 -0
+        break;
+    }
+}
+
+static const MemoryRegionOps goldfish_tty_ops = {
+    .read = goldfish_tty_read,
+    .write = goldfish_tty_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid.max_access_size = 4,
+    .impl.max_access_size = 4,

Missing:

.impl.min = 4,

Otherwise:

Quoted 2 lines
(quoted diff) +2 -0
+};
+
#4 lore raw

PATCH v2 3/7 intc: add goldfish-pic

In reply to Laurent Vivier
---
 include/hw/intc/goldfish_pic.h |  33 +++++
 hw/intc/goldfish_pic.c         | 214 +++++++++++++++++++++++++++++++++
 hw/intc/Kconfig                |   3 +
 hw/intc/meson.build            |   1 +
 hw/intc/trace-events           |   8 ++
 5 files changed, 259 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
new file mode 100644
index 000000000000..26e7ca75a3ec
@@ -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 */
+    int idx;
+};
+
+#endif
hw/intc/goldfish_pic.c new file +214 -0

214 lines not on this page · raw message

hw/intc/Kconfig +3 -0
index d07954086a59..7ed79e7ac29f 100644
@@ -73,3 +73,6 @@ config SIFIVE_CLINT
 
 config SIFIVE_PLIC
     bool
+
+config GOLDFISH_PIC
+    bool
hw/intc/meson.build +1 -0
index 7c3e9daf586e..8a5dfe4289ae 100644
@@ -54,3 +54,4 @@ specific_ss.add(when: 'CONFIG_XICS_SPAPR', if_true: files('xics_spapr.c'))
 specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c'))
 specific_ss.add(when: 'CONFIG_XIVE_KVM', if_true: files('spapr_xive_kvm.c'))
 specific_ss.add(when: 'CONFIG_XIVE_SPAPR', if_true: files('spapr_xive.c'))
+specific_ss.add(when: 'CONFIG_GOLDFISH_PIC', if_true: files('goldfish_pic.c'))
hw/intc/trace-events +8 -0
index 8ed397a0d587..e9b64ee568fd 100644
@@ -236,3 +236,11 @@ xive_tctx_tm_write(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"P
 xive_tctx_tm_read(uint64_t offset, unsigned int size, uint64_t value) "@0x0x%"PRIx64" sz=%d val=0x%" PRIx64
 xive_presenter_notify(uint8_t nvt_blk, uint32_t nvt_idx, uint8_t ring) "found NVT 0x%x/0x%x ring=0x%x"
 xive_end_source_read(uint8_t end_blk, uint32_t end_idx, uint64_t addr) "END 0x%x/0x%x @0x0x%"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, int idx) "pic: %p goldfish-irq.%d"
Signature · 1 line
2.29.2
Reviewed-by on v2 3/7
#5 lore raw

Re: [PATCH v2 3/7] intc: add goldfish-pic

Quoted 35 lines · Laurent Vivier
---
 include/hw/intc/goldfish_pic.h |  33 +++++
 hw/intc/goldfish_pic.c         | 214 +++++++++++++++++++++++++++++++++
 hw/intc/Kconfig                |   3 +
 hw/intc/meson.build            |   1 +
 hw/intc/trace-events           |   8 ++
 5 files changed, 259 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 +18 -0
new file mode 100644
index 000000000000..26e7ca75a3ec
@@ -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 {

include/hw/intc/goldfish_pic.h line 28

Quoted 10 lines
include/hw/intc/goldfish_pic.h new file +10 -0
+    SysBusDevice parent_obj;
+
+    MemoryRegion iomem;
+    qemu_irq irq;
+
+    uint32_t pending;
+    uint32_t enabled;
+
+    /* statistics */
+    uint64_t stats_irq_count[32];

GOLDFISH_PIC_IRQ_NB?

hw/intc/goldfish_pic.c line 132

Quoted 13 lines
include/hw/intc/goldfish_pic.h new file +5 -0
+    /* for tracing */
+    int idx;
+};
+
+#endif
hw/intc/goldfish_pic.c +6 -0
 
+static const MemoryRegionOps goldfish_pic_ops = {
+    .read = goldfish_pic_read,
+    .write = goldfish_pic_write,
+    .endianness = DEVICE_NATIVE_ENDIAN,
+    .valid.max_access_size = 4,
+    .impl.max_access_size = 4,

Missing:

       .impl.min_access_size = 4,

Otherwise:

Quoted 2 lines
hw/intc/goldfish_pic.c +2 -0
+};
+
#6 lore raw

PATCH v2 4/7 m68k: add an interrupt controller

In reply to Laurent Vivier
---
 include/hw/intc/m68k_irqc.h |  28 +++++++++
 hw/intc/m68k_irqc.c         | 120 ++++++++++++++++++++++++++++++++++++
 hw/intc/Kconfig             |   3 +
 hw/intc/meson.build         |   1 +
 4 files changed, 152 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 +28 -0
new file mode 100644
index 000000000000..c40b1b4df8fa
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifer: GPL-2.0-or-later
+ *
+ * QEMU Motorla 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)
+
+typedef struct M68KIRQCState {
+    SysBusDevice parent_obj;
+
+    uint8_t ipr;
+
+    /* statistics */
+    uint64_t stats_irq_count[7];
+} M68KIRQCState;
+
+#endif
hw/intc/m68k_irqc.c new file +120 -0

120 lines not on this page · raw message

hw/intc/Kconfig +3 -0
index 7ed79e7ac29f..318d76c7cb52 100644
@@ -76,3 +76,6 @@ config SIFIVE_PLIC
 
 config GOLDFISH_PIC
     bool
+
+config M68K_IRQC
+    bool
hw/intc/meson.build +1 -0
index 8a5dfe4289ae..81bd0191f9cd 100644
@@ -55,3 +55,4 @@ specific_ss.add(when: 'CONFIG_XIVE', if_true: files('xive.c'))
 specific_ss.add(when: 'CONFIG_XIVE_KVM', if_true: files('spapr_xive_kvm.c'))
 specific_ss.add(when: 'CONFIG_XIVE_SPAPR', if_true: files('spapr_xive.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
#7 lore raw

Re: [PATCH v2 4/7] m68k: add an interrupt controller

Quoted 4 lines · Laurent Vivier
---
 include/hw/intc/m68k_irqc.h |  28 +++++++++
 hw/intc/m68k_irqc.c         | 120 ++++++++++++++++++++++++++++++++++++

Missing MAINTAINERS entries?

Quoted 12 lines
 hw/intc/Kconfig             |   3 +
 hw/intc/meson.build         |   1 +
 4 files changed, 152 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 +0 -0
new file mode 100644
index 000000000000..c40b1b4df8fa

include/hw/intc/m68k_irqc.h line 4

Quoted 4 lines
include/hw/intc/m68k_irqc.h new file +4 -0
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifer: GPL-2.0-or-later
+ *
+ * QEMU Motorla 680x0 IRQ Controller

Typo "Motorola".

Are there any specs to refer at?

Quoted 4 lines
include/hw/intc/m68k_irqc.h new file +4 -0
+ *
+ * (c) 2020 Laurent Vivier <[email protected]>
+ *
+ */
#8 lore raw

Re: [PATCH v2 4/7] m68k: add an interrupt controller

Le 24/01/2021 à 17:46, Philippe Mathieu-Daudé a écrit :

Quoted 7 lines · Laurent Vivier
Quoted 4 lines
---
 include/hw/intc/m68k_irqc.h |  28 +++++++++
 hw/intc/m68k_irqc.c         | 120 ++++++++++++++++++++++++++++++++++++

Missing MAINTAINERS entries?

new devices are added in patch 7 (where I add the machine and the section in MAINTAINER), but I've missed this one. Thanks.

Quoted 7 lines
Quoted 7 lines
 hw/intc/Kconfig             |   3 +
 hw/intc/meson.build         |   1 +
 4 files changed, 152 insertions(+)
 create mode 100644 include/hw/intc/m68k_irqc.h
 create mode 100644 hw/intc/m68k_irqc.c
Quoted 12 lines

include/hw/intc/m68k_irqc.h line 4

Quoted 10 lines
include/hw/intc/m68k_irqc.h new file +4 -0
new file mode 100644
index 000000000000..c40b1b4df8fa
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifer: GPL-2.0-or-later
+ *
+ * QEMU Motorla 680x0 IRQ Controller

Typo "Motorola".

Thank you (there is another typo: "q800_irq_register_types" that must be renamed)

Quoted 2 lines

Are there any specs to refer at?

There is no specs. It's a (generic) copy of the GLUE device we already have for q800.

I don't update Q800 because the GLUE device may disappear because Q800 uses actually djMEMC that is also a memory controller (I have that in my q800-dev branch, but for the moment it's only needed for the MacROM and Mark is working on that).

Thanks,
Laurent

#9 lore raw

Re: [PATCH v2 4/7] m68k: add an interrupt controller

In reply to Laurent Vivier
Quoted 31 lines · Laurent Vivier
---
 include/hw/intc/m68k_irqc.h |  28 +++++++++
 hw/intc/m68k_irqc.c         | 120 ++++++++++++++++++++++++++++++++++++
 hw/intc/Kconfig             |   3 +
 hw/intc/meson.build         |   1 +
 4 files changed, 152 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 +15 -0
new file mode 100644
index 000000000000..c40b1b4df8fa
@@ -0,0 +1,28 @@
+/*
+ * SPDX-License-Identifer: GPL-2.0-or-later
+ *
+ * QEMU Motorla 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"

include/hw/intc/m68k_irqc.h line 25

Quoted 10 lines
include/hw/intc/m68k_irqc.h new file +10 -0
+#define M68K_IRQC(obj) OBJECT_CHECK(M68KIRQCState, (obj), \
+                                    TYPE_M68K_IRQC)
+
+typedef struct M68KIRQCState {
+    SysBusDevice parent_obj;
+
+    uint8_t ipr;
+
+    /* statistics */
+    uint64_t stats_irq_count[7];

So we have 8 IRQs, one is NMI. Is that correct?

Could you add #definitions? Patch LGTM but I'll wait for definitions to give a R-b ;)

Quoted 3 lines
include/hw/intc/m68k_irqc.h new file +3 -0
+} M68KIRQCState;
+
+#endif
#10 lore raw

PATCH v2 5/7 m68k: add a system controller

In reply to Laurent Vivier
---
 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
new file mode 100644
index 000000000000..1db7960e5477
@@ -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
index cf18ac08e666..62fdabb5fb85 100644
@@ -164,4 +164,7 @@ config SIFIVE_U_OTP
 config SIFIVE_U_PRCI
     bool
 
+config M68K_VIRT_CTRL
+    bool
+
 source macio/Kconfig
hw/misc/meson.build +3 -0
index ce15ffceb958..3e8aebc8eb72 100644
@@ -23,6 +23,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
index b5118acd3fd5..f8a4b74d8154 100644
@@ -237,3 +237,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
#11 lore raw

PATCH v2 6/7 goldfish_rtc: re-arm the alarm after migration

In reply to Laurent Vivier

After a migration the clock offset is updated, but we also need to re-arm the alarm if needed.

---
 hw/rtc/goldfish_rtc.c | 2 ++
 1 file changed, 2 insertions(+)
hw/rtc/goldfish_rtc.c +2 -0
index 0f4e8185a796..e07ff0164e0c 100644
@@ -211,6 +211,8 @@ static int goldfish_rtc_post_load(void *opaque, int version_id)
             qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     s->tick_offset = s->tick_offset_vmstate - delta;
 
+    goldfish_rtc_set_alarm(s);
+
     return 0;
 }
 
Signature · 1 line
2.29.2
#12 lore raw

Re: [PATCH v2 6/7] goldfish_rtc: re-arm the alarm after migration

Is there someone to merge this?

Thanks,
Laurent

Le 20/12/2020 à 12:26, Laurent Vivier a écrit :

Quoted 23 lines

After a migration the clock offset is updated, but we also need to re-arm the alarm if needed.

---
 hw/rtc/goldfish_rtc.c | 2 ++
 1 file changed, 2 insertions(+)
hw/rtc/goldfish_rtc.c +2 -0
index 0f4e8185a796..e07ff0164e0c 100644
@@ -211,6 +211,8 @@ static int goldfish_rtc_post_load(void *opaque, int version_id)
             qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     s->tick_offset = s->tick_offset_vmstate - delta;
 
+    goldfish_rtc_set_alarm(s);
+
     return 0;
 }
 
#13 lore raw

Re: [PATCH v2 6/7] goldfish_rtc: re-arm the alarm after migration

Quoted 2 lines · Laurent Vivier

Is there someone to merge this?

Do you mean just this patch or the whole series?

Alistair

Quoted 30 lines

Thanks,
Laurent

Quoted 23 lines · Laurent Vivier

After a migration the clock offset is updated, but we also need to re-arm the alarm if needed.

---
 hw/rtc/goldfish_rtc.c | 2 ++
 1 file changed, 2 insertions(+)
hw/rtc/goldfish_rtc.c +2 -0
index 0f4e8185a796..e07ff0164e0c 100644
@@ -211,6 +211,8 @@ static int goldfish_rtc_post_load(void *opaque, int version_id)
             qemu_clock_get_ns(QEMU_CLOCK_VIRTUAL);
     s->tick_offset = s->tick_offset_vmstate - delta;
 
+    goldfish_rtc_set_alarm(s);
+
     return 0;
 }
 
#14 lore raw

Re: [PATCH v2 6/7] goldfish_rtc: re-arm the alarm after migration

Le 26/01/2021 à 00:44, Alistair Francis a écrit :

Quoted 5 lines · Laurent Vivier
Quoted 2 lines

Is there someone to merge this?

Do you mean just this patch or the whole series?

Sorry, I missed your mail.

I mean only this patch.

Thanks,
Laurent

#15 lore raw

Re: [PATCH v2 6/7] goldfish_rtc: re-arm the alarm after migration

Quoted 11 lines · Laurent Vivier
Quoted 5 lines · Alistair Francis
Quoted 2 lines · Laurent Vivier

Is there someone to merge this?

Do you mean just this patch or the whole series?

Sorry, I missed your mail.

I mean only this patch.

Ok, I have applied it.

Thanks!

Applied to riscv-to-apply.next

Alistair

Quoted 4 lines

Thanks,
Laurent

Reviewed-by on v2 6/7
#16 lore raw

Re: [PATCH v2 6/7] goldfish_rtc: re-arm the alarm after migration

In reply to Laurent Vivier
Quoted 8 lines · Laurent Vivier

After a migration the clock offset is updated, but we also need to re-arm the alarm if needed.

---
 hw/rtc/goldfish_rtc.c | 2 ++
 1 file changed, 2 insertions(+)
#17 lore raw

PATCH v2 7/7 m68k: add Virtual M68k Machine

In reply to Laurent Vivier

The 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                                | 312 ++++++++++++++++++
 MAINTAINERS                                   |   9 +
 hw/m68k/Kconfig                               |  10 +
 hw/m68k/meson.build                           |   1 +
 6 files changed, 351 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
index 6629fd2aa330..7f8619e42786 100644
@@ -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
new file mode 100644
index 000000000000..81be1e092497
@@ -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 +312 -0

312 lines not on this page · raw message

MAINTAINERS +9 -0
index 7640dfb5f0fc..5a290151cdec 100644
@@ -1105,6 +1105,15 @@ 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: include/hw/char/goldfish_tty.h
+F: include/hw/intc/goldfish_pic.h
+
 MicroBlaze Machines
 -------------------
 petalogix_s3adsp1800
hw/m68k/Kconfig +10 -0
index 60d7bcfb8f2b..f90d06d1cab7 100644
@@ -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
index ca0044c652d3..31248641d301 100644
@@ -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
#18 lore raw
Quoted 18 lines · Laurent Vivier

The 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                                | 312 ++++++++++++++++++
 MAINTAINERS                                   |   9 +
 hw/m68k/Kconfig                               |  10 +
 hw/m68k/meson.build                           |   1 +
 6 files changed, 351 insertions(+)
 create mode 100644 include/standard-headers/asm-m68k/bootinfo-virt.h
 create mode 100644 hw/m68k/virt.c

...

Quoted 14 lines
include/standard-headers/asm-m68k/bootinfo-virt.h new file +8 -0
new file mode 100644
index 000000000000..81be1e092497
@@ -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
+

include/standard-headers/asm-m68k/bootinfo-virt.h line 18

Quoted 10 lines
include/standard-headers/asm-m68k/bootinfo-virt.h new file +10 -0
+#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 */

Doesn't this belong to patch #1?

#19 lore raw

Le 24/01/2021 à 01:18, Philippe Mathieu-Daudé a écrit :

Quoted 39 lines · Laurent Vivier
Quoted 18 lines

The 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                                | 312 ++++++++++++++++++
 MAINTAINERS                                   |   9 +
 hw/m68k/Kconfig                               |  10 +
 hw/m68k/meson.build                           |   1 +
 6 files changed, 351 insertions(+)
 create mode 100644 include/standard-headers/asm-m68k/bootinfo-virt.h
 create mode 100644 hw/m68k/virt.c

...

Quoted 18 lines
include/standard-headers/asm-m68k/bootinfo-virt.h new file +12 -0
new file mode 100644
index 000000000000..81be1e092497
@@ -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
Quoted 9 lines

include/standard-headers/asm-m68k/bootinfo-virt.h line 18

Quoted 6 lines
include/standard-headers/asm-m68k/bootinfo-virt.h new file +6 -0
+#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 */

Doesn't this belong to patch #1?

No, because in PATCH #1 the m68k-virt machine doesn't exist.

PATCH #1 can be merged outside of this series, it's a generic patch.

Thanks,
Laurent