[PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1

Mark Cave-Ayland posted 24 patches 10 months, 2 weeks ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20230621085353.113233-1-mark.cave-ayland@ilande.co.uk
Maintainers: Laurent Vivier <laurent@vivier.eu>, Jason Wang <jasowang@redhat.com>
MAINTAINERS                 |   3 +
hw/m68k/meson.build         |   2 +-
hw/m68k/q800-glue.c         | 249 +++++++++++++++++
hw/m68k/q800.c              | 526 ++++++++++++++----------------------
hw/misc/mac_via.c           |  13 +-
hw/net/dp8393x.c            |  32 +--
include/hw/m68k/q800-glue.h |  50 ++++
include/hw/m68k/q800.h      |  66 +++++
include/hw/net/dp8393x.h    |  60 ++++
9 files changed, 635 insertions(+), 366 deletions(-)
create mode 100644 hw/m68k/q800-glue.c
create mode 100644 include/hw/m68k/q800-glue.h
create mode 100644 include/hw/m68k/q800.h
create mode 100644 include/hw/net/dp8393x.h
[PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Mark Cave-Ayland 10 months, 2 weeks ago
[MCA: the original series has now been split into 2 separate parts based upon
Phil's comments re: QOM parenting for objects in Q800MachineState. Part 1
consists of the Q800MachineState patches along with QOM parenting fixes and
the 2 mac_via RTC patches.]

This series contains the remaining patches needed to allow QEMU's q800
machine to boot MacOS Classic when used in conjunction with a real
Quadra 800 ROM image. In fact with this series applied it is possible
to boot all of the following OSs:

  - MacOS 7.1 - 8.1, with or without virtual memory enabled
  - A/UX 3.0.1
  - NetBSD 9.3
  - Linux (via EMILE)

If you are ready to experience some 90s nostalgia then all you need is
to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) and a
suitable install ISO as follows:

  # Prepare a PRAM image
  $ qemu-img create -f raw pram.img 256b

  # Launch QEMU with blank disk and install CDROM
  $ ./qemu-system-m68k \
      -M q800 \
      -m 128 \
      -bios Quadra800.rom \
      -drive file=pram.img,format=raw,if=mtd \
      -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
      -device scsi-hd,scsi-id=0,drive=hd \
      -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
      -device scsi-cd,scsi-id=3,drive=cd

And off you go! For more in-depth information about the installation process
I highly recommend the installation guide over at emaculation.com [1].
Compatibility is generally very good, and I'm pleased to report it is possible
to run one of the most popular productivity apps from the 90s [2].

I'd like to add a big thank you to all the people who have helped me work on
this series, including testing on real hardware, answering questions about
MacOS Classic internals and helping to diagnose and fix bugs in the 68k
emulation. In particular thanks go to Laurent Vivier, Finn Thain, Howard
Spoelstra, Volker Rümelin, Richard Henderson, Martin Husemann, Rin Okuyama,
Elliot Nunn, and SolraBizna.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

[1] https://www.emaculation.com/doku.php/qemu
[2] https://www.youtube.com/watch?v=yI21gURQ1Ew


Patches missing review tags: 8 (new)

v4:
- Rebase onto master
- Add R-B tags from Phil and Laurent
- Use qdev_realize() in patch 5 as suggested by Markus
- Add new patch 8 to switch q800-glue.c to use the DEFINE_TYPES macro
  as suggested by Phil

v3:
- Add R-B tags from Phil and Laurent
- Add missing headers in patches indicated by Phil
- Change patch 5 to use valid_cpu_types Machine class property and the cpu_type
  Machine property to initialise the CPU
- Remove osdep.h header from dp8393x.h in patch 13 noticed by Phil
- Change sysbus_realize_and_unref() to sysbus_realize() in patch 19
- Use memory_region_add_subregion() instead of sysbus_mmio_map() in patch 19

v2:
- Split series into 2 parts (this is part 1)
- Update QOM parenting for objects in Q800MachineState (Phil)
- Split GLUE device into separate glue.c and glue.h files
- Split TYPE_DP8393X and dp8393xState into dp8393x.h
- Add R-B tags from Laurent (where I still believe they are valid)


Mark Cave-Ayland (24):
  q800: fix up minor spacing issues in hw_compat_q800 GlobalProperty
    array
  q800: add missing space after parent object in GLUEState
  q800: introduce Q800MachineState
  q800: rename q800_init() to q800_machine_init()
  q800: move CPU object into Q800MachineState
  q800: move ROM memory region to Q800MachineState
  q800: move GLUE device into separate q800-glue.c file
  q800-glue.c: switch TypeInfo registration to use DEFINE_TYPES() macro
  q800: move GLUE device to Q800MachineState
  q800: introduce mac-io container memory region
  q800: reimplement mac-io region aliasing using IO memory region
  q800: move VIA1 device to Q800MachineState
  q800: move VIA2 device to Q800MachineState
  hw/net/dp8393x.c: move TYPE_DP8393X and dp8393xState into dp8393x.h
  q800: move dp8393x device to Q800MachineState
  q800: move ESCC device to Q800MachineState
  q800: move escc_orgate device to Q800MachineState
  q800: move ESP device to Q800MachineState
  q800: move SWIM device to Q800MachineState
  q800: move mac-nubus-bridge device to Q800MachineState
  q800: don't access Nubus bus directly from the mac-nubus-bridge device
  q800: move macfb device to Q800MachineState
  mac_via: fix rtc command decoding from PRAM addresses 0x0 to 0xf
  mac_via: fix rtc command decoding for the PRAM seconds registers

 MAINTAINERS                 |   3 +
 hw/m68k/meson.build         |   2 +-
 hw/m68k/q800-glue.c         | 249 +++++++++++++++++
 hw/m68k/q800.c              | 526 ++++++++++++++----------------------
 hw/misc/mac_via.c           |  13 +-
 hw/net/dp8393x.c            |  32 +--
 include/hw/m68k/q800-glue.h |  50 ++++
 include/hw/m68k/q800.h      |  66 +++++
 include/hw/net/dp8393x.h    |  60 ++++
 9 files changed, 635 insertions(+), 366 deletions(-)
 create mode 100644 hw/m68k/q800-glue.c
 create mode 100644 include/hw/m68k/q800-glue.h
 create mode 100644 include/hw/m68k/q800.h
 create mode 100644 include/hw/net/dp8393x.h

-- 
2.30.2


Re: [PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Philippe Mathieu-Daudé 10 months, 2 weeks ago
On 21/6/23 10:53, Mark Cave-Ayland wrote:
> [MCA: the original series has now been split into 2 separate parts based upon
> Phil's comments re: QOM parenting for objects in Q800MachineState. Part 1
> consists of the Q800MachineState patches along with QOM parenting fixes and
> the 2 mac_via RTC patches.]
> 
> This series contains the remaining patches needed to allow QEMU's q800
> machine to boot MacOS Classic when used in conjunction with a real
> Quadra 800 ROM image. In fact with this series applied it is possible
> to boot all of the following OSs:
> 
>    - MacOS 7.1 - 8.1, with or without virtual memory enabled
>    - A/UX 3.0.1
>    - NetBSD 9.3
>    - Linux (via EMILE)
> 
> If you are ready to experience some 90s nostalgia then all you need is
> to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) and a
> suitable install ISO as follows:
> 
>    # Prepare a PRAM image
>    $ qemu-img create -f raw pram.img 256b
> 
>    # Launch QEMU with blank disk and install CDROM
>    $ ./qemu-system-m68k \
>        -M q800 \
>        -m 128 \
>        -bios Quadra800.rom \
>        -drive file=pram.img,format=raw,if=mtd \
>        -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
>        -device scsi-hd,scsi-id=0,drive=hd \
>        -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
>        -device scsi-cd,scsi-id=3,drive=cd
> 
> And off you go! For more in-depth information about the installation process
> I highly recommend the installation guide over at emaculation.com [1].
> Compatibility is generally very good, and I'm pleased to report it is possible
> to run one of the most popular productivity apps from the 90s [2].

Could you add an Avocado test for this machine? See how the
MipsFuloong2e test (tests/avocado/machine_mips_fuloong2e.py)
handles the firmware (RESCUE_YL_PATH).
Re: [PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Mark Cave-Ayland 10 months, 2 weeks ago
On 21/06/2023 10:42, Philippe Mathieu-Daudé wrote:

> On 21/6/23 10:53, Mark Cave-Ayland wrote:
>> [MCA: the original series has now been split into 2 separate parts based upon
>> Phil's comments re: QOM parenting for objects in Q800MachineState. Part 1
>> consists of the Q800MachineState patches along with QOM parenting fixes and
>> the 2 mac_via RTC patches.]
>>
>> This series contains the remaining patches needed to allow QEMU's q800
>> machine to boot MacOS Classic when used in conjunction with a real
>> Quadra 800 ROM image. In fact with this series applied it is possible
>> to boot all of the following OSs:
>>
>>    - MacOS 7.1 - 8.1, with or without virtual memory enabled
>>    - A/UX 3.0.1
>>    - NetBSD 9.3
>>    - Linux (via EMILE)
>>
>> If you are ready to experience some 90s nostalgia then all you need is
>> to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) and a
>> suitable install ISO as follows:
>>
>>    # Prepare a PRAM image
>>    $ qemu-img create -f raw pram.img 256b
>>
>>    # Launch QEMU with blank disk and install CDROM
>>    $ ./qemu-system-m68k \
>>        -M q800 \
>>        -m 128 \
>>        -bios Quadra800.rom \
>>        -drive file=pram.img,format=raw,if=mtd \
>>        -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
>>        -device scsi-hd,scsi-id=0,drive=hd \
>>        -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
>>        -device scsi-cd,scsi-id=3,drive=cd
>>
>> And off you go! For more in-depth information about the installation process
>> I highly recommend the installation guide over at emaculation.com [1].
>> Compatibility is generally very good, and I'm pleased to report it is possible
>> to run one of the most popular productivity apps from the 90s [2].
> 
> Could you add an Avocado test for this machine? See how the
> MipsFuloong2e test (tests/avocado/machine_mips_fuloong2e.py)
> handles the firmware (RESCUE_YL_PATH).

In theory it is possible to do this, but how do we handle booting proprietary OS ISOs 
that are still within copyright? Also this is only part 1 of the required changes, 
you'll need part 2 applied in order to achieve a successful boot :)


ATB,

Mark.


Re: [PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Philippe Mathieu-Daudé 10 months, 2 weeks ago
On 21/6/23 16:06, Mark Cave-Ayland wrote:
> On 21/06/2023 10:42, Philippe Mathieu-Daudé wrote:
> 
>> On 21/6/23 10:53, Mark Cave-Ayland wrote:
>>> [MCA: the original series has now been split into 2 separate parts 
>>> based upon
>>> Phil's comments re: QOM parenting for objects in Q800MachineState. 
>>> Part 1
>>> consists of the Q800MachineState patches along with QOM parenting 
>>> fixes and
>>> the 2 mac_via RTC patches.]
>>>
>>> This series contains the remaining patches needed to allow QEMU's q800
>>> machine to boot MacOS Classic when used in conjunction with a real
>>> Quadra 800 ROM image. In fact with this series applied it is possible
>>> to boot all of the following OSs:
>>>
>>>    - MacOS 7.1 - 8.1, with or without virtual memory enabled
>>>    - A/UX 3.0.1
>>>    - NetBSD 9.3
>>>    - Linux (via EMILE)
>>>
>>> If you are ready to experience some 90s nostalgia then all you need is
>>> to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) 
>>> and a
>>> suitable install ISO as follows:
>>>
>>>    # Prepare a PRAM image
>>>    $ qemu-img create -f raw pram.img 256b
>>>
>>>    # Launch QEMU with blank disk and install CDROM
>>>    $ ./qemu-system-m68k \
>>>        -M q800 \
>>>        -m 128 \
>>>        -bios Quadra800.rom \
>>>        -drive file=pram.img,format=raw,if=mtd \
>>>        -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
>>>        -device scsi-hd,scsi-id=0,drive=hd \
>>>        -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
>>>        -device scsi-cd,scsi-id=3,drive=cd
>>>
>>> And off you go! For more in-depth information about the installation 
>>> process
>>> I highly recommend the installation guide over at emaculation.com [1].
>>> Compatibility is generally very good, and I'm pleased to report it is 
>>> possible
>>> to run one of the most popular productivity apps from the 90s [2].
>>
>> Could you add an Avocado test for this machine? See how the
>> MipsFuloong2e test (tests/avocado/machine_mips_fuloong2e.py)
>> handles the firmware (RESCUE_YL_PATH).
> 
> In theory it is possible to do this, but how do we handle booting 
> proprietary OS ISOs that are still within copyright?

Just provide the hash. You are not redistributing anything.

> Also this is only 
> part 1 of the required changes, you'll need part 2 applied in order to 
> achieve a successful boot :)
> 
> 
> ATB,
> 
> Mark.
> 


