Commit 3371d27293dc40159069d6593da22ba77ac8513c

Authored by pbrook
1 parent 76a66253

Implement --cpu for ARM.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2474 c046a42c-6fe2-441c-8c8c-71466251a162
hw/integratorcp.c
@@ -471,7 +471,7 @@ static void icp_control_init(uint32_t base) @@ -471,7 +471,7 @@ static void icp_control_init(uint32_t base)
471 static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, 471 static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
472 DisplayState *ds, const char **fd_filename, int snapshot, 472 DisplayState *ds, const char **fd_filename, int snapshot,
473 const char *kernel_filename, const char *kernel_cmdline, 473 const char *kernel_filename, const char *kernel_cmdline,
474 - const char *initrd_filename, uint32_t cpuid) 474 + const char *initrd_filename, const char *cpu_model)
475 { 475 {
476 CPUState *env; 476 CPUState *env;
477 uint32_t bios_offset; 477 uint32_t bios_offset;
@@ -479,7 +479,9 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, @@ -479,7 +479,9 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
479 void *cpu_pic; 479 void *cpu_pic;
480 480
481 env = cpu_init(); 481 env = cpu_init();
482 - cpu_arm_set_model(env, cpuid); 482 + if (!cpu_model)
  483 + cpu_model = "arm926";
  484 + cpu_arm_set_model(env, cpu_model);
483 bios_offset = ram_size + vga_ram_size; 485 bios_offset = ram_size + vga_ram_size;
484 /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ 486 /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */
485 /* ??? RAM shoud repeat to fill physical memory space. */ 487 /* ??? RAM shoud repeat to fill physical memory space. */
@@ -513,34 +515,8 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device, @@ -513,34 +515,8 @@ static void integratorcp_init(int ram_size, int vga_ram_size, int boot_device,
513 initrd_filename, 0x113); 515 initrd_filename, 0x113);
514 } 516 }
515 517
516 -static void integratorcp926_init(int ram_size, int vga_ram_size,  
517 - int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,  
518 - const char *kernel_filename, const char *kernel_cmdline,  
519 - const char *initrd_filename, const char *cpu_model)  
520 -{  
521 - integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,  
522 - snapshot, kernel_filename, kernel_cmdline,  
523 - initrd_filename, ARM_CPUID_ARM926);  
524 -}  
525 -  
526 -static void integratorcp1026_init(int ram_size, int vga_ram_size,  
527 - int boot_device, DisplayState *ds, const char **fd_filename, int snapshot,  
528 - const char *kernel_filename, const char *kernel_cmdline,  
529 - const char *initrd_filename, const char *cpu_model)  
530 -{  
531 - integratorcp_init(ram_size, vga_ram_size, boot_device, ds, fd_filename,  
532 - snapshot, kernel_filename, kernel_cmdline,  
533 - initrd_filename, ARM_CPUID_ARM1026);  
534 -}  
535 -  
536 -QEMUMachine integratorcp926_machine = {  
537 - "integratorcp926", 518 +QEMUMachine integratorcp_machine = {
  519 + "integratorcp",
538 "ARM Integrator/CP (ARM926EJ-S)", 520 "ARM Integrator/CP (ARM926EJ-S)",
539 - integratorcp926_init,  
540 -};  
541 -  
542 -QEMUMachine integratorcp1026_machine = {  
543 - "integratorcp1026",  
544 - "ARM Integrator/CP (ARM1026EJ-S)",  
545 - integratorcp1026_init, 521 + integratorcp_init,
546 }; 522 };
hw/realview.c
@@ -26,8 +26,9 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device, @@ -26,8 +26,9 @@ static void realview_init(int ram_size, int vga_ram_size, int boot_device,
26 int done_smc = 0; 26 int done_smc = 0;
27 27
28 env = cpu_init(); 28 env = cpu_init();
29 - cpu_arm_set_model(env, ARM_CPUID_ARM926);  
30 - //cpu_arm_set_model(env, ARM_CPUID_ARM11MPCORE); 29 + if (!cpu_model)
  30 + cpu_model = "arm926";
  31 + cpu_arm_set_model(env, cpu_model);
31 /* ??? RAM shoud repeat to fill physical memory space. */ 32 /* ??? RAM shoud repeat to fill physical memory space. */
32 /* SDRAM at address zero. */ 33 /* SDRAM at address zero. */
33 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); 34 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
hw/versatilepb.c
@@ -154,7 +154,8 @@ static vpb_sic_state *vpb_sic_init(uint32_t base, void *parent, int irq) @@ -154,7 +154,8 @@ static vpb_sic_state *vpb_sic_init(uint32_t base, void *parent, int irq)
154 static void versatile_init(int ram_size, int vga_ram_size, int boot_device, 154 static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
155 DisplayState *ds, const char **fd_filename, int snapshot, 155 DisplayState *ds, const char **fd_filename, int snapshot,
156 const char *kernel_filename, const char *kernel_cmdline, 156 const char *kernel_filename, const char *kernel_cmdline,
157 - const char *initrd_filename, int board_id) 157 + const char *initrd_filename, const char *cpu_model,
  158 + int board_id)
