qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] sparc-softmmu with sun prom image?


From: Robert Reif
Subject: Re: [Qemu-devel] sparc-softmmu with sun prom image?
Date: Wed, 06 May 2009 22:41:24 -0400
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.21) Gecko/20090303 SeaMonkey/1.1.15 (Ubuntu-1.1.15+nobinonly-0ubuntu2)

Brian Wheeler wrote:
I grabbed a prom image from my SS10 and it mostly works, but the idprom
stuff seems to be broken.  Has anyone tried this?  When I run 'printenv'
at the ok prompt it gives me a data access error and when I turned on
the debuging of unmapped memory, it would try to read at an offset just
above the allocated ram.

Brian


Here is a patch I did about a month ago when more OpenBios
parameters were added to nvram.  The format used by
OpenBios is different from OpenBoot so the added parameters
made running an OpenBoot PROM image worse than before.

This patch lets you load nvram from a file rather than letting
qemu fill it with OpenBios parameters.  Use a file with all zeros
except for the idprom area.  I have a small program to generate
an nvram image with idprom for an SS-10. Start OpenBoot and run
set-defaults just like you would with a new NVRAM chip.  You
will then be able to run printenv without a crash.  You could also
get the nvram image from a real machine.

I never submitted this patch because there in no simple way
to save the nvram contents at program exit.  There are no
destructor functions for either QEMUMachine or a QEMU
hardware device.  Is anyone else interested in adding
destructor functions to devices or machines?  Is this even
feasible?

I also have a small patch for eccmemctl and a large patch
for better SuperSPARC CPU support that I'm sitting on.  They
help a little with getting an SS-10 OpenBoot PROM working
better but there is still a long way to go.  The biggest piece
missing from QEMU is probably sbus emulation.  This will
be needed before OpenBoot could be used to load an OS.
Index: vl.c
===================================================================
--- vl.c        (revision 6967)
+++ vl.c        (working copy)
@@ -189,6 +189,7 @@
 
 const char *bios_dir = CONFIG_QEMU_SHAREDIR;
 const char *bios_name = NULL;
+const char *nvram_name = NULL;
 static void *ioport_opaque[MAX_IOPORTS];
 static IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
 static IOPortWriteFunc *ioport_write_table[3][MAX_IOPORTS];
@@ -4658,6 +4659,9 @@
             case QEMU_OPTION_bios:
                 bios_name = optarg;
                 break;
+            case QEMU_OPTION_nvram:
+                nvram_name = optarg;
+                break;
             case QEMU_OPTION_S:
                 autostart = 0;
                 break;
Index: qemu-options.hx
===================================================================
--- qemu-options.hx     (revision 6967)
+++ qemu-options.hx     (working copy)
@@ -1265,6 +1265,13 @@
 Set the filename for the BIOS.
 ETEXI
 
+DEF("nvram", HAS_ARG, QEMU_OPTION_nvram, \
+    "-nvram file      set the filename for the NVRAM\n")
+STEXI
address@hidden -nvram @var{file}
+Set the filename for the NVRAM.
+ETEXI
+
 #ifdef USE_KQEMU
 DEF("kernel-kqemu", 0, QEMU_OPTION_kernel_kqemu, \
     "-kernel-kqemu   enable KQEMU full virtualization (default is user mode 
only)\n")
Index: sysemu.h
===================================================================
--- sysemu.h    (revision 6967)
+++ sysemu.h    (working copy)
@@ -11,6 +11,7 @@
 /* vl.c */
 extern const char *bios_name;
 extern const char *bios_dir;
+extern const char *nvram_name;
 
 extern int vm_running;
 extern const char *qemu_name;
Index: hw/sun4m.c
===================================================================
--- hw/sun4m.c  (revision 6967)
+++ hw/sun4m.c  (working copy)
@@ -536,32 +536,49 @@
     kernel_size = sun4m_load_kernel(kernel_filename, initrd_filename,
                                     RAM_size);
 
-    nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
-               boot_device, RAM_size, kernel_size, graphic_width,
-               graphic_height, graphic_depth, hwdef->nvram_machine_id,
-               "Sun4m");
+    if (nvram_name == NULL) {
+        nvram_init(nvram, (uint8_t *)&nd_table[0].macaddr, kernel_cmdline,
+                   boot_device, RAM_size, kernel_size, graphic_width,
+                   graphic_height, graphic_depth, hwdef->nvram_machine_id,
+                   "Sun4m");
+    } else {
+        uint8_t image[0x1ff0];
 
+        if (get_image_size(nvram_name) == sizeof(image)) {
+            load_image(nvram_name, image);
+
+            for (i = 0; i < sizeof(image); i++)
+                m48t59_write(nvram, i, image[i]);
+        } else {
+            fprintf(stderr, "qemu: invalid or missing NVRAM image %s\n",
+                    nvram_name);
+            exit(1);
+        }
+    }
+
     if (hwdef->ecc_base)
         ecc_init(hwdef->ecc_base, slavio_irq[hwdef->ecc_irq],
                  hwdef->ecc_version);
 
-    fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
-    fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
-    fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
-    if (kernel_cmdline) {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
-        pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
-    } else {
-        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
+    if (nvram_name == NULL) {
+        fw_cfg = fw_cfg_init(0, 0, CFG_ADDR, CFG_ADDR + 2);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_ID, 1);
+        fw_cfg_add_i64(fw_cfg, FW_CFG_RAM_SIZE, (uint64_t)ram_size);
+        fw_cfg_add_i16(fw_cfg, FW_CFG_MACHINE_ID, hwdef->machine_id);
+        fw_cfg_add_i16(fw_cfg, FW_CFG_SUN4M_DEPTH, graphic_depth);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_ADDR, KERNEL_LOAD_ADDR);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_SIZE, kernel_size);
+        if (kernel_cmdline) {
+            fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, CMDLINE_ADDR);
+            pstrcpy_targphys(CMDLINE_ADDR, TARGET_PAGE_SIZE, kernel_cmdline);
+        } else {
+            fw_cfg_add_i32(fw_cfg, FW_CFG_KERNEL_CMDLINE, 0);
+        }
+        fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
+        fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
+        fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
+        qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
     }
-    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_ADDR, INITRD_LOAD_ADDR);
-    fw_cfg_add_i32(fw_cfg, FW_CFG_INITRD_SIZE, 0); // not used
-    fw_cfg_add_i16(fw_cfg, FW_CFG_BOOT_DEVICE, boot_device[0]);
-    qemu_register_boot_set(fw_cfg_boot_set, fw_cfg);
 }
 
 enum {

reply via email to

[Prev in Thread] Current Thread [Next in Thread]