Add emulation of AmigaOne XE board
v4 cover Add emulation of AmigaOne XE board
Changes in v4:
- Found typo in comment in patch 1 so ended up rewording it again trying to make it more concise. Also take the idea of using range_covers_byte from Mark's patch
- Added RFC patch for avocado test (untested, I don't have Avocado)
Changes in v3:
- Update values, comment and commit message in patch 1 again
Changes in v2:
- Update comment and commit message in patch 1 (Mark)
- Fix irq mapping in patch 2 (Volker)
Regards,
BALATON Zoltan
BALATON Zoltan (4):
via-ide: Fix legacy mode emulation hw/pci-host: Add emulation of Mai Logic Articia S hw/ppc: Add emulation of AmigaOne XE board tests/avocado: Add test for amigaone board
MAINTAINERS | 8 + configs/devices/ppc-softmmu/default.mak | 1 + hw/ide/via.c | 43 +++- hw/pci-host/Kconfig | 5 + hw/pci-host/articia.c | 293 ++++++++++++++++++++++++ hw/pci-host/meson.build | 2 + hw/ppc/Kconfig | 7 + hw/ppc/amigaone.c | 164 +++++++++++++ hw/ppc/meson.build | 2 + include/hw/pci-host/articia.h | 17 ++ tests/avocado/ppc_amiga.py | 37 +++ 11 files changed, 574 insertions(+), 5 deletions(-) create mode 100644 hw/pci-host/articia.c create mode 100644 hw/ppc/amigaone.c create mode 100644 include/hw/pci-host/articia.h create mode 100644 tests/avocado/ppc_amiga.py
Signature · 1 line
2.30.9
PATCH v4 2/4 hw/pci-host: Add emulation of Mai Logic Articia S
The Articia S is a generic chipset supporting several different CPUs that were among others used on some PPC boards. This is a minimal emulation of the parts needed for emulating the AmigaOne board.
--- hw/pci-host/Kconfig | 5 + hw/pci-host/articia.c | 293 ++++++++++++++++++++++++++++++++++ hw/pci-host/meson.build | 2 + include/hw/pci-host/articia.h | 17 ++ 4 files changed, 317 insertions(+) create mode 100644 hw/pci-host/articia.c create mode 100644 include/hw/pci-host/articia.h
hw/pci-host/Kconfig +5 -0
@@ -73,6 +73,11 @@ config SH_PCI bool select PCI +config ARTICIA + bool + select PCI + select I8259 + config MV64361 bool select PCI
hw/pci-host/articia.c new file +293 -0
293 lines not on this page · raw message
hw/pci-host/meson.build +2 -0
@@ -20,6 +20,8 @@ pci_ss.add(when: 'CONFIG_GRACKLE_PCI', if_true: files('grackle.c')) pci_ss.add(when: 'CONFIG_UNIN_PCI', if_true: files('uninorth.c')) # PowerPC E500 boards pci_ss.add(when: 'CONFIG_PPCE500_PCI', if_true: files('ppce500.c')) +# AmigaOne +pci_ss.add(when: 'CONFIG_ARTICIA', if_true: files('articia.c')) # Pegasos2 pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c'))
include/hw/pci-host/articia.h new file +17 -0
@@ -0,0 +1,17 @@ +/* +* Mai Logic Articia S emulation +* +* Copyright (c) 2023 BALATON Zoltan +* +* This work is licensed under the GNU GPL license version 2 or later. +* +*/ + +#ifndef ARTICIA_H +#define ARTICIA_H + +#define TYPE_ARTICIA "articia" +#define TYPE_ARTICIA_PCI_HOST "articia-pci-host" +#define TYPE_ARTICIA_PCI_BRIDGE "articia-pci-bridge" + +#endif
Signature · 1 line
2.30.9
PATCH v4 1/4 via-ide: Fix legacy mode emulation
In reply to BALATON ZoltanThe initial value for BARs were set in reset method for emulating legacy mode at start but this does not work because PCI code resets BARs after calling device reset method. Remove this ineffective default to avoid confusion.
Instead move setting the BARs to a callback on writing the PCI config regsiter that sets legacy mode (which firmwares needing this mode seem to do). This does not fully emulate what the data sheet says (which is not very clear on this) but it implements enough to allow both modes as used by firmwares and guests on machines we emulate.
--- hw/ide/via.c | 43 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 5 deletions(-)
hw/ide/via.c +38 -5
@@ -28,6 +28,7 @@#include "hw/pci/pci.h" #include "migration/vmstate.h" #include "qemu/module.h" +#include "qemu/range.h" #include "sysemu/dma.h" #include "hw/isa/vt82c686.h" #include "hw/ide/pci.h"
@@ -132,11 +133,6 @@ static void via_ide_reset(DeviceState *dev)pci_set_word (pci_conf +PCI_STATUS ,PCI_STATUS_FAST_BACK |PCI_STATUS_DEVSEL_MEDIUM ); -pci_set_long (pci_conf +PCI_BASE_ADDRESS_0 ,0x000001f0 ); -pci_set_long (pci_conf +PCI_BASE_ADDRESS_1 ,0x000003f4 ); -pci_set_long (pci_conf +PCI_BASE_ADDRESS_2 ,0x00000170 ); -pci_set_long (pci_conf +PCI_BASE_ADDRESS_3 ,0x00000374 ); -pci_set_long (pci_conf +PCI_BASE_ADDRESS_4 ,0x0000cc01 );/* BMIBA: 20-23h */ pci_set_long (pci_conf +PCI_INTERRUPT_LINE ,0x0000010e );/* IDE chip enable, IDE configuration 1/2, IDE FIFO Configuration*/
@@ -159,6 +155,42 @@ static void via_ide_reset(DeviceState *dev)pci_set_long (pci_conf +0xc0 ,0x00020001 ); } +static void via_ide_cfg_write (PCIDevice *pd,uint32_t addr, +uint32_t val,int len) +{ +pci_default_write_config (pd, addr, val, len); +/* +* Bits 0 and 2 of the PCI programming interface register are documented to +* select between legacy and native mode for the two IDE channels. when the +* guest selects legacy mode we reset the PCI BARs to legacy ports which is +* their default value. We don't care about setting each channel separately +* as no guest is known to do or need that. But only do this when BARs are +* unset when writing this register as logs from real hardware show that +* setting legacy mode after BARs were set will still use ports set by BARs +* not ISA ports (Linux on pegasos2 does this after firmware set native +* mode and programmed BARs). If 0x8a is written after reset without +* setting BARs then we want legacy ports (this is done by the AmigaOne +* firmware). We can't set these in via_ide_reset() because PCI code clears +* BARs after calling device reset method. +*/ +if (range_covers_byte (addr, len,PCI_CLASS_PROG ) && + pd->config[PCI_CLASS_PROG ] ==0x8a && +pci_get_long (pd->config +PCI_BASE_ADDRESS_0 ) == +PCI_BASE_ADDRESS_SPACE_IO ) { +pci_set_long (pd->config +PCI_BASE_ADDRESS_0 ,0x1f0 + |PCI_BASE_ADDRESS_SPACE_IO ); +pci_set_long (pd->config +PCI_BASE_ADDRESS_1 ,0x3f4 + |PCI_BASE_ADDRESS_SPACE_IO ); +pci_set_long (pd->config +PCI_BASE_ADDRESS_2 ,0x170 + |PCI_BASE_ADDRESS_SPACE_IO ); +pci_set_long (pd->config +PCI_BASE_ADDRESS_3 ,0x374 + |PCI_BASE_ADDRESS_SPACE_IO ); +/* BMIBA: 20-23h */ +pci_set_long (pd->config +PCI_BASE_ADDRESS_4 ,0xcc00 + |PCI_BASE_ADDRESS_SPACE_IO ); + } +} +static void via_ide_realize (PCIDevice *dev,Error **errp) {PCIIDEState *d =PCI_IDE (dev);
@@ -221,6 +253,7 @@ static void via_ide_class_init(ObjectClass *klass, void *data)/* Reason: only works as function of VIA southbridge */ dc->user_creatable = false; + k->config_write = via_ide_cfg_write; k->realize = via_ide_realize; k->exit = via_ide_exitfn; k->vendor_id =PCI_VENDOR_ID_VIA ;
Signature · 1 line
2.30.9
PATCH v4 3/4 hw/ppc: Add emulation of AmigaOne XE board
In reply to BALATON ZoltanThe AmigaOne is a rebranded MAI Teron board that uses U-Boot firmware with patches to support AmigaOS and is very similar to pegasos2 so can be easily emulated sharing most code with pegasos2. The reason to emulate it is that AmigaOS comes in different versions for AmigaOne and PegasosII which only have drivers for one machine and firmware so these only run on the specific machine. Adding this board allows another AmigaOS version to be used reusing already existing peagasos2 emulation. (The AmigaOne was the first of these boards so likely most widespread which then inspired Pegasos that was later replaced with PegasosII due to problems with Articia S, so these have a lot of similarity. Pegasos mainly ran MorphOS while the PegasosII version of AmigaOS was added later and therefore less common than the AmigaOne version.)
--- MAINTAINERS | 8 ++ configs/devices/ppc-softmmu/default.mak | 1 + hw/ppc/Kconfig | 7 + hw/ppc/amigaone.c | 164 ++++++++++++++++++++++++ hw/ppc/meson.build | 2 + 5 files changed, 182 insertions(+) create mode 100644 hw/ppc/amigaone.c
MAINTAINERS +8 -0
@@ -1508,6 +1508,14 @@ F: hw/pci-host/mv64361.c F: hw/pci-host/mv643xx.h F: include/hw/pci-host/mv64361.h +amigaone +M: BALATON Zoltan <[email protected]> +L: [email protected] +S: Maintained +F: hw/ppc/amigaone.c +F: hw/pci-host/articia.c +F: include/hw/pci-host/articia.h + Virtual Open Firmware (VOF) M: Alexey Kardashevskiy <[email protected]> R: David Gibson <[email protected]>
configs/devices/ppc-softmmu/default.mak +1 -0
@@ -14,6 +14,7 @@ CONFIG_SAM460EX=y CONFIG_MAC_OLDWORLD=y CONFIG_MAC_NEWWORLD=y +CONFIG_AMIGAONE=y CONFIG_PEGASOS2=y # For PReP
hw/ppc/Kconfig +7 -0
@@ -69,6 +69,13 @@ config SAM460EX select USB_OHCI select FDT_PPC +config AMIGAONE + bool + imply ATI_VGA + select ARTICIA + select VT82C686 + select SMBUS_EEPROM + config PEGASOS2 bool imply ATI_VGA
hw/ppc/amigaone.c new file +164 -0
164 lines not on this page · raw message
hw/ppc/meson.build +2 -0
@@ -81,6 +81,8 @@ ppc_ss.add(when: 'CONFIG_E500', if_true: files( )) # PowerPC 440 Xilinx ML507 reference board. ppc_ss.add(when: 'CONFIG_VIRTEX', if_true: files('virtex_ml507.c')) +# a1xe +ppc_ss.add(when: 'CONFIG_AMIGAONE', if_true: files('amigaone.c')) # Pegasos2 ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c'))
Signature · 1 line
2.30.9
RFC PATCH v4 4/4 tests/avocado: Add test for amigaone board
In reply to BALATON Zoltan---
I have no idea if this works so testing and corrections are welcome but this could be a basic test. Booting further is a bit more involved as we'd need alternative VGA BIOS and selecting menu items in the firmware to allow CD boot so I did not try to automate that.
This could be simpler if the u-boot-amigaone.bin could be added to pc-bios. It's GPL so should be OK to include and distribute but irs sources seem to be lost and could not be recovered or reconstructed so we only have this binary. Who should be able to decide about that?
tests/avocado/ppc_amiga.py | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/avocado/ppc_amiga.py
tests/avocado/ppc_amiga.py new file +37 -0
@@ -0,0 +1,37 @@ +# Test AmigaNG boards +# +# Copyright (c) 2023 BALATON Zoltan +# +# This work is licensed under the terms of the GNU GPL, version 2 or +# later. See the COPYING file in the top-level directory. + +from avocado.utils import archive +from avocado.utils import process +from avocado_qemu import QemuSystemTest +from avocado_qemu import wait_for_console_pattern + +class AmigaOneMachine(QemuSystemTest): + + timeout = 90 + + def test_ppc_amigaone(self): + """ + :avocado: tags=arch:ppc + :avocado: tags=machine:amigaone + :avocado: tags=cpu:7457 + :avocado: tags=device:articia + :avocado: tags=accel:tcg + """ + self.require_accelerator("tcg") + tar_url = ('https://www.hyperion-entertainment.com/index.php/' + 'downloads?view=download&format=raw&file=25') + tar_hash = 'c52e59bc73e31d8bcc3cc2106778f7ac84f6c755' + file_path = self.fetch_asset(tar_url, asset_hash=tar_hash) + archive.extract(file_path, self.workdir) + cmd = f"tail -c 524288 {self.workdir}/floppy_edition/updater.image >{self.workdir}/u-boot-amigaone.bin" + process.run(cmd) + + self.vm.set_console() + self.vm.add_args('-bios', self.workdir + '/u-boot-amigaone.bin') + self.vm.launch() + wait_for_console_pattern(self, 'FLASH:')
Signature · 1 line
2.30.9
Re: [RFC PATCH v4 4/4] tests/avocado: Add test for amigaone board
Please add a short patch description if this moves from RFC to a real patch
Quoted 3 lines · BALATON Zoltan
Signed-off-by BALATON Zoltan <[email protected]>---
I have no idea if this works so testing and corrections are welcome
Why don't you test it on your own? I think this should be sufficient:
make check-avocado AVOCADO_TAGS=machine:amigaone
Quoted 8 lines
but this could be a basic test. Booting further is a bit more involved as we'd need alternative VGA BIOS and selecting menu items in the firmware to allow CD boot so I did not try to automate that.
This could be simpler if the u-boot-amigaone.bin could be added to pc-bios. It's GPL so should be OK to include and distribute but irs sources seem to be lost and could not be recovered or reconstructed so we only have this binary. Who should be able to decide about that?
I'm sorry, but if the sources are not available anymore, then I think it will not be possible to ship the binary in the QEMU tarball - since the GPL requires that the distributor of the binary can also provide the sources on request.
Thomas
Re: [RFC PATCH v4 4/4] tests/avocado: Add test for amigaone board
Quoted 10 lines · Thomas Huth
Please add a short patch description if this moves from RFC to a real patch
Quoted 3 lines · BALATON Zoltan
Signed-off-by BALATON Zoltan <[email protected]>---
I have no idea if this works so testing and corrections are welcomeWhy don't you test it on your own? I think this should be sufficient:
make check-avocado AVOCADO_TAGS=machine:amigaone
Test doesn't pass :
Fetching asset from tests/avocado/ppc_amiga.py:AmigaOneMachine.test_ppc_amigaone
JOB ID : 39645d61f6f6c90ae87e3a48fe29beb16146aa73
JOB LOG : /home/legoater/work/qemu/qemu.git/build/tests/results/job-2023-10-18T05.51-39645d6/job.log
(1/1) tests/avocado/ppc_amiga.py:AmigaOneMachine.test_ppc_amigaone: ERROR: file is not an archive (0.10 s)
Interrupting job (failfast).
RESULTS : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 2.53 s
C.
Quoted 14 lines
Quoted 9 lines
but this could be a basic test. Booting further is a bit more involved as we'd need alternative VGA BIOS and selecting menu items in the firmware to allow CD boot so I did not try to automate that.
This could be simpler if the u-boot-amigaone.bin could be added to pc-bios. It's GPL so should be OK to include and distribute but irs sources seem to be lost and could not be recovered or reconstructed so we only have this binary. Who should be able to decide about that?
I'm sorry, but if the sources are not available anymore, then I think it will not be possible to ship the binary in the QEMU tarball - since the GPL requires that the distributor of the binary can also provide the sources on request.
Thomas
Re: [RFC PATCH v4 4/4] tests/avocado: Add test for amigaone board
Quoted 10 lines · Cédric Le Goater
Quoted 9 lines · Thomas Huth
Please add a short patch description if this moves from RFC to a real patch
Quoted 3 lines · BALATON Zoltan
Signed-off-by BALATON Zoltan <[email protected]>---
I have no idea if this works so testing and corrections are welcomeWhy don't you test it on your own? I think this should be sufficient:
Quoted 8 lines
Quoted 1 line
make check-avocado AVOCADO_TAGS=machine:amigaone
Test doesn't pass :
Fetching asset from tests/avocado/ppc_amiga.py:AmigaOneMachine.test_ppc_amigaone
JOB ID :39645d61f6f6c90ae87e3a48fe29beb16146aa73
JOB LOG :/home/legoater/work/qemu/qemu.git/build/tests/results/job-2023-10-18T05.51-39645d6/job.log
(1/1) tests/avocado/ppc_amiga.py:AmigaOneMachine.test_ppc_amigaone: ERROR: file is not an archive (0.10 s)
OK then how to extract a zip file? Does it need to have name ending with .zip to work? The download may end up in a strangely named file due to how the URL ends. Anybody knows how to fix this? I never used Avocado, only followed examples found in other tests but possible I did not get how it should work.
Regards,
BALATON Zoltan
Quoted 23 lines
Interrupting job (failfast).
RESULTS : PASS 0 | ERROR 1 | FAIL 0 | SKIP 0 | WARN 0 | INTERRUPT 0 | CANCEL 0
JOB TIME : 2.53 sC.
Quoted 14 lines
Quoted 9 lines
but this could be a basic test. Booting further is a bit more involved as we'd need alternative VGA BIOS and selecting menu items in the firmware to allow CD boot so I did not try to automate that.
This could be simpler if the u-boot-amigaone.bin could be added to pc-bios. It's GPL so should be OK to include and distribute but irs sources seem to be lost and could not be recovered or reconstructed so we only have this binary. Who should be able to decide about that?
I'm sorry, but if the sources are not available anymore, then I think it will not be possible to ship the binary in the QEMU tarball - since the GPL requires that the distributor of the binary can also provide the sources on request.
Thomas