Skip to contentSkip to conversation

ppc: add a IBM 40p machine (RS/6000, PReP)

PATCH Applied Hervé Poussineau 4 participants 10 messages Jan 7, 2017 – Jan 10, 2017

lore
Share & tools
lore
#0 lore raw

v3 cover ppc: add a IBM 40p machine (RS/6000, PReP)

Hi,

This patchset adds the emulation of the IBM RS/6000 7020 (40p). The real machine is able to run AIX (up to 4.3.3), Windows NT (up to 4.0 SP1), the beta of OS/2 PowerPC, Solaris, Linux, NetBSD/PReP ...

I've tested current emulation with Open Hack'Ware, OpenBIOS and official firmware.

Linux kernel starts, and freezes during boot (seems like a problem with the SCSI adapter). Windows NT starts up to the point where it wants to change endianness. Other OSes have not been tested.

This machine is a superset of the 'prep' one, because we know exactly what is/should emulated, and that operating system list running on it is quite wide. I hope that 'prep' machine can be deprecated soon and then later removed.

Patch 1 is a cleanup, and can probably be committed first. Patches 2 to 4 are the real implementation of the IBM 40p.

Changes since v2:
- patch 2: fix mismatch between read and write functions for port 92
- patch 4: use error_report instead of fprintf/hw_error

Changes since v1:
- removed patches related to display adapter:
Let's wait for an emulation of the real display adapter (an S3 Trio), as current VGA adapter already mostly works with Open Hack'Ware and OpenBIOS
- various changes due to David Gibson's remarks

Hervé Poussineau (4):
prep: do not use global variable to access nvram
prep: add PReP System I/O
prep: add IBM RS/6000 7020 (40p) memory controller
prep: add IBM RS/6000 7020 (40p) machine emulation

 default-configs/ppc-softmmu.mak |   2 +
 hw/ppc/Makefile.objs            |   2 +
 hw/ppc/prep.c                   | 233 +++++++++++++++++++++++++++++-
 hw/ppc/prep_systemio.c          | 303 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/rs6000_mc.c              | 232 ++++++++++++++++++++++++++++++
 hw/ppc/trace-events             |  11 ++
 6 files changed, 781 insertions(+), 2 deletions(-)
 create mode 100644 hw/ppc/prep_systemio.c
 create mode 100644 hw/ppc/rs6000_mc.c
Signature · 1 line
2.1.4
#1 lore raw

PATCH v3 1/4 prep: do not use global variable to access nvram

---
 hw/ppc/prep.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
hw/ppc/prep.c +2 -2
index 054af1e..9fb89d3 100644
@@ -339,13 +339,13 @@ static PortioList prep_port_list;
 /* NVRAM helpers */
 static inline uint32_t nvram_read(Nvram *nvram, uint32_t addr)
 {
-    NvramClass *k = NVRAM_GET_CLASS(sysctrl->nvram);
+    NvramClass *k = NVRAM_GET_CLASS(nvram);
     return (k->read)(nvram, addr);
 }
 
 static inline void nvram_write(Nvram *nvram, uint32_t addr, uint32_t val)
 {
-    NvramClass *k = NVRAM_GET_CLASS(sysctrl->nvram);
+    NvramClass *k = NVRAM_GET_CLASS(nvram);
     (k->write)(nvram, addr, val);
 }
 
Signature · 1 line
2.1.4
#2 lore raw

PATCH v3 2/4 prep: add PReP System I/O

In reply to Hervé Poussineau

This device is a partial duplicate of System I/O device available in hw/ppc/prep.c This new one doesn't have all the Motorola-specific registers.
The old one should be deprecated and removed with the 'prep' machine.

Partial documentation available at ftp://ftp.software.ibm.com/rs6000/technology/spec/srp1_1.exe section 6.1.5 (I/O Device Mapping)

---
 hw/ppc/Makefile.objs   |   1 +
 hw/ppc/prep_systemio.c | 303 +++++++++++++++++++++++++++++++++++++++++++++++++
 hw/ppc/trace-events    |   4 +
 3 files changed, 308 insertions(+)
 create mode 100644 hw/ppc/prep_systemio.c
