Skip to contentSkip to conversation

m68k: Add basic support for the NeXTcube machine

PATCH Superseded Thomas Huth 2 participants 7 messages Jul 6, 2019

v3 of 5 Superseded Latest is v5 →

lore
Share & tools
lore
#0 lore raw

v3 cover m68k: Add basic support for the NeXTcube machine

During Google Summer of Code 2011, Bryce Lanham added the possibility to emulate the NeXTcube machine in QEMU, e.g. see these URLs for some details:

https://wiki.qemu.org/Google_Summer_of_Code_2011#NeXT_machines_system_emulation
https://lists.gnu.org/archive/html/qemu-devel/2011-08/msg02158.html

But since the machine requires a 68040 CPU and this was not included in upstream QEMU in 2011 yet, the patches have never been merged to upstream.

Then, during the last years, Laurent completed the full 680x0 support in upstream QEMU, so we could finally merge the NeXTcube support, too.

The QEMU interfaces changed a lot since 2011, so I had to modify the sources quite a bit, but with the attached patches, it is now possible to boot up to the firmware monitor again.

Note that boot device emulation is still missing (network and SCSI), so you can not boot any operating systems with this machine yet. I have the patches for these devices in my brach here:

https://gitlab.com/huth/qemu/commits/next-cube

... but they are not quite working yet, so I'll submit them later once they have been fixed and the basic support patches of this series have been merged.

v3:
- Don't connect the devices to the sysbus from the device files themselves, do it from next-cube.c instead.
- Adjusted some values according to Philippe's review comments
- The MMIO region at 0x820c0020 is now correctly initialized as alias
- Some more clean-ups here and there

v2:
- Don't use memory_region_allocate_system_memory() for the framebuffer device anymore
- Turn the keyboard device into a proper QOM device
- Put the global variables in the third patch into the machine state structure
- Got rid of the "//" C++ comments

Thomas Huth (4):
m68k: Add NeXTcube framebuffer device emulation
m68k: Add NeXTcube keyboard device
m68k: Add NeXTcube machine
m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file

 MAINTAINERS                      |   7 +
 default-configs/m68k-softmmu.mak |   1 +
 hw/display/Makefile.objs         |   1 +
 hw/display/next-fb.c             | 145 +++++
 hw/m68k/Kconfig                  |   4 +
 hw/m68k/Makefile.objs            |   1 +
 hw/m68k/next-cube.c              | 972 +++++++++++++++++++++++++++++++
 hw/m68k/next-kbd.c               | 284 +++++++++
 include/hw/m68k/next-cube.h      |  47 ++
 9 files changed, 1462 insertions(+)
 create mode 100644 hw/display/next-fb.c
 create mode 100644 hw/m68k/next-cube.c
 create mode 100644 hw/m68k/next-kbd.c
 create mode 100644 include/hw/m68k/next-cube.h
Signature · 1 line
2.21.0
#1 lore raw

PATCH v3 1/4 m68k: Add NeXTcube framebuffer device emulation

The NeXTcube uses a linear framebuffer with 4 greyscale colors and a fixed resolution of 1120 * 832.
This code has been taken from Bryce Lanham's GSoC 2011 NeXT branch at

https://github.com/blanham/qemu-NeXT/blob/next-cube/hw/next-fb.c

and altered to fit the latest interface of the current QEMU (e.g. the device has been "qdev"-ified etc.).

---
 default-configs/m68k-softmmu.mak |   1 +
 hw/display/Makefile.objs         |   1 +
 hw/display/next-fb.c             | 145 +++++++++++++++++++++++++++++++
 hw/m68k/Kconfig                  |   4 +
 include/hw/m68k/next-cube.h      |   7 ++
 5 files changed, 158 insertions(+)
 create mode 100644 hw/display/next-fb.c
 create mode 100644 include/hw/m68k/next-cube.h
default-configs/m68k-softmmu.mak +1 -0
index 4049a8f2ba..d67ab8b96d 100644
@@ -6,3 +6,4 @@ CONFIG_SEMIHOSTING=y
 #
 CONFIG_AN5206=y
 CONFIG_MCF5208=y
+CONFIG_NEXTCUBE=y
hw/display/Makefile.objs +1 -0
index a64998fc7b..8d1c71026d 100644
@@ -38,6 +38,7 @@ obj-$(CONFIG_RASPI) += bcm2835_fb.o
 obj-$(CONFIG_SM501) += sm501.o
 obj-$(CONFIG_TCX) += tcx.o
 obj-$(CONFIG_CG3) += cg3.o
+obj-$(CONFIG_NEXTCUBE) += next-fb.o
 
 obj-$(CONFIG_VGA) += vga.o
 