Re: [PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Mark Cave-Ayland 10 months, 1 week ago
On 22/06/2023 11:07, Philippe Mathieu-Daudé wrote:

> On 21/6/23 16:06, Mark Cave-Ayland wrote:
>> On 21/06/2023 10:42, Philippe Mathieu-Daudé wrote:
>>
>>> On 21/6/23 10:53, Mark Cave-Ayland wrote:
>>>> [MCA: the original series has now been split into 2 separate parts based upon
>>>> Phil's comments re: QOM parenting for objects in Q800MachineState. Part 1
>>>> consists of the Q800MachineState patches along with QOM parenting fixes and
>>>> the 2 mac_via RTC patches.]
>>>>
>>>> This series contains the remaining patches needed to allow QEMU's q800
>>>> machine to boot MacOS Classic when used in conjunction with a real
>>>> Quadra 800 ROM image. In fact with this series applied it is possible
>>>> to boot all of the following OSs:
>>>>
>>>>    - MacOS 7.1 - 8.1, with or without virtual memory enabled
>>>>    - A/UX 3.0.1
>>>>    - NetBSD 9.3
>>>>    - Linux (via EMILE)
>>>>
>>>> If you are ready to experience some 90s nostalgia then all you need is
>>>> to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) and a
>>>> suitable install ISO as follows:
>>>>
>>>>    # Prepare a PRAM image
>>>>    $ qemu-img create -f raw pram.img 256b
>>>>
>>>>    # Launch QEMU with blank disk and install CDROM
>>>>    $ ./qemu-system-m68k \
>>>>        -M q800 \
>>>>        -m 128 \
>>>>        -bios Quadra800.rom \
>>>>        -drive file=pram.img,format=raw,if=mtd \
>>>>        -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
>>>>        -device scsi-hd,scsi-id=0,drive=hd \
>>>>        -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
>>>>        -device scsi-cd,scsi-id=3,drive=cd
>>>>
>>>> And off you go! For more in-depth information about the installation process
>>>> I highly recommend the installation guide over at emaculation.com [1].
>>>> Compatibility is generally very good, and I'm pleased to report it is possible
>>>> to run one of the most popular productivity apps from the 90s [2].
>>>
>>> Could you add an Avocado test for this machine? See how the
>>> MipsFuloong2e test (tests/avocado/machine_mips_fuloong2e.py)
>>> handles the firmware (RESCUE_YL_PATH).
>>
>> In theory it is possible to do this, but how do we handle booting proprietary OS 
>> ISOs that are still within copyright?
> 
> Just provide the hash. You are not redistributing anything.