hw/ppc/Makefile.objs +1 -0
index 8025129..db72297 100644
@@ -16,6 +16,7 @@ obj-y += ppc405_boards.o ppc4xx_devs.o ppc405_uc.o ppc440_bamboo.o
 obj-y += ppc4xx_pci.o
 # PReP
 obj-$(CONFIG_PREP) += prep.o
+obj-$(CONFIG_PREP) += prep_systemio.o
 # OldWorld PowerMac
 obj-$(CONFIG_MAC) += mac_oldworld.o
 # NewWorld PowerMac
hw/ppc/prep_systemio.c new file +303 -0

303 lines not on this page · raw message

hw/ppc/trace-events +4 -0
index 2297ead..2ba6166 100644
@@ -74,3 +74,7 @@ ppc_tb_adjust(uint64_t offs1, uint64_t offs2, int64_t diff, int64_t seconds) "ad
 # hw/ppc/prep.c
 prep_io_800_writeb(uint32_t addr, uint32_t val) "0x%08" PRIx32 " => 0x%02" PRIx32
 prep_io_800_readb(uint32_t addr, uint32_t retval) "0x%08" PRIx32 " <= 0x%02" PRIx32
+
+# hw/ppc/prep_systemio.c
+prep_systemio_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+prep_systemio_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
Signature · 1 line
2.1.4
#3 lore raw

PATCH v3 3/4 prep: add IBM RS/6000 7020 (40p) memory controller

In reply to Hervé Poussineau
---
 default-configs/ppc-softmmu.mak |   1 +
 hw/ppc/Makefile.objs            |   1 +
 hw/ppc/rs6000_mc.c              | 232 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/trace-events             |   7 ++
 4 files changed, 241 insertions(+)
 create mode 100644 hw/ppc/rs6000_mc.c
default-configs/ppc-softmmu.mak +1 -0
index d4d0f9b..e567658 100644
@@ -47,3 +47,4 @@ CONFIG_LIBDECNUMBER=y
 # For PReP
 CONFIG_MC146818RTC=y
 CONFIG_ISA_TESTDEV=y
+CONFIG_RS6000_MC=y
hw/ppc/Makefile.objs +1 -0
index db72297..0012934 100644
@@ -17,6 +17,7 @@ obj-y += ppc4xx_pci.o
 # PReP
 obj-$(CONFIG_PREP) += prep.o
 obj-$(CONFIG_PREP) += prep_systemio.o
+obj-${CONFIG_RS6000_MC} += rs6000_mc.o
 # OldWorld PowerMac
 obj-$(CONFIG_MAC) += mac_oldworld.o
 # NewWorld PowerMac
hw/ppc/rs6000_mc.c new file +232 -0

232 lines not on this page · raw message

hw/ppc/trace-events +7 -0
index 2ba6166..42b8ec0 100644
@@ -78,3 +78,10 @@ prep_io_800_readb(uint32_t addr, uint32_t retval) "0x%08" PRIx32 " <= 0x%02" PRI
 # hw/ppc/prep_systemio.c
 prep_systemio_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
 prep_systemio_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
+
+# hw/ppc/rs6000_mc.c
+rs6000mc_id_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+rs6000mc_presence_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+rs6000mc_size_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
+rs6000mc_size_write(uint32_t addr, uint32_t val) "write addr=%x val=%x"
+rs6000mc_parity_read(uint32_t addr, uint32_t val) "read addr=%x val=%x"
Signature · 1 line
2.1.4
#4 lore raw

PATCH v3 4/4 prep: add IBM RS/6000 7020 (40p) machine emulation

In reply to Hervé Poussineau

Machine supports both Open Hack'Ware and OpenBIOS.
Open Hack'Ware is the default because OpenBIOS is currently unable to boot PReP boot partitions or PReP kernels.

---
 default-configs/ppc-softmmu.mak |   1 +
 hw/ppc/prep.c                   | 229 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 230 insertions(+)
default-configs/ppc-softmmu.mak +1 -0
index e567658..7dd004e 100644
@@ -18,6 +18,7 @@ CONFIG_I82378=y
 CONFIG_PC87312=y
 CONFIG_MACIO=y
 CONFIG_PCSPK=y
+CONFIG_CS4231A=y
 CONFIG_CUDA=y
 CONFIG_ADB=y
 CONFIG_MAC_NVRAM=y
hw/ppc/prep.c +229 -0

257 lines not on this page · raw message

Signature · 1 line
2.1.4
#5 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 4/4] prep: add IBM RS/6000 7020 (40p) machine emulation

