Qemu/PPC and OpenBSD
This is as far as I was able to get to booting OpenBSD/macppc under qemu. Posting in the hopes that it will be useful to someone, or motivate someone who understands PCI better than I do to give me a nudge in the right direction.
- Take the OpenHack'Ware 0.4.1 tarball.
- Apply the patch from qemu/pc-bios/ohw.diff.
- Apply the patch attached to this message.
- Unpack a zlib 1.2.3 tarball and rename it to src/libz in OHW.
- Get a powerpc-linux cross compiler.
- Build OHW by 'make CROSS_COMPILE=powerpc-linux-'.
- Point qemu at the build copy with an appropriate -L option.
- Boot qemu like this:
./obj/ppc-softmmu/qemu-system-ppc -hda openbsd.img -cdrom cd40.iso \
-L OpenHackWare-release-0.4 -boot d -M mac99
You can get cd40.iso off of ftp.openbsd.org.
I added zlib support, because the OpenBSD boot image is compressed ELF. It's not pretty, but that part works fine. I also made it work with my 4.1-based compiler, fixed a cosmetic bug in printf, and provided /memory/available since OpenBSD relies on it.
Right now it hangs initializing ADB. The Cuda starts starts out at 0x80896000, then moves to 0x80816000 at some point during PCI initialization. OpenBSD stalls trying to get a response from it at the first address when qemu thinks it's at the second address. I don't know where it's supposed to be, but I would guess this is a problem in the emulation of the PCI controller.
The console is a bit messed up too.
-M g3bw: Seems to be the same. The console doesn't stop updating earlier in the boot, so something is a tiny bit happier, but cuda still gets stuck.
-M prep: doesn't check for ADB, so doesn't hang there. Crashes later. Not sure where, GDB couldn't backtrace far enough.
Signature · 2 lines
Daniel Jacobowitz CodeSourcery
Makefile renamed from OpenHackWare-release-0.4/Makefile +9 -0
@@ -44,6 +44,7 @@ DISTDIR:= . SRCDIR:= src CC_BASE:= $(shell $(CC) -print-search-dirs | grep install | sed -e 's/.*\ //') +CC_BASE:= $(shell $(CC) -print-file-name=include | sed -e 's,/include$$,,') CFLAGS= -Wall -W -Werror -O2 -g -fno-builtin -fno-common -nostdinc -mregnames CFLAGS+= -DBUILD_DATE=$(BUILD_DATE) -DBUILD_TIME=$(BUILD_TIME) CFLAGS+= -I$(SRCDIR)/ -I$(SRCDIR)/libc/include -I$(CC_BASE)/include
@@ -97,6 +98,9 @@ main.out_OBJS+= $(addprefix $(OBJDIR)/, # libexec objects libexec_OBJS:= core.o elf.o xcoff.o macho.o chrp.o prep.o pef.o main.out_OBJS+= $(addprefix $(OBJDIR)/exec_, $(libexec_OBJS)) +# libz objects +libz_OBJS:= inflate.o adler32.o crc32.o inftrees.o inffast.o zutil.o +main.out_OBJS+= $(addprefix $(OBJDIR)/z_, $(libz_OBJS)) # libfs objects libfs_OBJS:= core.o raw.o ext2.o isofs.o hfs.o main.out_OBJS+= $(addprefix $(OBJDIR)/fs_, $(libfs_OBJS))
@@ -207,6 +211,11 @@ $(OBJDIR)/exec_%.o: $(SRCDIR)/libexec/%. @$(DEBUG) "CFLAGS = $(CFLAGS)" $(CC) -c $(CFLAGS) -o $@ $< +# libz objects +$(OBJDIR)/z_%.o: $(SRCDIR)/libz/%.c + @$(DEBUG) "CFLAGS = $(CFLAGS)" + $(CC) -c $(CFLAGS) -DZ_PREFIX -o $@ $< + # libfs objects $(OBJDIR)/fs_%.o: $(SRCDIR)/libfs/%.c @$(DEBUG) "CFLAGS = $(CFLAGS)"
src/bios.h renamed from OpenHackWare-release-0.4/src/bios.h +1 -1
@@ -22,7 +22,7 @@#define __BIOS_H__#define USE_OPENFIRMWARE -//#define DEBUG_BIOS 1 +#define DEBUG_BIOS 1#define BIOS_VERSION "0.4.1"
src/libc/include/limits.h renamed from OpenHackWare-release-0.4/src/libc/include/limits.h +1 -0
@@ -0,0 +1 @@ +/* empty for now? */
src/libc/src/format.c renamed from OpenHackWare-release-0.4/src/libc/src/format.c +1 -1
@@ -187,7 +187,7 @@ static size_t outhex (outf_t outf, void } }if (fill >0 ) - fill -= pos -7 ; + fill -=7 - pos;for (; fill !=0 && pos != (size_t )-1 ; fill--) { buffer[pos--] ='0' ; }
src/libexec/chrp.c renamed from OpenHackWare-release-0.4/src/libexec/chrp.c +3 -1
@@ -169,7 +169,7 @@ int exec_load_chrp (inode_t *file, voidcase CHRP_TAG_BOOT_SCRIPT :/* Here is the interresting part... */ crc =crc32 (0 , tag->data, tag->dlen); -#if 0 +#if 1 DPRINTF ("Forth script: %08x\n%s\n" , crc, (char *)tag->data);#endif
@@ -207,6 +207,8 @@ int exec_load_chrp (inode_t *file, void/* OpenBSD 3.5 */ case 0x3b7ea9e1 :/* OpenBSD 3.6 */ +case 0xd67495a2 : +/* OpenBSD 4.0 */ script_type =CHRP_SCRIPT_LOAD_BOOT ; goto do_script;case 0xB7981DBC :
src/libexec/core.c renamed from OpenHackWare-release-0.4/src/libexec/core.c +4 -0
@@ -43,6 +43,7 @@ uint32_t file_seek (inode_t *file, uint3enum {FILE_TYPE_ELF =0 , +FILE_TYPE_ZELF ,FILE_TYPE_XCOFF ,FILE_TYPE_MACHO ,FILE_TYPE_PEF ,
@@ -73,6 +74,9 @@ int _bootfile_load (inode_t *file, voidcase FILE_TYPE_ELF : do_load = &exec_load_elf;break ; +case FILE_TYPE_ZELF : + do_load = &exec_load_zelf; +break ;case FILE_TYPE_XCOFF : do_load = &exec_load_xcoff;break ;
src/libexec/elf.c renamed from OpenHackWare-release-0.4/src/libexec/elf.c +172 -0
181 lines not on this page · raw message
src/libexec/exec.h renamed from OpenHackWare-release-0.4/src/libexec/exec.h +2 -0
@@ -26,6 +26,8 @@ int _bootfile_load (inode_t *file, void uint32_t loffset, int type);int exec_load_elf (inode_t *file,void **dest,void **entry,void **end,uint32_t loffset); +int exec_load_zelf (inode_t *file,void **dest,void **entry,void **end, +uint32_t loffset);int exec_load_xcoff (inode_t *file,void **dest,void **entry,void **end,uint32_t loffset); int exec_load_macho (inode_t *file, void **dest, void **entry, void **end,
src/main.ld renamed from OpenHackWare-release-0.4/src/main.ld +1 -1
@@ -49,7 +49,7 @@ SECTIONS _sdata_end = . ; . = ALIGN(4) ; _ro_start = . ; - .rodata : { *(.rodata) } > bios + .rodata : { *(.rodata*) } > bios _ro_end = . ; . = ALIGN(4) ; _RTAS_start = .;
src/of.c renamed from OpenHackWare-release-0.4/src/of.c +6 -5
@@ -1970,10 +1970,11 @@ int OF_register_memory (uint32_t memsize regs[3 ].address =0x00000000 ; regs[3 ].size =0x00000000 ;OF_property_new (OF_env, mem,"reg" , regs,4 *sizeof (OF_regprop_t)); -#if 0 #if 1 - regs[0 ].address =0x00000000 ; - regs[0 ].size =0x05800000 ; +#if 1 +/* Remove 0x3000 for the interrupt table. */ + regs[0 ].address =0x00003000 ; + regs[0 ].size =0x05800000 -0x3000 ; regs[1 ].address =0x06000000 ; regs[1 ].size = memsize -0x06000000 ; regs[2 ].address =0x00000000 ;
@@ -3101,8 +3102,8 @@ static void OF_serial_write (OF_env_t *O/* XXX: should use directly the serial port * and have another console package. */ -console_write (str, len); -pushd (OF_env,0 ); + len =console_write (str, len); +pushd (OF_env, len); }static void OF_serial_read (OF_env_t *OF_env)