As a newbee in this space I got qemu-system-sparc[64] running on a linux machine.
Trying to find out how qemu and openbios work together I'm currently looking into building openbios-sparc64.
This goes with mixed success as https://www.openfirmware.info/OpenBIOS has nice description on how to build openbios, but there's a missing link as to how to harvest the openbios-sparc64 from this.
My build of openbios is done on an Ultra60(Sparc) machine that runs:
Linux ultra60 4.19.0-2-sparc64 #1 Debian 4.19.16-1 (2019-01-17) sparc64 GNU/Linux
with gcc --version
gcc (Debian 8.3.0-2) 8.3.0
It seems like the file openbios/obj-sparc64/openbios-builtin.elf may be the candidate to become openbios-sparc64??
When giving this a try, and moving openbios-builtin.elf to my x86 qemu machine, it crashes spectacularly with:
qemu: fatal: Trap 0x0064 while trap level (5) >= MAXTL (5), Error state
pc: 0000000000004c80 npc: 0000000000004c84
%g0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%g4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%o0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%o4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%l0-3: 00000000fff001e0 000001ff00000000 000001fff0080000 0000000000000000
%l4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%i0-3: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%i4-7: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f00: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f08: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f16: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f24: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f32: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f40: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f48: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
%f56: 0000000000000000 0000000000000000 0000000000000000 0000000000000000
pstate: 00000414 ccr: 44 (icc: -Z-- xcc: -Z--) asi: 00 tl: 5 pil: 0 gl: 2
tbr: 0000000000000000 hpstate: 0000000000000000 htba: 0000000000000000
cansave: 6 canrestore: 0 otherwin: 0 wstate: 0 cleanwin: 6 cwp: 7
fsr: 0000000000000000 y: 0000000000000000 fprs: 0000000000000000
On x86: Booting qemu with the provided openbios-sparc64 rom works flawless.
On the Ultra60: Running ./openbios-unix openbios-sparc64.dict seems to behave as expected:
Output device screen not found.
Input device keyboard not found.
Output device screen not found.
Type 'help' for detailed information
[unix] Booting default not supported.
Trying disk...
No valid state has been set by load or init-program
0 > help
To get openbios build, I had to make a small change in Makefile.target:
#CFLAGS+= -Werror
CFLAGS+= -Wno-error
To "fix":
Building OpenBIOS for sparc64
Building...
/usr/bin/xsltproc
error:
CC target/arch/unix/unix.o
CC target/arch/unix/boot.o
/sources/openbios/arch/unix/boot.c:101:6: error: redundant redeclaration of 'forth_fw_cfg_read_file' [-Werror=redundant-decls]
void forth_fw_cfg_read_file(void);
^~~~~~~~~~~~~~~~~~~~~~
In file included from ./target/include/asm/io.h:8,
from /sources/openbios/include/kernel/kernel.h:22,
from /sources/openbios/include/libopenbios/bindings.h:21,
from /sources/openbios/arch/unix/boot.c:6:
/sources/openbios/include/arch/common/fw_cfg.h:104:6: note: previous declaration of 'forth_fw_cfg_read_file' was here
void forth_fw_cfg_read_file(void);
^~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
Any pointers or suggestions to continue this journey are appreciated.
Ok, I made those changes to openbios, here is the output.
> On May 8, 2018, at 6:50 AM, Joe van Tunen <joevt(a)shaw.ca> wrote:
>
> : (debug-feval) ( fcode# -- fcode# )
> \ Address
> fcode-stream 1 - . here u. ." : "
>
> \ Indicate if word is compiled
> state @ 0<> if
> ." (compile) "
> then
> dup fcode>xt cell - lfa2name type
> dup ." [ 0x" . ." ]" cr
> ;
QEMU mac99 emulates two of the three PCI buses found on real
PowerMac3,1 but OpenBIOS only handles a single PCI bus and initialises
and puts info in the device tree of the second PCI bus only which is
where devices are connected and calls it bus 0. However, some clients
may not know about this or have hardcoded assumptions and erroneously
use the address of the first bus to access PCI config registers for
devices on the second bus which silently fails as these requests will
go to the other empty bus emulated and return invalid values. Devices
mapped via MMIO still appear to work but they may not be correctly
initialised and some cards are not detected because of this.
Until support for multiple PCI buses is implemented add an empty node
in the device tree for the uninitialised bus to let clients know about
it. This fixes detecting PCI devices (such as USB) under MorphOS and
may also fix enabling the bus master bit needed with some network
cards and allow the workarund for that to be reverted.
Signed-off-by: BALATON Zoltan <balaton(a)eik.bme.hu>
---
arch/ppc/qemu/init.c | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 50 insertions(+)
diff --git a/arch/ppc/qemu/init.c b/arch/ppc/qemu/init.c
index f72728c..a996404 100644
--- a/arch/ppc/qemu/init.c
+++ b/arch/ppc/qemu/init.c
@@ -716,6 +716,46 @@ static void kvm_of_init(void)
fword("finish-device");
}
+static void empty_pci_bus_init(void)
+{
+ if (machine_id == ARCH_MAC99) {
+ activate_device("/");
+ fword("new-device");
+ push_str("pci");
+ fword("device-name");
+ push_str("pci");
+ fword("device-type");
+ PUSH(0xf0000000);
+ fword("encode-int");
+ PUSH(0x02000000);
+ fword("encode-int");
+ fword("encode+");
+ push_str("reg");
+ fword("property");
+ PUSH(3);
+ fword("encode-int");
+ push_str("#address-cells");
+ fword("property");
+ PUSH(2);
+ fword("encode-int");
+ push_str("#size-cells");
+ fword("property");
+ PUSH(1);
+ fword("encode-int");
+ push_str("#interrupt-cells");
+ fword("property");
+ PUSH(0);
+ fword("encode-int");
+ PUSH(0);
+ fword("encode-int");
+ fword("encode+");
+ push_str("bus-range");
+ fword("property");
+ fword("finish-device");
+ device_end();
+ }
+}
+
/*
* filll ( addr bytes quad -- )
*/
@@ -859,7 +899,17 @@ arch_of_init(void)
feval("['] ppc-dma-sync to (dma-sync)");
#ifdef CONFIG_DRIVER_PCI
+ /* Add empty node for first pci bus on MAC99 */
+ /* Remove this when pci driver is fixed to handle multiple buses */
+ empty_pci_bus_init();
ob_pci_init();
+ if (machine_id == ARCH_MAC99) {
+ phandle_t dev = find_dev("/pci@f2000000");
+ if (dev) {
+ u32 props[2] = {0, 1};
+ set_property(dev, "bus-range", (char *)props, 2 * sizeof(props[0]));
+ }
+ }
#endif
printk("\n");
--
2.13.7
A recent patch to QEMU that allows sun4m machines to be launched with -vga none
revealed a crash on startup due to the missing framebuffer.
Signed-off-by: Mark Cave-Ayland <mark.cave-ayland(a)ilande.co.uk>
Mark Cave-Ayland (2):
sbus: don't use internal fallback TCX driver with QEMU
SPARC32: use serial console when QEMU is launched with -vga none
arch/sparc32/init.fs | 7 +++++--
arch/sparc32/openbios.c | 8 ++++++++
drivers/sbus.c | 11 +++++++++++
3 files changed, 24 insertions(+), 2 deletions(-)
--
2.11.0