Hi,

Quoted 65 lines · Hervé Poussineau

Machine supports both Open Hack'Ware and OpenBIOS.
Open Hack'Ware is the default because OpenBIOS is currently unable to boot PReP boot partitions or PReP kernels.

---
 default-configs/ppc-softmmu.mak |   1 +
 hw/ppc/prep.c                   | 229 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 230 insertions(+)
default-configs/ppc-softmmu.mak +1 -0
index e567658..7dd004e 100644
@@ -18,6 +18,7 @@ CONFIG_I82378=y
 CONFIG_PC87312=y
 CONFIG_MACIO=y
 CONFIG_PCSPK=y
+CONFIG_CS4231A=y
 CONFIG_CUDA=y
 CONFIG_ADB=y
 CONFIG_MAC_NVRAM=y
hw/ppc/prep.c +10 -0
index 9fb89d3..9bdf573 100644
@@ -2,6 +2,7 @@
  * QEMU PPC PREP hardware System Emulator
  *
  * Copyright (c) 2003-2007 Jocelyn Mayer
+ * Copyright (c) 2017 Hervé Poussineau
  *
  * Permission is hereby granted, free of charge, to any person obtaining a copy
  * of this software and associated documentation files (the "Software"), to deal
@@ -43,6 +44,7 @@
 #include "hw/isa/pc87312.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/arch_init.h"
+#include "sysemu/kvm.h"
 #include "sysemu/qtest.h"
 #include "exec/address-spaces.h"
 #include "trace.h"
@@ -54,6 +56,8 @@
 
 #define MAX_IDE_BUS 2
 
+#define CFG_ADDR 0xf0000510
+
 #define BIOS_SIZE (1024 * 1024)
 #define BIOS_FILENAME "ppc_rom.bin"
 #define KERNEL_LOAD_ADDR 0x01000000
@@ -316,6 +320,12 @@ static uint32_t PREP_io_800_readb (void *opaque, uint32_t addr)
 
 #define NVRAM_SIZE        0x2000
 
+static void fw_cfg_boot_set(void *opaque, const char *boot_device,
+                            Error **errp)
+{
+    fw_cfg_modify_i16(opaque, FW_CFG_BOOT_DEVICE, boot_device[0]);
+}
+
 static void ppc_prep_reset(void *opaque)
 {
     PowerPCCPU *cpu = opaque;
@@ -677,4 +687,223 @@ static void prep_machine_init(MachineClass *mc)

[...]

hw/ppc/prep.c static void prep_machine_init(MachineClass *mc) · line 877

Quoted 12 lines
hw/ppc/prep.c +12 -0
+
+    fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_IS_KVM, kvm_enabled());
+    if (kvm_enabled()) {
+#ifdef CONFIG_KVM
+        uint8_t *hypercall;
+
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
+        hypercall = g_malloc(16);
+        kvmppc_get_hypercall(env, hypercall, 16);
+        fw_cfg_add_bytes(fw_cfg, FW_CFG_PPC_KVM_HC, hypercall, 16);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_KVM_PID, getpid());
+#endif

This currently does not compile on a ppc64 host where CONFIG_KVM is set:

hw/ppc/prep.c: In function ‘ibm_40p_init’:
hw/ppc/prep.c:872:9: error: implicit declaration of function ‘kvmppc_get_tbfreq’ [-Werror=implicit-function-declaration]

         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
         ^
hw/ppc/prep.c:872:9: error: nested extern declaration of ‘kvmppc_get_tbfreq’ [-Werror=nested-externs]
hw/ppc/prep.c:874:9: error: implicit declaration of function ‘kvmppc_get_hypercall’ [-Werror=implicit-function-declaration]
         kvmppc_get_hypercall(env, hypercall, 16);
         ^

hw/ppc/prep.c:874:9: error: nested extern declaration of ‘kvmppc_get_hypercall’ [-Werror=nested-externs]

You need to #include "kvm_ppc.h" to get the prototype of the kvmppc_get_tbfreq() function.

Thomas

#6 lore raw

Re: [Qemu-devel] [Qemu-ppc] [PATCH v3 4/4] prep: add IBM RS/6000 7020 (40p) machine emulation

Quoted 12 lines · Thomas Huth

Hi,

