New -cpu options: choose CPU model for emulated target.
authorj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 5 Mar 2007 19:44:02 +0000 (19:44 +0000)
committerj_mayer <j_mayer@c046a42c-6fe2-441c-8c8c-71466251a162>
Mon, 5 Mar 2007 19:44:02 +0000 (19:44 +0000)
 Only relevant on PowerPC targets, for now.

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2468 c046a42c-6fe2-441c-8c8c-71466251a162

13 files changed:
hw/integratorcp.c
hw/mips_malta.c
hw/mips_r4k.c
hw/pc.c
hw/ppc_chrp.c
hw/ppc_prep.c
hw/realview.c
hw/shix.c
hw/sun4m.c
hw/sun4u.c
hw/versatilepb.c
vl.c
vl.h

index 4e5f4ac9f722729b1f871f726c63b40f5f3016d1..fd1675b40b6b8b64018fa4b34eaa61fd17598287 100644 (file)
@@ -516,7 +516,7 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
 static void integratorcp926_init(int ram_size, int vga_ram_size,
     int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
     const char *kernel_filename, const char *kernel_cmdline,
-    const char *initrd_filename)
+    const char *initrd_filename, const char *cpu_model)
 {
     integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
                       snapshot, kernel_filename, kernel_cmdline,
@@ -526,7 +526,7 @@ static void integratorcp926_init(int ram_size, int vga_ram_size,
 static void integratorcp1026_init(int ram_size, int vga_ram_size,
     int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,
     const char *kernel_filename, const char *kernel_cmdline,
-    const char *initrd_filename)
+    const char *initrd_filename, const char *cpu_model)
 {
     integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,
                       snapshot, kernel_filename, kernel_cmdline,
index 8d77b780034587813111eaccac213e160d41b04d..d137658fbdc045876ce507cf9a2ff33627990fe2 100644 (file)
@@ -615,7 +615,7 @@ static
 void mips_malta_init (int ram_size, int vga_ram_size, int boot_device,
                       DisplayState *ds, const char **fd_filename, int snapshot,
                       const char *kernel_filename, const char *kernel_cmdline,
-                      const char *initrd_filename)
+                      const char *initrd_filename, const char *cpu_model)
 {
     char buf[1024];
     unsigned long bios_offset;
index b6054fd51732332dfe3ed7763e0d06886b2ac0cc..91d8021ddaf9c7d830fcefad1b95b66127af5881 100644 (file)
@@ -130,7 +130,7 @@ static
 void mips_r4k_init (int ram_size, int vga_ram_size, int boot_device,
                     DisplayState *ds, const char **fd_filename, int snapshot,
                     const char *kernel_filename, const char *kernel_cmdline,
-                    const char *initrd_filename)
+                    const char *initrd_filename, const char *cpu_model)
 {
     char buf[1024];
     unsigned long bios_offset;
diff --git a/hw/pc.c b/hw/pc.c
index 0560ff1f92b0230aac120a555624cb5eed36217c..ba9c2d94732d190627ce04e6c962d8cba19b73a0 100644 (file)
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -758,7 +758,8 @@ static void pc_init_pci(int ram_size, int vga_ram_size, int boot_device,
                         int snapshot, 
                         const char *kernel_filename, 
                         const char *kernel_cmdline,
-                        const char *initrd_filename)
+                        const char *initrd_filename,
+                        const char *cpu_model)
 {
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
@@ -771,7 +772,8 @@ static void pc_init_isa(int ram_size, int vga_ram_size, int boot_device,
                         int snapshot, 
                         const char *kernel_filename, 
                         const char *kernel_cmdline,
-                        const char *initrd_filename)
+                        const char *initrd_filename,
+                        const char *cpu_model)
 {
     pc_init1(ram_size, vga_ram_size, boot_device,
              ds, fd_filename, snapshot,
index 1e0fd2e9da73f5ef2e31a61b6df73cbdd95f0fa8..937be150ceeb02b9cb25f8ff174e4d9a542096d7 100644 (file)
@@ -292,13 +292,14 @@ void pmac_format_nvram_partition(uint8_t *buf, int len)
 }    
 
 /* PowerPC CHRP hardware initialisation */
-static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
-                          DisplayState *ds, const char **fd_filename, 
-                          int snapshot,
-                          const char *kernel_filename, 
-                          const char *kernel_cmdline,
-                          const char *initrd_filename,
-                          int is_heathrow)
+static void ppc_chrp_init (int ram_size, int vga_ram_size, int boot_device,
+                           DisplayState *ds, const char **fd_filename,
+                           int snapshot,
+                           const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           const char *cpu_model,
+                           int is_heathrow)
 {
     CPUState *env;
     char buf[1024];
@@ -320,22 +321,16 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
     env = cpu_init();
     register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
 
-    /* Register CPU as a 74x/75x */
+    /* Default CPU is a generic 74x/75x */
+    if (cpu_model == NULL)
+        cpu_model = "750";
     /* XXX: CPU model (or PVR) should be provided on command line */
     //    ppc_find_by_name("750gx", &def); // Linux boot OK
     //    ppc_find_by_name("750fx", &def); // Linux boot OK
     /* Linux does not boot on 750cxe (and probably other 750cx based)
      * because it assumes it has 8 IBAT & DBAT pairs as it only have 4.
      */
-    //    ppc_find_by_name("750cxe", &def);
-    //    ppc_find_by_name("750p", &def);
-    //    ppc_find_by_name("740p", &def);
-    ppc_find_by_name("750", &def);
-    //    ppc_find_by_name("740", &def);
-    //    ppc_find_by_name("G3", &def);
-    //    ppc_find_by_name("604r", &def);
-    //    ppc_find_by_name("604e", &def);
-    //    ppc_find_by_name("604", &def);
+    ppc_find_by_name(cpu_model, &def);
     if (def == NULL) {
         cpu_abort(env, "Unable to find PowerPC CPU definition\n");
     }
@@ -525,30 +520,32 @@ static void ppc_chrp_init(int ram_size, int vga_ram_size, int boot_device,
     register_ioport_write(0x0F00, 4, 1, &PPC_debug_write, NULL);
 }
 
-static void ppc_core99_init(int ram_size, int vga_ram_size, int boot_device,
-                            DisplayState *ds, const char **fd_filename, 
-                            int snapshot,
-                            const char *kernel_filename, 
-                            const char *kernel_cmdline,
-                            const char *initrd_filename)
+static void ppc_core99_init (int ram_size, int vga_ram_size, int boot_device,
+                             DisplayState *ds, const char **fd_filename,
+                             int snapshot,
+                             const char *kernel_filename,
+                             const char *kernel_cmdline,
+                             const char *initrd_filename,
+                             const char *cpu_model)
 {
     ppc_chrp_init(ram_size, vga_ram_size, boot_device,
                   ds, fd_filename, snapshot,
                   kernel_filename, kernel_cmdline,
-                  initrd_filename, 0);
+                  initrd_filename, cpu_model, 0);
 }
     
-static void ppc_heathrow_init(int ram_size, int vga_ram_size, int boot_device,
-                              DisplayState *ds, const char **fd_filename, 
-                              int snapshot,
-                              const char *kernel_filename, 
-                              const char *kernel_cmdline,
-                              const char *initrd_filename)
+static void ppc_heathrow_init (int ram_size, int vga_ram_size, int boot_device,
+                               DisplayState *ds, const char **fd_filename,
+                               int snapshot,
+                               const char *kernel_filename,
+                               const char *kernel_cmdline,
+                               const char *initrd_filename,
+                               const char *cpu_model)
 {
     ppc_chrp_init(ram_size, vga_ram_size, boot_device,
                   ds, fd_filename, snapshot,
                   kernel_filename, kernel_cmdline,
-                  initrd_filename, 1);
+                  initrd_filename, cpu_model, 1);
 }
 
 QEMUMachine core99_machine = {
index c4b7ff5baa3af127d1b1b3b87b1146cc1da682c6..27d3d4848612868debf04b7d70d2891371ebe442 100644 (file)
@@ -518,10 +518,12 @@ CPUReadMemoryFunc *PPC_prep_io_read[] = {
 #define NVRAM_SIZE        0x2000
 
 /* PowerPC PREP hardware initialisation */
-static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
-                          DisplayState *ds, const char **fd_filename, int snapshot,
-                          const char *kernel_filename, const char *kernel_cmdline,
-                          const char *initrd_filename)
+static void ppc_prep_init (int ram_size, int vga_ram_size, int boot_device,
+                           DisplayState *ds, const char **fd_filename,
+                           int snapshot, const char *kernel_filename,
+                           const char *kernel_cmdline,
+                           const char *initrd_filename,
+                           const char *cpu_model)
 {
     CPUState *env;
     char buf[1024];
@@ -543,12 +545,11 @@ static void ppc_prep_init(int ram_size, int vga_ram_size, int boot_device,
 
     env = cpu_init();
     register_savevm("cpu", 0, 3, cpu_save, cpu_load, env);
-    
-    /* Register CPU as a 604 */
-    /* XXX: CPU model (or PVR) should be provided on command line */
-    //    ppc_find_by_name("604r", &def);
-    //    ppc_find_by_name("604e", &def);
-    ppc_find_by_name("604", &def);
+
+    /* Default CPU is a 604 */
+    if (cpu_model == NULL)
+        cpu_model = "604";
+    ppc_find_by_name(cpu_model, &def);
     if (def == NULL) {
         cpu_abort(env, "Unable to find PowerPC CPU definition\n");
     }
index ea42705adb4433e69d291d1ea76bc6f393aa969f..325b3d1ab3279f153cfa4ea7a99cc94b8946b244 100644 (file)
@@ -15,7 +15,7 @@
 static void realview_init(int ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
-                     const char *initrd_filename)
+                     const char *initrd_filename, const char *cpu_model)
 {
     CPUState *env;
     void *pic;
index 9577c092c28d7208cb1757a6375d37318f7a23d6..5857d0e06b4e2c89de60f8dd7cce0817549bb056 100644 (file)
--- a/hw/shix.c
+++ b/hw/shix.c
@@ -70,7 +70,7 @@ void vga_screen_dump(const char *filename)
 void shix_init(int ram_size, int vga_ram_size, int boot_device,
               DisplayState * ds, const char **fd_filename, int snapshot,
               const char *kernel_filename, const char *kernel_cmdline,
-              const char *initrd_filename)
+              const char *initrd_filename, const char *cpu_model)
 {
     int ret;
     CPUState *env;
index 9b6aae53c8e373ec889ae9cdc7129f70dd2d37f7..c5f6ddda8bc0c50650dd626bb799c1b4e9c01c42 100644 (file)
@@ -211,7 +211,7 @@ static void main_cpu_reset(void *opaque)
 static void sun4m_init(int ram_size, int vga_ram_size, int boot_device,
                        DisplayState *ds, const char **fd_filename, int snapshot,
                        const char *kernel_filename, const char *kernel_cmdline,
-                       const char *initrd_filename)
+                       const char *initrd_filename, const char *cpu_model)
 {
     CPUState *env, *envs[MAX_CPUS];
     char buf[1024];
index 61069a6529c2ded351256c9c9524f5d5a3b4aa2b..2357dc974aac1d9fd28925d5027ef51cf0ce19a2 100644 (file)
@@ -257,7 +257,7 @@ static fdctrl_t *floppy_controller;
 static void sun4u_init(int ram_size, int vga_ram_size, int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
-             const char *initrd_filename)
+             const char *initrd_filename, const char *cpu_model)
 {
     CPUState *env;
     char buf[1024];
index bc42472ade3bc3674040a8617cf023d6371b031a..1bcc160b332bf2e375fb37396c06820e3b66147d 100644 (file)
@@ -257,7 +257,7 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
 static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
-                     const char *initrd_filename)
+                     const char *initrd_filename, const char *cpu_model)
 {
     versatile_init(ram_size, vga_ram_size, boot_device,
                    ds, fd_filename, snapshot,
@@ -268,7 +268,7 @@ static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
 static void vab_init(int ram_size, int vga_ram_size, int boot_device,
                      DisplayState *ds, const char **fd_filename, int snapshot,
                      const char *kernel_filename, const char *kernel_cmdline,
-                     const char *initrd_filename)
+                     const char *initrd_filename, const char *cpu_model)
 {
     versatile_init(ram_size, vga_ram_size, boot_device,
                    ds, fd_filename, snapshot,
diff --git a/vl.c b/vl.c
index cfe6a2a5def2e95c82140b856d789037b453274e..99d4766b91c46b0ac21f255dadbec40ad03008ec 100644 (file)
--- a/vl.c
+++ b/vl.c
@@ -6355,6 +6355,7 @@ void help(void)
            "\n"
            "Standard options:\n"
            "-M machine      select emulated machine (-M ? for list)\n"
+           "-cpu cpu        select CPU (-C ? for list)\n"
            "-fda/-fdb file  use 'file' as floppy disk 0/1 image\n"
            "-hda/-hdb file  use 'file' as IDE hard disk 0/1 image\n"
            "-hdc/-hdd file  use 'file' as IDE hard disk 2/3 image\n"
@@ -6487,6 +6488,7 @@ enum {
     QEMU_OPTION_h,
 
     QEMU_OPTION_M,
+    QEMU_OPTION_cpu,
     QEMU_OPTION_fda,
     QEMU_OPTION_fdb,
     QEMU_OPTION_hda,
@@ -6562,6 +6564,7 @@ const QEMUOption qemu_options[] = {
     { "help", 0, QEMU_OPTION_h },
 
     { "M", HAS_ARG, QEMU_OPTION_M },
+    { "cpu", HAS_ARG, QEMU_OPTION_cpu },
     { "fda", HAS_ARG, QEMU_OPTION_fda },
     { "fdb", HAS_ARG, QEMU_OPTION_fdb },
     { "hda", HAS_ARG, QEMU_OPTION_hda },
@@ -6867,6 +6870,7 @@ int main(int argc, char **argv)
     int parallel_device_index;
     const char *loadvm = NULL;
     QEMUMachine *machine;
+    const char *cpu_model;
     char usb_devices[MAX_USB_CMDLINE][128];
     int usb_devices_index;
     int fds[2];
@@ -6904,6 +6908,7 @@ int main(int argc, char **argv)
 
     register_machines();
     machine = first_machine;
+    cpu_model = NULL;
     initrd_filename = NULL;
     for(i = 0; i < MAX_FD; i++)
         fd_filename[i] = NULL;
@@ -6995,6 +7000,17 @@ int main(int argc, char **argv)
                     exit(1);
                 }
                 break;
+            case QEMU_OPTION_cpu:
+                /* hw initialization will check this */
+                if (optarg[0] == '?') {
+#if defined(TARGET_PPC)
+                    ppc_cpu_list(stdout, &fprintf);
+#endif
+                    exit(1);
+                } else {
+                    cpu_model = optarg;
+                }
+                break;
             case QEMU_OPTION_initrd:
                 initrd_filename = optarg;
                 break;
@@ -7569,7 +7585,7 @@ int main(int argc, char **argv)
 
     machine->init(ram_size, vga_ram_size, boot_device,
                   ds, fd_filename, snapshot,
-                  kernel_filename, kernel_cmdline, initrd_filename);
+                  kernel_filename, kernel_cmdline, initrd_filename, cpu_model);
 
     /* init USB devices */
     if (usb_enabled) {
diff --git a/vl.h b/vl.h
index ae501e24b6a366785e58a2a832e3674db9d6a1b0..0f5ab97004218fd28c8a2bfac1ff1bdac3259dae 100644 (file)
--- a/vl.h
+++ b/vl.h
@@ -695,7 +695,7 @@ typedef void QEMUMachineInitFunc(int ram_size, int vga_ram_size,
                                  int boot_device,
              DisplayState *ds, const char **fd_filename, int snapshot,
              const char *kernel_filename, const char *kernel_cmdline,
-             const char *initrd_filename);
+             const char *initrd_filename, const char *cpu_model);
 
 typedef struct QEMUMachine {
     const char *name;
@@ -709,6 +709,10 @@ int qemu_register_machine(QEMUMachine *m);
 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
 typedef void IRQRequestFunc(void *opaque, int level);
 
+#if defined(TARGET_PPC)
+void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
+#endif
+
 /* ISA bus */
 
 extern target_phys_addr_t isa_mem_base;