hw/display/next-fb.c new file +145 -0

145 lines not on this page · raw message

hw/m68k/Kconfig +4 -0
index 49ef0b3f6d..ec58a2eb06 100644
@@ -7,3 +7,7 @@ config MCF5208
     bool
     select COLDFIRE
     select PTIMER
+
+config NEXTCUBE
+    bool
+    select FRAMEBUFFER
include/hw/m68k/next-cube.h new file +7 -0
new file mode 100644
index 0000000000..090c7c51aa
@@ -0,0 +1,7 @@
+
+#ifndef NEXT_CUBE_H
+#define NEXT_CUBE_H
+
+#define TYPE_NEXTFB "next-fb"
+
+#endif /* NEXT_CUBE_H */
Signature · 1 line
2.21.0
#2 lore raw

PATCH v3 2/4 m68k: Add NeXTcube keyboard device

In reply to Thomas Huth

It is likely still quite incomplete (e.g. mouse and interrupts are not implemented yet), but it is good enough for keyboard input at the firmware monitor.
This code has been taken from Bryce Lanham's GSoC 2011 NeXT branch at

https://github.com/blanham/qemu-NeXT/blob/next-cube/hw/next-kbd.c

and altered to fit the latest interface of the current QEMU (e.g. to use memory_region_init_io() instead of cpu_register_physical_memory()).

---
 hw/m68k/Makefile.objs       |   1 +
 hw/m68k/next-kbd.c          | 284 ++++++++++++++++++++++++++++++++++++
 include/hw/m68k/next-cube.h |   2 +
 3 files changed, 287 insertions(+)
 create mode 100644 hw/m68k/next-kbd.c
hw/m68k/Makefile.objs +1 -0
index 482f8477b4..688002cac1 100644
@@ -1,2 +1,3 @@
 obj-$(CONFIG_AN5206) += an5206.o mcf5206.o
 obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o
+obj-$(CONFIG_NEXTCUBE) += next-kbd.o
hw/m68k/next-kbd.c new file +284 -0

284 lines not on this page · raw message

include/hw/m68k/next-cube.h +2 -0
index 090c7c51aa..37f7ce3e34 100644
@@ -4,4 +4,6 @@
 
 #define TYPE_NEXTFB "next-fb"
 
+#define TYPE_NEXTKBD "next-kbd"
+
 #endif /* NEXT_CUBE_H */
Signature · 1 line
2.21.0
#3 lore raw

PATCH v3 3/4 m68k: Add NeXTcube machine

In reply to Thomas Huth

It is still quite incomplete (no SCSI, no floppy emulation, no network, etc.), but the firmware already shows up the debug monitor prompt in the framebuffer display, so at least the very basics are already working.

This code has been taken from Bryce Lanham's GSoC 2011 NeXT branch at

https://github.com/blanham/qemu-NeXT/blob/next-cube/hw/next-cube.c

and altered quite a bit to fit the latest interface and coding conventions of the current QEMU.

---
 hw/m68k/Makefile.objs       |   2 +-
 hw/m68k/next-cube.c         | 972 ++++++++++++++++++++++++++++++++++++
 include/hw/m68k/next-cube.h |  38 ++
 3 files changed, 1011 insertions(+), 1 deletion(-)
 create mode 100644 hw/m68k/next-cube.c
hw/m68k/Makefile.objs +1 -1
index 688002cac1..f25854730d 100644
@@ -1,3 +1,3 @@
 obj-$(CONFIG_AN5206) += an5206.o mcf5206.o
 obj-$(CONFIG_MCF5208) += mcf5208.o mcf_intc.o
-obj-$(CONFIG_NEXTCUBE) += next-kbd.o
+obj-$(CONFIG_NEXTCUBE) += next-kbd.o next-cube.o
hw/m68k/next-cube.c new file +972 -0

972 lines not on this page · raw message

include/hw/m68k/next-cube.h +38 -0
index 37f7ce3e34..a3be2b32ab 100644
@@ -6,4 +6,42 @@
 
 #define TYPE_NEXTKBD "next-kbd"
 