Quoted 9 lines · Hervé Poussineau

Machine supports both Open Hack'Ware and OpenBIOS.
Open Hack'Ware is the default because OpenBIOS is currently unable to boot PReP boot partitions or PReP kernels.

---
 default-configs/ppc-softmmu.mak |   1 +
 hw/ppc/prep.c                   | 229 ++++++++++++++++++++++++++++++++++++++++
 2 files changed, 230 insertions(+)

[...]

Quoted 11 lines

This currently does not compile on a ppc64 host where CONFIG_KVM is set:

hw/ppc/prep.c: In function ‘ibm_40p_init’:
hw/ppc/prep.c:872:9: error: implicit declaration of function ‘kvmppc_get_tbfreq’ [-Werror=implicit-function-declaration]

         fw_cfg_add_i32(fw_cfg, FW_CFG_PPC_TBFREQ, kvmppc_get_tbfreq());
         ^
hw/ppc/prep.c:872:9: error: nested extern declaration of ‘kvmppc_get_tbfreq’ [-Werror=nested-externs]
hw/ppc/prep.c:874:9: error: implicit declaration of function ‘kvmppc_get_hypercall’ [-Werror=implicit-function-declaration]
         kvmppc_get_hypercall(env, hypercall, 16);
         ^
Quoted 4 lines

hw/ppc/prep.c:874:9: error: nested extern declaration of ‘kvmppc_get_hypercall’ [-Werror=nested-externs]

You need to #include "kvm_ppc.h" to get the prototype of the kvmppc_get_tbfreq() function.

Done

Applied
#7 lore raw
In reply to Hervé Poussineau
Quoted 12 lines · Hervé Poussineau

Hi,

This patchset adds the emulation of the IBM RS/6000 7020 (40p). The real machine is able to run AIX (up to 4.3.3), Windows NT (up to 4.0 SP1), the beta of OS/2 PowerPC, Solaris, Linux, NetBSD/PReP ...

I've tested current emulation with Open Hack'Ware, OpenBIOS and official firmware.

Linux kernel starts, and freezes during boot (seems like a problem with the SCSI adapter). Windows NT starts up to the point where it wants to change endianness. Other OSes have not been tested.

Quoted 6 lines

This machine is a superset of the 'prep' one, because we know exactly what is/should emulated, and that operating system list running on it is quite wide. I hope that 'prep' machine can be deprecated soon and then later removed.

Patch 1 is a cleanup, and can probably be committed first. Patches 2 to 4 are the real implementation of the IBM 40p.

Applied to ppc-for-2.9, with a slight config tweak to 3/4 to avoid breaking make check on ppc64.

Quoted 27 lines

Changes since v2:
- patch 2: fix mismatch between read and write functions for port 92
- patch 4: use error_report instead of fprintf/hw_error

Changes since v1:
- removed patches related to display adapter:
Let's wait for an emulation of the real display adapter (an S3 Trio), as current VGA adapter already mostly works with Open Hack'Ware and OpenBIOS
- various changes due to David Gibson's remarks

Hervé Poussineau (4):
prep: do not use global variable to access nvram
prep: add PReP System I/O
prep: add IBM RS/6000 7020 (40p) memory controller
prep: add IBM RS/6000 7020 (40p) machine emulation

 default-configs/ppc-softmmu.mak |   2 +
 hw/ppc/Makefile.objs            |   2 +
 hw/ppc/prep.c                   | 233 +++++++++++++++++++++++++++++-
 hw/ppc/prep_systemio.c          | 303 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/rs6000_mc.c              | 232 ++++++++++++++++++++++++++++++
 hw/ppc/trace-events             |  11 ++
 6 files changed, 781 insertions(+), 2 deletions(-)
 create mode 100644 hw/ppc/prep_systemio.c
 create mode 100644 hw/ppc/rs6000_mc.c
Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson
#8 lore raw
In reply to Hervé Poussineau
Quoted 35 lines · Hervé Poussineau

Hi,

This patchset adds the emulation of the IBM RS/6000 7020 (40p). The real machine is able to run AIX (up to 4.3.3), Windows NT (up to 4.0 SP1), the beta of OS/2 PowerPC, Solaris, Linux, NetBSD/PReP ...

I've tested current emulation with Open Hack'Ware, OpenBIOS and official firmware.

