Commit 1192dad8798e4e4b72b14ff3a93c11cbb26eae5b

Authored by j_mayer
1 parent e9c05b42

New '-bios' option, used to select an alternate BIOS image from bios_dir.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3331 c046a42c-6fe2-441c-8c8c-71466251a162
hw/mips_malta.c
@@ -791,7 +791,9 @@ void mips_malta_init (int ram_size, int vga_ram_size, int boot_device, @@ -791,7 +791,9 @@ void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
791 791
792 /* Load a BIOS image unless a kernel image has been specified. */ 792 /* Load a BIOS image unless a kernel image has been specified. */
793 if (!kernel_filename) { 793 if (!kernel_filename) {
794 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 794 + if (bios_name == NULL)
  795 + bios_name = BIOS_FILENAME;
  796 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
795 ret = load_image(buf, phys_ram_base + bios_offset); 797 ret = load_image(buf, phys_ram_base + bios_offset);
796 if (ret < 0 || ret > BIOS_SIZE) { 798 if (ret < 0 || ret > BIOS_SIZE) {
797 fprintf(stderr, 799 fprintf(stderr,
hw/mips_pica61.c
@@ -94,7 +94,9 @@ void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device, @@ -94,7 +94,9 @@ void mips_pica61_init (int ram_size, int vga_ram_size, int boot_device,
94 94
95 /* load a BIOS image */ 95 /* load a BIOS image */
96 bios_offset = ram_size + vga_ram_size; 96 bios_offset = ram_size + vga_ram_size;
97 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 97 + if (bios_name == NULL)
  98 + bios_name = BIOS_FILENAME;
  99 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
98 bios_size = load_image(buf, phys_ram_base + bios_offset); 100 bios_size = load_image(buf, phys_ram_base + bios_offset);
99 if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) { 101 if ((bios_size <= 0) || (bios_size > BIOS_SIZE)) {
100 /* fatal */ 102 /* fatal */
hw/mips_r4k.c
@@ -179,7 +179,9 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device, @@ -179,7 +179,9 @@ void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
179 preloaded we also initialize the hardware, since the BIOS wasn't 179 preloaded we also initialize the hardware, since the BIOS wasn't
180 run. */ 180 run. */
181 bios_offset = ram_size + vga_ram_size; 181 bios_offset = ram_size + vga_ram_size;
182 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 182 + if (bios_name == NULL)
  183 + bios_name = BIOS_FILENAME;
  184 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
183 bios_size = load_image(buf, phys_ram_base + bios_offset); 185 bios_size = load_image(buf, phys_ram_base + bios_offset);
184 if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) { 186 if ((bios_size > 0) && (bios_size <= BIOS_SIZE)) {
185 cpu_register_physical_memory(0x1fc00000, 187 cpu_register_physical_memory(0x1fc00000,
@@ -706,7 +706,9 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device, @@ -706,7 +706,9 @@ static void pc_init1(int ram_size, int vga_ram_size, int boot_device,
706 vga_ram_addr = qemu_ram_alloc(vga_ram_size); 706 vga_ram_addr = qemu_ram_alloc(vga_ram_size);
707 707
708 /* BIOS load */ 708 /* BIOS load */
709 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 709 + if (bios_name == NULL)
  710 + bios_name = BIOS_FILENAME;
  711 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
710 bios_size = get_image_size(buf); 712 bios_size = get_image_size(buf);
711 if (bios_size <= 0 || 713 if (bios_size <= 0 ||
712 (bios_size % 65536) != 0) { 714 (bios_size % 65536) != 0) {
hw/ppc405_boards.c
@@ -236,7 +236,9 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device, @@ -236,7 +236,9 @@ static void ref405ep_init (int ram_size, int vga_ram_size, int boot_device,
236 #ifdef DEBUG_BOARD_INIT 236 #ifdef DEBUG_BOARD_INIT
237 printf("Load BIOS from file\n"); 237 printf("Load BIOS from file\n");
238 #endif 238 #endif
239 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 239 + if (bios_name == NULL)
  240 + bios_name = BIOS_FILENAME;
  241 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
240 bios_size = load_image(buf, phys_ram_base + bios_offset); 242 bios_size = load_image(buf, phys_ram_base + bios_offset);
241 if (bios_size < 0 || bios_size > BIOS_SIZE) { 243 if (bios_size < 0 || bios_size > BIOS_SIZE) {
242 fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); 244 fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
@@ -549,7 +551,9 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device, @@ -549,7 +551,9 @@ static void taihu_405ep_init(int ram_size, int vga_ram_size, int boot_device,
549 #ifdef DEBUG_BOARD_INIT 551 #ifdef DEBUG_BOARD_INIT
550 printf("Load BIOS from file\n"); 552 printf("Load BIOS from file\n");
551 #endif 553 #endif
552 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 554 + if (bios_name == NULL)
  555 + bios_name = BIOS_FILENAME;
  556 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
553 bios_size = load_image(buf, phys_ram_base + bios_offset); 557 bios_size = load_image(buf, phys_ram_base + bios_offset);
554 if (bios_size < 0 || bios_size > BIOS_SIZE) { 558 if (bios_size < 0 || bios_size > BIOS_SIZE) {
555 fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf); 559 fprintf(stderr, "qemu: could not load PowerPC bios '%s'\n", buf);
hw/ppc_chrp.c
@@ -349,7 +349,9 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device, @@ -349,7 +349,9 @@ static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
349 349
350 /* allocate and load BIOS */ 350 /* allocate and load BIOS */
351 bios_offset = ram_size + vga_ram_size; 351 bios_offset = ram_size + vga_ram_size;
352 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 352 + if (bios_name == NULL)
  353 + bios_name = BIOS_FILENAME;
  354 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
353 bios_size = load_image(buf, phys_ram_base + bios_offset); 355 bios_size = load_image(buf, phys_ram_base + bios_offset);
354 if (bios_size < 0 || bios_size > BIOS_SIZE) { 356 if (bios_size < 0 || bios_size > BIOS_SIZE) {
355 cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf); 357 cpu_abort(env, "qemu: could not load PowerPC bios '%s'\n", buf);
hw/ppc_prep.c
@@ -564,7 +564,9 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device, @@ -564,7 +564,9 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
564 564
565 /* allocate and load BIOS */ 565 /* allocate and load BIOS */
566 bios_offset = ram_size + vga_ram_size; 566 bios_offset = ram_size + vga_ram_size;
567 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, BIOS_FILENAME); 567 + if (bios_name == NULL)
  568 + bios_name = BIOS_FILENAME;
  569 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
568 bios_size = load_image(buf, phys_ram_base + bios_offset); 570 bios_size = load_image(buf, phys_ram_base + bios_offset);
569 if (bios_size < 0 || bios_size > BIOS_SIZE) { 571 if (bios_size < 0 || bios_size > BIOS_SIZE) {
570 cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf); 572 cpu_abort(env, "qemu: could not load PPC PREP bios '%s'\n", buf);
hw/shix.c
@@ -83,12 +83,14 @@ void shix_init(int ram_size, int vga_ram_size, int boot_device, @@ -83,12 +83,14 @@ void shix_init(int ram_size, int vga_ram_size, int boot_device,
83 cpu_register_physical_memory(0x0c000000, 0x01000000, 0x01004000); 83 cpu_register_physical_memory(0x0c000000, 0x01000000, 0x01004000);
84 84
85 /* Load BIOS in 0 (and access it through P2, 0xA0000000) */ 85 /* Load BIOS in 0 (and access it through P2, 0xA0000000) */
86 - printf("%s: load BIOS '%s'\n", __func__, BIOS_FILENAME);  
87 - ret = load_image(BIOS_FILENAME, phys_ram_base); 86 + if (bios_name == NULL)
  87 + bios_name = BIOS_FILENAME;
  88 + printf("%s: load BIOS '%s'\n", __func__, bios_name);
  89 + ret = load_image(bios_name, phys_ram_base);
88 if (ret < 0) { /* Check bios size */ 90 if (ret < 0) { /* Check bios size */
89 fprintf(stderr, "ret=%d\n", ret); 91 fprintf(stderr, "ret=%d\n", ret);
90 fprintf(stderr, "qemu: could not load SHIX bios '%s'\n", 92 fprintf(stderr, "qemu: could not load SHIX bios '%s'\n",
91 - BIOS_FILENAME); 93 + bios_name);
92 exit(1); 94 exit(1);
93 } 95 }
94 96
hw/sun4m.c
@@ -430,7 +430,9 @@ static void sun4m_load_kernel(long vram_size, int RAM_size, int boot_device, @@ -430,7 +430,9 @@ static void sun4m_load_kernel(long vram_size, int RAM_size, int boot_device,
430 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK, 430 (PROM_SIZE_MAX + TARGET_PAGE_SIZE - 1) & TARGET_PAGE_MASK,
431 prom_offset | IO_MEM_ROM); 431 prom_offset | IO_MEM_ROM);
432 432
433 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME); 433 + if (bios_name == NULL)
  434 + bios_name = PROM_FILENAME;
  435 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
434 ret = load_elf(buf, PROM_PADDR - PROM_VADDR, NULL, NULL, NULL); 436 ret = load_elf(buf, PROM_PADDR - PROM_VADDR, NULL, NULL, NULL);
435 if (ret < 0) { 437 if (ret < 0) {
436 fprintf(stderr, "qemu: could not load prom '%s'\n", 438 fprintf(stderr, "qemu: could not load prom '%s'\n",
hw/sun4u.c
@@ -382,7 +382,9 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device, @@ -382,7 +382,9 @@ static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
382 (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK, 382 (PROM_SIZE_MAX + TARGET_PAGE_SIZE) & TARGET_PAGE_MASK,
383 prom_offset | IO_MEM_ROM); 383 prom_offset | IO_MEM_ROM);
384 384
385 - snprintf(buf, sizeof(buf), "%s/%s", bios_dir, PROM_FILENAME); 385 + if (bios_name == NULL)
  386 + bios_name = PROM_FILENAME;
  387 + snprintf(buf, sizeof(buf), "%s/%s", bios_dir, bios_name);
386 ret = load_elf(buf, PROM_ADDR - PROM_VADDR, NULL, NULL, NULL); 388 ret = load_elf(buf, PROM_ADDR - PROM_VADDR, NULL, NULL, NULL);
387 if (ret < 0) { 389 if (ret < 0) {
388 fprintf(stderr, "qemu: could not load prom '%s'\n", 390 fprintf(stderr, "qemu: could not load prom '%s'\n",
@@ -143,6 +143,7 @@ int inet_aton(const char *cp, struct in_addr *ia); @@ -143,6 +143,7 @@ int inet_aton(const char *cp, struct in_addr *ia);
143 #define MAX_IOPORTS 65536 143 #define MAX_IOPORTS 65536
144 144
145 const char *bios_dir = CONFIG_QEMU_SHAREDIR; 145 const char *bios_dir = CONFIG_QEMU_SHAREDIR;
  146 +const char *bios_name = NULL;
146 char phys_ram_file[1024]; 147 char phys_ram_file[1024];
147 void *ioport_opaque[MAX_IOPORTS]; 148 void *ioport_opaque[MAX_IOPORTS];
148 IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS]; 149 IOPortReadFunc *ioport_read_table[3][MAX_IOPORTS];
@@ -7149,6 +7150,7 @@ enum { @@ -7149,6 +7150,7 @@ enum {
7149 QEMU_OPTION_d, 7150 QEMU_OPTION_d,
7150 QEMU_OPTION_hdachs, 7151 QEMU_OPTION_hdachs,
7151 QEMU_OPTION_L, 7152 QEMU_OPTION_L,
  7153 + QEMU_OPTION_bios,
7152 QEMU_OPTION_no_code_copy, 7154 QEMU_OPTION_no_code_copy,
7153 QEMU_OPTION_k, 7155 QEMU_OPTION_k,
7154 QEMU_OPTION_localtime, 7156 QEMU_OPTION_localtime,
@@ -7241,6 +7243,7 @@ const QEMUOption qemu_options[] = { @@ -7241,6 +7243,7 @@ const QEMUOption qemu_options[] = {
7241 { "d", HAS_ARG, QEMU_OPTION_d }, 7243 { "d", HAS_ARG, QEMU_OPTION_d },
7242 { "hdachs", HAS_ARG, QEMU_OPTION_hdachs }, 7244 { "hdachs", HAS_ARG, QEMU_OPTION_hdachs },
7243 { "L", HAS_ARG, QEMU_OPTION_L }, 7245 { "L", HAS_ARG, QEMU_OPTION_L },
  7246 + { "bios", HAS_ARG, QEMU_OPTION_bios },
7244 { "no-code-copy", 0, QEMU_OPTION_no_code_copy }, 7247 { "no-code-copy", 0, QEMU_OPTION_no_code_copy },
7245 #ifdef USE_KQEMU 7248 #ifdef USE_KQEMU
7246 { "no-kqemu", 0, QEMU_OPTION_no_kqemu }, 7249 { "no-kqemu", 0, QEMU_OPTION_no_kqemu },
@@ -7887,6 +7890,9 @@ int main(int argc, char **argv) @@ -7887,6 +7890,9 @@ int main(int argc, char **argv)
7887 case QEMU_OPTION_L: 7890 case QEMU_OPTION_L:
7888 bios_dir = optarg; 7891 bios_dir = optarg;
7889 break; 7892 break;
  7893 + case QEMU_OPTION_bios:
  7894 + bios_name = optarg;
  7895 + break;
7890 case QEMU_OPTION_S: 7896 case QEMU_OPTION_S:
7891 autostart = 0; 7897 autostart = 0;
7892 break; 7898 break;
@@ -129,6 +129,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c); @@ -129,6 +129,7 @@ uint64_t muldiv64(uint64_t a, uint32_t b, uint32_t c);
129 void hw_error(const char *fmt, ...); 129 void hw_error(const char *fmt, ...);
130 130
131 extern const char *bios_dir; 131 extern const char *bios_dir;
  132 +extern const char *bios_name;
132 133
133 extern int vm_running; 134 extern int vm_running;
134 extern const char *qemu_name; 135 extern const char *qemu_name;