+enum next_dma_chan {
+    NEXTDMA_FD,
+    NEXTDMA_ENRX,
+    NEXTDMA_ENTX,
+    NEXTDMA_SCSI,
+    NEXTDMA_SCC,
+    NEXTDMA_SND
+};
+
+#define DMA_ENABLE      0x01000000
+#define DMA_SUPDATE     0x02000000
+#define DMA_COMPLETE    0x08000000
+
+#define DMA_M2DEV       0x0
+#define DMA_SETENABLE   0x00010000
+#define DMA_SETSUPDATE  0x00020000
+#define DMA_DEV2M       0x00040000
+#define DMA_CLRCOMPLETE 0x00080000
+#define DMA_RESET       0x00100000
+
+enum next_irqs {
+    NEXT_FD_I,
+    NEXT_KBD_I,
+    NEXT_PWR_I,
+    NEXT_ENRX_I,
+    NEXT_ENTX_I,
+    NEXT_SCSI_I,
+    NEXT_CLK_I,
+    NEXT_SCC_I,
+    NEXT_ENTX_DMA_I,
+    NEXT_ENRX_DMA_I,
+    NEXT_SCSI_DMA_I,
+    NEXT_SCC_DMA_I,
+    NEXT_SND_I
+};
+
+void next_irq(void *opaque, int number, int level);
+
 #endif /* NEXT_CUBE_H */
Signature · 1 line
2.21.0
#4 lore raw

PATCH v3 4/4 m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file

In reply to Thomas Huth

I don't have much clue about the NeXT hardware, but at least I know now the source files a little bit, so I volunteer to pick up patches and send PULL requests for them until someone else with more knowledge steps up to do this job instead.

---
 MAINTAINERS | 7 +++++++
 1 file changed, 7 insertions(+)
MAINTAINERS +7 -0
index 2cce50287a..539f8a6f10 100644
@@ -910,6 +910,13 @@ F: hw/char/mcf_uart.c
 F: hw/net/mcf_fec.c
 F: include/hw/m68k/mcf*.h
 
+NeXTcube
+M: Thomas Huth <[email protected]>
+S: Odd Fixes
+F: hw/m68k/next-*.c
+F: hw/display/next-fb.c
+F: include/hw/m68k/next-cube.h
+
 MicroBlaze Machines
 -------------------
 petalogix_s3adsp1800
Signature · 1 line
2.21.0
#5 lore raw
In reply to Thomas Huth
Patchew URL: https://patchew.org/QEMU/[email protected]/

Patchew URL: https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

Message-id: [email protected]
Type: series
Subject: [Qemu-devel] [PATCH v3 0/4] m68k: Add basic support for the NeXTcube machine

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

From https://github.com/patchew-project/qemu
* [new tag] patchew/[email protected] -> patchew/[email protected]
Switched to a new branch 'test'
ef92db6583 m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file 83bed1b09c m68k: Add NeXTcube machine
86ab91916c m68k: Add NeXTcube keyboard device
870bb92660 m68k: Add NeXTcube framebuffer device emulation

=== OUTPUT BEGIN ===
1/4 Checking commit 870bb92660ae (m68k: Add NeXTcube framebuffer device emulation)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #41:
new file mode 100644

total: 0 errors, 1 warnings, 170 lines checked

Patch 1/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
2/4 Checking commit 86ab91916cb0 (m68k: Add NeXTcube keyboard device)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #29:
new file mode 100644

total: 0 errors, 1 warnings, 293 lines checked

Patch 2/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.
3/4 Checking commit 83bed1b09cef (m68k: Add NeXTcube machine)
WARNING: added, moved or deleted file(s), does MAINTAINERS need updating? #31:
new file mode 100644

WARNING: Block comments use * on subsequent lines
#118: FILE: hw/m68k/next-cube.c:83:
+/*
+static const uint8_t rtc_ram3[32] = {

ERROR: space required after that ',' (ctx:VxV)
#938: FILE: hw/m68k/next-cube.c:903:
+ memory_region_init_alias(aliasmem, NULL,"next.unknown", mmiomem, 0xc0020,

                                            ^

total: 1 errors, 2 warnings, 1018 lines checked

Patch 3/4 has style problems, please review. If any of these errors are false positives report them to the maintainer, see CHECKPATCH in MAINTAINERS.

4/4 Checking commit ef92db658309 (m68k: Add an entry for the NeXTcube machine to the MAINTAINERS file) === OUTPUT END ===

Test command exited with code: 1

The full log is available at
http://patchew.org/logs/[email protected]/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to [email protected]

#6 lore raw

Am Sat, 6 Jul 2019 08:54:13 -0700 (PDT)
schrieb [email protected]:

Quoted 7 lines

Patchew URL:
https://patchew.org/QEMU/[email protected]/

Hi,

This series seems to have some coding style problems. See output below for more information:

[...]

Quoted 4 lines

ERROR: space required after that ',' (ctx:VxV)
#938: FILE: hw/m68k/next-cube.c:903:
+ memory_region_init_alias(aliasmem, NULL,"next.unknown", mmiomem,
0xc0020, ^

Stupid typo - I'll fix of course, and change the name of the region to "next.alias" or something similar.

Thomas