Commit 94fc95cdb2e91826bd6a4c98cea4f4d9fa0fffb1

Authored by j_mayer
1 parent 7a2d6d96

New -cpu options: choose CPU model for emulated target.

Only relevant on PowerPC targets, for now.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2468 c046a42c-6fe2-441c-8c8c-71466251a162
hw/integratorcp.c
... ... @@ -516,7 +516,7 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
516 516 static void integratorcp926_init(int ram_size, int vga_ram_size,
517 517 int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
518 518 const char *kernel_filename, const char *kernel_cmdline,
519   - const char *initrd_filename)
  519 + const char *initrd_filename, const char *cpu_model)
520 520 {
521 521 integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
522 522 snapshot, kernel_filename, kernel_cmdline,
... ... @@ -526,7 +526,7 @@ static void integratorcp926_init(int ram_size, int vga_ram_size,
526 526 static void integratorcp1026_init(int ram_size, int vga_ram_size,
527 527 int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
528 528 const char *kernel_filename, const char *kernel_cmdline,
529   - const char *initrd_filename)
  529 + const char *initrd_filename, const char *cpu_model)
530 530 {
531 531 integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
532 532 snapshot, kernel_filename, kernel_cmdline,
... ...
hw/mips_malta.c
... ... @@ -615,7 +615,7 @@ static
615 615 void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
616 616 DisplayState *ds, const char **fd_filename, int snapshot,
617 617 const char *kernel_filename, const char *kernel_cmdline,
618   - const char *initrd_filename)
  618 + const char *initrd_filename, const char *cpu_model)
619 619 {
620 620 char buf[1024];
621 621 unsigned long bios_offset;
... ...
hw/mips_r4k.c
... ... @@ -130,7 +130,7 @@ static
130 130 void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
131 131 DisplayState *ds, const char **fd_filename, int snapshot,
132 132 const char *kernel_filename, const char *kernel_cmdline,
133   - const char *initrd_filename)
  133 + const char *initrd_filename, const char *cpu_model)
134 134 {
135 135 char buf[1024];
136 136 unsigned long bios_offset;
... ...
... ... @@ -758,7 +758,8 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
758 758 int snapshot,
759 759 const char *kernel_filename,
760 760 const char *kernel_cmdline,
761   - const char *initrd_filename)
  761 + const char *initrd_filename,
  762 + const char *cpu_model)
762 763 {
763 764 pc_init1(ram_size, vga_ram_size, boot_device,
764 765 ds, fd_filename, snapshot,
... ... @@ -771,7 +772,8 @@ static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
771 772 int snapshot,
772 773 const char *kernel_filename,
773 774 const char *kernel_cmdline,
774   - const char *initrd_filename)
  775 + const char *initrd_filename,
  776 + const char *cpu_model)
775 777 {
776 778 pc_init1(ram_size, vga_ram_size, boot_device,
777 779 ds, fd_filename, snapshot,
... ...
hw/ppc_chrp.c
... ... @@ -292,13 +292,14 @@ void pmac_format_nvram_partition(uint8_t *buf, int len)
292 292 }
293 293  
294 294 /* PowerPC CHRP hardware initialisation */
295   -static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
296   - DisplayState *ds, const char **fd_filename,
297   - int snapshot,
298   - const char *kernel_filename,
299   - const char *kernel_cmdline,
300   - const char *initrd_filename,
301   - int is_heathrow)
  295 +static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
  296 + DisplayState *ds, const char **fd_filename,
  297 + int snapshot,
  298 + const char *kernel_filename,
  299 + const char *kernel_cmdline,
  300 + const char *initrd_filename,
  301 + const char *cpu_model,
  302 + int is_heathrow)
