Index: openbios-quilt/arch/ppc/qemu/init.c
===================================================================
--- openbios-quilt.orig/arch/ppc/qemu/init.c	2008-12-21 19:31:01.000000000 +0000
+++ openbios-quilt/arch/ppc/qemu/init.c	2008-12-21 19:31:43.000000000 +0000
@@ -27,6 +27,14 @@
 #include "qemu/qemu.h"
 #include "ofmem.h"
 #include "openbios-version.h"
+#include "libc/byteorder.h"
+#define NO_QEMU_PROTOS
+#include "openbios/fw_cfg.h"
+
+#define BIOS_CFG_CMD  0x510
+#define BIOS_CFG_DATA 0x511
+
+#define UUID_FMT "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x"
 
 extern void unexpected_excep( int vector );
 extern void ob_pci_init( void );
@@ -65,6 +73,11 @@
 void
 entry( void )
 {
+        uint32_t temp;
+        unsigned int i;
+        uint16_t machine_id;
+        char buf[256], qemu_uuid[16];
+
 	arch = &known_arch[ARCH_HEATHROW];
 	isa_io_base = arch->io_base;
 
@@ -74,6 +87,47 @@
 	printk("=============================================================\n");
 	printk("OpenBIOS %s [%s]\n", OPENBIOS_RELEASE, OPENBIOS_BUILD_DATE );
 
+        outw(__cpu_to_be16(FW_CFG_SIGNATURE), BIOS_CFG_CMD);
+        for (i = 0; i < 4; i++)
+            buf[i] = inb(BIOS_CFG_DATA);
+
+        buf[4] = '\0';
+
+        printk("Configuration device id %s", buf);
+
+        outw(__cpu_to_be16(FW_CFG_ID), BIOS_CFG_CMD);
+        for (i = 0; i < 4; i++)
+            buf[i] = inb(BIOS_CFG_DATA);
+
+        temp = __le32_to_cpu(*(uint32_t *)buf);
+        printk(" version %d", temp);
+
+        outw(__cpu_to_be16(FW_CFG_MACHINE_ID), BIOS_CFG_CMD);
+        for (i = 0; i < 2; i++)
+            buf[i] = inb(BIOS_CFG_DATA);
+
+        machine_id = __le16_to_cpu(*(uint16_t *)buf);
+
+        printk(" machine id %d\n", machine_id);
+
+        outw(__cpu_to_be16(FW_CFG_NB_CPUS), BIOS_CFG_CMD);
+        for (i = 0; i < 4; i++)
+            buf[i] = inb(BIOS_CFG_DATA);
+
+        temp = __le32_to_cpu(*(uint32_t *)buf);
+
+        printk("CPUs: %x\n", temp);
+
+        outw(__cpu_to_be16(FW_CFG_UUID), BIOS_CFG_CMD);
+        for (i = 0; i < 16; i++)
+            qemu_uuid[i] = inb(BIOS_CFG_DATA);
+
+        printk("UUID: " UUID_FMT "\n", qemu_uuid[0], qemu_uuid[1], qemu_uuid[2],
+               qemu_uuid[3], qemu_uuid[4], qemu_uuid[5], qemu_uuid[6],
+               qemu_uuid[7], qemu_uuid[8], qemu_uuid[9], qemu_uuid[10],
+               qemu_uuid[11], qemu_uuid[12], qemu_uuid[13], qemu_uuid[14],
+               qemu_uuid[15]);
+
 	ofmem_init();
 	initialize_forth();
 	/* won't return */
Index: openbios-quilt/arch/ppc/qemu/main.c
===================================================================
--- openbios-quilt.orig/arch/ppc/qemu/main.c	2008-12-21 19:31:42.000000000 +0000
+++ openbios-quilt/arch/ppc/qemu/main.c	2008-12-21 19:31:43.000000000 +0000
@@ -33,6 +33,8 @@
 #define ELF_DPRINTF(fmt, args...) do { } while (0)
 #endif
 
+#define NVRAM_PORT 0x76
+
 static void
 transfer_control_to_elf( ulong elf_entry )
 {
@@ -130,6 +132,24 @@
     /* won't come here */
 }
 
+static uint8_t nvram_read(uint16_t offset)
+{
+    outb(offset & 0xff, 0x74);
+    outb(offset >> 8, 0x75);
+    return inb(0x77);
+}
+
+static uint32_t nvram_read_be32(uint16_t offset)
+{
+    uint32_t ret;
+
+    ret = nvram_read(offset) << 24;
+    ret |= nvram_read(offset + 1) << 16;
+    ret |= nvram_read(offset + 2) << 8;
+    ret |= nvram_read(offset + 3);
+    return ret;
+}
+
 static void
 yaboot_startup( void )
 {
@@ -160,6 +180,18 @@
                     param = pop_fstr_copy();
                 }
                 try_path(path, param);
+            } else {
+                char boot_device = nvram_read(0x34);
+                switch (boot_device) {
+                case 'c':
+                    path = strdup("hd:2,\\yaboot");
+                    break;
+                default:
+                case 'd':
+                    path = strdup("cdrom:2,\\yaboot");
+                    break;
+                }
+                try_path(path, "");
             }
         }
         for( i=0; i < sizeof(paths) / sizeof(paths[0]); i++ ) {
@@ -168,6 +200,22 @@
 	printk("*** Boot failure! No secondary bootloader specified ***\n");
 }
 
+static void check_preloaded_kernel(void)
+{
+    unsigned long kernel_image, kernel_size, cmdline;
+    unsigned long initrd_image, initrd_size;
+
+    kernel_size = nvram_read_be32(0x3c);
+    if (kernel_size) {
+        kernel_image = nvram_read_be32(0x38);
+        cmdline = nvram_read_be32(0x40);
+        initrd_image = nvram_read_be32(0x48);
+        initrd_size = nvram_read_be32(0x4c);
+        printk("[ppc] Kernel already loaded (0x%8.8lx + 0x%8.8lx)\n",
+               kernel_image, kernel_size);
+        call_elf(kernel_image);
+    }
+}
 
 /************************************************************************/
 /*	entry								*/
@@ -177,5 +225,6 @@
 boot( void )
 {
 	fword("update-chosen");
+        check_preloaded_kernel();
 	yaboot_startup();
 }
