This tiny patch unifies the -cpu ? option for all cpu that actually can
handle it.
It changes the arm_cpu_list to use the same prototype as ppc, mips and
sparc and add a new define cpu_list in target_xxx/cpu.h
As the cpu selection is not implemented for all targets, I had to
protect the call to cpu_list with a #if defined(cpu_list) that will have
to be suppressed once all target will implement this feature.

Please comment.

-- 
J. Mayer <[EMAIL PROTECTED]>
Never organized
Index: vl.c
===================================================================
RCS file: /sources/qemu/qemu/vl.c,v
retrieving revision 1.347
diff -u -d -d -p -r1.347 vl.c
--- vl.c	8 Oct 2007 13:16:14 -0000	1.347
+++ vl.c	9 Oct 2007 22:56:04 -0000
@@ -7690,14 +7693,9 @@ int main(int argc, char **argv)
             case QEMU_OPTION_cpu:
                 /* hw initialization will check this */
                 if (*optarg == '?') {
-#if defined(TARGET_PPC)
-                    ppc_cpu_list(stdout, &fprintf);
-#elif defined(TARGET_ARM)
-                    arm_cpu_list();
-#elif defined(TARGET_MIPS)
-                    mips_cpu_list(stdout, &fprintf);
-#elif defined(TARGET_SPARC)
-                    sparc_cpu_list(stdout, &fprintf);
+/* XXX: implement xxx_cpu_list for targets that still miss it */
+#if defined(cpu_list)
+                    cpu_list(stdout, &fprintf);
 #endif
                     exit(0);
                 } else {
Index: vl.h
===================================================================
RCS file: /sources/qemu/qemu/vl.h,v
retrieving revision 1.277
diff -u -d -d -p -r1.277 vl.h
--- vl.h	9 Oct 2007 03:08:56 -0000	1.277
+++ vl.h	9 Oct 2007 22:56:04 -0000
@@ -741,14 +741,6 @@ int qemu_register_machine(QEMUMachine *m
 
 typedef void SetIRQFunc(void *opaque, int irq_num, int level);
 
-#if defined(TARGET_PPC)
-void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
-#endif
-
-#if defined(TARGET_MIPS)
-void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...));
-#endif
-
 #include "hw/irq.h"
 
 /* ISA bus */
Index: target-arm/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-arm/cpu.h,v
retrieving revision 1.34
diff -u -d -d -p -r1.34 cpu.h
--- target-arm/cpu.h	27 Sep 2007 16:44:31 -0000	1.34
+++ target-arm/cpu.h	9 Oct 2007 22:56:04 -0000
@@ -299,5 +299,6 @@ void cpu_arm_set_cp_io(CPUARMState *env,
 #define cpu_exec cpu_arm_exec
 #define cpu_gen_code cpu_arm_gen_code
 #define cpu_signal_handler cpu_arm_signal_handler
+#define cpu_list arm_cpu_list
 #include "cpu-all.h"
 
Index: target-arm/helper.c
===================================================================
RCS file: /sources/qemu/qemu/target-arm/helper.c,v
retrieving revision 1.21
diff -u -d -d -p -r1.21 helper.c
--- target-arm/helper.c	16 Sep 2007 21:08:01 -0000	1.21
+++ target-arm/helper.c	9 Oct 2007 22:56:04 -0000
@@ -126,13 +126,13 @@ static const struct arm_cpu_t arm_cpu_na
     { 0, NULL}
 };
 
-void arm_cpu_list(void)
+void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...))
 {
     int i;
 
-    printf ("Available CPUs:\n");
+    (*cpu_fprintf)(f, "Available CPUs:\n");
     for (i = 0; arm_cpu_names[i].name; i++) {
-        printf("  %s\n", arm_cpu_names[i].name);
+        (*cpu_fprintf)(f, "  %s\n", arm_cpu_names[i].name);
     }
 }
 
Index: target-mips/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-mips/cpu.h,v
retrieving revision 1.47
diff -u -d -d -p -r1.47 cpu.h
--- target-mips/cpu.h	27 Sep 2007 16:44:31 -0000	1.47
+++ target-mips/cpu.h	9 Oct 2007 22:56:04 -0000
@@ -482,6 +482,7 @@ int cpu_mips_register (CPUMIPSState *env
 #define cpu_exec cpu_mips_exec
 #define cpu_gen_code cpu_mips_gen_code
 #define cpu_signal_handler cpu_mips_signal_handler
+#define cpu_list mips_cpu_list
 
 #include "cpu-all.h"
 
Index: target-ppc/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-ppc/cpu.h,v
retrieving revision 1.78
diff -u -d -d -p -r1.78 cpu.h
--- target-ppc/cpu.h	8 Oct 2007 02:58:07 -0000	1.78
+++ target-ppc/cpu.h	9 Oct 2007 22:56:04 -0000
@@ -697,6 +695,7 @@ int ppc_dcr_write (ppc_dcr_t *dcr_env, i
 #define cpu_exec cpu_ppc_exec
 #define cpu_gen_code cpu_ppc_gen_code
 #define cpu_signal_handler cpu_ppc_signal_handler
+#define cpu_list ppc_cpu_list
 
 #include "cpu-all.h"
 
Index: target-sparc/cpu.h
===================================================================
RCS file: /sources/qemu/qemu/target-sparc/cpu.h,v
retrieving revision 1.52
diff -u -d -d -p -r1.52 cpu.h
--- target-sparc/cpu.h	27 Sep 2007 16:44:32 -0000	1.52
+++ target-sparc/cpu.h	9 Oct 2007 22:56:04 -0000
@@ -315,6 +315,7 @@ void cpu_check_irqs(CPUSPARCState *env);
 #define cpu_exec cpu_sparc_exec
 #define cpu_gen_code cpu_sparc_gen_code
 #define cpu_signal_handler cpu_sparc_signal_handler
+#define cpu_list sparc_cpu_list
 
 #include "cpu-all.h"
 

Reply via email to