From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1M1tYO-0005tf-Rr for qemu-devel@nongnu.org; Wed, 06 May 2009 22:41:44 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1M1tYK-0005tT-3x for qemu-devel@nongnu.org; Wed, 06 May 2009 22:41:44 -0400 Received: from [199.232.76.173] (port=53059 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1M1tYK-0005tQ-0P for qemu-devel@nongnu.org; Wed, 06 May 2009 22:41:40 -0400 Received: from pop-siberian.atl.sa.earthlink.net ([207.69.195.71]:36627) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1M1tYJ-0003B8-KD for qemu-devel@nongnu.org; Wed, 06 May 2009 22:41:39 -0400 Message-ID: <4A024A54.6030006@earthlink.net> Date: Wed, 06 May 2009 22:41:24 -0400 From: Robert Reif MIME-Version: 1.0 Subject: Re: [Qemu-devel] sparc-softmmu with sun prom image? References: <1241640634.18565.257.camel@nibbler.dlib.indiana.edu> In-Reply-To: <1241640634.18565.257.camel@nibbler.dlib.indiana.edu> Content-Type: multipart/mixed; boundary="------------020803080308020600070305" List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Brian Wheeler Cc: qemu-devel@nongnu.org This is a multi-part message in MIME format. --------------020803080308020600070305 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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. --------------020803080308020600070305 Content-Type: text/plain; name="nvram.diff.txt" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename="nvram.diff.txt" 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 +@item -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 { --------------020803080308020600070305--