GXemul: SGI O2 emulation

Back to the index.

The SGI O2 emulation mode tries to emulate enough of the main MIPS processor and other peripherals of a real SGI O2 machine, to be able to boot guest OSes.

Emulated hardware:

Things not yet emulated include: SCSI, audio/video boards, the VICE chipset, ...

This page contains instructions for how to install and run:

and also some hints on how to make a backup copy of the PROM from your own O2 and run it in the emulator.


NetBSD/sgimips:

NetBSD/sgimips can run in GXemul on an emulated SGI O2 (also known as IP32). The SCSI controller is not emulated yet, so NetBSD needs to boot with root-on-NFS:

  1. First of all, an "nfs server" machine must be set up. This needs to have a 4000 MB /tftpboot partition. Install NetBSD/pmax 8.0 from CDROM. Do not configure the network and do not install any X11 packages on the nfs server, as they are not needed. Don't forget to add the extra partition!

  2. Download the files corresponding to a NetBSD/sgimips CD-ROM iso image, and the GENERIC and INSTALL kernels:
    	ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-8.0/sgimips/binary/kernel/netbsd-GENERIC32_IP3x.gz
    	ftp://ftp.NetBSD.org/pub/NetBSD/NetBSD-8.0/sgimips/binary/kernel/netbsd-INSTALL32_IP3x.gz
    
    	wget -np -l 0 -r ftp://ftp.netbsd.org/pub/NetBSD/NetBSD-8.0/sgimips/binary/sets/
    	mkisofs -U -o sgimips.iso ftp.netbsd.org/pub/NetBSD/NetBSD-8.0
    
    
  3. Start the DECstation emulation:
    	gxemul -e 3max -d nbsd_pmax.img -d sgimips.iso
    
    
    Log in as root, configure the pmax machine as an NFS server, and extract the files from the sgimips CD-ROM image:

           
    echo hostname=server >> /etc/rc.conf
    echo ifconfig_le0=\"inet 10.0.0.2\" >> /etc/rc.conf
    echo nameserver 10.0.0.254 >> /etc/resolv.conf
    echo 10.0.0.254 > /etc/mygate
    echo /tftpboot -maproot=root 10.0.0.1 > /etc/exports
    echo rpcbind=YES >> /etc/rc.conf
    echo nfs_server=YES >> /etc/rc.conf
    echo mountd=YES >> /etc/rc.conf
    echo bootparamd=YES >> /etc/rc.conf
    printf "client root=10.0.0.2:/tftpboot \\\n swap=10.0.0.2:/tftpboot/swap\n" > /etc/bootparams
    echo "bootps dgram udp wait root /usr/sbin/bootpd bootpd -d 4 -h 10.0.0.2" >> /etc/inetd.conf
    cat >> /etc/bootptab
    client:\
            :ht=ether:\
            :ha=082030000010:\
            :sm=255.0.0.0:\
            :lg=10.0.0.254:\
            :ip=10.0.0.1:\
            :rp=/tftpboot:
    (press CTRL-D)
    echo "08:20:30:00:00:10 client" > /etc/ethers
    echo 10.0.0.1 client > /etc/hosts
    
    cd /tftpboot; mount /dev/cd0a /mnt
    for a in /mnt/*/binary/sets/[bcegmtx]*.tgz; do echo $a; tar zxfp $a; done
    echo 10.0.0.2:/tftpboot / nfs rw 0 0 > /tftpboot/etc/fstab
    echo rc_configured=YES >> /tftpboot/etc/rc.conf
    echo 10.0.0.254 >> /tftpboot/etc/mygate
    echo nameserver 10.0.0.254 >> /tftpboot/etc/resolv.conf
    echo rc_configured=YES >> /tftpboot/etc/rc.conf
    dd if=/dev/zero of=swap bs=1024 count=262144
    cd /; umount /mnt; halt
    

  4. Create a configuration file called config_client:
           
    !  Configuration file for running NetBSD/sgimips diskless with
    !  a NetBSD/pmax machine as the nfs server.
    
    net(
    	add_remote("localhost:12444")   ! the server
    	local_port(12445)               ! the client
    )
    
    machine(
    	name("client machine")
    	serial_nr(1)
    
            type("sgi")
            subtype("o2")
    	use_x11(1)
    	memory(256)
    
            load("netbsd-INSTALL32_IP3x.gz")
            ! load("netbsd-GENERIC32_IP3x.gz")
    )
    
    
    ... and another configuration file for the server, config_server:
           
    net(
    	local_port(12444)               ! the server
    	add_remote("localhost:12445")   ! the client
    )
    
    machine(
    	name("nfs server")
    	serial_nr(2)
    
            type("dec")
            subtype("5000/200")
    
            disk("nbsd_pmax.img")
    )
    
    
  5. Boot the "nfs server" and the NetBSD/sgimips "client machine" as two separate emulator instances:
    	in one xterm:
    	gxemul @config_server
    
    	and then, in another xterm:
    	gxemul @config_client
    
    
  6. In the NetBSD/sgimips window, choose "x: Exit Install System" in the installer's main menu, and then type:
    	ifconfig mec0 10.0.0.1; route add default 10.0.0.254
    	mount -v 10.0.0.2:/tftpboot /mnt
    	cd /mnt/dev; ./MAKEDEV all; cd /; umount /mnt
    	halt
    
    Then, once the client machine has halted, log in as root on the server machine and type reboot.

  7. Once everything has been set up correctly, change netbsd-INSTALL32_IP3x.gz in config_client to netbsd-GENERIC32_IP3x.gz (the GENERIC kernel).

You might want to log in as root on the server machine, and run tcpdump -lnvv or similar, to see that what the client machine actually does on the network.

It should now be possible to boot NetBSD/sgimips using the NetBSD/pmax nfs server, using the following commands: (NOTE! Execute these two commands in separate xterms!)

	gxemul @config_server
	gxemul @config_client

If/when asked for "root device:" etc. on the client machine, enter the following values:

	root device: mec0
	dump device: 				(leave blank)
	file system (default generic): 		(leave blank)
	..
	init path (default /sbin/init):		(leave blank)
	Enter pathname of shell or RETURN for /bin/sh:	(leave blank)
	Terminal type? [unknown] xterm
	..
	# exit			(to leave the single-user shell)

Note: Netbooting like this is very slow, so you need a lot of patience.


OpenBSD/sgi:

OpenBSD/sgi can run in GXemul on an emulated O2 (SGI-IP32), with root on NFS.

https://www.openbsd.org/sgi.html says "The OpenBSD/sgi port was discontinued after the 6.7 release", but it seems that 6.8 is available from the official FTP site anyway.

GXemul does not yet emulate the AHC PCI SCSI controller in the O2, so it needs to boot via the emulated network. Another emulated machine must then be used as the nfs root server, and the emulated O2 machine must boot as a diskless client. Performing this setup is quite time consuming, but necessary:

  1. First of all, the "nfs server" machine must be set up. Install NetBSD/pmax 8.0 from CDROM, perform a default install from CDROM without configuring the network, but add a 4000 MB /tftpboot partition when configuring the disk!

  2. On the host, download the OpenBSD distribution:

           
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/base68.tgz
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/comp68.tgz
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/xbase68.tgz
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/xfont68.tgz
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/xserv68.tgz
    wget http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/xshare68.tgz
    

  3. Start the emulation of the DECstation NFS server using this command line:

           
    gxemul -xe 3max -d nbsd_pmax.img -d base68.tgz -d comp68.tgz -d xbase68.tgz -d xfont68.tgz -d xserv68.tgz -d xshare68.tgz
    
    and enter the following commands to configure the server for NFS serving and extract the OpenBSD distribution:
           
    echo hostname=server >> /etc/rc.conf
    echo ifconfig_le0=\"inet 10.0.0.2\" >> /etc/rc.conf
    echo nameserver 10.0.0.254 >> /etc/resolv.conf
    echo 10.0.0.254 > /etc/mygate
    echo /tftpboot -maproot=root -alldirs 10.0.0.1 > /etc/exports
    echo rpcbind=YES >> /etc/rc.conf
    echo nfs_server=YES >> /etc/rc.conf
    echo mountd=YES >> /etc/rc.conf
    echo bootparamd=YES >> /etc/rc.conf
    printf "client root=10.0.0.2:/tftpboot swap=10.0.0.2:/tftpboot/swap\n" > /etc/bootparams
    echo "08:20:30:00:00:10 client" > /etc/ethers
    echo 10.0.0.1 client > /etc/hosts
    
    cd /tftpboot
    tar xzf /dev/sd1c
    tar xzf /dev/sd2c
    tar xzf /dev/sd3c
    tar xzf /dev/sd4c
    tar xzf /dev/sd5c
    tar xzf /dev/sd6c
    
    tar zxfv var/sysmerge/etc.tgz
    tar zxfv var/sysmerge/xetc.tgz
    
    chmod 1777 tmp
    
    dd if=/dev/zero of=swap bs=1024 count=262144
    
    echo inet 10.0.0.1 > /tftpboot/etc/hostname.mec0
    chmod 640 /tftpboot/etc/hostname.mec0
    echo 10.0.0.254 > /tftpboot/etc/mygate
    echo nameserver 10.0.0.254 > /tftpboot/etc/resolv.conf
    echo 10.0.0.2:/tftpboot / nfs rw 0 0 > /tftpboot/etc/fstab
    echo 10.0.0.2:/tftpboot/swap none swap sw,nfsmntpt=/swap >> /tftpboot/etc/fstab
    
    halt
    

  4. Download the OpenBSD/sgi GENERIC and RAMDISK kernels:
    	http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/bsd.IP32
    	http://ftp.eu.openbsd.org/pub/OpenBSD/6.8/sgi/bsd.rd.IP32
    
    
  5. Create a configuration file called config_client:
           
    !  Configuration file for running OpenBSD/sgi diskless with
    !  a NetBSD/pmax machine as the nfs server.
    !
    !  This config file is for the client.
    
    net(
    	add_remote("localhost:12444")   ! the server
    	local_port(12445)               ! the client
    )
    
    machine(
    	name("client machine")
    	serial_nr(1)
    
            type("sgi")
            subtype("o2")
    	use_x11(1)
    	memory(1024)
    
            load("bsd.rd.IP32")
            ! load("bsd.IP32")
    )
    
    
    ... and another configuration file for the server, config_server:
           
    net(
    	local_port(12444)               ! the server
    	add_remote("localhost:12445")   ! the client
    )
    
    machine(
    	name("nfs server")
    	serial_nr(2)
    
            type("dec")
            subtype("5000/200")
    
            disk("nbsd_pmax.img")
    )
    
    
  6. Boot the "nfs server" and the OpenBSD/sgi "client machine" as two separate emulator instances:
    	in one xterm:
    	gxemul @config_server
    
    	and then, in another xterm:
    	gxemul @config_client
    
    
  7. In the emulated OpenBSD/sgi client, type 's' for Shell and run these commands:
           
    ifconfig mec0 10.0.0.1; route add default 10.0.0.254
    mount -v 10.0.0.2:/tftpboot /mnt
    cd /mnt/dev; ./MAKEDEV all; cd /; umount /mnt
    reboot
    
  8. Change bsd.rd.IP32 to bsd.IP32 in the client configuration file.
  9. Finally, run the client again:
    	gxemul @config_client
    
    

    If the root device is not auto-detected, enter mec0.

Log in as root, with empty password. To start X11, type startx. Note that the emulation is a bit slow, mostly due to having the file system on NFS.


Linux for O2

NOTE: This does not work yet. Some old kernels may work, but I have not had the time to set up NFS netbooting so I don't know whether that would really work, or trigger other bugs.

Some kernels (Linux 2.5 and 2.6) from the years 2002 - 2004 can be found here: https://www.linux-mips.org/~glaurung/
Other kernels here: Debian Linux for O2

Example with https://www.linux-mips.org/~glaurung/O2/linux-2.5.47/kernel/vmlinux64-r10k (launced using gxemul -X -e o2 vmlinux64-r10k):

Another kernel to try could be: http://mirrors.telepoint.bg/debian/dists/stretch/main/installer-mips/20150718/images/r5k-ip32/netboot-boot.img


Experimenting with booting IRIX from a real SGI O2

NOTE: This does not work yet. These instructions are here mostly for me to know where to continue debugging, when there is time.

Preliminary instruction for how to boot the kernel from your real O2:

$ gxemul -X -e o2 unix

where unix is the IP32 kernel. If you do not want to use the graphical framebuffer (-X), you can use lower-case -x to just use an xterm instead.

IRIX Release 6.5 IP32 Version 10151453 System V
Copyright 1987-2002 Silicon Graphics, Inc.
All Rights Reserved.

Total real memory  = 131072 kbytes
CPU Frequency = 134Mhz
1 CPU(s)

Free small K0 = 0x411 pages (adding 0xa4 pages)

QLFC: running as interrupt thread.
QLFC: using spinlocks.

PCI Configuration Report

keyboard on port 0, mouse on port 1
ec0: hardware ethernet address 08:20:30:00:00:10
919 buffers
PANIC: vfs_mountroot: no root found
[Press reset to restart the machine.]

Right now, it does not work. There are several problems, most importantly there is no way to get IRIX to find the root file system from which to run; SCSI is not emulated, and the network emulation in GXemul is not good enough for IRIX to accept it for root-on-nfs. Also, attempting to use more than 256 MB of RAM fails.


Experimenting with a PROM from a real SGI O2

Note: Normally, a dump of the PROM image from your real SGI O2 is not needed, if what you want to do is to run guest operating systems in the emulator.

Using a serial console hooked up to your O2, executing the PROM command

>> dump -b 0xBFC00000:0xBFC80000

will dump 512 KB of the PROM range. Make sure you capture all the output into a file, and then convert the result into a raw binary. (If you don't have time to write a converter tool yourself, there is an example converter in the GXemul source code distribution: experiments/sgiprom_to_bin.)

Assuming you have extracted the PROM from your real machine into a file called prom, the following example shows how to start up the emulator with that image:

$ gxemul -Q -X -e o2 0xbfc00000:prom

-Q turns off GXemul's built-in PROM emulation, allowing raw PROM images to be used. -X is used to display the graphical framebuffer. (-X can be omitted if only serial console is what you want.) And finally, -e o2 selects the O2 emulation mode. 0xbfc00000 is the standard ROM address for MIPS-based systems.

The photo on the left is from the real machine. The screenshot to the right is from the emulator.

NOTE: The SGI O2 PROM does some hardware tests during startup that do not work in GXemul, in particular cache detection. So right now, there is a hack/workaround which skips cache detection in an ugly way. This has been verified to work with PROM versions 2.3, 4.13, and 4.18. For other versions, it may need to be manually skipped.

With a IP32 PROM version 4.13 for example, if the hack is commented out, the cache detection routine at 0xbfc05180 must be skipped:

$ gxemul -p 0xffffffffbfc05180 -X -Q -e o2 0xbfc00000:prom-4.13

...
when the breakpoint is hit, type:

pc = ra
continue

If the 'console' variable in the PROM's environment variable section was set to something starting with 'g', output will be graphical, otherwise it will be to serial console.

Note however that almost nothing works; most importantly, SCSI is not implemented for the SGI O2, so the emulated machine will not be able to boot from any kind of disk or CDROM. Audio or video hardware is not emulated at all yet either. Also, while the graphics emulation has been implemented well enough to run NetBSD, OpenBSD, and perhaps also Linux, other things may not work.