Another couple of questions: even without distributing the ROM or ISO, do I still 
need to provide URLs to these resources? I see that ISOs generally have URLs but 
given that the Mac sites hosting these images tend to be quite small, I'm not sure 
that providing a link to these sites within QEMU is something they would be 
particularly happy with.

I'm also not sure what is the best way to set up the test to confirm boot is working 
correctly. Ideally we would want to boot a MacOS install CD to the desktop, but there 
isn't an easy way to determine when this has occurred. Perhaps take a screendump 
every 2s or so and use tesseract-ocr to parse for when the menu bar appears on screen?


ATB,

Mark.


Re: [PATCH v4 00/24] q800: add support for booting MacOS Classic - part 1
Posted by Laurent Vivier 10 months, 2 weeks ago
Le 21/06/2023 à 10:53, Mark Cave-Ayland a écrit :
> [MCA: the original series has now been split into 2 separate parts based upon
> Phil's comments re: QOM parenting for objects in Q800MachineState. Part 1
> consists of the Q800MachineState patches along with QOM parenting fixes and
> the 2 mac_via RTC patches.]
> 
> This series contains the remaining patches needed to allow QEMU's q800
> machine to boot MacOS Classic when used in conjunction with a real
> Quadra 800 ROM image. In fact with this series applied it is possible
> to boot all of the following OSs:
> 
>    - MacOS 7.1 - 8.1, with or without virtual memory enabled
>    - A/UX 3.0.1
>    - NetBSD 9.3
>    - Linux (via EMILE)
> 
> If you are ready to experience some 90s nostalgia then all you need is
> to grab yourself a copy of the Quadra 800 ROM (checksum 0xf1acad13) and a
> suitable install ISO as follows:
> 
>    # Prepare a PRAM image
>    $ qemu-img create -f raw pram.img 256b
> 
>    # Launch QEMU with blank disk and install CDROM
>    $ ./qemu-system-m68k \
>        -M q800 \
>        -m 128 \
>        -bios Quadra800.rom \
>        -drive file=pram.img,format=raw,if=mtd \
>        -drive file=disk.img,media=disk,format=raw,if=none,id=hd \
>        -device scsi-hd,scsi-id=0,drive=hd \
>        -drive file=cdrom.iso,media=cdrom,if=none,id=cd \
>        -device scsi-cd,scsi-id=3,drive=cd
> 
> And off you go! For more in-depth information about the installation process
> I highly recommend the installation guide over at emaculation.com [1].
> Compatibility is generally very good, and I'm pleased to report it is possible
> to run one of the most popular productivity apps from the 90s [2].
> 
> I'd like to add a big thank you to all the people who have helped me work on
> this series, including testing on real hardware, answering questions about
> MacOS Classic internals and helping to diagnose and fix bugs in the 68k
> emulation. In particular thanks go to Laurent Vivier, Finn Thain, Howard
> Spoelstra, Volker Rümelin, Richard Henderson, Martin Husemann, Rin Okuyama,
> Elliot Nunn, and SolraBizna.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
> 
> [1] https://www.emaculation.com/doku.php/qemu
> [2] https://www.youtube.com/watch?v=yI21gURQ1Ew
> 
> 
> Patches missing review tags: 8 (new)
> 
> v4:
> - Rebase onto master
> - Add R-B tags from Phil and Laurent
> - Use qdev_realize() in patch 5 as suggested by Markus
> - Add new patch 8 to switch q800-glue.c to use the DEFINE_TYPES macro
>    as suggested by Phil
> 
> v3:
> - Add R-B tags from Phil and Laurent
> - Add missing headers in patches indicated by Phil
> - Change patch 5 to use valid_cpu_types Machine class property and the cpu_type
>    Machine property to initialise the CPU
> - Remove osdep.h header from dp8393x.h in patch 13 noticed by Phil
> - Change sysbus_realize_and_unref() to sysbus_realize() in patch 19
> - Use memory_region_add_subregion() instead of sysbus_mmio_map() in patch 19
> 
> v2:
> - Split series into 2 parts (this is part 1)
> - Update QOM parenting for objects in Q800MachineState (Phil)
> - Split GLUE device into separate glue.c and glue.h files
> - Split TYPE_DP8393X and dp8393xState into dp8393x.h
> - Add R-B tags from Laurent (where I still believe they are valid)
> 
> 
> Mark Cave-Ayland (24):
>    q800: fix up minor spacing issues in hw_compat_q800 GlobalProperty
>      array
>    q800: add missing space after parent object in GLUEState
>    q800: introduce Q800MachineState
>    q800: rename q800_init() to q800_machine_init()
>    q800: move CPU object into Q800MachineState
>    q800: move ROM memory region to Q800MachineState
>    q800: move GLUE device into separate q800-glue.c file
>    q800-glue.c: switch TypeInfo registration to use DEFINE_TYPES() macro
>    q800: move GLUE device to Q800MachineState
>    q800: introduce mac-io container memory region
>    q800: reimplement mac-io region aliasing using IO memory region
>    q800: move VIA1 device to Q800MachineState
>    q800: move VIA2 device to Q800MachineState
>    hw/net/dp8393x.c: move TYPE_DP8393X and dp8393xState into dp8393x.h
>    q800: move dp8393x device to Q800MachineState
>    q800: move ESCC device to Q800MachineState
>    q800: move escc_orgate device to Q800MachineState
>    q800: move ESP device to Q800MachineState
>    q800: move SWIM device to Q800MachineState
>    q800: move mac-nubus-bridge device to Q800MachineState
>    q800: don't access Nubus bus directly from the mac-nubus-bridge device
>    q800: move macfb device to Q800MachineState
>    mac_via: fix rtc command decoding from PRAM addresses 0x0 to 0xf
>    mac_via: fix rtc command decoding for the PRAM seconds registers
> 
>   MAINTAINERS                 |   3 +
>   hw/m68k/meson.build         |   2 +-
>   hw/m68k/q800-glue.c         | 249 +++++++++++++++++
>   hw/m68k/q800.c              | 526 ++++++++++++++----------------------
>   hw/misc/mac_via.c           |  13 +-
>   hw/net/dp8393x.c            |  32 +--
>   include/hw/m68k/q800-glue.h |  50 ++++
>   include/hw/m68k/q800.h      |  66 +++++
>   include/hw/net/dp8393x.h    |  60 ++++
>   9 files changed, 635 insertions(+), 366 deletions(-)
>   create mode 100644 hw/m68k/q800-glue.c
>   create mode 100644 include/hw/m68k/q800-glue.h
>   create mode 100644 include/hw/m68k/q800.h
>   create mode 100644 include/hw/net/dp8393x.h
> 

Queued

Thanks,
Laurent