302 303 {
303 304 CPUState *env;
304 305 char buf[1024];
... ... @@ -320,22 +321,16 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
320 321 env = cpu_init();
321 322 register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
322 323  
323   - /* Register CPU as a 74x/75x */
  324 + /* Default CPU is a generic 74x/75x */
  325 + if (cpu_model == NULL)
  326 + cpu_model = "750";
324 327 /* XXX: CPU model (or PVR) should be provided on command line */
325 328 // ppc_find_by_name("750gx", &def); // Linux boot OK
326 329 // ppc_find_by_name("750fx", &def); // Linux boot OK
327 330 /* Linux does not boot on 750cxe (and probably other 750cx based)
328 331 * because it assumes it has 8 IBAT & DBAT pairs as it only have 4.
329 332 */
330   - // ppc_find_by_name("750cxe", &def);
331   - // ppc_find_by_name("750p", &def);
332   - // ppc_find_by_name("740p", &def);
333   - ppc_find_by_name("750", &def);
334   - // ppc_find_by_name("740", &def);
335   - // ppc_find_by_name("G3", &def);
336   - // ppc_find_by_name("604r", &def);
337   - // ppc_find_by_name("604e", &def);
338   - // ppc_find_by_name("604", &def);
  333 + ppc_find_by_name(cpu_model, &def);
339 334 if (def == NULL) {
340 335 cpu_abort(env, "Unable to find PowerPC CPU definition\n");
341 336 }
... ... @@ -525,30 +520,32 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
525 520 register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
526 521 }
527 522  
528   -static void ppc_core99_init(int ram_size, int vga_ram_size, int boot_device,
529   - DisplayState *ds, const char **fd_filename,
530   - int snapshot,
531   - const char *kernel_filename,
532   - const char *kernel_cmdline,
533   - const char *initrd_filename)
  523 +static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
  524 + DisplayState *ds, const char **fd_filename,
  525 + int snapshot,
  526 + const char *kernel_filename,
  527 + const char *kernel_cmdline,
  528 + const char *initrd_filename,
  529 + const char *cpu_model)
534 530 {
535 531 ppc_chrp_init(ram_size, vga_ram_size, boot_device,
536 532 ds, fd_filename, snapshot,
537 533 kernel_filename, kernel_cmdline,
538   - initrd_filename, 0);
  534 + initrd_filename, cpu_model, 0);
539 535 }
540 536  
541   -static void ppc_heathrow_init(int ram_size, int vga_ram_size, int boot_device,
542   - DisplayState *ds, const char **fd_filename,
543   - int snapshot,
544   - const char *kernel_filename,
545   - const char *kernel_cmdline,
546   - const char *initrd_filename)
  537 +static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
  538 + DisplayState *ds, const char **fd_filename,
  539 + int snapshot,
  540 + const char *kernel_filename,
  541 + const char *kernel_cmdline,
  542 + const char *initrd_filename,
  543 + const char *cpu_model)
547 544 {
548 545 ppc_chrp_init(ram_size, vga_ram_size, boot_device,
549 546 ds, fd_filename, snapshot,
550 547 kernel_filename, kernel_cmdline,
551   - initrd_filename, 1);
  548 + initrd_filename, cpu_model, 1);
552 549 }
553 550  
554 551 QEMUMachine core99_machine = {
... ...
hw/ppc_prep.c
... ... @@ -518,10 +518,12 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
518 518 #define NVRAM_SIZE 0x2000
519 519  
520 520 /* PowerPC PREP hardware initialisation */
521   -static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
522   - DisplayState *ds, const char **fd_filename, int snapshot,
523   - const char *kernel_filename, const char *kernel_cmdline,
524   - const char *initrd_filename)
  521 +static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
  522 + DisplayState *ds, const char **fd_filename,
  523 + int snapshot, const char *kernel_filename,
  524 + const char *kernel_cmdline,
  525 + const char *initrd_filename,
  526 + const char *cpu_model)
