After applying this version 2 of this patch series, I can successfully run "Micoport UNIX System V/386, v 2.1" (ca 1987) under qemu. (although not if I try to enable KVM)
Version 1 of this series was posted about 4 weeks ago. See http://patchwork.ozlabs.org/project/qemu-devel/list/?submitter=15654 The patches are all independent, except that the documentation part of patch 5 (vga) adds onto patch 4 (retrace=) changes. Patches 2 (mov crN), 5 (vga/cga), and 6 (spurious interrupts) are required to run this UNIX. The other three patches are trivial improvements I noticed while tracking down the main issues. The first four patches are probably trivially obvious. The last two patches might be a little controversial, since they add hacks to work around what could be argued are operating system bugs. But I've tried to make them minimal impact (leave them disabled by default, isolate relevant code in minimal number of places, etc), and tried to implement and describe them so that they might be useful for other old OS's and programs besides my old version of UNIX. ================== Just for reference, in case someone else wants to debug similar issues with other operating systems, here are some notes about running and debugging this UNIX system under qemu: - This version of UNIX seems to hard code the number of tracks per cylinder for the hard drive to 17. So build your drive image with that in mind, and tell qemu to use 17 tracks per cylinder. - This version of UNIX seems to think it doesn't have any RAM unless I configure the virtual machine with 17MB or less RAM. I've mostly been reducing that to 15 while debugging other issues, just to eliminate any possible problems at 16. Someday I'll try 17 again. - I use a command line similar to the following (from a shell script): qemu-system-i386 -monitor stdio -m 15 -hdachs 977,5,17 -hda "$diskC" \ -drive file="$installDisk",if=floppy,snapshot=on -no-fd-bootchk \ -vga std,cga_hacks=palette_blanking+font_height \ -no-spurious-interrupt-hack - -no-shutdown and -no-reboot were also handy for tracking some of the early bootup issues (mov crN patch). - Without my cga hacks patch, you can get a snapshot of the screen by running "pmemsave 0xb8000 0x8000 screenDump.out" in the monitor, and then examining every other byte of screenDump.out externally. - Other tools: - I can mount the first install floppy in Linux if I skip the first track: mount -t sysv -r -o loop,offset=15K "$installDisk" /mnt/misc - I can also mount the UNIX hard drive in Linux, but I don't know a good way to find the correct offset. UNIX seems to use it's own partition scheme within a DOS-style partition, so it doesn't work to just use the offset of the (DOS) partition. "kpartx" and "pvscan" sounded promising, but only seem to find DOS partitions. Perhaps reboot with the "max_part" option on a kernel configured with the correct partitioning scheme enabled? I found the offset by brute force trying every sector on the the above hard disk. The actual number likely depends on a lot of things. mount -t sysv -r -o loop,offset=5178880 "$diskC" /mnt/misc - GNU objdump can dissassemble the kernel with something like "objdump -s -d $MOUNTPOINT/unix" from Linux, including function names but not much else. But objdump needs to be configured with something like: ./configure -enable-target=i386-foobar-coff - gdb can recognize function names from UNIX kernel if configured with something like "./configure -target=i386-foobar-coff". Use qemu's "-s" option, run "gdb $MOUNTPOINT/unix", and issue the gdb command "target remote:1234". After the floppy boots (kernel loaded in RAM), but before it accesses the hard disk, I could set breakpoints early in panic like "break splintpanic2". I could examine registers ("info registers" or "info all-registers") and memory, but the call stack tended to be truncated early. ================== Matthew Ogilvie (6): fix some debug printf format strings target-i386/translate.c: mov to/from crN/drN: ignore mod bits vl: fix -hdachs/-hda argument order parsing issues qemu-options.hx: mention retrace= VGA option vga: add some optional CGA compatibility hacks i8259: add -no-spurious-interrupt-hack option cpu-exec.c | 12 +++++---- hw/cirrus_vga.c | 4 +-- hw/i8259.c | 21 +++++++++++++++- hw/ide/cmd646.c | 5 ++-- hw/ide/via.c | 5 ++-- hw/pc.h | 4 +++ hw/vga.c | 39 +++++++++++++++++++++++------ qemu-options.hx | 38 +++++++++++++++++++++++++++- sysemu.h | 1 + target-i386/translate.c | 14 ++++++++--- vl.c | 66 +++++++++++++++++++++++++++++++++---------------- 11 files changed, 163 insertions(+), 46 deletions(-) -- 1.7.10.2.484.gcd07cc5