* [Qemu-devel] OpenHackWare hacking
@ 2007-04-20 23:08 Ed Swierk
2007-04-23 5:10 ` Ed Swierk
2007-04-25 12:13 ` David Woodhouse
0 siblings, 2 replies; 3+ messages in thread
From: Ed Swierk @ 2007-04-20 23:08 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1158 bytes --]
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
[-- Attachment #2: ohw2.patch --]
[-- Type: text/x-diff, Size: 2711 bytes --]
[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);
}
}
}
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] OpenHackWare hacking
2007-04-20 23:08 [Qemu-devel] OpenHackWare hacking Ed Swierk
@ 2007-04-23 5:10 ` Ed Swierk
2007-04-25 12:13 ` David Woodhouse
1 sibling, 0 replies; 3+ messages in thread
From: Ed Swierk @ 2007-04-23 5:10 UTC (permalink / raw)
To: qemu-devel
[-- Attachment #1: Type: text/plain, Size: 1942 bytes --]
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
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:
>
> - 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.
[-- Attachment #2: ohw2.patch --]
[-- Type: text/x-diff, Size: 6402 bytes --]
Index: OpenHackWare-release-0.4/src/libexec/chrp.c
===================================================================
--- OpenHackWare-release-0.4.orig/src/libexec/chrp.c
+++ OpenHackWare-release-0.4/src/libexec/chrp.c
@@ -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, void
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;
Index: OpenHackWare-release-0.4/src/libfs/core.c
===================================================================
--- OpenHackWare-release-0.4.orig/src/libfs/core.c
+++ OpenHackWare-release-0.4/src/libfs/core.c
@@ -421,13 +421,15 @@ int fs_seek (inode_t *inode, uint32_t bl
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 @@ int fs_read (inode_t *inode, void *buffe
total += done;
}
+ if (total > max)
+ return max;
return total;
}
Index: OpenHackWare-release-0.4/src/main.ld
===================================================================
--- OpenHackWare-release-0.4.orig/src/main.ld
+++ OpenHackWare-release-0.4/src/main.ld
@@ -49,7 +49,7 @@ SECTIONS
_sdata_end = . ;
. = ALIGN(4) ;
_ro_start = . ;
- .rodata : { *(.rodata) } > bios
+ .rodata : { *(.rodata*) } > bios
_ro_end = . ;
. = ALIGN(4) ;
_RTAS_start = .;
Index: OpenHackWare-release-0.4/src/of.c
===================================================================
--- OpenHackWare-release-0.4.orig/src/of.c
+++ OpenHackWare-release-0.4/src/of.c
@@ -2371,6 +2371,14 @@ int OF_register_bus (const unsigned char
sprintf(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 c
unsigned 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_en
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);
}
}
}
[-- Attachment #3: qemu-ppc-interrupts.patch --]
[-- Type: text/x-diff, Size: 1065 bytes --]
Index: qemu-snapshot-2007-02-09_05/hw/grackle_pci.c
===================================================================
--- qemu-snapshot-2007-02-09_05.orig/hw/grackle_pci.c
+++ qemu-snapshot-2007-02-09_05/hw/grackle_pci.c
@@ -82,7 +82,7 @@ static int pci_grackle_map_irq(PCIDevice
static 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)
Index: qemu-snapshot-2007-02-09_05/hw/heathrow_pic.c
===================================================================
--- qemu-snapshot-2007-02-09_05.orig/hw/heathrow_pic.c
+++ qemu-snapshot-2007-02-09_05/hw/heathrow_pic.c
@@ -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;
}
[-- Attachment #4: ppc_rom.bin.bz2 --]
[-- Type: application/x-bzip2, Size: 61164 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [Qemu-devel] OpenHackWare hacking
2007-04-20 23:08 [Qemu-devel] OpenHackWare hacking Ed Swierk
2007-04-23 5:10 ` Ed Swierk
@ 2007-04-25 12:13 ` David Woodhouse
1 sibling, 0 replies; 3+ messages in thread
From: David Woodhouse @ 2007-04-25 12:13 UTC (permalink / raw)
To: qemu-devel
On Fri, 2007-04-20 at 16:08 -0700, Ed Swierk wrote:
> - 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.
--
dwmw2
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-04-25 12:20 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-04-20 23:08 [Qemu-devel] OpenHackWare hacking Ed Swierk
2007-04-23 5:10 ` Ed Swierk
2007-04-25 12:13 ` David Woodhouse
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).