525 527 {
526 528 CPUState *env;
527 529 char buf[1024];
... ... @@ -543,12 +545,11 @@ static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
543 545  
544 546 env = cpu_init();
545 547 register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
546   -
547   - /* Register CPU as a 604 */
548   - /* XXX: CPU model (or PVR) should be provided on command line */
549   - // ppc_find_by_name("604r", &def);
550   - // ppc_find_by_name("604e", &def);
551   - ppc_find_by_name("604", &def);
  548 +
  549 + /* Default CPU is a 604 */
  550 + if (cpu_model == NULL)
  551 + cpu_model = "604";
  552 + ppc_find_by_name(cpu_model, &def);
552 553 if (def == NULL) {
553 554 cpu_abort(env, "Unable to find PowerPC CPU definition\n");
554 555 }
... ...
hw/realview.c
... ... @@ -15,7 +15,7 @@
15 15 static void realview_init(int ram_size, int vga_ram_size, int boot_device,
16 16 DisplayState *ds, const char **fd_filename, int snapshot,
17 17 const char *kernel_filename, const char *kernel_cmdline,
18   - const char *initrd_filename)
  18 + const char *initrd_filename, const char *cpu_model)
19 19 {
20 20 CPUState *env;
21 21 void *pic;
... ...
hw/shix.c
... ... @@ -70,7 +70,7 @@ void vga_screen_dump(const char *filename)
70 70 void shix_init(int ram_size, int vga_ram_size, int boot_device,
71 71 DisplayState * ds, const char **fd_filename, int snapshot,
72 72 const char *kernel_filename, const char *kernel_cmdline,
73   - const char *initrd_filename)
  73 + const char *initrd_filename, const char *cpu_model)
74 74 {
75 75 int ret;
76 76 CPUState *env;
... ...
hw/sun4m.c
... ... @@ -211,7 +211,7 @@ static void main_cpu_reset(void *opaque)
211 211 static void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
212 212 DisplayState *ds, const char **fd_filename, int snapshot,
213 213 const char *kernel_filename, const char *kernel_cmdline,
214   - const char *initrd_filename)
  214 + const char *initrd_filename, const char *cpu_model)
215 215 {
216 216 CPUState *env, *envs[MAX_CPUS];
217 217 char buf[1024];
... ...
hw/sun4u.c
... ... @@ -257,7 +257,7 @@ static fdctrl_t *floppy_controller;
257 257 static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
258 258 DisplayState *ds, const char **fd_filename, int snapshot,
259 259 const char *kernel_filename, const char *kernel_cmdline,
260   - const char *initrd_filename)
  260 + const char *initrd_filename, const char *cpu_model)
261 261 {
262 262 CPUState *env;
263 263 char buf[1024];
... ...
hw/versatilepb.c
... ... @@ -257,7 +257,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
257 257 static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
258 258 DisplayState *ds, const char **fd_filename, int snapshot,
259 259 const char *kernel_filename, const char *kernel_cmdline,
260   - const char *initrd_filename)
  260 + const char *initrd_filename, const char *cpu_model)
