OpenHackWare hacking
The attached patch addresses a few problems in OpenHackWare:
- The return value from the OpenFirmware read function should not exceed the actual file size by more than one block; otherwise the Linux kernel's initramfs routines get confused by the extra junk and reject the initramfs.
- The OpenFirmware nextprop function should return 1 when a property is found, not the length of the property's name. Otherwise Linux fails to find any properties when unflattening the device tree.
- If the boot file's checksum is unknown, OpenHackWare should assume it's a Linux or OpenBSD boot script rather than barfing.
- The linker script requires Daniel Jacobowitz's fix to build on Fedora 6.
These changes get me a few steps closer to booting an unmodified Fedora 6 PowerPC boot.iso. Outstanding issues include:
- The Fedora 6 version of yaboot looks for a "conf=" parameter in the bootargs to tell it where to find yaboot.conf; OHW needs to read this parameter from the boot script and pass it along.
- After the kernel finally boots, it complains about unhandled interrupts for the CD device. I assume this is a Qemu issue.
Comments welcome.
--Ed
[5~[5~[5~[5~diff -BurN OpenHackWare-release-0.4/src/libexec/chrp.c OpenHackWare-release-0.4.mine/src/libexec/chrp.c
src/libexec/chrp.c +2 -3
@@ -243,9 +243,8 @@DPRINTF ("Boot file embedded at the end of boot script\n" );break ;default : -ERROR ("XML error: unknown Forth script: %08x\n%s\n" , - crc, (char *)tag->data); - goto out; + script_type =CHRP_SCRIPT_LOAD_BOOT ; + goto do_script; }break ;
src/libfs/core.c +5 -1
@@ -421,13 +421,15 @@int fs_read (inode_t *inode,void *buffer,int len) { -uint32_t bsize, total; +uint32_t bsize, total, max;int done, tmp; bsize =part_blocsize (inode->fs->part); total =0 ;if (fs_seek (inode, inode->vbloc, inode->vpos) <0 )return -1 ; + max = inode->size.bloc * bsize + inode->size.offset + - inode->vbloc * bsize + inode->vpos;for (; len !=0 ; len -= done) { tmp = bsize - inode->vpos;if (len < tmp)
@@ -444,6 +446,8 @@ total += done; } +if (total > max) +return max;return total; }
src/main.ld +1 -1
@@ -49,7 +49,7 @@ _sdata_end = . ; . = ALIGN(4) ; _ro_start = . ; - .rodata : { *(.rodata) } > bios + .rodata : { *(.rodata*) } > bios _ro_end = . ; . = ALIGN(4) ; _RTAS_start = .;
src/of.c +1 -1
@@ -4058,7 +4058,7 @@OF_DPRINTF ("Return property name [%s]\n" , next->name);OF_sts (next_name, (void *)(next->name));OF_DUMP_STRING (OF_env, next_name); -pushd (OF_env,strlen (next->name) +1 ); +pushd (OF_env,1 ); } } }
A bit more progress--I can boot the Fedora 6 PPC boot.iso and start Anaconda.
- Both VGA and serial console work with the g3bw machine type; mac99 still crashes early on.
- IDE interrupts are still messed up; my Qemu patch is obviously not quite right.
- OHW's CHRP boot script parsing isn't sophisticated enough to pass arguments to yaboot, as the Fedora 6 boot script does, but you can the arguments manually with the -append option.
- The Linux serial console is very slow.
Here's how I'm starting Qemu:
qemu-system-ppc -cdrom boot.iso -s -append 'conf=cd:, \ppc\ppc32\yaboot.conf' -nographic
Please see the attached patches to OHW and Qemu; I've also included a compiled OHW image.
--Ed
Quoted 18 lines · On Friday 20 April 2007 16:08:56 Ed Swierk wrote:
The attached patch addresses a few problems in OpenHackWare:
- The return value from the OpenFirmware read function should not exceed the actual file size by more than one block; otherwise the Linux kernel's initramfs routines get confused by the extra junk and reject the initramfs.
- The OpenFirmware nextprop function should return 1 when a property is found, not the length of the property's name. Otherwise Linux fails to find any properties when unflattening the device tree.
- If the boot file's checksum is unknown, OpenHackWare should assume it's a Linux or OpenBSD boot script rather than barfing.
- The linker script requires Daniel Jacobowitz's fix to build on Fedora 6.
These changes get me a few steps closer to booting an unmodified Fedora 6 PowerPC boot.iso. Outstanding issues include:
Quoted 8 lines
- The Fedora 6 version of yaboot looks for a "conf=" parameter in the bootargs to tell it where to find yaboot.conf; OHW needs to read this parameter from the boot script and pass it along.
- After the kernel finally boots, it complains about unhandled interrupts for the CD device. I assume this is a Qemu issue.
Comments welcome.
src/libexec/chrp.c +2 -45
@@ -174,48 +174,6 @@ int exec_load_chrp (inode_t *file, void crc, (char *)tag->data);#endif switch (crc) { -case 0x5464F92C : -/* Mandrake 9.1 CD1 boot script */ -case 0x4BC74ECF : -/* Mandrake 10.1 & 10.2 CD1 boot script */ -case 0x5B265246 : -/* Gentoo 1.2-r1 */ -/* Gentoo 2004.1 minimal install CD */ -/* Gentoo 1.4 live CDROM */ -/* Knopix PPC beta-pre12 */ -case 0x75420D8A : -/* Debian woody */ -/* Debian 3.0r1 */ - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -case 0x633e4c9c : -/* Debian Sarge */ -case 0xbe3abf60 : -/* Debian Sarge, installed on a hard disk drive */ - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -case 0x07b86bfe : -/* Linux Fedora Core 3 */ - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -case 0x9ccdf371 : - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -case 0xEF423926 : -/* OpenBSD 3.4 */ -case 0x68e4f265 : -/* OpenBSD 3.5 */ -case 0x3b7ea9e1 : -/* OpenBSD 3.6 */ - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -case 0xB7981DBC : -/* iBook 2 hw test CDROM */ -#if 1 - script_type =CHRP_SCRIPT_LOAD_BOOT ; - goto do_script; -#endif -case 0xEA06C1A7 :/* MacOS 9.2 boot script: * the XCOFF loader is embedded in the file...
@@ -243,9 +201,8 @@ int exec_load_chrp (inode_t *file, voidDPRINTF ("Boot file embedded at the end of boot script\n" );break ;default : -ERROR ("XML error: unknown Forth script: %08x\n%s\n" , - crc, (char *)tag->data); - goto out; + script_type =CHRP_SCRIPT_LOAD_BOOT ; + goto do_script; }break ;
src/libfs/core.c +5 -1
@@ -421,13 +421,15 @@ int fs_seek (inode_t *inode, uint32_t blint fs_read (inode_t *inode,void *buffer,int len) { -uint32_t bsize, total; +uint32_t bsize, total, max;int done, tmp; bsize =part_blocsize (inode->fs->part); total =0 ;if (fs_seek (inode, inode->vbloc, inode->vpos) <0 )return -1 ; + max = inode->size.bloc * bsize + inode->size.offset + - inode->vbloc * bsize + inode->vpos;for (; len !=0 ; len -= done) { tmp = bsize - inode->vpos;if (len < tmp)
@@ -444,6 +446,8 @@ int fs_read (inode_t *inode, void *buffe total += done; } +if (total > max) +return max;return total; }
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 +15 -1
@@ -2371,6 +2371,14 @@ int OF_register_bus (const unsigned charsprintf (buffer,"/%s" , name);OF_prop_string_set (OF_env, als, name, buffer);/* For ISA, should add DMA ranges */ +if (!strcmp (type,"ISA" )) { +uint32_t ranges[4 ]; + ranges[0 ] =0x1 ; + ranges[1 ] =0x0 ; + ranges[2 ] = address; + ranges[3 ] =0x00800000 ; +OF_property_new (OF_env, bus,"ranges" , ranges,16 ); + }OF_node_put (OF_env, bus);OF_node_put (OF_env, als);
@@ -2385,6 +2393,7 @@ int OF_register_serial (const unsigned cunsigned char tmp[OF_NAMELEN_MAX ];OF_env_t *OF_env;OF_node_t *busn, *srl, *als; +uint32_t reg[3 ]; OF_env = OF_env_main; als =OF_node_get (OF_env,"aliases" );
@@ -2401,14 +2410,19 @@ int OF_register_serial (const unsigned c }OF_prop_string_set (OF_env, srl,"device_type" ,"serial" );OF_prop_string_set (OF_env, srl,"compatible" ,"pnpPNP,501" ); + reg[0 ] =1 ;/* IO space */ + reg[1 ] = io_base;/* base address */ + reg[2 ] =8 ;/* range length */ switch (io_base) {case 0x3F8 :OF_pack_get_path (OF_env, tmp,512 , srl);OF_prop_string_new (OF_env, als,"com1" , tmp); +OF_property_new (OF_env, srl,"reg" , reg,12 );break ;case 0x2F8 :OF_pack_get_path (OF_env, tmp,512 , srl);OF_prop_string_new (OF_env, als,"com2" , tmp); +OF_property_new (OF_env, srl,"reg" , reg,12 );break ;default :break ;
@@ -4058,7 +4072,7 @@ static void OF_nextprop (OF_env_t *OF_enOF_DPRINTF ("Return property name [%s]\n" , next->name);OF_sts (next_name, (void *)(next->name));OF_DUMP_STRING (OF_env, next_name); -pushd (OF_env,strlen (next->name) +1 ); +pushd (OF_env,1 ); } } }
hw/grackle_pci.c +1 -1
@@ -82,7 +82,7 @@ static int pci_grackle_map_irq(PCIDevicestatic void pci_grackle_set_irq (void *pic,int irq_num,int level) { -heathrow_pic_set_irq (pic, irq_num +8 , level); +heathrow_pic_set_irq (pic, irq_num +0x15 , level); }PCIBus *pci_grackle_init (uint32_t base,void *pic)
hw/heathrow_pic.c +1 -1
@@ -162,7 +162,7 @@ HeathrowPICS *heathrow_pic_init(int *pme s =qemu_mallocz (sizeof (HeathrowPICS)); s->pics[0 ].level_triggered =0 ; - s->pics[1 ].level_triggered =0x1ff00000 ; + s->pics[1 ].level_triggered =0 ; *pmem_index =cpu_register_io_memory (0 , pic_read, pic_write, s);return s; }
Quoted 3 lines · Ed Swierk
- The Fedora 6 version of yaboot looks for a "conf=" parameter in the bootargs to tell it where to find yaboot.conf; OHW needs to read this parameter from the boot script and pass it along.
That's optional -- if you don't pass it, then yaboot should find /etc/yaboot.conf instead of the 32-bit-specific one, and you'll have to manually choose 'linux32' instead of the default 'linux64'. But the installer should work nonetheless.
Signature · 1 line
dwmw2