158 { 159 {
159 CPUState *env; 160 CPUState *env;
160 void *pic; 161 void *pic;
@@ -166,7 +167,9 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device, @@ -166,7 +167,9 @@ static void versatile_init(int ram_size, int vga_ram_size, int boot_device,
166 int done_smc = 0; 167 int done_smc = 0;
167 168
168 env = cpu_init(); 169 env = cpu_init();
169 - cpu_arm_set_model(env, ARM_CPUID_ARM926); 170 + if (!cpu_model)
  171 + cpu_model = "arm926";
  172 + cpu_arm_set_model(env, cpu_model);
170 /* ??? RAM shoud repeat to fill physical memory space. */ 173 /* ??? RAM shoud repeat to fill physical memory space. */
171 /* SDRAM at address zero. */ 174 /* SDRAM at address zero. */
172 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); 175 cpu_register_physical_memory(0, ram_size, IO_MEM_RAM);
@@ -262,7 +265,7 @@ static void vpb_init(int ram_size, int vga_ram_size, int boot_device, @@ -262,7 +265,7 @@ static void vpb_init(int ram_size, int vga_ram_size, int boot_device,
262 versatile_init(ram_size, vga_ram_size, boot_device, 265 versatile_init(ram_size, vga_ram_size, boot_device,
263 ds, fd_filename, snapshot, 266 ds, fd_filename, snapshot,
264 kernel_filename, kernel_cmdline, 267 kernel_filename, kernel_cmdline,
265 - initrd_filename, 0x183); 268 + initrd_filename, cpu_model, 0x183);
266 } 269 }
267 270
268 static void vab_init(int ram_size, int vga_ram_size, int boot_device, 271 static void vab_init(int ram_size, int vga_ram_size, int boot_device,
@@ -273,7 +276,7 @@ static void vab_init(int ram_size, int vga_ram_size, int boot_device, @@ -273,7 +276,7 @@ static void vab_init(int ram_size, int vga_ram_size, int boot_device,
273 versatile_init(ram_size, vga_ram_size, boot_device, 276 versatile_init(ram_size, vga_ram_size, boot_device,
274 ds, fd_filename, snapshot, 277 ds, fd_filename, snapshot,
275 kernel_filename, kernel_cmdline, 278 kernel_filename, kernel_cmdline,
276 - initrd_filename, 0x25e); 279 + initrd_filename, cpu_model, 0x25e);
277 } 280 }
278 281
279 QEMUMachine versatilepb_machine = { 282 QEMUMachine versatilepb_machine = {
linux-user/main.c
@@ -1756,7 +1756,7 @@ int main(int argc, char **argv) @@ -1756,7 +1756,7 @@ int main(int argc, char **argv)
1756 #elif defined(TARGET_ARM) 1756 #elif defined(TARGET_ARM)
1757 { 1757 {
1758 int i; 1758 int i;
1759 - cpu_arm_set_model(env, ARM_CPUID_ARM1026); 1759 + cpu_arm_set_model(env, "arm926");
1760 cpsr_write(env, regs->uregs[16], 0xffffffff); 1760 cpsr_write(env, regs->uregs[16], 0xffffffff);
1761 for(i = 0; i < 16; i++) { 1761 for(i = 0; i < 16; i++) {
1762 env->regs[i] = regs->uregs[i]; 1762 env->regs[i] = regs->uregs[i];
target-arm/cpu.h
@@ -209,7 +209,7 @@ static inline int arm_feature(CPUARMState *env, int feature) @@ -209,7 +209,7 @@ static inline int arm_feature(CPUARMState *env, int feature)
209 return (env->features & (1u << feature)) != 0; 209 return (env->features & (1u << feature)) != 0;
210 } 210 }
211 211
212 -void cpu_arm_set_model(CPUARMState *env, uint32_t id); 212 +void cpu_arm_set_model(CPUARMState *env, const char *name);
213 213
214 #define ARM_CPUID_ARM1026 0x4106a262 214 #define ARM_CPUID_ARM1026 0x4106a262
215 #define ARM_CPUID_ARM926 0x41069265 215 #define ARM_CPUID_ARM926 0x41069265
target-arm/helper.c
@@ -36,8 +36,35 @@ static inline void set_feature(CPUARMState *env, int feature) @@ -36,8 +36,35 @@ static inline void set_feature(CPUARMState *env, int feature)
36 env->features |= 1u << feature; 36 env->features |= 1u << feature;
37 } 37 }
38 38
39 -void cpu_arm_set_model(CPUARMState *env, uint32_t id) 39 +struct arm_cpu_t {
  40 + uint32_t id;
  41 + const char *name;
  42 +};
  43 +
  44 +static const struct arm_cpu_t arm_cpu_names[] = {
  45 + { ARM_CPUID_ARM926, "arm926"},
  46 + { ARM_CPUID_ARM1026, "arm1026"},
  47 + { 0, NULL}
  48 +};
  49 +
  50 +void cpu_arm_set_model(CPUARMState *env, const char *name)
40 { 51 {
  52 + int i;
  53 + uint32_t id;
  54 +
  55 + id = 0;
  56 + i = 0;
  57 + for (i = 0; arm_cpu_names[i].name; i++) {
  58 + if (strcmp(name, arm_cpu_names[i].name) == 0) {
  59 + id = arm_cpu_names[i].id;
  60 + break;
  61 + }
  62 + }
  63 + if (!id) {
  64 + cpu_abort(env, "Unknown CPU '%s'", name);
  65 + return;
  66 + }
  67 +
41 env->cp15.c0_cpuid = id; 68 env->cp15.c0_cpuid = id;
42 switch (id) { 69 switch (id) {
43 case ARM_CPUID_ARM926: 70 case ARM_CPUID_ARM926:
@@ -6710,8 +6710,7 @@ void register_machines(void) @@ -6710,8 +6710,7 @@ void register_machines(void)
6710 qemu_register_machine(&sun4m_machine); 6710 qemu_register_machine(&sun4m_machine);
6711 #endif 6711 #endif
6712 #elif defined(TARGET_ARM) 6712 #elif defined(TARGET_ARM)
6713 - qemu_register_machine(&integratorcp926_machine);  
6714 - qemu_register_machine(&integratorcp1026_machine); 6713 + qemu_register_machine(&integratorcp_machine);
6715 qemu_register_machine(&versatilepb_machine); 6714 qemu_register_machine(&versatilepb_machine);
6716 qemu_register_machine(&versatileab_machine); 6715 qemu_register_machine(&versatileab_machine);
6717 qemu_register_machine(&realview_machine); 6716 qemu_register_machine(&realview_machine);
@@ -1304,8 +1304,7 @@ void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id); @@ -1304,8 +1304,7 @@ void lsi_scsi_attach(void *opaque, BlockDriverState *bd, int id);
1304 void *lsi_scsi_init(PCIBus *bus, int devfn); 1304 void *lsi_scsi_init(PCIBus *bus, int devfn);
1305 1305
1306 /* integratorcp.c */ 1306 /* integratorcp.c */
1307 -extern QEMUMachine integratorcp926_machine;  
1308 -extern QEMUMachine integratorcp1026_machine; 1307 +extern QEMUMachine integratorcp_machine;
1309 1308
1310 /* versatilepb.c */ 1309 /* versatilepb.c */
1311 extern QEMUMachine versatilepb_machine; 1310 extern QEMUMachine versatilepb_machine;