Linux kernel starts, and freezes during boot (seems like a problem with the SCSI adapter). Windows NT starts up to the point where it wants to change endianness. Other OSes have not been tested.

This machine is a superset of the 'prep' one, because we know exactly what is/should emulated, and that operating system list running on it is quite wide. I hope that 'prep' machine can be deprecated soon and then later removed.

Patch 1 is a cleanup, and can probably be committed first. Patches 2 to 4 are the real implementation of the IBM 40p.

Changes since v2:
- patch 2: fix mismatch between read and write functions for port 92
- patch 4: use error_report instead of fprintf/hw_error

Changes since v1:
- removed patches related to display adapter:
Let's wait for an emulation of the real display adapter (an S3 Trio), as current VGA adapter already mostly works with Open Hack'Ware and OpenBIOS
- various changes due to David Gibson's remarks

Hervé Poussineau (4):
prep: do not use global variable to access nvram
prep: add PReP System I/O
prep: add IBM RS/6000 7020 (40p) memory controller
prep: add IBM RS/6000 7020 (40p) machine emulation

Quoted 9 lines
 default-configs/ppc-softmmu.mak |   2 +
 hw/ppc/Makefile.objs            |   2 +
 hw/ppc/prep.c                   | 233 +++++++++++++++++++++++++++++-
 hw/ppc/prep_systemio.c          | 303 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/rs6000_mc.c              | 232 ++++++++++++++++++++++++++++++
 hw/ppc/trace-events             |  11 ++
 6 files changed, 781 insertions(+), 2 deletions(-)
 create mode 100644 hw/ppc/prep_systemio.c
 create mode 100644 hw/ppc/rs6000_mc.c

By the way, the PReP machine currently does not have a proper maintainer according to the MAINTAINERS file ... would you maybe volunteer to do that job? If so, could you please send a patch for the MAINTAINERS file?

Thomas

#9 lore raw
Quoted 46 lines · Thomas Huth
Quoted 35 lines · Hervé Poussineau

Hi,

This patchset adds the emulation of the IBM RS/6000 7020 (40p). The real machine is able to run AIX (up to 4.3.3), Windows NT (up to 4.0 SP1), the beta of OS/2 PowerPC, Solaris, Linux, NetBSD/PReP ...

I've tested current emulation with Open Hack'Ware, OpenBIOS and official firmware.

Linux kernel starts, and freezes during boot (seems like a problem with the SCSI adapter). Windows NT starts up to the point where it wants to change endianness. Other OSes have not been tested.

This machine is a superset of the 'prep' one, because we know exactly what is/should emulated, and that operating system list running on it is quite wide. I hope that 'prep' machine can be deprecated soon and then later removed.

Patch 1 is a cleanup, and can probably be committed first. Patches 2 to 4 are the real implementation of the IBM 40p.

Changes since v2:
- patch 2: fix mismatch between read and write functions for port 92
- patch 4: use error_report instead of fprintf/hw_error

Changes since v1:
- removed patches related to display adapter:
Let's wait for an emulation of the real display adapter (an S3 Trio), as current VGA adapter already mostly works with Open Hack'Ware and OpenBIOS
- various changes due to David Gibson's remarks

Hervé Poussineau (4):
prep: do not use global variable to access nvram
prep: add PReP System I/O
prep: add IBM RS/6000 7020 (40p) memory controller
prep: add IBM RS/6000 7020 (40p) machine emulation

Quoted 9 lines
 default-configs/ppc-softmmu.mak |   2 +
 hw/ppc/Makefile.objs            |   2 +
 hw/ppc/prep.c                   | 233 +++++++++++++++++++++++++++++-
 hw/ppc/prep_systemio.c          | 303 ++++++++++++++++++++++++++++++++++++++++
 hw/ppc/rs6000_mc.c              | 232 ++++++++++++++++++++++++++++++
 hw/ppc/trace-events             |  11 ++
 6 files changed, 781 insertions(+), 2 deletions(-)
 create mode 100644 hw/ppc/prep_systemio.c
 create mode 100644 hw/ppc/rs6000_mc.c
Quoted 3 lines

By the way, the PReP machine currently does not have a proper maintainer according to the MAINTAINERS file ... would you maybe volunteer to do that job? If so, could you please send a patch for the MAINTAINERS file?

Yes, that would be much appreciated.

Signature · 4 lines
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson