On 03/12/2025 06:43, Matt Jacobson wrote:

[Please notify me of any process errors -- this is my first contribution to
QEMU.  Thanks.]

Implement the SWIM2 floppy controller for the q800 machine.
(For details, see: <https://archive.org/details/SWIMDesignDocs/SWIM2%20ERS/>.)

Reading and writing work, and booting from a system disk works.
Tested with the Quadra 800 ROM and System 7.

Future areas of work here could include:

* Allowing for disk formatting/duplication to work
* Fleshing out the SWIM1 and hooking it up to the emulated drive
* Implementing the IWM for earlier machines (this could share code with SWIM1)

Matt Jacobson (1):
   hw/m68k: add working floppy controller for q800

  hw/block/meson.build               |   2 +-
  hw/block/sony_superdrive.c         | 940 +++++++++++++++++++++++++++++
  hw/block/swim2.c                   | 657 ++++++++++++++++++++
  hw/block/trace-events              |  17 +
  hw/m68k/q800.c                     |   4 +-
  include/hw/block/sony_superdrive.h |  55 ++
  include/hw/block/swim2.h           |  66 ++
  include/hw/m68k/q800.h             |   4 +-
  8 files changed, 1740 insertions(+), 5 deletions(-)
  create mode 100644 hw/block/sony_superdrive.c
  create mode 100644 hw/block/swim2.c
  create mode 100644 include/hw/block/sony_superdrive.h
  create mode 100644 include/hw/block/swim2.h

Thanks for the contribution! I've applied this patch and managed to get it to compile successfully, but I'm struggling to find a suitable disk image that works. Can you point me towards both a GCR and an MFM image I can use for testing? I think this might be because the images I use here are simply HFS(+) images.

Some initial thoughts from looking over the code:

- The basic implementation looks fairly good from what I can see, but I can see a number of places that don't match our code style guidelines. You can do a basic style check running "./scripts/checkpatch.pl HEAD~1..HEAD" from a git checkout with your patch applied which will pick up the majority of issues.

- Having everything in one patch makes it harder to review: I think it would make sense to introduce the SONY drive in one patch, the updated SWIM2 controller in another, and then a final patch to update the q800 machine to switch over the SWIM2. And maybe even an extra patch to remove the existing SWIM1 stub? The stub was added with just enough implemented to allow Linux to boot.

- Have you tested with an A/UX 3.0.1 boot floppy? A number of people are interested to run AUX 3.0.1 as per https://www.emaculation.com/doku.php/m68k-qemu-on-windows#running_qemu-system-m68k_with_a_ux_3x_guests_in_windows and it would be good to be able to use the real floppy image here.

- QEMU already has a fairly good Fifo8 implementation: is it possible to use that or Fifo32 instead of reinventing it here?

- It's worth updating the cover letter to include an example command line. I had to go digging into the patch to discover that I needed to add something like "-drive file=/tmp/Install.img,if=none,id=floppy" to attempt a floppy boot. Configuring internal devices can be fiddly: I'm wondering if there is existing precedent in the way PC floppy drives work that we can use to keep things consistent?

- When booting a test Linux image I got stuck in a boot loop, both with and without a floppy inserted in the drive:

swim2_mmio_read addr=0x1e00 size=1 reg=7 [HANDSHAKE] value=0x8 mode=0xca setup=0x28 phase=0x74 fifo=0 swim2_mmio_read addr=0x1e00 size=1 reg=7 [HANDSHAKE] value=0x8 mode=0xca setup=0x28 phase=0x74 fifo=0
...
...

Since the Linux maintainers make use of QEMU for testing, I think we need to get this working. Laurent - do you know if the 68K Mac kernel driver works on real hardware?

I appreciate the time and effort that has gone into creating this patch, and I'm really looking forward to getting it to a point where it can be merged :)


ATB,

Mark.


Reply via email to