-------- Forwarded Message --------
> From: J. Mayer <[EMAIL PROTECTED]>
> Reply-To: qemu-devel@nongnu.org
> To: qemu-devel@nongnu.org
> Subject: [Qemu-devel] RFC: BIOS filename option
> Date: Thu, 04 Oct 2007 05:11:55 +0200
> 
> Hi,
> 
> This is a proposal to allow the user to select a BIOS file name on the
> command line. The goal is mainly to ease debug, for example when I want
> to try to run a firmware comming from a real machine instead of the
> default one.
> The only change is to add a -bios <filename> option, use the given file
> if any or use the default if none were given.
> Maybe the options would be better named as -biosfile.... Or it maybe a
> good idea to give a full path, not to concatenate the given name with
> the bios_dir prefix...
> Some may find this option is not so useful, as one can specify a
> directory to find the target BIOS. But I feel more confortable keeping
> all BIOS images together at the same place.
> 
> Please comment.

Hum, seems like I forgot to attach the patch. Here it is...

-- 
J. Mayer <[EMAIL PROTECTED]>
Never organized
Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.343
diff -u -d -d -p -r1.343 vl.c
--- vl.c	29 Sep 2007 19:24:40 -0000	1.343
+++ vl.c	4 Oct 2007 03:05:18 -0000
@@ -143,6 +143,7 @@ int inet_aton(const char *cp, struct in_
 #define MAX_IOPORTS 65536
 
 const char *bios_dir = CONFIG_QEMU_SHAREDIR;
+const char *bios_name = NULL;
 char phys_ram_file[1024];
 void *ioport_opaque[MAX_IOPORTS];
 IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
@@ -7151,6 +7154,7 @@ enum {
     QEMU_OPTION_d,
     QEMU_OPTION_hdachs,
     QEMU_OPTION_L,
+    QEMU_OPTION_bios,
     QEMU_OPTION_no_code_copy,
     QEMU_OPTION_k,
     QEMU_OPTION_localtime,
@@ -7243,6 +7247,7 @@ const QEMUOption qemu_options[] = {
     { "d", HAS_ARG, QEMU_OPTION_d },
     { "hdachs", HAS_ARG, QEMU_OPTION_hdachs },
     { "L", HAS_ARG, QEMU_OPTION_L },
+    { "bios", HAS_ARG, QEMU_OPTION_bios },
     { "no-code-copy", 0, QEMU_OPTION_no_code_copy },
 #ifdef USE_KQEMU
     { "no-kqemu", 0, QEMU_OPTION_no_kqemu },
@@ -7889,6 +7895,9 @@ int main(int argc, char **argv)
             case QEMU_OPTION_L:
                 bios_dir = optarg;
                 break;
+            case QEMU_OPTION_bios:
+                bios_name = optarg;
+                break;
             case QEMU_OPTION_S:
                 autostart = 0;
                 break;
Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.273
diff -u -d -d -p -r1.273 vl.h
--- vl.h	30 Sep 2007 14:44:52 -0000	1.273
+++ vl.h	4 Oct 2007 03:05:18 -0000
@@ -129,6 +129,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b
 void hw_error(const char *fmt, ...);
 
 extern const char *bios_dir;
+extern const char *bios_name;
 
 extern int vm_running;
 extern const char *qemu_name;
Index: hw/mips_malta.c
===================================================================
RCS file: /sources/qemu/qemu/hw/mips_malta.c,v
retrieving revision 1.44
diff -u -d -d -p -r1.44 mips_malta.c
--- hw/mips_malta.c	17 Sep 2007 08:09:47 -0000	1.44
+++ hw/mips_malta.c	4 Oct 2007 03:05:18 -0000
@@ -791,7 +791,9 @@ void mips_malta_init (int ram_size, int 
 
     /* Load a BIOS image unless a kernel image has been specified. */
     if (!kernel_filename) {
-        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        if (bios_name == NULL)
+            bios_name = BIOS_FILENAME;
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
         ret = load_image(buf, phys_ram_base + bios_offset);
         if (ret < 0 || ret > BIOS_SIZE) {
             fprintf(stderr,
Index: hw/mips_pica61.c
===================================================================
RCS file: /sources/qemu/qemu/hw/mips_pica61.c,v
retrieving revision 1.8
diff -u -d -d -p -r1.8 mips_pica61.c
--- hw/mips_pica61.c	25 Jun 2007 10:57:10 -0000	1.8
+++ hw/mips_pica61.c	4 Oct 2007 03:05:18 -0000
@@ -94,7 +94,9 @@ void mips_pica61_init (int ram_size, int
 
     /* load a BIOS image */
     bios_offset = ram_size + vga_ram_size;
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     bios_size = load_image(buf, phys_ram_base + bios_offset);
     if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
         /* fatal */
Index: hw/mips_r4k.c
===================================================================
RCS file: /sources/qemu/qemu/hw/mips_r4k.c,v
retrieving revision 1.47
diff -u -d -d -p -r1.47 mips_r4k.c
--- hw/mips_r4k.c	16 Sep 2007 21:07:54 -0000	1.47
+++ hw/mips_r4k.c	4 Oct 2007 03:05:18 -0000
@@ -179,7 +179,9 @@ void mips_r4k_init (int ram_size, int vg
        preloaded we also initialize the hardware, since the BIOS wasn't
        run. */
     bios_offset = ram_size + vga_ram_size;
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     bios_size = load_image(buf, phys_ram_base + bios_offset);
     if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
 	cpu_register_physical_memory(0x1fc00000,
Index: hw/pc.c
===================================================================
RCS file: /sources/qemu/qemu/hw/pc.c,v
retrieving revision 1.85
diff -u -d -d -p -r1.85 pc.c
--- hw/pc.c	17 Sep 2007 08:09:47 -0000	1.85
+++ hw/pc.c	4 Oct 2007 03:05:18 -0000
@@ -706,7 +706,9 @@ static void pc_init1(int ram_size, int v
     vga_ram_addr = qemu_ram_alloc(vga_ram_size);
 
     /* BIOS load */
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     bios_size = get_image_size(buf);
     if (bios_size <= 0 ||
         (bios_size % 65536) != 0) {
Index: hw/ppc405_boards.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ppc405_boards.c,v
retrieving revision 1.6
diff -u -d -d -p -r1.6 ppc405_boards.c
--- hw/ppc405_boards.c	3 Oct 2007 01:04:20 -0000	1.6
+++ hw/ppc405_boards.c	4 Oct 2007 03:05:18 -0000
@@ -236,7 +236,9 @@ static void ref405ep_init (int ram_size,
 #ifdef DEBUG_BOARD_INIT
         printf("Load BIOS from file\n");
 #endif
-        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        if (bios_name == NULL)
+            bios_name = BIOS_FILENAME;
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
         bios_size = load_image(buf, phys_ram_base + bios_offset);
         if (bios_size < 0 || bios_size > BIOS_SIZE) {
             fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
@@ -549,7 +551,9 @@ static void taihu_405ep_init(int ram_siz
 #ifdef DEBUG_BOARD_INIT
         printf("Load BIOS from file\n");
 #endif
-        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+        if (bios_name == NULL)
+            bios_name = BIOS_FILENAME;
+        snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
         bios_size = load_image(buf, phys_ram_base + bios_offset);
         if (bios_size < 0 || bios_size > BIOS_SIZE) {
             fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
Index: hw/ppc_chrp.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ppc_chrp.c,v
retrieving revision 1.43
diff -u -d -d -p -r1.43 ppc_chrp.c
--- hw/ppc_chrp.c	3 Oct 2007 01:06:57 -0000	1.43
+++ hw/ppc_chrp.c	4 Oct 2007 03:05:18 -0000
@@ -349,7 +371,9 @@ static void ppc_chrp_init (int ram_size,
 
     /* allocate and load BIOS */
     bios_offset = ram_size + vga_ram_size;
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     bios_size = load_image(buf, phys_ram_base + bios_offset);
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
Index: hw/ppc_prep.c
===================================================================
RCS file: /sources/qemu/qemu/hw/ppc_prep.c,v
retrieving revision 1.43
diff -u -d -d -p -r1.43 ppc_prep.c
--- hw/ppc_prep.c	3 Oct 2007 01:06:57 -0000	1.43
+++ hw/ppc_prep.c	4 Oct 2007 03:05:18 -0000
@@ -564,7 +564,9 @@ static void ppc_prep_init (int ram_size,
 
     /* allocate and load BIOS */
     bios_offset = ram_size + vga_ram_size;
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     bios_size = load_image(buf, phys_ram_base + bios_offset);
     if (bios_size < 0 || bios_size > BIOS_SIZE) {
         cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf);
Index: hw/shix.c
===================================================================
RCS file: /sources/qemu/qemu/hw/shix.c,v
retrieving revision 1.4
diff -u -d -d -p -r1.4 shix.c
--- hw/shix.c	16 Sep 2007 21:07:56 -0000	1.4
+++ hw/shix.c	4 Oct 2007 03:05:18 -0000
@@ -83,12 +83,14 @@ void shix_init(int ram_size, int vga_ram
     cpu_register_physical_memory(0x0c000000, 0x01000000, 0x01004000);
 
     /* Load BIOS in 0 (and access it through P2, 0xA0000000) */
-    printf("%s: load BIOS '%s'\n", __func__, BIOS_FILENAME);
-    ret = load_image(BIOS_FILENAME, phys_ram_base);
+    if (bios_name == NULL)
+        bios_name = BIOS_FILENAME;
+    printf("%s: load BIOS '%s'\n", __func__, bios_name);
+    ret = load_image(bios_name, phys_ram_base);
     if (ret < 0) {		/* Check bios size */
 	fprintf(stderr, "ret=%d\n", ret);
 	fprintf(stderr, "qemu: could not load SHIX bios '%s'\n",
-		BIOS_FILENAME);
+		bios_name);
 	exit(1);
     }
 
Index: hw/sun4m.c
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4m.c,v
retrieving revision 1.51
diff -u -d -d -p -r1.51 sun4m.c
--- hw/sun4m.c	2 Oct 2007 19:15:48 -0000	1.51
+++ hw/sun4m.c	4 Oct 2007 03:05:18 -0000
@@ -430,7 +430,9 @@ static void sun4m_load_kernel(long vram_
                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK,
                                  prom_offset | IO_MEM_ROM);
 
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);
+    if (bios_name == NULL)
+        bios_name = PROM_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     ret = load_elf(buf, PROM_PADDR - PROM_VADDR, NULL, NULL, NULL);
     if (ret < 0) {
 	fprintf(stderr, "qemu: could not load prom '%s'\n",
Index: hw/sun4u.c
===================================================================
RCS file: /sources/qemu/qemu/hw/sun4u.c,v
retrieving revision 1.20
diff -u -d -d -p -r1.20 sun4u.c
--- hw/sun4u.c	16 Sep 2007 21:07:56 -0000	1.20
+++ hw/sun4u.c	4 Oct 2007 03:05:18 -0000
@@ -382,7 +382,9 @@ static void sun4u_init(int ram_size, int
                                  (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK,
                                  prom_offset | IO_MEM_ROM);
 
-    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME);
+    if (bios_name == NULL)
+        bios_name = PROM_FILENAME;
+    snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
     ret = load_elf(buf, PROM_ADDR - PROM_VADDR, NULL, NULL, NULL);
     if (ret < 0) {
 	fprintf(stderr, "qemu: could not load prom '%s'\n",

Reply via email to