261 261 {
262 262 versatile_init(ram_size, vga_ram_size, boot_device,
263 263 ds, fd_filename, snapshot,
... ... @@ -268,7 +268,7 @@ static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
268 268 static void vab_init(int ram_size, int vga_ram_size, int boot_device,
269 269 DisplayState *ds, const char **fd_filename, int snapshot,
270 270 const char *kernel_filename, const char *kernel_cmdline,
271   - const char *initrd_filename)
  271 + const char *initrd_filename, const char *cpu_model)
272 272 {
273 273 versatile_init(ram_size, vga_ram_size, boot_device,
274 274 ds, fd_filename, snapshot,
... ...
... ... @@ -6355,6 +6355,7 @@ void help(void)
6355 6355 "\n"
6356 6356 "Standard options:\n"
6357 6357 "-M machine select emulated machine (-M ? for list)\n"
  6358 + "-cpu cpu select CPU (-C ? for list)\n"
6358 6359 "-fda/-fdb file use 'file' as floppy disk 0/1 image\n"
6359 6360 "-hda/-hdb file use 'file' as IDE hard disk 0/1 image\n"
6360 6361 "-hdc/-hdd file use 'file' as IDE hard disk 2/3 image\n"
... ... @@ -6487,6 +6488,7 @@ enum {
6487 6488 QEMU_OPTION_h,
6488 6489  
6489 6490 QEMU_OPTION_M,
  6491 + QEMU_OPTION_cpu,
6490 6492 QEMU_OPTION_fda,
6491 6493 QEMU_OPTION_fdb,
6492 6494 QEMU_OPTION_hda,
... ... @@ -6562,6 +6564,7 @@ const QEMUOption qemu_options[] = {
6562 6564 { "help", 0, QEMU_OPTION_h },
6563 6565  
6564 6566 { "M", HAS_ARG, QEMU_OPTION_M },
  6567 + { "cpu", HAS_ARG, QEMU_OPTION_cpu },
6565 6568 { "fda", HAS_ARG, QEMU_OPTION_fda },
6566 6569 { "fdb", HAS_ARG, QEMU_OPTION_fdb },
6567 6570 { "hda", HAS_ARG, QEMU_OPTION_hda },
... ... @@ -6867,6 +6870,7 @@ int main(int argc, char **argv)
6867 6870 int parallel_device_index;
6868 6871 const char *loadvm = NULL;
6869 6872 QEMUMachine *machine;
  6873 + const char *cpu_model;
6870 6874 char usb_devices[MAX_USB_CMDLINE][128];
6871 6875 int usb_devices_index;
6872 6876 int fds[2];
... ... @@ -6904,6 +6908,7 @@ int main(int argc, char **argv)
6904 6908  
6905 6909 register_machines();
6906 6910 machine = first_machine;
  6911 + cpu_model = NULL;
6907 6912 initrd_filename = NULL;
6908 6913 for(i = 0; i < MAX_FD; i++)
6909 6914 fd_filename[i] = NULL;
... ... @@ -6995,6 +7000,17 @@ int main(int argc, char **argv)
6995 7000 exit(1);
6996 7001 }
6997 7002 break;
  7003 + case QEMU_OPTION_cpu:
  7004 + /* hw initialization will check this */
  7005 + if (optarg[0] == '?') {
  7006 +#if defined(TARGET_PPC)
  7007 + ppc_cpu_list(stdout, &fprintf);
  7008 +#endif
  7009 + exit(1);
  7010 + } else {
  7011 + cpu_model = optarg;
  7012 + }
  7013 + break;
6998 7014 case QEMU_OPTION_initrd:
6999 7015 initrd_filename = optarg;
7000 7016 break;
... ... @@ -7569,7 +7585,7 @@ int main(int argc, char **argv)
7569 7585  
7570 7586 machine->init(ram_size, vga_ram_size, boot_device,
7571 7587 ds, fd_filename, snapshot,
7572   - kernel_filename, kernel_cmdline, initrd_filename);
  7588 + kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
7573 7589  
7574 7590 /* init USB devices */
7575 7591 if (usb_enabled) {
... ...
... ... @@ -695,7 +695,7 @@ typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
695 695 int boot_device,
696 696 DisplayState *ds, const char **fd_filename, int snapshot,
697 697 const char *kernel_filename, const char *kernel_cmdline,
698   - const char *initrd_filename);
  698 + const char *initrd_filename, const char *cpu_model);
699 699  
700 700 typedef struct QEMUMachine {
701 701 const char *name;
... ... @@ -709,6 +709,10 @@ int qemu_register_machine(QEMUMachine *m);
709 709 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
710 710 typedef void IRQRequestFunc(void *opaque, int level);
711 711  
  712 +#if defined(TARGET_PPC)
  713 +void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
  714 +#endif
  715 +
712 716 /* ISA bus */
713 717  
714 718 extern target_phys_addr_t isa_mem_base;
... ...