Pegasos2 emulation
v9 cover Pegasos2 emulation
Hello,
This is adding a new PPC board called pegasos2. More info on it can be found at:
https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2
Currently it needs a firmware ROM image that I cannot include due to original copyright holder (bPlan) did not release it under a free licence but I have plans to write a replacement in the future. With the original board firmware it can boot MorphOS now as:
qemu-system-ppc -M pegasos2 -cdrom morphos.iso -device ati-vga,romfile="" -serial stdio
then enter "boot cd boot.img" at the firmware "ok" prompt as described in the MorphOS.readme. To boot Linux use same command line with e.g. -cdrom debian-8.11.0-powerpc-netinst.iso then enter
"boot cd install/pegasos"
The last patch adds the actual board code after previous patches adding VT8231 and MV64361 system controller chip emulation.
Regards,
BALATON Zoltan
v9: Rebased to master
v8: Do not emulate setting of serial port address via register, just
hard code a default address instead
v7: Fix errp usage in patch 2
v6: Rebased on master, updated commit message about migration change
v5: Changes for review comments from David and Philippe
V4: Rename pegasos2_reset to pegasos2_cpu_reset
Add new files to MAINTAINERS
BALATON Zoltan (6):
vt82c686: QOM-ify superio related functionality
vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO
vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it
vt82c686: Add emulation of VT8231 south bridge hw/pci-host: Add emulation of Marvell MV64361 PPC system controller hw/ppc: Add emulation of Genesi/bPlan Pegasos II
Philippe Mathieu-Daudé (1):
hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APM
MAINTAINERS | 10 + default-configs/devices/ppc-softmmu.mak | 2 + hw/isa/Kconfig | 1 + hw/isa/vt82c686.c | 422 +++++++++-- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++ hw/pci-host/trace-events | 6 + hw/ppc/Kconfig | 9 + hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++ include/hw/isa/vt82c686.h | 2 +- include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 4 +- 15 files changed, 2418 insertions(+), 82 deletions(-) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 hw/ppc/pegasos2.c create mode 100644 include/hw/pci-host/mv64361.h
Signature · 1 line
2.21.4
PATCH v9 2/7 vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO
The VT8231 south bridge is very similar to VT82C686B but there are some differences in register addresses and functionality, e.g. the VT8231 only has one serial port. This commit adds VT8231_SUPERIO subclass based on the abstract VIA_SUPERIO class to emulate the superio part of VT8231.
--- hw/isa/vt82c686.c | 102 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 102 insertions(+)
hw/isa/vt82c686.c +102 -0
@@ -417,6 +417,107 @@ static const TypeInfo vt82c686b_superio_info = { }; +#define TYPE_VT8231_SUPERIO "vt8231-superio" + +static void vt8231_superio_cfg_write (void *opaque,hwaddr addr, +uint64_t data,unsigned size) +{ +ViaSuperIOState *sc = opaque; +uint8_t idx = sc->regs[0 ]; + +if (addr ==0 ) {/* config index register */ + sc->regs[0 ] = data; +return ; + } + +/* config data register */ +trace_via_superio_write (idx, data); +switch (idx) { + case 0x00 ... 0xdf: + case 0xe7 ... 0xef: + case 0xf0 ... 0xf1: +case 0xf5 : +case 0xf8 : +case 0xfd : +/* ignore write to read only registers */ +return ; +default : +qemu_log_mask (LOG_UNIMP , +"via_superio_cfg: unimplemented register 0x%x\n" , idx); +break ; + } + sc->regs[idx] = data; +} + +static const MemoryRegionOps vt8231_superio_cfg_ops = { + .read = via_superio_cfg_read, + .write = vt8231_superio_cfg_write, + .endianness =DEVICE_NATIVE_ENDIAN , + .impl = { + .min_access_size =1 , + .max_access_size =1 , + }, +}; + +static void vt8231_superio_reset (DeviceState *dev) +{ +ViaSuperIOState *s =VIA_SUPERIO (dev); + +memset (s->regs,0 ,sizeof (s->regs)); +/* Device ID */ + s->regs[0xf0 ] =0x3c ; +/* Device revision */ + s->regs[0xf1 ] =0x01 ; +/* Function select - all disabled */ +vt8231_superio_cfg_write (s,0 ,0xf2 ,1 ); +vt8231_superio_cfg_write (s,1 ,0x03 ,1 ); +/* Serial port base addr */ +vt8231_superio_cfg_write (s,0 ,0xf4 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xfe ,1 ); +/* Parallel port base addr */ +vt8231_superio_cfg_write (s,0 ,0xf6 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xde ,1 ); +/* Floppy ctrl base addr */ +vt8231_superio_cfg_write (s,0 ,0xf7 ,1 ); +vt8231_superio_cfg_write (s,1 ,0xfc ,1 ); + +vt8231_superio_cfg_write (s,0 ,0 ,1 ); +} + +static void vt8231_superio_init (Object *obj) +{ +VIA_SUPERIO (obj)->io_ops = &vt8231_superio_cfg_ops; +} + +static uint16_t vt8231_superio_serial_iobase (ISASuperIODevice *sio, +uint8_t index) +{ +return 0x2f8 ;/* FIXME: This should be settable via registers f2-f4 */ +} + +static void vt8231_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + dc->reset = vt8231_superio_reset; + sc->serial.count =1 ; + sc->serial.get_iobase = vt8231_superio_serial_iobase; + sc->parallel.count =1 ; + sc->ide.count =0 ;/* emulated by via-ide */ + sc->floppy.count =1 ; +} + +static const TypeInfo vt8231_superio_info = { + .name =TYPE_VT8231_SUPERIO , + .parent =TYPE_VIA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .instance_init = vt8231_superio_init, + .class_size =sizeof (ISASuperIOClass), + .class_init = vt8231_superio_class_init, +}; + + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA)struct VT82C686BISAState {
@@ -540,6 +641,7 @@ static void vt82c686b_register_types(void)type_register_static (&vt8231_pm_info);type_register_static (&via_superio_info);type_register_static (&vt82c686b_superio_info); +type_register_static (&vt8231_superio_info);type_register_static (&via_info); }
Signature · 1 line
2.21.4
PATCH v9 1/7 vt82c686: QOM-ify superio related functionality
In reply to BALATON ZoltanCollect superio functionality and its controlling config registers handling in an abstract VIA_SUPERIO class that is a subclass of ISA_SUPERIO and put vt82c686b specific parts in a subclass of this abstract class.
--- hw/isa/vt82c686.c | 196 +++++++++++++++++++++++++------------- include/hw/isa/vt82c686.h | 1 - 2 files changed, 132 insertions(+), 65 deletions(-)
hw/isa/vt82c686.c +132 -64
@@ -249,15 +249,80 @@ static const TypeInfo vt8231_pm_info = { }; -typedef struct SuperIOConfig { +#define TYPE_VIA_SUPERIO "via-superio" +OBJECT_DECLARE_SIMPLE_TYPE(ViaSuperIOState, VIA_SUPERIO) + +struct ViaSuperIOState { +ISASuperIODevice superio;uint8_t regs[0x100 ]; +const MemoryRegionOps *io_ops;MemoryRegion io; -}SuperIOConfig ; +}; + +static inline void via_superio_io_enable (ViaSuperIOState *s,bool enable) +{ +memory_region_set_enabled (&s->io, enable); +} + +static void via_superio_realize (DeviceState *d,Error **errp) +{ +ViaSuperIOState *s =VIA_SUPERIO (d); +ISASuperIOClass *ic =ISA_SUPERIO_GET_CLASS (s); +Error *local_err =NULL ; + +assert (s->io_ops); + ic->parent_realize (d, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +memory_region_init_io (&s->io,OBJECT (d), s->io_ops, s,"via-superio" ,2 ); +memory_region_set_enabled (&s->io, false); +/* The floppy also uses 0x3f0 and 0x3f1 but this seems to work anyway */ +memory_region_add_subregion (isa_address_space_io (ISA_DEVICE (s)),0x3f0 , + &s->io); +} + +static uint64_t via_superio_cfg_read (void *opaque,hwaddr addr,unsigned size) +{ +ViaSuperIOState *sc = opaque; +uint8_t idx = sc->regs[0 ]; +uint8_t val = sc->regs[idx]; + +if (addr ==0 ) { +return idx; + } +if (addr ==1 && idx ==0 ) { + val =0 ;/* reading reg 0 where we store index value */ + } +trace_via_superio_read (idx, val); +return val; +} + +static void via_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + sc->parent_realize = dc->realize; + dc->realize = via_superio_realize; +} + +static const TypeInfo via_superio_info = { + .name =TYPE_VIA_SUPERIO , + .parent =TYPE_ISA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .class_size =sizeof (ISASuperIOClass), + .class_init = via_superio_class_init, + .abstract = true, +}; + +#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" -static void superio_cfg_write (void *opaque,hwaddr addr,uint64_t data, -unsigned size) +static void vt82c686b_superio_cfg_write (void *opaque,hwaddr addr, +uint64_t data,unsigned size) { -SuperIOConfig *sc = opaque; +ViaSuperIOState *sc = opaque;uint8_t idx = sc->regs[0 ];if (addr ==0 ) {/* config index register */
@@ -288,25 +353,9 @@ static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, sc->regs[idx] = data; } -static uint64_t superio_cfg_read (void *opaque,hwaddr addr,unsigned size) -{ -SuperIOConfig *sc = opaque; -uint8_t idx = sc->regs[0 ]; -uint8_t val = sc->regs[idx]; - -if (addr ==0 ) { -return idx; - } -if (addr ==1 && idx ==0 ) { - val =0 ;/* reading reg 0 where we store index value */ - } -trace_via_superio_read (idx, val); -return val; -} - -static const MemoryRegionOps superio_cfg_ops = { - .read = superio_cfg_read, - .write = superio_cfg_write, +static const MemoryRegionOps vt82c686b_superio_cfg_ops = { + .read = via_superio_cfg_read, + .write = vt82c686b_superio_cfg_write, .endianness =DEVICE_NATIVE_ENDIAN , .impl = { .min_access_size =1 ,
@@ -314,13 +363,66 @@ static const MemoryRegionOps superio_cfg_ops = { }, }; +static void vt82c686b_superio_reset (DeviceState *dev) +{ +ViaSuperIOState *s =VIA_SUPERIO (dev); + +memset (s->regs,0 ,sizeof (s->regs)); +/* Device ID */ +vt82c686b_superio_cfg_write (s,0 ,0xe0 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x3c ,1 ); +/* Function select - all disabled */ +vt82c686b_superio_cfg_write (s,0 ,0xe2 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x03 ,1 ); +/* Floppy ctrl base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe3 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfc ,1 ); +/* Parallel port base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe6 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xde ,1 ); +/* Serial port 1 base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe7 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfe ,1 ); +/* Serial port 2 base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe8 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xbe ,1 ); + +vt82c686b_superio_cfg_write (s,0 ,0 ,1 ); +} + +static void vt82c686b_superio_init (Object *obj) +{ +VIA_SUPERIO (obj)->io_ops = &vt82c686b_superio_cfg_ops; +} + +static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + dc->reset = vt82c686b_superio_reset; + sc->serial.count =2 ; + sc->parallel.count =1 ; + sc->ide.count =0 ;/* emulated by via-ide */ + sc->floppy.count =1 ; +} + +static const TypeInfo vt82c686b_superio_info = { + .name =TYPE_VT82C686B_SUPERIO , + .parent =TYPE_VIA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .instance_init = vt82c686b_superio_init, + .class_size =sizeof (ISASuperIOClass), + .class_init = vt82c686b_superio_class_init, +}; + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA)struct VT82C686BISAState {PCIDevice dev;qemu_irq cpu_intr; -SuperIOConfig superio_cfg; +ViaSuperIOState *via_sio; };static void via_isa_request_i8259_irq (void *opaque,int irq,int level)
@@ -338,7 +440,7 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr,pci_default_write_config (d, addr, val, len);if (addr ==0x85 ) {/* BIT(1): enable or disable superio config io ports */ -memory_region_set_enabled (&s->superio_cfg.io, val &BIT (1 )); +via_superio_io_enable (s->via_sio, val &BIT (1 )); } }
@@ -370,13 +472,6 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5a ] =0x04 ;/* KBC/RTC Control*/ pci_conf[0x5f ] =0x04 ; pci_conf[0x77 ] =0x10 ;/* GPIO Control 1/2/3/4 */ - - s->superio_cfg.regs[0xe0 ] =0x3c ;/* Device ID */ - s->superio_cfg.regs[0xe2 ] =0x03 ;/* Function select */ - s->superio_cfg.regs[0xe3 ] =0xfc ;/* Floppy ctrl base addr */ - s->superio_cfg.regs[0xe6 ] =0xde ;/* Parallel port base addr */ - s->superio_cfg.regs[0xe7 ] =0xfe ;/* Serial port 1 base addr */ - s->superio_cfg.regs[0xe8 ] =0xbe ;/* Serial port 2 base addr */ }static void vt82c686b_realize (PCIDevice *d,Error **errp)
@@ -394,7 +489,8 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)isa_bus_irqs (isa_bus,i8259_init (isa_bus, *isa_irq));i8254_pit_init (isa_bus,0x40 ,0 ,NULL );i8257_dma_init (isa_bus,0 ); -isa_create_simple (isa_bus,TYPE_VT82C686B_SUPERIO ); + s->via_sio =VIA_SUPERIO (isa_create_simple (isa_bus, +TYPE_VT82C686B_SUPERIO ));mc146818_rtc_init (isa_bus,2000 ,NULL );for (i =0 ; i <PCI_CONFIG_HEADER_SIZE ; i++) {
@@ -402,16 +498,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp) d->wmask[i] =0 ; } } - -memory_region_init_io (&s->superio_cfg.io,OBJECT (d), &superio_cfg_ops, - &s->superio_cfg,"superio_cfg" ,2 ); -memory_region_set_enabled (&s->superio_cfg.io, false); -/* -* The floppy also uses 0x3f0 and 0x3f1. -* But we do not emulate a floppy, so just set it here. -*/ -memory_region_add_subregion (isa_bus->address_space_io,0x3f0 , - &s->superio_cfg.io); }static void via_class_init (ObjectClass *klass,void *data)
@@ -447,32 +533,14 @@ static const TypeInfo via_info = { }; -static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) -{ -ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); - - sc->serial.count =2 ; - sc->parallel.count =1 ; - sc->ide.count =0 ; - sc->floppy.count =1 ; -} - -static const TypeInfo via_superio_info = { - .name =TYPE_VT82C686B_SUPERIO , - .parent =TYPE_ISA_SUPERIO , - .instance_size =sizeof (ISASuperIODevice), - .class_size =sizeof (ISASuperIOClass), - .class_init = vt82c686b_superio_class_init, -}; - -static void vt82c686b_register_types (void ) {type_register_static (&via_pm_info);type_register_static (&vt82c686b_pm_info);type_register_static (&vt8231_pm_info); -type_register_static (&via_info);type_register_static (&via_superio_info); +type_register_static (&vt82c686b_superio_info); +type_register_static (&via_info); }type_init (vt82c686b_register_types)
include/hw/isa/vt82c686.h +0 -1
@@ -2,7 +2,6 @@#define HW_VT82C686_H #define TYPE_VT82C686B_ISA "vt82c686b-isa" -#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"#define TYPE_VT82C686B_PM "vt82c686b-pm"#define TYPE_VT8231_PM "vt8231-pm"#define TYPE_VIA_AC97 "via-ac97"
Signature · 1 line
2.21.4
PATCH v9 6/7 hw/pci-host: Add emulation of Marvell MV64361 PPC system controller
In reply to BALATON ZoltanThe Marvell Discovery II aka. MV64361 is a PowerPC system controller chip that is used on the pegasos2 PPC board. This adds emulation of it that models the device enough to boot guests on this board. The mv643xx.h header with register definitions is taken from Linux 4.15.10 only fixing white space errors, removing not needed parts and changing formatting for QEMU coding style.
--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 6 + include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 1 + 7 files changed, 1905 insertions(+) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 include/hw/pci-host/mv64361.h
hw/pci-host/Kconfig +4 -0
@@ -72,3 +72,7 @@ config REMOTE_PCIHOST config SH_PCI bool select PCI + +config MV64361 + bool + select PCI
hw/pci-host/meson.build +2 -0
@@ -19,6 +19,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')) +# Pegasos2 +pci_ss.add(when: 'CONFIG_MV64361', if_true: files('mv64361.c')) # ARM devices pci_ss.add(when: 'CONFIG_VERSATILE_PCI', if_true: files('versatile.c'))
hw/pci-host/mv64361.c new file +966 -0
966 lines not on this page · raw message
hw/pci-host/mv643xx.h new file +918 -0
918 lines not on this page · raw message
hw/pci-host/trace-events +6 -0
@@ -3,6 +3,12 @@ # grackle.c grackle_set_irq(int irq_num, int level) "set_irq num %d level %d" +# mv64361.c +mv64361_region_map(const char *name, uint64_t poffs, uint64_t size, uint64_t moffs) "Mapping %s 0x%"PRIx64"+0x%"PRIx64" @ 0x%"PRIx64 +mv64361_region_enable(const char *op, int num) "Should %s region %d" +mv64361_reg_read(uint64_t addr, uint32_t val) "0x%"PRIx64" -> 0x%x" +mv64361_reg_write(uint64_t addr, uint64_t val) "0x%"PRIx64" <- 0x%"PRIx64 + # sabre.c sabre_set_request(int irq_num) "request irq %d" sabre_clear_request(int irq_num) "clear request irq %d"
include/hw/pci-host/mv64361.h new file +8 -0
@@ -0,0 +1,8 @@ +#ifndef MV64361_H +#define MV64361_H + +#define TYPE_MV64361 "mv64361" + +PCIBus *mv64361_get_pci_bus (DeviceState *dev,int n); + +#endif
include/hw/pci/pci_ids.h +1 -0
@@ -214,6 +214,7 @@#define PCI_DEVICE_ID_VIA_8231_PM 0x8235#define PCI_VENDOR_ID_MARVELL 0x11ab +#define PCI_DEVICE_ID_MARVELL_MV6436X 0x6460#define PCI_VENDOR_ID_SILICON_MOTION 0x126f#define PCI_DEVICE_ID_SM501 0x0501
Signature · 1 line
2.21.4
PATCH v9 4/7 vt82c686: Add emulation of VT8231 south bridge
In reply to BALATON ZoltanAdd emulation of VT8231 south bridge ISA part based on the similar VT82C686B but implemented in a separate subclass that holds the differences while reusing parts that can be shared.
--- hw/isa/vt82c686.c | 84 +++++++++++++++++++++++++++++++++++++++ include/hw/isa/vt82c686.h | 1 + include/hw/pci/pci_ids.h | 1 + 3 files changed, 86 insertions(+)
hw/isa/vt82c686.c +84 -0
@@ -8,6 +8,9 @@* * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. +* +* VT8231 south bridge support and general clean up to allow it +* Copyright (c) 2018-2020 BALATON Zoltan */ #include "qemu/osdep.h"
@@ -640,6 +643,86 @@ static const TypeInfo vt82c686b_isa_info = { .class_init = vt82c686b_class_init, }; +/* TYPE_VT8231_ISA */ + +static void vt8231_write_config (PCIDevice *d,uint32_t addr, +uint32_t val,int len) +{ +ViaISAState *s =VIA_ISA (d); + +trace_via_isa_write (addr, val, len); +pci_default_write_config (d, addr, val, len); +if (addr ==0x50 ) { +/* BIT(2): enable or disable superio config io ports */ +via_superio_io_enable (s->via_sio, val &BIT (2 )); + } +} + +static void vt8231_isa_reset (DeviceState *dev) +{ +ViaISAState *s =VIA_ISA (dev); +uint8_t *pci_conf = s->dev.config; + +pci_set_long (pci_conf +PCI_CAPABILITY_LIST ,0x000000c0 ); +pci_set_word (pci_conf +PCI_COMMAND ,PCI_COMMAND_IO |PCI_COMMAND_MEMORY | +PCI_COMMAND_MASTER |PCI_COMMAND_SPECIAL ); +pci_set_word (pci_conf +PCI_STATUS ,PCI_STATUS_DEVSEL_MEDIUM ); + + pci_conf[0x58 ] =0x40 ;/* Miscellaneous Control 0 */ + pci_conf[0x67 ] =0x08 ;/* Fast IR Config */ + pci_conf[0x6b ] =0x01 ;/* Fast IR I/O Base */ +} + +static void vt8231_realize (PCIDevice *d,Error **errp) +{ +ViaISAState *s =VIA_ISA (d); +DeviceState *dev =DEVICE (d); +ISABus *isa_bus; +qemu_irq *isa_irq; +int i; + +qdev_init_gpio_out (dev, &s->cpu_intr,1 ); + isa_irq =qemu_allocate_irqs (via_isa_request_i8259_irq, s,1 ); + isa_bus =isa_bus_new (dev,get_system_memory (),pci_address_space_io (d), + &error_fatal); +isa_bus_irqs (isa_bus,i8259_init (isa_bus, *isa_irq)); +i8254_pit_init (isa_bus,0x40 ,0 ,NULL ); +i8257_dma_init (isa_bus,0 ); + s->via_sio =VIA_SUPERIO (isa_create_simple (isa_bus,TYPE_VT8231_SUPERIO )); +mc146818_rtc_init (isa_bus,2000 ,NULL ); + +for (i =0 ; i <PCI_CONFIG_HEADER_SIZE ; i++) { +if (i <PCI_COMMAND || i >=PCI_REVISION_ID ) { + d->wmask[i] =0 ; + } + } +} + +static void vt8231_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +PCIDeviceClass *k =PCI_DEVICE_CLASS (klass); + + k->realize = vt8231_realize; + k->config_write = vt8231_write_config; + k->vendor_id =PCI_VENDOR_ID_VIA ; + k->device_id =PCI_DEVICE_ID_VIA_8231_ISA ; + k->class_id =PCI_CLASS_BRIDGE_ISA ; + k->revision =0x10 ; + dc->reset = vt8231_isa_reset; + dc->desc ="ISA bridge" ; + dc->vmsd = &vmstate_via; +/* Reason: part of VIA VT8231 southbridge, needs to be wired up */ + dc->user_creatable = false; +} + +static const TypeInfo vt8231_isa_info = { + .name =TYPE_VT8231_ISA , + .parent =TYPE_VIA_ISA , + .instance_size =sizeof (ViaISAState), + .class_init = vt8231_class_init, +}; +static void vt82c686b_register_types (void ) {
@@ -651,6 +734,7 @@ static void vt82c686b_register_types(void)type_register_static (&vt8231_superio_info);type_register_static (&via_isa_info);type_register_static (&vt82c686b_isa_info); +type_register_static (&vt8231_isa_info); }type_init (vt82c686b_register_types)
include/hw/isa/vt82c686.h +1 -0
@@ -3,6 +3,7 @@#define TYPE_VT82C686B_ISA "vt82c686b-isa"#define TYPE_VT82C686B_PM "vt82c686b-pm" +#define TYPE_VT8231_ISA "vt8231-isa"#define TYPE_VT8231_PM "vt8231-pm"#define TYPE_VIA_AC97 "via-ac97"#define TYPE_VIA_MC97 "via-mc97"
include/hw/pci/pci_ids.h +1 -0
@@ -210,6 +210,7 @@#define PCI_DEVICE_ID_VIA_82C686B_PM 0x3057#define PCI_DEVICE_ID_VIA_AC97 0x3058#define PCI_DEVICE_ID_VIA_MC97 0x3068 +#define PCI_DEVICE_ID_VIA_8231_ISA 0x8231#define PCI_DEVICE_ID_VIA_8231_PM 0x8235#define PCI_VENDOR_ID_MARVELL 0x11ab
Signature · 1 line
2.21.4
PATCH v9 3/7 vt82c686: Introduce abstract TYPE_VIA_ISA and base vt82c686b_isa on it
In reply to BALATON ZoltanTo allow reusing ISA bridge emulation for vt8231_isa move the device state of vt82c686b_isa emulation in an abstract via_isa class. This change breaks migration back compatibility but this is not an issue for Fuloong2E machine which is not versioned or migration supported.
--- hw/isa/vt82c686.c | 70 ++++++++++++++++++++++------------------ include/hw/pci/pci_ids.h | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-)
hw/isa/vt82c686.c +39 -31
@@ -518,24 +518,48 @@ static const TypeInfo vt8231_superio_info = { }; -OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) +#define TYPE_VIA_ISA "via-isa" +OBJECT_DECLARE_SIMPLE_TYPE(ViaISAState, VIA_ISA) -struct VT82C686BISAState { +struct ViaISAState {PCIDevice dev;qemu_irq cpu_intr;ViaSuperIOState *via_sio; }; +static const VMStateDescription vmstate_via = { + .name ="via-isa" , + .version_id =1 , + .minimum_version_id =1 , + .fields = (VMStateField []) { +VMSTATE_PCI_DEVICE (dev, ViaISAState), +VMSTATE_END_OF_LIST () + } +}; + +static const TypeInfo via_isa_info = { + .name =TYPE_VIA_ISA , + .parent =TYPE_PCI_DEVICE , + .instance_size =sizeof (ViaISAState), + .abstract = true, + .interfaces = (InterfaceInfo []) { + {INTERFACE_CONVENTIONAL_PCI_DEVICE }, + { }, + }, +}; +static void via_isa_request_i8259_irq (void *opaque,int irq,int level) { -VT82C686BISAState *s = opaque; +ViaISAState *s = opaque;qemu_set_irq (s->cpu_intr, level); } +/* TYPE_VT82C686B_ISA */ +static void vt82c686b_write_config (PCIDevice *d,uint32_t addr,uint32_t val,int len) { -VT82C686BISAState *s =VT82C686B_ISA (d); +ViaISAState *s =VIA_ISA (d);trace_via_isa_write (addr, val, len);pci_default_write_config (d, addr, val, len);
@@ -545,19 +569,9 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, } } -static const VMStateDescription vmstate_via = { - .name ="vt82c686b" , - .version_id =1 , - .minimum_version_id =1 , - .fields = (VMStateField []) { -VMSTATE_PCI_DEVICE (dev, VT82C686BISAState), -VMSTATE_END_OF_LIST () - } -}; -static void vt82c686b_isa_reset (DeviceState *dev) { -VT82C686BISAState *s =VT82C686B_ISA (dev); +ViaISAState *s =VIA_ISA (dev);uint8_t *pci_conf = s->dev.config;pci_set_long (pci_conf +PCI_CAPABILITY_LIST ,0x000000c0 );
@@ -577,7 +591,7 @@ static void vt82c686b_isa_reset(DeviceState *dev)static void vt82c686b_realize (PCIDevice *d,Error **errp) { -VT82C686BISAState *s =VT82C686B_ISA (d); +ViaISAState *s =VIA_ISA (d);DeviceState *dev =DEVICE (d);ISABus *isa_bus;qemu_irq *isa_irq;
@@ -601,7 +615,7 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp) } } -static void via_class_init (ObjectClass *klass,void *data) +static void vt82c686b_class_init (ObjectClass *klass,void *data) {DeviceClass *dc =DEVICE_CLASS (klass);PCIDeviceClass *k =PCI_DEVICE_CLASS (klass);
@@ -609,28 +623,21 @@ static void via_class_init(ObjectClass *klass, void *data) k->realize = vt82c686b_realize; k->config_write = vt82c686b_write_config; k->vendor_id =PCI_VENDOR_ID_VIA ; - k->device_id =PCI_DEVICE_ID_VIA_ISA_BRIDGE ; + k->device_id =PCI_DEVICE_ID_VIA_82C686B_ISA ; k->class_id =PCI_CLASS_BRIDGE_ISA ; k->revision =0x40 ; dc->reset = vt82c686b_isa_reset; dc->desc ="ISA bridge" ; dc->vmsd = &vmstate_via; -/* -* Reason: part of VIA VT82C686 southbridge, needs to be wired up, -* e.g. by mips_fuloong2e_init() -*/ +/* Reason: part of VIA VT82C686 southbridge, needs to be wired up */ dc->user_creatable = false; } -static const TypeInfo via_info = { +static const TypeInfo vt82c686b_isa_info = { .name =TYPE_VT82C686B_ISA , - .parent =TYPE_PCI_DEVICE , - .instance_size =sizeof (VT82C686BISAState), - .class_init = via_class_init, - .interfaces = (InterfaceInfo []) { - {INTERFACE_CONVENTIONAL_PCI_DEVICE }, - { }, - }, + .parent =TYPE_VIA_ISA , + .instance_size =sizeof (ViaISAState), + .class_init = vt82c686b_class_init, };
@@ -642,7 +649,8 @@ static void vt82c686b_register_types(void)type_register_static (&via_superio_info);type_register_static (&vt82c686b_superio_info);type_register_static (&vt8231_superio_info); -type_register_static (&via_info); +type_register_static (&via_isa_info); +type_register_static (&vt82c686b_isa_info); }type_init (vt82c686b_register_types)
include/hw/pci/pci_ids.h +1 -1
@@ -204,7 +204,7 @@#define PCI_VENDOR_ID_XILINX 0x10ee#define PCI_VENDOR_ID_VIA 0x1106 -#define PCI_DEVICE_ID_VIA_ISA_BRIDGE 0x0686 +#define PCI_DEVICE_ID_VIA_82C686B_ISA 0x0686#define PCI_DEVICE_ID_VIA_IDE 0x0571#define PCI_DEVICE_ID_VIA_UHCI 0x3038#define PCI_DEVICE_ID_VIA_82C686B_PM 0x3057
Signature · 1 line
2.21.4
PATCH v9 7/7 hw/ppc: Add emulation of Genesi/bPlan Pegasos II
In reply to BALATON ZoltanAdd new machine called pegasos2 emulating the Genesi/bPlan Pegasos II, a PowerPC board based on the Marvell MV64361 system controller and the VIA VT8231 integrated south bridge/superio chips. It can run Linux, AmigaOS and a wide range of MorphOS versions. Currently a firmware ROM image is needed to boot and only MorphOS has a video driver to produce graphics output. Linux could work too but distros that supported this machine don't include usual video drivers so those only run with serial console for now.
--- MAINTAINERS | 10 ++ default-configs/devices/ppc-softmmu.mak | 2 + hw/ppc/Kconfig | 9 ++ hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++++++++++++++++++++++ 5 files changed, 167 insertions(+) create mode 100644 hw/ppc/pegasos2.c
MAINTAINERS +10 -0
@@ -1353,6 +1353,16 @@ F: pc-bios/canyonlands.dt[sb] F: pc-bios/u-boot-sam460ex-20100605.bin F: roms/u-boot-sam460ex +pegasos2 +M: BALATON Zoltan <[email protected]> +R: David Gibson <[email protected]> +L: [email protected] +S: Maintained +F: hw/ppc/pegasos2.c +F: hw/pci-host/mv64361.c +F: hw/pci-host/mv643xx.h +F: include/hw/pci-host/mv64361.h + RISC-V Machines --------------- OpenTitan
default-configs/devices/ppc-softmmu.mak +2 -0
@@ -14,5 +14,7 @@ CONFIG_SAM460EX=y CONFIG_MAC_OLDWORLD=y CONFIG_MAC_NEWWORLD=y +CONFIG_PEGASOS2=y + # For PReP CONFIG_PREP=y
hw/ppc/Kconfig +9 -0
@@ -68,6 +68,15 @@ config SAM460EX select USB_OHCI select FDT_PPC +config PEGASOS2 + bool + select MV64361 + select VT82C686 + select IDE_VIA + select SMBUS_EEPROM +# This should come with VT82C686 + select ACPI_X86 + config PREP bool imply PCI_DEVICES
hw/ppc/meson.build +2 -0
@@ -78,5 +78,7 @@ 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')) +# Pegasos2 +ppc_ss.add(when: 'CONFIG_PEGASOS2', if_true: files('pegasos2.c')) hw_arch += {'ppc': ppc_ss}
hw/ppc/pegasos2.c new file +144 -0
144 lines not on this page · raw message
Signature · 1 line
2.21.4
PATCH v9 5/7 hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APM
In reply to BALATON ZoltanFrom: Philippe Mathieu-Daudé <[email protected]>
TYPE_VIA_PM calls apm_init() in via_pm_realize(), so requires APM to be selected.
--- hw/isa/Kconfig | 1 + 1 file changed, 1 insertion(+)
hw/isa/Kconfig +1 -0
@@ -48,6 +48,7 @@ config VT82C686 select SERIAL_ISA select FDC select USB_UHCI + select APM config SMC37C669 bool
Signature · 1 line
2.21.4
Re: [PATCH v9 1/7] vt82c686: QOM-ify superio related functionality
In reply to BALATON ZoltanQuoted 150 lines · BALATON Zoltan
Collect superio functionality and its controlling config registers handling in an abstract
VIA_SUPERIOclass that is a subclass ofISA_SUPERIOand put vt82c686b specific parts in a subclass of this abstract class.Signed-off-by BALATON Zoltan <[email protected]>--- hw/isa/vt82c686.c | 196 +++++++++++++++++++++++++------------- include/hw/isa/vt82c686.h | 1 - 2 files changed, 132 insertions(+), 65 deletions(-)hw/isa/vt82c686.c +89
-24@@ -249,15 +249,80 @@ static const TypeInfo vt8231_pm_info = { }; -typedef struct SuperIOConfig { +#define TYPE_VIA_SUPERIO "via-superio" +OBJECT_DECLARE_SIMPLE_TYPE(ViaSuperIOState, VIA_SUPERIO) + +struct ViaSuperIOState { +ISASuperIODevice superio;uint8_t regs[0x100 ]; +const MemoryRegionOps *io_ops;MemoryRegion io; -}SuperIOConfig ; +}; + +static inline void via_superio_io_enable (ViaSuperIOState *s,bool enable) +{ +memory_region_set_enabled (&s->io, enable); +} + +static void via_superio_realize (DeviceState *d,Error **errp) +{ +ViaSuperIOState *s =VIA_SUPERIO (d); +ISASuperIOClass *ic =ISA_SUPERIO_GET_CLASS (s); +Error *local_err =NULL ; + +assert (s->io_ops); + ic->parent_realize (d, &local_err); +if (local_err) { +error_propagate (errp, local_err); +return ; + } +memory_region_init_io (&s->io,OBJECT (d), s->io_ops, s,"via-superio" ,2 ); +memory_region_set_enabled (&s->io, false); +/* The floppy also uses 0x3f0 and 0x3f1 but this seems to work anyway */ +memory_region_add_subregion (isa_address_space_io (ISA_DEVICE (s)),0x3f0 , + &s->io); +} + +static uint64_t via_superio_cfg_read (void *opaque,hwaddr addr,unsigned size) +{ +ViaSuperIOState *sc = opaque; +uint8_t idx = sc->regs[0 ]; +uint8_t val = sc->regs[idx]; + +if (addr ==0 ) { +return idx; + } +if (addr ==1 && idx ==0 ) { + val =0 ;/* reading reg 0 where we store index value */ + } +trace_via_superio_read (idx, val); +return val; +} + +static void via_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + sc->parent_realize = dc->realize; + dc->realize = via_superio_realize; +} + +static const TypeInfo via_superio_info = { + .name =TYPE_VIA_SUPERIO , + .parent =TYPE_ISA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .class_size =sizeof (ISASuperIOClass), + .class_init = via_superio_class_init, + .abstract = true, +}; + +#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" -static void superio_cfg_write (void *opaque,hwaddr addr,uint64_t data, -unsigned size) +static void vt82c686b_superio_cfg_write (void *opaque,hwaddr addr, +uint64_t data,unsigned size) { -SuperIOConfig *sc = opaque; +ViaSuperIOState *sc = opaque;uint8_t idx = sc->regs[0 ];if (addr ==0 ) {/* config index register */ @@ -288,25 +353,9 @@ static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, sc->regs[idx] = data; } -static uint64_t superio_cfg_read (void *opaque,hwaddr addr,unsigned size) -{ -SuperIOConfig *sc = opaque; -uint8_t idx = sc->regs[0 ]; -uint8_t val = sc->regs[idx]; - -if (addr ==0 ) { -return idx; - } -if (addr ==1 && idx ==0 ) { - val =0 ;/* reading reg 0 where we store index value */ - } -trace_via_superio_read (idx, val); -return val; -} - -static const MemoryRegionOps superio_cfg_ops = { - .read = superio_cfg_read, - .write = superio_cfg_write, +static const MemoryRegionOps vt82c686b_superio_cfg_ops = { + .read = via_superio_cfg_read, + .write = vt82c686b_superio_cfg_write, .endianness =DEVICE_NATIVE_ENDIAN , .impl = { .min_access_size =1 ,@@ -314,13 +363,66 @@ static const MemoryRegionOps superio_cfg_ops = { }, }; +static void vt82c686b_superio_reset (DeviceState *dev) +{ +ViaSuperIOState *s =VIA_SUPERIO (dev); + +memset (s->regs,0 ,sizeof (s->regs)); +/* Device ID */ +vt82c686b_superio_cfg_write (s,0 ,0xe0 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x3c ,1 ); +/* Function select - all disabled */ +vt82c686b_superio_cfg_write (s,0 ,0xe2 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0x03 ,1 ); +/* Floppy ctrl base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe3 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfc ,1 ); +/* Parallel port base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe6 ,1 );
hw/isa/vt82c686.c static const MemoryRegionOps superio_cfg_ops = { · line 391
Quoted 10 lines
hw/isa/vt82c686.c +10
-0+vt82c686b_superio_cfg_write (s,1 ,0xde ,1 ); +/* Serial port 1 base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe7 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xfe ,1 ); +/* Serial port 2 base addr */ +vt82c686b_superio_cfg_write (s,0 ,0xe8 ,1 ); +vt82c686b_superio_cfg_write (s,1 ,0xbe ,1 ); + +vt82c686b_superio_cfg_write (s,0 ,0 ,1 ); +}
I'd say that you need to add the base addresses of the floppy/parallel/serial devices into the comment as otherwise it's impossible to validate that the configuration you're writing here matches what is visible in "info mtree"/the SuperIO defaults without having to dig through the datasheet.
Quoted 127 lines
hw/isa/vt82c686.c +32
-40+static void vt82c686b_superio_init (Object *obj) +{ +VIA_SUPERIO (obj)->io_ops = &vt82c686b_superio_cfg_ops; +} + +static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) +{ +DeviceClass *dc =DEVICE_CLASS (klass); +ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); + + dc->reset = vt82c686b_superio_reset; + sc->serial.count =2 ; + sc->parallel.count =1 ; + sc->ide.count =0 ;/* emulated by via-ide */ + sc->floppy.count =1 ; +} + +static const TypeInfo vt82c686b_superio_info = { + .name =TYPE_VT82C686B_SUPERIO , + .parent =TYPE_VIA_SUPERIO , + .instance_size =sizeof (ViaSuperIOState), + .instance_init = vt82c686b_superio_init, + .class_size =sizeof (ISASuperIOClass), + .class_init = vt82c686b_superio_class_init, +}; + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA)struct VT82C686BISAState {PCIDevice dev;qemu_irq cpu_intr; -SuperIOConfig superio_cfg; +ViaSuperIOState *via_sio; };static void via_isa_request_i8259_irq (void *opaque,int irq,int level)@@ -338,7 +440,7 @@ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr,pci_default_write_config (d, addr, val, len);if (addr ==0x85 ) {/* BIT(1): enable or disable superio config io ports */ -memory_region_set_enabled (&s->superio_cfg.io, val &BIT (1 )); +via_superio_io_enable (s->via_sio, val &BIT (1 )); } }@@ -370,13 +472,6 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5a ] =0x04 ;/* KBC/RTC Control*/ pci_conf[0x5f ] =0x04 ; pci_conf[0x77 ] =0x10 ;/* GPIO Control 1/2/3/4 */ - - s->superio_cfg.regs[0xe0 ] =0x3c ;/* Device ID */ - s->superio_cfg.regs[0xe2 ] =0x03 ;/* Function select */ - s->superio_cfg.regs[0xe3 ] =0xfc ;/* Floppy ctrl base addr */ - s->superio_cfg.regs[0xe6 ] =0xde ;/* Parallel port base addr */ - s->superio_cfg.regs[0xe7 ] =0xfe ;/* Serial port 1 base addr */ - s->superio_cfg.regs[0xe8 ] =0xbe ;/* Serial port 2 base addr */ }static void vt82c686b_realize (PCIDevice *d,Error **errp)@@ -394,7 +489,8 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp)isa_bus_irqs (isa_bus,i8259_init (isa_bus, *isa_irq));i8254_pit_init (isa_bus,0x40 ,0 ,NULL );i8257_dma_init (isa_bus,0 ); -isa_create_simple (isa_bus,TYPE_VT82C686B_SUPERIO ); + s->via_sio =VIA_SUPERIO (isa_create_simple (isa_bus, +TYPE_VT82C686B_SUPERIO ));mc146818_rtc_init (isa_bus,2000 ,NULL );for (i =0 ; i <PCI_CONFIG_HEADER_SIZE ; i++) {@@ -402,16 +498,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **errp) d->wmask[i] =0 ; } } - -memory_region_init_io (&s->superio_cfg.io,OBJECT (d), &superio_cfg_ops, - &s->superio_cfg,"superio_cfg" ,2 ); -memory_region_set_enabled (&s->superio_cfg.io, false); -/* -* The floppy also uses 0x3f0 and 0x3f1. -* But we do not emulate a floppy, so just set it here. -*/ -memory_region_add_subregion (isa_bus->address_space_io,0x3f0 , - &s->superio_cfg.io); }static void via_class_init (ObjectClass *klass,void *data)@@ -447,32 +533,14 @@ static const TypeInfo via_info = { }; -static void vt82c686b_superio_class_init (ObjectClass *klass,void *data) -{ -ISASuperIOClass *sc =ISA_SUPERIO_CLASS (klass); - - sc->serial.count =2 ; - sc->parallel.count =1 ; - sc->ide.count =0 ; - sc->floppy.count =1 ; -} - -static const TypeInfo via_superio_info = { - .name =TYPE_VT82C686B_SUPERIO , - .parent =TYPE_ISA_SUPERIO , - .instance_size =sizeof (ISASuperIODevice), - .class_size =sizeof (ISASuperIOClass), - .class_init = vt82c686b_superio_class_init, -}; - -static void vt82c686b_register_types (void ) {type_register_static (&via_pm_info);type_register_static (&vt82c686b_pm_info);type_register_static (&vt8231_pm_info); -type_register_static (&via_info);type_register_static (&via_superio_info); +type_register_static (&vt82c686b_superio_info); +type_register_static (&via_info); }type_init (vt82c686b_register_types)include/hw/isa/vt82c686.h +0
-0
include/hw/isa/vt82c686.h line 7
Quoted 7 lines
include/hw/isa/vt82c686.h +0
-1@@ -2,7 +2,6 @@#define HW_VT82C686_H #define TYPE_VT82C686B_ISA "vt82c686b-isa" -#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio"#define TYPE_VT82C686B_PM "vt82c686b-pm"#define TYPE_VT8231_PM "vt8231-pm"#define TYPE_VIA_AC97 "via-ac97"
With the updated comments:
ATB,
Mark.
Quoted 66 lines · BALATON Zoltan
Hello,
This is adding a new PPC board called pegasos2. More info on it can be found at:
https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2
Currently it needs a firmware ROM image that I cannot include due to original copyright holder (bPlan) did not release it under a free licence but I have plans to write a replacement in the future. With the original board firmware it can boot MorphOS now as:
qemu-system-ppc -M pegasos2 -cdrom morphos.iso -device ati-vga,romfile="" -serial stdio
then enter "boot cd boot.img" at the firmware "ok" prompt as described in the MorphOS.readme. To boot Linux use same command line with e.g. -cdrom debian-8.11.0-powerpc-netinst.iso then enter
"boot cd install/pegasos"The last patch adds the actual board code after previous patches adding VT8231 and MV64361 system controller chip emulation.
Regards,
BALATON Zoltanv9: Rebased to master
v8: Do not emulate setting of serial port address via register, just
hard code a default address insteadv7: Fix errp usage in patch 2
v6: Rebased on master, updated commit message about migration change
v5: Changes for review comments from David and Philippe
V4: Rename
pegasos2_resettopegasos2_cpu_reset
Add new files toMAINTAINERSBALATON Zoltan (6):
vt82c686: QOM-ify superio related functionality
vt82c686: AddVT8231_SUPERIObased onVIA_SUPERIO
vt82c686: Introduce abstractTYPE_VIA_ISAand basevt82c686b_isaon it
vt82c686: Add emulation of VT8231 south bridge hw/pci-host: Add emulation of Marvell MV64361 PPC system controller hw/ppc: Add emulation of Genesi/bPlan Pegasos IIPhilippe Mathieu-Daudé (1):
hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APMMAINTAINERS | 10 + default-configs/devices/ppc-softmmu.mak | 2 + hw/isa/Kconfig | 1 + hw/isa/vt82c686.c | 422 +++++++++-- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++ hw/pci-host/trace-events | 6 + hw/ppc/Kconfig | 9 + hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++ include/hw/isa/vt82c686.h | 2 +- include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 4 +- 15 files changed, 2418 insertions(+), 82 deletions(-)
Quoted 4 lines
create mode 100644
hw/pci-host/mv64361.ccreate mode 100644hw/pci-host/mv643xx.hcreate mode 100644hw/ppc/pegasos2.ccreate mode 100644include/hw/pci-host/mv64361.h
FWIW I've not really been involved in this patchset, but having had a quick glance over it the QOM/device modelling and the general direction of the patchset looks okay. For that reason I don't feel I'm the right person to send a PR, particularly as I'm not regularly using the VIA devices and for non-Mac PPC machines the final nod really should come from David.
The important part is that it doesn't regress existing machines using the VIA devices: have you run it through Gitlab CI? Posting a link to a full green pipeline in GitLab gives confidence to a maintainer for machines/devices that are less common such as this that the code is stable and ready to merge.
ATB,
Mark.
Re: [PATCH v9 6/7] hw/pci-host: Add emulation of Marvell MV64361 PPC system controller
In reply to BALATON ZoltanQuoted 36 lines · BALATON Zoltan
The Marvell Discovery II aka. MV64361 is a PowerPC system controller chip that is used on the pegasos2 PPC board. This adds emulation of it that models the device enough to boot guests on this board. The
mv643xx.hheader with register definitions is taken from Linux 4.15.10 only fixing white space errors, removing not needed parts and changing formatting for QEMU coding style.Signed-off-by BALATON Zoltan <[email protected]>--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 6 + include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 1 + 7 files changed, 1905 insertions(+) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 include/hw/pci-host/mv64361.hhw/pci-host/mv64361.c new file +15
-0+static void unmap_region (MemoryRegion *mr) +{ +if (memory_region_is_mapped (mr)) { +memory_region_del_subregion (get_system_memory (), mr); +object_unparent (OBJECT (mr)); + } +} + +static void map_pci_region (MemoryRegion *mr,MemoryRegion *parent, +struct Object *owner,const char *name, +hwaddr poffs,uint64_t size,hwaddr moffs) +{ +memory_region_init_alias (mr, owner, name, parent, poffs, size); +memory_region_add_subregion (get_system_memory (), moffs, mr); +trace_mv64361_region_map (name, poffs, size, moffs);
hw/pci-host/mv64361.c line 249
Quoted 10 lines
hw/pci-host/mv64361.c new file +10
-0+} + +static void setup_mem_windows (MV64361State *s,uint32_t val) +{ +MV64361PCIState *p; +MemoryRegion *mr; +uint32_t mask; +int i; + + val &=0x1fffff ;
magic value for PCI_WINDOW_SIZE_MASK?
Quoted 1 line
+ for (mask = 1, i = 0; i < 21; i++, mask <<= 1) {
magic 21.
Quoted 154 lines
hw/pci-host/mv64361.c new file +154
-0+if ((val & mask) != (s->base_addr_enable & mask)) { +trace_mv64361_region_enable (!(val & mask) ?"enable" :"disable" , i); +switch (i) { +/* +* 0-3 are SDRAM chip selects but we map all RAM directly +* 4-7 are device chip selects (not sure what those are) +* 8 is Boot device (ROM) chip select but we map that directly too +*/ +case 9 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->io,OBJECT (s),"pci0-io-win" , + p->remap[4 ], (p->io_size +1 ) <<16 , + (p->io_base &0xfffff ) <<16 ); + } +break ; +case 10 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem0-win" , + p->remap[0 ], (p->mem_size[0 ] +1 ) <<16 , + (p->mem_base[0 ] &0xfffff ) <<16 ); + } +break ; +case 11 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem1-win" , + p->remap[1 ], (p->mem_size[1 ] +1 ) <<16 , + (p->mem_base[1 ] &0xfffff ) <<16 ); + } +break ; +case 12 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem2-win" , + p->remap[2 ], (p->mem_size[2 ] +1 ) <<16 , + (p->mem_base[2 ] &0xfffff ) <<16 ); + } +break ; +case 13 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem3-win" , + p->remap[3 ], (p->mem_size[3 ] +1 ) <<16 , + (p->mem_base[3 ] &0xfffff ) <<16 ); + } +break ; +case 14 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->io,OBJECT (s),"pci1-io-win" , + p->remap[4 ], (p->io_size +1 ) <<16 , + (p->io_base &0xfffff ) <<16 ); + } +break ; +case 15 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem0-win" , + p->remap[0 ], (p->mem_size[0 ] +1 ) <<16 , + (p->mem_base[0 ] &0xfffff ) <<16 ); + } +break ; +case 16 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem1-win" , + p->remap[1 ], (p->mem_size[1 ] +1 ) <<16 , + (p->mem_base[1 ] &0xfffff ) <<16 ); + } +break ; +case 17 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem2-win" , + p->remap[2 ], (p->mem_size[2 ] +1 ) <<16 , + (p->mem_base[2 ] &0xfffff ) <<16 ); + } +break ; +case 18 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem3-win" , + p->remap[3 ], (p->mem_size[3 ] +1 ) <<16 , + (p->mem_base[3 ] &0xfffff ) <<16 ); + } +break ; +/* 19 is integrated SRAM */ +case 20 : + mr = &s->regs; +unmap_region (mr); +if (!(val & mask)) { +memory_region_add_subregion (get_system_memory (), + (s->regs_base &0xfffff ) <<16 , mr); + } +break ; + } + } + } +} + +static void mv64361_update_irq (void *opaque,int n,int level) +{ +MV64361State *s = opaque; +uint64_t val = s->main_int_cr; + +if (level) { + val |=BIT_ULL (n); + }else { + val &= ~BIT_ULL (n); + } +if ((s->main_int_cr & s->cpu0_int_mask) != (val & s->cpu0_int_mask)) { +qemu_set_irq (s->cpu_irq, level); + } + s->main_int_cr = val; +} + +static uint64_t mv64361_read (void *opaque,hwaddr addr,unsigned int size) +{ +MV64361State *s =MV64361 (opaque); +uint32_t ret =0 ; + +switch (addr) { +case MV64340_CPU_CONFIG : + ret = s->cpu_conf; +break ; +case MV64340_PCI_0_IO_BASE_ADDR : + ret = s->pci[0 ].io_base; +break ; +case MV64340_PCI_0_IO_SIZE : + ret = s->pci[0 ].io_size; +break ; +case MV64340_PCI_0_IO_ADDR_REMAP :
hw/pci-host/mv64361.c line 414
Quoted 10 lines
hw/pci-host/mv64361.c new file +10
-0+ ret = s->pci[0 ].remap[4 ] >>16 ; +break ; +case MV64340_PCI_0_MEMORY0_BASE_ADDR : + ret = s->pci[0 ].mem_base[0 ]; +break ; +case MV64340_PCI_0_MEMORY0_SIZE : + ret = s->pci[0 ].mem_size[0 ]; +break ; +case MV64340_PCI_0_MEMORY0_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[0 ] &0xffff0000 ) >>16 ;
extract32()
Quoted 100 lines
hw/pci-host/mv64361.c new file +100
-0+break ; +case MV64340_PCI_0_MEMORY0_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[0 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY1_BASE_ADDR : + ret = s->pci[0 ].mem_base[1 ]; +break ; +case MV64340_PCI_0_MEMORY1_SIZE : + ret = s->pci[0 ].mem_size[1 ]; +break ; +case MV64340_PCI_0_MEMORY1_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[1 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY1_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[1 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY2_BASE_ADDR : + ret = s->pci[0 ].mem_base[2 ]; +break ; +case MV64340_PCI_0_MEMORY2_SIZE : + ret = s->pci[0 ].mem_size[2 ]; +break ; +case MV64340_PCI_0_MEMORY2_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[2 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY2_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[2 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY3_BASE_ADDR : + ret = s->pci[0 ].mem_base[3 ]; +break ; +case MV64340_PCI_0_MEMORY3_SIZE : + ret = s->pci[0 ].mem_size[3 ]; +break ; +case MV64340_PCI_0_MEMORY3_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[3 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY3_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[3 ] >>32 ; +break ; +case MV64340_PCI_1_IO_BASE_ADDR : + ret = s->pci[1 ].io_base; +break ; +case MV64340_PCI_1_IO_SIZE : + ret = s->pci[1 ].io_size; +break ; +case MV64340_PCI_1_IO_ADDR_REMAP : + ret = s->pci[1 ].remap[4 ] >>16 ; +break ; +case MV64340_PCI_1_MEMORY0_BASE_ADDR : + ret = s->pci[1 ].mem_base[0 ]; +break ; +case MV64340_PCI_1_MEMORY0_SIZE : + ret = s->pci[1 ].mem_size[0 ]; +break ; +case MV64340_PCI_1_MEMORY0_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[0 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY0_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[0 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY1_BASE_ADDR : + ret = s->pci[1 ].mem_base[1 ]; +break ; +case MV64340_PCI_1_MEMORY1_SIZE : + ret = s->pci[1 ].mem_size[1 ]; +break ; +case MV64340_PCI_1_MEMORY1_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[1 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY1_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[1 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY2_BASE_ADDR : + ret = s->pci[1 ].mem_base[2 ]; +break ; +case MV64340_PCI_1_MEMORY2_SIZE : + ret = s->pci[1 ].mem_size[2 ]; +break ; +case MV64340_PCI_1_MEMORY2_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[2 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY2_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[2 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY3_BASE_ADDR : + ret = s->pci[1 ].mem_base[3 ]; +break ; +case MV64340_PCI_1_MEMORY3_SIZE : + ret = s->pci[1 ].mem_size[3 ]; +break ; +case MV64340_PCI_1_MEMORY3_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[3 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY3_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[3 ] >>32 ; +break ; +case MV64340_INTERNAL_SPACE_BASE_ADDR : + ret = s->regs_base; +break ;
hw/pci-host/mv64361.c line 524
Quoted 10 lines
hw/pci-host/mv64361.c new file +10
-0+case MV64340_BASE_ADDR_ENABLE : + ret = s->base_addr_enable; +break ; +case MV64340_PCI_0_CONFIG_ADDR : + ret = pci_host_conf_le_ops.read (PCI_HOST_BRIDGE (&s->pci[0 ]),0 , size); +break ; + case MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG ... +MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG +3 : + ret = pci_host_data_le_ops.read (PCI_HOST_BRIDGE (&s->pci[0 ]), + addr -MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG , size);
Code smell... You probably want memory_region_dispatch_read().
Quoted 64 lines
hw/pci-host/mv64361.c new file +64
-0+break ; +case MV64340_PCI_1_CONFIG_ADDR : + ret = pci_host_conf_le_ops.read (PCI_HOST_BRIDGE (&s->pci[1 ]),0 , size); +break ; + case MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG ... +MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG +3 : + ret = pci_host_data_le_ops.read (PCI_HOST_BRIDGE (&s->pci[1 ]), + addr -MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG , size); +break ; +case MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG : +/* FIXME: Should this be sent via the PCI bus somehow? */ +if (s->gpp_int_level && (s->gpp_value &BIT (31 ))) { + ret =pic_read_irq (isa_pic); + } +break ; +case MV64340_MAIN_INTERRUPT_CAUSE_LOW : + ret = s->main_int_cr; +break ; +case MV64340_MAIN_INTERRUPT_CAUSE_HIGH : + ret = s->main_int_cr >>32 ; +break ; +case MV64340_CPU_INTERRUPT0_MASK_LOW : + ret = s->cpu0_int_mask; +break ; +case MV64340_CPU_INTERRUPT0_MASK_HIGH : + ret = s->cpu0_int_mask >>32 ; +break ; +case MV64340_CPU_INTERRUPT0_SELECT_CAUSE : + ret = s->main_int_cr; +if (s->main_int_cr & s->cpu0_int_mask) { +if (!(s->main_int_cr & s->cpu0_int_mask &0xffffffff )) { + ret = s->main_int_cr >>32 |BIT (30 ); + }else if ((s->main_int_cr & s->cpu0_int_mask) >>32 ) { + ret |=BIT (31 ); + } + } +break ; +case MV64340_CUNIT_ARBITER_CONTROL_REG : + ret =0x11ff0000 | (s->gpp_int_level <<10 ); +break ; +case MV64340_GPP_IO_CONTROL : + ret = s->gpp_io; +break ; +case MV64340_GPP_LEVEL_CONTROL : + ret = s->gpp_level; +break ; +case MV64340_GPP_VALUE : + ret = s->gpp_value; +break ; +case MV64340_GPP_VALUE_SET : +case MV64340_GPP_VALUE_CLEAR : + ret =0 ; +break ; +case MV64340_GPP_INTERRUPT_CAUSE : + ret = s->gpp_int_cr; +break ; +case MV64340_GPP_INTERRUPT_MASK0 : +case MV64340_GPP_INTERRUPT_MASK1 : + ret = s->gpp_int_mask; +break ; +default : +qemu_log_mask (LOG_UNIMP ,"%s: Unimplemented register read 0x%" + HWADDR_PRIx"\n" , __func__, addr); +break ;
hw/pci-host/mv64361.c line 598
Quoted 10 lines
hw/pci-host/mv64361.c new file +10
-0+ } +if (addr !=MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG ) { +trace_mv64361_reg_read (addr, ret); + } +return ret; +} + +static void warn_swap_bit (uint64_t val) +{ +if ((val &0x3000000ULL ) >>24 !=1 ) {
Code smell. Shouldn't this be a MemoryRegion?
Quoted 14 lines
hw/pci-host/mv64361.c new file +14
-0+qemu_log_mask (LOG_UNIMP ,"%s: Data swap not implemented" , __func__); + } +} + +static void mv64361_set_pci_mem_remap (MV64361State *s,int bus,int idx, +uint64_t val,bool high) +{ +if (high) { + s->pci[bus].remap[idx] = val; + }else { + s->pci[bus].remap[idx] &=0xffffffff00000000ULL ; + s->pci[bus].remap[idx] |= (val &0xffffULL ) <<16 ; + } +}
Re: [PATCH v9 6/7] hw/pci-host: Add emulation of Marvell MV64361 PPC system controller
Quoted 41 lines · Philippe Mathieu-Daudé
Quoted 40 lines · BALATON Zoltan
The Marvell Discovery II aka. MV64361 is a PowerPC system controller chip that is used on the pegasos2 PPC board. This adds emulation of it that models the device enough to boot guests on this board. The
mv643xx.hheader with register definitions is taken from Linux 4.15.10 only fixing white space errors, removing not needed parts and changing formatting for QEMU coding style.Signed-off-by BALATON Zoltan <[email protected]>--- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++++++++++++ hw/pci-host/trace-events | 6 + include/hw/pci-host/mv64361.h | 8 + include/hw/pci/pci_ids.h | 1 + 7 files changed, 1905 insertions(+) create mode 100644 hw/pci-host/mv64361.c create mode 100644 hw/pci-host/mv643xx.h create mode 100644 include/hw/pci-host/mv64361.hhw/pci-host/mv64361.c new file +19
-0+static void unmap_region (MemoryRegion *mr) +{ +if (memory_region_is_mapped (mr)) { +memory_region_del_subregion (get_system_memory (), mr); +object_unparent (OBJECT (mr)); + } +} + +static void map_pci_region (MemoryRegion *mr,MemoryRegion *parent, +struct Object *owner,const char *name, +hwaddr poffs,uint64_t size,hwaddr moffs) +{ +memory_region_init_alias (mr, owner, name, parent, poffs, size); +memory_region_add_subregion (get_system_memory (), moffs, mr); +trace_mv64361_region_map (name, poffs, size, moffs); +} + +static void setup_mem_windows (MV64361State *s,uint32_t val) +{
Quoted 8 lines
hw/pci-host/mv64361.c line 249
Quoted 6 lines
hw/pci-host/mv64361.c new file +6
-0+MV64361PCIState *p; +MemoryRegion *mr; +uint32_t mask; +int i; + + val &=0x1fffff ;magic value for
PCI_WINDOW_SIZE_MASK?
That constant does not exist. I could define it but don't see how is it better then literal value if it's only needed once.
Quoted 3 lines
Quoted 1 line
+ for (mask = 1, i = 0; i < 21; i++, mask <<= 1) {
magic 21.
Same here, 21 is number of memory windows as is clear from the below comments and this is only used here so hiding it behind a constant that you'd have to scroll up to figure out the value of would not make it clearer in my opinion.
Quoted 158 lines
Quoted 158 lines
hw/pci-host/mv64361.c new file +158
-0+if ((val & mask) != (s->base_addr_enable & mask)) { +trace_mv64361_region_enable (!(val & mask) ?"enable" :"disable" , i); +switch (i) { +/* +* 0-3 are SDRAM chip selects but we map all RAM directly +* 4-7 are device chip selects (not sure what those are) +* 8 is Boot device (ROM) chip select but we map that directly too +*/ +case 9 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->io,OBJECT (s),"pci0-io-win" , + p->remap[4 ], (p->io_size +1 ) <<16 , + (p->io_base &0xfffff ) <<16 ); + } +break ; +case 10 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem0-win" , + p->remap[0 ], (p->mem_size[0 ] +1 ) <<16 , + (p->mem_base[0 ] &0xfffff ) <<16 ); + } +break ; +case 11 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem1-win" , + p->remap[1 ], (p->mem_size[1 ] +1 ) <<16 , + (p->mem_base[1 ] &0xfffff ) <<16 ); + } +break ; +case 12 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem2-win" , + p->remap[2 ], (p->mem_size[2 ] +1 ) <<16 , + (p->mem_base[2 ] &0xfffff ) <<16 ); + } +break ; +case 13 : + p = &s->pci[0 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci0-mem3-win" , + p->remap[3 ], (p->mem_size[3 ] +1 ) <<16 , + (p->mem_base[3 ] &0xfffff ) <<16 ); + } +break ; +case 14 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->io,OBJECT (s),"pci1-io-win" , + p->remap[4 ], (p->io_size +1 ) <<16 , + (p->io_base &0xfffff ) <<16 ); + } +break ; +case 15 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem0-win" , + p->remap[0 ], (p->mem_size[0 ] +1 ) <<16 , + (p->mem_base[0 ] &0xfffff ) <<16 ); + } +break ; +case 16 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem1-win" , + p->remap[1 ], (p->mem_size[1 ] +1 ) <<16 , + (p->mem_base[1 ] &0xfffff ) <<16 ); + } +break ; +case 17 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem2-win" , + p->remap[2 ], (p->mem_size[2 ] +1 ) <<16 , + (p->mem_base[2 ] &0xfffff ) <<16 ); + } +break ; +case 18 : + p = &s->pci[1 ]; + mr = &s->cpu_win[i]; +unmap_region (mr); +if (!(val & mask)) { +map_pci_region (mr, &p->mem,OBJECT (s),"pci1-mem3-win" , + p->remap[3 ], (p->mem_size[3 ] +1 ) <<16 , + (p->mem_base[3 ] &0xfffff ) <<16 ); + } +break ; +/* 19 is integrated SRAM */ +case 20 : + mr = &s->regs; +unmap_region (mr); +if (!(val & mask)) { +memory_region_add_subregion (get_system_memory (), + (s->regs_base &0xfffff ) <<16 , mr); + } +break ; + } + } + } +} + +static void mv64361_update_irq (void *opaque,int n,int level) +{ +MV64361State *s = opaque; +uint64_t val = s->main_int_cr; + +if (level) { + val |=BIT_ULL (n); + }else { + val &= ~BIT_ULL (n); + } +if ((s->main_int_cr & s->cpu0_int_mask) != (val & s->cpu0_int_mask)) { +qemu_set_irq (s->cpu_irq, level); + } + s->main_int_cr = val; +} + +static uint64_t mv64361_read (void *opaque,hwaddr addr,unsigned int size) +{ +MV64361State *s =MV64361 (opaque); +uint32_t ret =0 ; + +switch (addr) { +case MV64340_CPU_CONFIG : + ret = s->cpu_conf; +break ; +case MV64340_PCI_0_IO_BASE_ADDR : + ret = s->pci[0 ].io_base; +break ; +case MV64340_PCI_0_IO_SIZE : + ret = s->pci[0 ].io_size; +break ; +case MV64340_PCI_0_IO_ADDR_REMAP : + ret = s->pci[0 ].remap[4 ] >>16 ; +break ; +case MV64340_PCI_0_MEMORY0_BASE_ADDR : + ret = s->pci[0 ].mem_base[0 ];
Quoted 8 lines
hw/pci-host/mv64361.c line 414
Quoted 6 lines
hw/pci-host/mv64361.c new file +6
-0+break ; +case MV64340_PCI_0_MEMORY0_SIZE : + ret = s->pci[0 ].mem_size[0 ]; +break ; +case MV64340_PCI_0_MEMORY0_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[0 ] &0xffff0000 ) >>16 ;
extract32()
I don't like that because it has an unneded assert for every invocation so I usually avoid it unless it would make code clearer. This is pretty clear already this way, in fact I think clrearer than having to check what the params of extract32 are. I might consider extract* if it was a macro without additional unnecessary checks.
Quoted 111 lines
Quoted 100 lines
hw/pci-host/mv64361.c new file +100
-0+break ; +case MV64340_PCI_0_MEMORY0_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[0 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY1_BASE_ADDR : + ret = s->pci[0 ].mem_base[1 ]; +break ; +case MV64340_PCI_0_MEMORY1_SIZE : + ret = s->pci[0 ].mem_size[1 ]; +break ; +case MV64340_PCI_0_MEMORY1_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[1 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY1_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[1 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY2_BASE_ADDR : + ret = s->pci[0 ].mem_base[2 ]; +break ; +case MV64340_PCI_0_MEMORY2_SIZE : + ret = s->pci[0 ].mem_size[2 ]; +break ; +case MV64340_PCI_0_MEMORY2_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[2 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY2_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[2 ] >>32 ; +break ; +case MV64340_PCI_0_MEMORY3_BASE_ADDR : + ret = s->pci[0 ].mem_base[3 ]; +break ; +case MV64340_PCI_0_MEMORY3_SIZE : + ret = s->pci[0 ].mem_size[3 ]; +break ; +case MV64340_PCI_0_MEMORY3_LOW_ADDR_REMAP : + ret = (s->pci[0 ].remap[3 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_0_MEMORY3_HIGH_ADDR_REMAP : + ret = s->pci[0 ].remap[3 ] >>32 ; +break ; +case MV64340_PCI_1_IO_BASE_ADDR : + ret = s->pci[1 ].io_base; +break ; +case MV64340_PCI_1_IO_SIZE : + ret = s->pci[1 ].io_size; +break ; +case MV64340_PCI_1_IO_ADDR_REMAP : + ret = s->pci[1 ].remap[4 ] >>16 ; +break ; +case MV64340_PCI_1_MEMORY0_BASE_ADDR : + ret = s->pci[1 ].mem_base[0 ]; +break ; +case MV64340_PCI_1_MEMORY0_SIZE : + ret = s->pci[1 ].mem_size[0 ]; +break ; +case MV64340_PCI_1_MEMORY0_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[0 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY0_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[0 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY1_BASE_ADDR : + ret = s->pci[1 ].mem_base[1 ]; +break ; +case MV64340_PCI_1_MEMORY1_SIZE : + ret = s->pci[1 ].mem_size[1 ]; +break ; +case MV64340_PCI_1_MEMORY1_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[1 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY1_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[1 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY2_BASE_ADDR : + ret = s->pci[1 ].mem_base[2 ]; +break ; +case MV64340_PCI_1_MEMORY2_SIZE : + ret = s->pci[1 ].mem_size[2 ]; +break ; +case MV64340_PCI_1_MEMORY2_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[2 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY2_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[2 ] >>32 ; +break ; +case MV64340_PCI_1_MEMORY3_BASE_ADDR : + ret = s->pci[1 ].mem_base[3 ]; +break ; +case MV64340_PCI_1_MEMORY3_SIZE : + ret = s->pci[1 ].mem_size[3 ]; +break ; +case MV64340_PCI_1_MEMORY3_LOW_ADDR_REMAP : + ret = (s->pci[1 ].remap[3 ] &0xffff0000 ) >>16 ; +break ; +case MV64340_PCI_1_MEMORY3_HIGH_ADDR_REMAP : + ret = s->pci[1 ].remap[3 ] >>32 ; +break ; +case MV64340_INTERNAL_SPACE_BASE_ADDR : + ret = s->regs_base; +break ;hw/pci-host/mv64361.c line 524
Quoted 10 lines
hw/pci-host/mv64361.c new file +10
-0+case MV64340_BASE_ADDR_ENABLE : + ret = s->base_addr_enable; +break ; +case MV64340_PCI_0_CONFIG_ADDR : + ret = pci_host_conf_le_ops.read (PCI_HOST_BRIDGE (&s->pci[0 ]),0 , size); +break ; + case MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG ... +MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG +3 : + ret = pci_host_data_le_ops.read (PCI_HOST_BRIDGE (&s->pci[0 ]), + addr -MV64340_PCI_0_CONFIG_DATA_VIRTUAL_REG , size);
Quoted 1 line
Code smell... You probably want
memory_region_dispatch_read().
Never heard of that, no idea how to use that and how would that would help here. Any examples? But at this point I really don't want to change any of this as that could break it while this was tested to work.
Quoted 68 lines
Quoted 68 lines
hw/pci-host/mv64361.c new file +68
-0+break ; +case MV64340_PCI_1_CONFIG_ADDR : + ret = pci_host_conf_le_ops.read (PCI_HOST_BRIDGE (&s->pci[1 ]),0 , size); +break ; + case MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG ... +MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG +3 : + ret = pci_host_data_le_ops.read (PCI_HOST_BRIDGE (&s->pci[1 ]), + addr -MV64340_PCI_1_CONFIG_DATA_VIRTUAL_REG , size); +break ; +case MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG : +/* FIXME: Should this be sent via the PCI bus somehow? */ +if (s->gpp_int_level && (s->gpp_value &BIT (31 ))) { + ret =pic_read_irq (isa_pic); + } +break ; +case MV64340_MAIN_INTERRUPT_CAUSE_LOW : + ret = s->main_int_cr; +break ; +case MV64340_MAIN_INTERRUPT_CAUSE_HIGH : + ret = s->main_int_cr >>32 ; +break ; +case MV64340_CPU_INTERRUPT0_MASK_LOW : + ret = s->cpu0_int_mask; +break ; +case MV64340_CPU_INTERRUPT0_MASK_HIGH : + ret = s->cpu0_int_mask >>32 ; +break ; +case MV64340_CPU_INTERRUPT0_SELECT_CAUSE : + ret = s->main_int_cr; +if (s->main_int_cr & s->cpu0_int_mask) { +if (!(s->main_int_cr & s->cpu0_int_mask &0xffffffff )) { + ret = s->main_int_cr >>32 |BIT (30 ); + }else if ((s->main_int_cr & s->cpu0_int_mask) >>32 ) { + ret |=BIT (31 ); + } + } +break ; +case MV64340_CUNIT_ARBITER_CONTROL_REG : + ret =0x11ff0000 | (s->gpp_int_level <<10 ); +break ; +case MV64340_GPP_IO_CONTROL : + ret = s->gpp_io; +break ; +case MV64340_GPP_LEVEL_CONTROL : + ret = s->gpp_level; +break ; +case MV64340_GPP_VALUE : + ret = s->gpp_value; +break ; +case MV64340_GPP_VALUE_SET : +case MV64340_GPP_VALUE_CLEAR : + ret =0 ; +break ; +case MV64340_GPP_INTERRUPT_CAUSE : + ret = s->gpp_int_cr; +break ; +case MV64340_GPP_INTERRUPT_MASK0 : +case MV64340_GPP_INTERRUPT_MASK1 : + ret = s->gpp_int_mask; +break ; +default : +qemu_log_mask (LOG_UNIMP ,"%s: Unimplemented register read 0x%" + HWADDR_PRIx"\n" , __func__, addr); +break ; + } +if (addr !=MV64340_PCI_1_INTERRUPT_ACKNOWLEDGE_VIRTUAL_REG ) { +trace_mv64361_reg_read (addr, ret); + }
Quoted 8 lines
hw/pci-host/mv64361.c line 598
Quoted 6 lines
hw/pci-host/mv64361.c new file +6
-0+return ret; +} + +static void warn_swap_bit (uint64_t val) +{ +if ((val &0x3000000ULL ) >>24 !=1 ) {Code smell. Shouldn't this be a MemoryRegion?
Why is this a code smell? It is a memory region but can you flip its endianness during runtime or only when declaring it? Anyway, fortunately nothing seems to need this, I've only put the warning here to see if it would be needed but never have seen it firing. (The chip has an endianness bit that can enable swapping of memory region accesses but we don't emulate that. This function checks that guest does not try to enable it.)
Regards,
BALATON Zoltan
Quoted 16 lines
Quoted 14 lines
hw/pci-host/mv64361.c new file +14
-0+qemu_log_mask (LOG_UNIMP ,"%s: Data swap not implemented" , __func__); + } +} + +static void mv64361_set_pci_mem_remap (MV64361State *s,int bus,int idx, +uint64_t val,bool high) +{ +if (high) { + s->pci[bus].remap[idx] = val; + }else { + s->pci[bus].remap[idx] &=0xffffffff00000000ULL ; + s->pci[bus].remap[idx] |= (val &0xffffULL ) <<16 ; + } +}
Quoted 67 lines · Mark Cave-Ayland
Quoted 65 lines · BALATON Zoltan
Hello,
This is adding a new PPC board called pegasos2. More info on it can be found at:
https://osdn.net/projects/qmiga/wiki/SubprojectPegasos2
Currently it needs a firmware ROM image that I cannot include due to original copyright holder (bPlan) did not release it under a free licence but I have plans to write a replacement in the future. With the original board firmware it can boot MorphOS now as:
qemu-system-ppc -M pegasos2 -cdrom morphos.iso -device ati-vga,romfile="" -serial stdio
then enter "boot cd boot.img" at the firmware "ok" prompt as described in the MorphOS.readme. To boot Linux use same command line with e.g. -cdrom debian-8.11.0-powerpc-netinst.iso then enter
"boot cd install/pegasos"The last patch adds the actual board code after previous patches adding VT8231 and MV64361 system controller chip emulation.
Regards,
BALATON Zoltanv9: Rebased to master
v8: Do not emulate setting of serial port address via register, just
hard code a default address insteadv7: Fix errp usage in patch 2
v6: Rebased on master, updated commit message about migration change
v5: Changes for review comments from David and Philippe
V4: Rename
pegasos2_resettopegasos2_cpu_reset
Add new files toMAINTAINERSBALATON Zoltan (6):
vt82c686: QOM-ify superio related functionality
vt82c686: AddVT8231_SUPERIObased onVIA_SUPERIO
vt82c686: Introduce abstractTYPE_VIA_ISAand basevt82c686b_isaon it
vt82c686: Add emulation of VT8231 south bridge hw/pci-host: Add emulation of Marvell MV64361 PPC system controller hw/ppc: Add emulation of Genesi/bPlan Pegasos IIPhilippe Mathieu-Daudé (1):
hw/isa/Kconfig: Add missing dependency VIA VT82C686 -> APMMAINTAINERS | 10 + default-configs/devices/ppc-softmmu.mak | 2 + hw/isa/Kconfig | 1 + hw/isa/vt82c686.c | 422 +++++++++-- hw/pci-host/Kconfig | 4 + hw/pci-host/meson.build | 2 + hw/pci-host/mv64361.c | 966 ++++++++++++++++++++++++ hw/pci-host/mv643xx.h | 918 ++++++++++++++++++++++ hw/pci-host/trace-events | 6 + hw/ppc/Kconfig | 9 + hw/ppc/meson.build | 2 + hw/ppc/pegasos2.c | 144 ++++ include/hw/isa/vt82c686.h | 2 +- include/hw/pci-host/mv64361.h | 8 +
Quoted 8 lines
Quoted 6 lines
include/hw/pci/pci_ids.h | 4 +- 15 files changed, 2418 insertions(+), 82 deletions(-)create mode 100644
hw/pci-host/mv64361.ccreate mode 100644hw/pci-host/mv643xx.hcreate mode 100644hw/ppc/pegasos2.ccreate mode 100644include/hw/pci-host/mv64361.hFWIW I've not really been involved in this patchset, but having had a quick glance over it the QOM/device modelling and the general direction of the patchset looks okay. For that reason I don't feel I'm the right person to send a PR, particularly as I'm not regularly using the VIA devices and for non-Mac PPC machines the final nod really should come from David.
Thanks for the review, I've updated comments and sent v10. David is away this week so maybe it's only Philippe now who could still take this series before it's too late for 6.0 (if it isn't already).
Quoted 1 line
The important part is that it doesn't regress existing machines using the VIA devices: have you run it through Gitlab CI? Posting a link to a full green pipeline in GitLab gives confidence to a maintainer for machines/devices that are less common such as this that the code is stable and ready to merge.
These are adding new device model that's only used by the new machine. How could it regress anything? Those patches that changed existing devices are already upstream. Also if it touches anything that's fuloong2e which is harfly critical and was barely working before I've started to clean it up to be able to use it's devices as a basis for pegasos2. Lastly the freeze is for finding and fixing regressions but for that the series should first be allowed to get in to be tested more widely.
I don't know how to run Gitlab CI, I don't even have an account. Thought that's what maintainers are there for to run these tests.
Regards,
BALATON Zoltan