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
--- OpenHackWare-release-0.4/src/libexec/chrp.c	2005-03-30 23:23:33.000000000 -0800
+++ OpenHackWare-release-0.4.mine/src/libexec/chrp.c	2007-04-19 13:06:53.000000000 -0700
@@ -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;
 
diff -BurN OpenHackWare-release-0.4/src/libfs/core.c OpenHackWare-release-0.4.mine/src/libfs/core.c
--- OpenHackWare-release-0.4/src/libfs/core.c	2005-03-30 23:23:33.000000000 -0800
+++ OpenHackWare-release-0.4.mine/src/libfs/core.c	2007-04-20 15:50:02.000000000 -0700
@@ -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;
 }
 
diff -BurN OpenHackWare-release-0.4/src/main.ld OpenHackWare-release-0.4.mine/src/main.ld
--- OpenHackWare-release-0.4/src/main.ld	2005-03-30 23:23:33.000000000 -0800
+++ OpenHackWare-release-0.4.mine/src/main.ld	2007-04-19 13:01:25.000000000 -0700
@@ -49,7 +49,7 @@
         _sdata_end = . ;
         . = ALIGN(4) ;
         _ro_start = . ;
-        .rodata    : { *(.rodata) } > bios
+        .rodata    : { *(.rodata*) } > bios
         _ro_end = . ;
         . = ALIGN(4) ;
         _RTAS_start = .;
diff -BurN OpenHackWare-release-0.4/src/of.c OpenHackWare-release-0.4.mine/src/of.c
--- OpenHackWare-release-0.4/src/of.c	2007-04-20 15:46:23.000000000 -0700
+++ OpenHackWare-release-0.4.mine/src/of.c	2007-04-20 14:56:56.000000000 -0700
@@ -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);
         }
     }
 }

Reply via email to