Commit aaed909a495e78364abc6812df672d2e764961a8
1 parent
7d77bf20
added cpu_model parameter to cpu_init()
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3562 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
46 changed files
with
320 additions
and
324 deletions
darwin-user/main.c
@@ -785,6 +785,7 @@ int main(int argc, char **argv) | @@ -785,6 +785,7 @@ int main(int argc, char **argv) | ||
785 | int optind; | 785 | int optind; |
786 | short use_gdbstub = 0; | 786 | short use_gdbstub = 0; |
787 | const char *r; | 787 | const char *r; |
788 | + const char *cpu_model; | ||
788 | 789 | ||
789 | if (argc <= 1) | 790 | if (argc <= 1) |
790 | usage(); | 791 | usage(); |
@@ -855,7 +856,15 @@ int main(int argc, char **argv) | @@ -855,7 +856,15 @@ int main(int argc, char **argv) | ||
855 | 856 | ||
856 | /* NOTE: we need to init the CPU at this stage to get | 857 | /* NOTE: we need to init the CPU at this stage to get |
857 | qemu_host_page_size */ | 858 | qemu_host_page_size */ |
858 | - env = cpu_init(); | 859 | +#if defined(TARGET_I386) |
860 | + cpu_model = "qemu32"; | ||
861 | +#elif defined(TARGET_PPC) | ||
862 | + cpu_model = "750"; | ||
863 | +#else | ||
864 | +#error unsupported CPU | ||
865 | +#endif | ||
866 | + | ||
867 | + env = cpu_init(cpu_model); | ||
859 | 868 | ||
860 | printf("Starting %s with qemu\n----------------\n", filename); | 869 | printf("Starting %s with qemu\n----------------\n", filename); |
861 | 870 |
exec.c
@@ -1314,6 +1314,8 @@ void cpu_abort(CPUState *env, const char *fmt, ...) | @@ -1314,6 +1314,8 @@ void cpu_abort(CPUState *env, const char *fmt, ...) | ||
1314 | 1314 | ||
1315 | CPUState *cpu_copy(CPUState *env) | 1315 | CPUState *cpu_copy(CPUState *env) |
1316 | { | 1316 | { |
1317 | +#if 0 | ||
1318 | + /* XXX: broken, must be handled by each CPU */ | ||
1317 | CPUState *new_env = cpu_init(); | 1319 | CPUState *new_env = cpu_init(); |
1318 | /* preserve chaining and index */ | 1320 | /* preserve chaining and index */ |
1319 | CPUState *next_cpu = new_env->next_cpu; | 1321 | CPUState *next_cpu = new_env->next_cpu; |
@@ -1322,6 +1324,9 @@ CPUState *cpu_copy(CPUState *env) | @@ -1322,6 +1324,9 @@ CPUState *cpu_copy(CPUState *env) | ||
1322 | new_env->next_cpu = next_cpu; | 1324 | new_env->next_cpu = next_cpu; |
1323 | new_env->cpu_index = cpu_index; | 1325 | new_env->cpu_index = cpu_index; |
1324 | return new_env; | 1326 | return new_env; |
1327 | +#else | ||
1328 | + return NULL; | ||
1329 | +#endif | ||
1325 | } | 1330 | } |
1326 | 1331 | ||
1327 | #if !defined(CONFIG_USER_ONLY) | 1332 | #if !defined(CONFIG_USER_ONLY) |
hw/an5206.c
@@ -37,10 +37,10 @@ static void an5206_init(int ram_size, int vga_ram_size, const char *boot_device, | @@ -37,10 +37,10 @@ static void an5206_init(int ram_size, int vga_ram_size, const char *boot_device, | ||
37 | uint64_t elf_entry; | 37 | uint64_t elf_entry; |
38 | target_ulong entry; | 38 | target_ulong entry; |
39 | 39 | ||
40 | - env = cpu_init(); | ||
41 | if (!cpu_model) | 40 | if (!cpu_model) |
42 | cpu_model = "m5206"; | 41 | cpu_model = "m5206"; |
43 | - if (cpu_m68k_set_model(env, cpu_model)) { | 42 | + env = cpu_init(cpu_model); |
43 | + if (!env) { | ||
44 | cpu_abort(env, "Unable to find m68k CPU definition\n"); | 44 | cpu_abort(env, "Unable to find m68k CPU definition\n"); |
45 | } | 45 | } |
46 | 46 |
hw/etraxfs.c
@@ -121,7 +121,7 @@ void bareetraxfs_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -121,7 +121,7 @@ void bareetraxfs_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
121 | if (cpu_model == NULL) { | 121 | if (cpu_model == NULL) { |
122 | cpu_model = "crisv32"; | 122 | cpu_model = "crisv32"; |
123 | } | 123 | } |
124 | - env = cpu_init(); | 124 | + env = cpu_init(cpu_model); |
125 | /* register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */ | 125 | /* register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); */ |
126 | qemu_register_reset(main_cpu_reset, env); | 126 | qemu_register_reset(main_cpu_reset, env); |
127 | irqs = qemu_allocate_irqs(dummy_cpu_set_irq, env, 32); | 127 | irqs = qemu_allocate_irqs(dummy_cpu_set_irq, env, 32); |
hw/integratorcp.c
@@ -473,10 +473,13 @@ static void integratorcp_init(int ram_size, int vga_ram_size, | @@ -473,10 +473,13 @@ static void integratorcp_init(int ram_size, int vga_ram_size, | ||
473 | qemu_irq *pic; | 473 | qemu_irq *pic; |
474 | qemu_irq *cpu_pic; | 474 | qemu_irq *cpu_pic; |
475 | 475 | ||
476 | - env = cpu_init(); | ||
477 | if (!cpu_model) | 476 | if (!cpu_model) |
478 | cpu_model = "arm926"; | 477 | cpu_model = "arm926"; |
479 | - cpu_arm_set_model(env, cpu_model); | 478 | + env = cpu_init(cpu_model); |
479 | + if (!env) { | ||
480 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
481 | + exit(1); | ||
482 | + } | ||
480 | bios_offset = ram_size + vga_ram_size; | 483 | bios_offset = ram_size + vga_ram_size; |
481 | /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ | 484 | /* ??? On a real system the first 1Mb is mapped as SSRAM or boot flash. */ |
482 | /* ??? RAM shoud repeat to fill physical memory space. */ | 485 | /* ??? RAM shoud repeat to fill physical memory space. */ |
hw/mcf5208.c
@@ -209,11 +209,12 @@ static void mcf5208evb_init(int ram_size, int vga_ram_size, | @@ -209,11 +209,12 @@ static void mcf5208evb_init(int ram_size, int vga_ram_size, | ||
209 | target_ulong entry; | 209 | target_ulong entry; |
210 | qemu_irq *pic; | 210 | qemu_irq *pic; |
211 | 211 | ||
212 | - env = cpu_init(); | ||
213 | if (!cpu_model) | 212 | if (!cpu_model) |
214 | cpu_model = "m5208"; | 213 | cpu_model = "m5208"; |
215 | - if (cpu_m68k_set_model(env, cpu_model)) { | ||
216 | - cpu_abort(env, "Unable to find m68k CPU definition\n"); | 214 | + env = cpu_init(cpu_model); |
215 | + if (!env) { | ||
216 | + fprintf(stderr, "Unable to find m68k CPU definition\n"); | ||
217 | + exit(1); | ||
217 | } | 218 | } |
218 | 219 | ||
219 | /* Initialize CPU registers. */ | 220 | /* Initialize CPU registers. */ |
hw/mips_malta.c
@@ -735,7 +735,6 @@ static void main_cpu_reset(void *opaque) | @@ -735,7 +735,6 @@ static void main_cpu_reset(void *opaque) | ||
735 | { | 735 | { |
736 | CPUState *env = opaque; | 736 | CPUState *env = opaque; |
737 | cpu_reset(env); | 737 | cpu_reset(env); |
738 | - cpu_mips_register(env, NULL); | ||
739 | 738 | ||
740 | /* The bootload does not need to be rewritten as it is located in a | 739 | /* The bootload does not need to be rewritten as it is located in a |
741 | read only location. The kernel location and the arguments table | 740 | read only location. The kernel location and the arguments table |
@@ -761,7 +760,6 @@ void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -761,7 +760,6 @@ void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
761 | /* fdctrl_t *floppy_controller; */ | 760 | /* fdctrl_t *floppy_controller; */ |
762 | MaltaFPGAState *malta_fpga; | 761 | MaltaFPGAState *malta_fpga; |
763 | int ret; | 762 | int ret; |
764 | - mips_def_t *def; | ||
765 | qemu_irq *i8259; | 763 | qemu_irq *i8259; |
766 | int piix4_devfn; | 764 | int piix4_devfn; |
767 | uint8_t *eeprom_buf; | 765 | uint8_t *eeprom_buf; |
@@ -776,10 +774,11 @@ void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -776,10 +774,11 @@ void mips_malta_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
776 | cpu_model = "24Kf"; | 774 | cpu_model = "24Kf"; |
777 | #endif | 775 | #endif |
778 | } | 776 | } |
779 | - if (mips_find_by_name(cpu_model, &def) != 0) | ||
780 | - def = NULL; | ||
781 | - env = cpu_init(); | ||
782 | - cpu_mips_register(env, def); | 777 | + env = cpu_init(cpu_model); |
778 | + if (!env) { | ||
779 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
780 | + exit(1); | ||
781 | + } | ||
783 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); | 782 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); |
784 | qemu_register_reset(main_cpu_reset, env); | 783 | qemu_register_reset(main_cpu_reset, env); |
785 | 784 |
hw/mips_mipssim.c
@@ -94,7 +94,6 @@ static void main_cpu_reset(void *opaque) | @@ -94,7 +94,6 @@ static void main_cpu_reset(void *opaque) | ||
94 | { | 94 | { |
95 | CPUState *env = opaque; | 95 | CPUState *env = opaque; |
96 | cpu_reset(env); | 96 | cpu_reset(env); |
97 | - cpu_mips_register(env, NULL); | ||
98 | 97 | ||
99 | if (loaderparams.kernel_filename) | 98 | if (loaderparams.kernel_filename) |
100 | load_kernel (env); | 99 | load_kernel (env); |
@@ -120,10 +119,11 @@ mips_mipssim_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -120,10 +119,11 @@ mips_mipssim_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
120 | cpu_model = "24Kf"; | 119 | cpu_model = "24Kf"; |
121 | #endif | 120 | #endif |
122 | } | 121 | } |
123 | - if (mips_find_by_name(cpu_model, &def) != 0) | ||
124 | - def = NULL; | ||
125 | - env = cpu_init(); | ||
126 | - cpu_mips_register(env, def); | 122 | + env = cpu_init(cpu_model); |
123 | + if (!env) { | ||
124 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
125 | + exit(1); | ||
126 | + } | ||
127 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); | 127 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); |
128 | qemu_register_reset(main_cpu_reset, env); | 128 | qemu_register_reset(main_cpu_reset, env); |
129 | 129 |
hw/mips_pica61.c
@@ -51,7 +51,6 @@ static void main_cpu_reset(void *opaque) | @@ -51,7 +51,6 @@ static void main_cpu_reset(void *opaque) | ||
51 | { | 51 | { |
52 | CPUState *env = opaque; | 52 | CPUState *env = opaque; |
53 | cpu_reset(env); | 53 | cpu_reset(env); |
54 | - cpu_mips_register(env, NULL); | ||
55 | } | 54 | } |
56 | 55 | ||
57 | static | 56 | static |
@@ -78,10 +77,11 @@ void mips_pica61_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -78,10 +77,11 @@ void mips_pica61_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
78 | cpu_model = "24Kf"; | 77 | cpu_model = "24Kf"; |
79 | #endif | 78 | #endif |
80 | } | 79 | } |
81 | - if (mips_find_by_name(cpu_model, &def) != 0) | ||
82 | - def = NULL; | ||
83 | - env = cpu_init(); | ||
84 | - cpu_mips_register(env, def); | 80 | + env = cpu_init(cpu_model); |
81 | + if (!env) { | ||
82 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
83 | + exit(1); | ||
84 | + } | ||
85 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); | 85 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); |
86 | qemu_register_reset(main_cpu_reset, env); | 86 | qemu_register_reset(main_cpu_reset, env); |
87 | 87 |
hw/mips_r4k.c
@@ -135,7 +135,6 @@ static void main_cpu_reset(void *opaque) | @@ -135,7 +135,6 @@ static void main_cpu_reset(void *opaque) | ||
135 | { | 135 | { |
136 | CPUState *env = opaque; | 136 | CPUState *env = opaque; |
137 | cpu_reset(env); | 137 | cpu_reset(env); |
138 | - cpu_mips_register(env, NULL); | ||
139 | 138 | ||
140 | if (loaderparams.kernel_filename) | 139 | if (loaderparams.kernel_filename) |
141 | load_kernel (env); | 140 | load_kernel (env); |
@@ -164,10 +163,11 @@ void mips_r4k_init (int ram_size, int vga_ram_size, const char *boot_device, | @@ -164,10 +163,11 @@ void mips_r4k_init (int ram_size, int vga_ram_size, const char *boot_device, | ||
164 | cpu_model = "24Kf"; | 163 | cpu_model = "24Kf"; |
165 | #endif | 164 | #endif |
166 | } | 165 | } |
167 | - if (mips_find_by_name(cpu_model, &def) != 0) | ||
168 | - def = NULL; | ||
169 | - env = cpu_init(); | ||
170 | - cpu_mips_register(env, def); | 166 | + env = cpu_init(cpu_model); |
167 | + if (!env) { | ||
168 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
169 | + exit(1); | ||
170 | + } | ||
171 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); | 171 | register_savevm("cpu", 0, 3, cpu_save, cpu_load, env); |
172 | qemu_register_reset(main_cpu_reset, env); | 172 | qemu_register_reset(main_cpu_reset, env); |
173 | 173 |
hw/omap.c
@@ -4620,15 +4620,20 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, | @@ -4620,15 +4620,20 @@ struct omap_mpu_state_s *omap310_mpu_init(unsigned long sdram_size, | ||
4620 | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) | 4620 | struct omap_mpu_state_s *s = (struct omap_mpu_state_s *) |
4621 | qemu_mallocz(sizeof(struct omap_mpu_state_s)); | 4621 | qemu_mallocz(sizeof(struct omap_mpu_state_s)); |
4622 | ram_addr_t imif_base, emiff_base; | 4622 | ram_addr_t imif_base, emiff_base; |
4623 | + | ||
4624 | + if (!core) | ||
4625 | + core = "ti925t"; | ||
4623 | 4626 | ||
4624 | /* Core */ | 4627 | /* Core */ |
4625 | s->mpu_model = omap310; | 4628 | s->mpu_model = omap310; |
4626 | - s->env = cpu_init(); | 4629 | + s->env = cpu_init(core); |
4630 | + if (!s->env) { | ||
4631 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
4632 | + exit(1); | ||
4633 | + } | ||
4627 | s->sdram_size = sdram_size; | 4634 | s->sdram_size = sdram_size; |
4628 | s->sram_size = OMAP15XX_SRAM_SIZE; | 4635 | s->sram_size = OMAP15XX_SRAM_SIZE; |
4629 | 4636 | ||
4630 | - cpu_arm_set_model(s->env, core ?: "ti925t"); | ||
4631 | - | ||
4632 | s->wakeup = qemu_allocate_irqs(omap_mpu_wakeup, s, 1)[0]; | 4637 | s->wakeup = qemu_allocate_irqs(omap_mpu_wakeup, s, 1)[0]; |
4633 | 4638 | ||
4634 | /* Clocks */ | 4639 | /* Clocks */ |
hw/pc.c
@@ -700,12 +700,12 @@ static void pc_init1(int ram_size, int vga_ram_size, const char *boot_device, | @@ -700,12 +700,12 @@ static void pc_init1(int ram_size, int vga_ram_size, const char *boot_device, | ||
700 | #endif | 700 | #endif |
701 | } | 701 | } |
702 | 702 | ||
703 | - if (x86_find_cpu_by_name(cpu_model)) { | ||
704 | - fprintf(stderr, "Unable to find x86 CPU definition\n"); | ||
705 | - exit(1); | ||
706 | - } | ||
707 | for(i = 0; i < smp_cpus; i++) { | 703 | for(i = 0; i < smp_cpus; i++) { |
708 | - env = cpu_init(); | 704 | + env = cpu_init(cpu_model); |
705 | + if (!env) { | ||
706 | + fprintf(stderr, "Unable to find x86 CPU definition\n"); | ||
707 | + exit(1); | ||
708 | + } | ||
709 | if (i != 0) | 709 | if (i != 0) |
710 | env->hflags |= HF_HALTED_MASK; | 710 | env->hflags |= HF_HALTED_MASK; |
711 | if (smp_cpus > 1) { | 711 | if (smp_cpus > 1) { |
hw/ppc4xx_devs.c
@@ -37,17 +37,14 @@ CPUState *ppc4xx_init (const unsigned char *cpu_model, | @@ -37,17 +37,14 @@ CPUState *ppc4xx_init (const unsigned char *cpu_model, | ||
37 | uint32_t sysclk) | 37 | uint32_t sysclk) |
38 | { | 38 | { |
39 | CPUState *env; | 39 | CPUState *env; |
40 | - ppc_def_t *def; | ||
41 | 40 | ||
42 | /* init CPUs */ | 41 | /* init CPUs */ |
43 | - env = cpu_init(); | ||
44 | - ppc_find_by_name(cpu_model, &def); | ||
45 | - if (def == NULL) { | ||
46 | - cpu_abort(env, "Unable to find PowerPC %s CPU definition\n", | ||
47 | - cpu_model); | 42 | + env = cpu_init(cpu_model); |
43 | + if (!env) { | ||
44 | + fprintf(stderr, "Unable to find PowerPC %s CPU definition\n", | ||
45 | + cpu_model); | ||
46 | + exit(1); | ||
48 | } | 47 | } |
49 | - cpu_ppc_register(env, def); | ||
50 | - cpu_ppc_reset(env); | ||
51 | cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */ | 48 | cpu_clk->cb = NULL; /* We don't care about CPU clock frequency changes */ |
52 | cpu_clk->opaque = env; | 49 | cpu_clk->opaque = env; |
53 | /* Set time-base frequency to sysclk */ | 50 | /* Set time-base frequency to sysclk */ |
hw/ppc_chrp.c
@@ -56,14 +56,13 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, | @@ -56,14 +56,13 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, | ||
56 | const char *initrd_filename, | 56 | const char *initrd_filename, |
57 | const char *cpu_model) | 57 | const char *cpu_model) |
58 | { | 58 | { |
59 | - CPUState *env, *envs[MAX_CPUS]; | 59 | + CPUState *env = NULL, *envs[MAX_CPUS]; |
60 | char buf[1024]; | 60 | char buf[1024]; |
61 | qemu_irq *pic, **openpic_irqs; | 61 | qemu_irq *pic, **openpic_irqs; |
62 | int unin_memory; | 62 | int unin_memory; |
63 | int linux_boot, i; | 63 | int linux_boot, i; |
64 | unsigned long bios_offset, vga_bios_offset; | 64 | unsigned long bios_offset, vga_bios_offset; |
65 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; | 65 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
66 | - ppc_def_t *def; | ||
67 | PCIBus *pci_bus; | 66 | PCIBus *pci_bus; |
68 | nvram_t nvram; | 67 | nvram_t nvram; |
69 | #if 0 | 68 | #if 0 |
@@ -80,16 +79,14 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, | @@ -80,16 +79,14 @@ static void ppc_core99_init (int ram_size, int vga_ram_size, | ||
80 | linux_boot = (kernel_filename != NULL); | 79 | linux_boot = (kernel_filename != NULL); |
81 | 80 | ||
82 | /* init CPUs */ | 81 | /* init CPUs */ |
83 | - env = cpu_init(); | ||
84 | if (cpu_model == NULL) | 82 | if (cpu_model == NULL) |
85 | cpu_model = "default"; | 83 | cpu_model = "default"; |
86 | - ppc_find_by_name(cpu_model, &def); | ||
87 | - if (def == NULL) { | ||
88 | - cpu_abort(env, "Unable to find PowerPC CPU definition\n"); | ||
89 | - } | ||
90 | for (i = 0; i < smp_cpus; i++) { | 84 | for (i = 0; i < smp_cpus; i++) { |
91 | - cpu_ppc_register(env, def); | ||
92 | - cpu_ppc_reset(env); | 85 | + env = cpu_init(cpu_model); |
86 | + if (!env) { | ||
87 | + fprintf(stderr, "Unable to find PowerPC CPU definition\n"); | ||
88 | + exit(1); | ||
89 | + } | ||
93 | /* Set time-base frequency to 100 Mhz */ | 90 | /* Set time-base frequency to 100 Mhz */ |
94 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); | 91 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
95 | #if 0 | 92 | #if 0 |
hw/ppc_oldworld.c
@@ -100,7 +100,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | @@ -100,7 +100,7 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | ||
100 | const char *initrd_filename, | 100 | const char *initrd_filename, |
101 | const char *cpu_model) | 101 | const char *cpu_model) |
102 | { | 102 | { |
103 | - CPUState *env, *envs[MAX_CPUS]; | 103 | + CPUState *env = NULL, *envs[MAX_CPUS]; |
104 | char buf[1024]; | 104 | char buf[1024]; |
105 | qemu_irq *pic, **heathrow_irqs; | 105 | qemu_irq *pic, **heathrow_irqs; |
106 | nvram_t nvram; | 106 | nvram_t nvram; |
@@ -108,7 +108,6 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | @@ -108,7 +108,6 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | ||
108 | int linux_boot, i; | 108 | int linux_boot, i; |
109 | unsigned long bios_offset, vga_bios_offset; | 109 | unsigned long bios_offset, vga_bios_offset; |
110 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; | 110 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
111 | - ppc_def_t *def; | ||
112 | PCIBus *pci_bus; | 111 | PCIBus *pci_bus; |
113 | MacIONVRAMState *nvr; | 112 | MacIONVRAMState *nvr; |
114 | int vga_bios_size, bios_size; | 113 | int vga_bios_size, bios_size; |
@@ -119,16 +118,14 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | @@ -119,16 +118,14 @@ static void ppc_heathrow_init (int ram_size, int vga_ram_size, | ||
119 | linux_boot = (kernel_filename != NULL); | 118 | linux_boot = (kernel_filename != NULL); |
120 | 119 | ||
121 | /* init CPUs */ | 120 | /* init CPUs */ |
122 | - env = cpu_init(); | ||
123 | if (cpu_model == NULL) | 121 | if (cpu_model == NULL) |
124 | cpu_model = "default"; | 122 | cpu_model = "default"; |
125 | - ppc_find_by_name(cpu_model, &def); | ||
126 | - if (def == NULL) { | ||
127 | - cpu_abort(env, "Unable to find PowerPC CPU definition\n"); | ||
128 | - } | ||
129 | for (i = 0; i < smp_cpus; i++) { | 123 | for (i = 0; i < smp_cpus; i++) { |
130 | - cpu_ppc_register(env, def); | ||
131 | - cpu_ppc_reset(env); | 124 | + env = cpu_init(cpu_model); |
125 | + if (!env) { | ||
126 | + fprintf(stderr, "Unable to find PowerPC CPU definition\n"); | ||
127 | + exit(1); | ||
128 | + } | ||
132 | /* Set time-base frequency to 100 Mhz */ | 129 | /* Set time-base frequency to 100 Mhz */ |
133 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); | 130 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
134 | env->osi_call = vga_osi_call; | 131 | env->osi_call = vga_osi_call; |
hw/ppc_prep.c
@@ -536,7 +536,6 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi | @@ -536,7 +536,6 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi | ||
536 | int linux_boot, i, nb_nics1, bios_size; | 536 | int linux_boot, i, nb_nics1, bios_size; |
537 | unsigned long bios_offset; | 537 | unsigned long bios_offset; |
538 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; | 538 | uint32_t kernel_base, kernel_size, initrd_base, initrd_size; |
539 | - ppc_def_t *def; | ||
540 | PCIBus *pci_bus; | 539 | PCIBus *pci_bus; |
541 | qemu_irq *i8259; | 540 | qemu_irq *i8259; |
542 | int ppc_boot_device = boot_device[0]; | 541 | int ppc_boot_device = boot_device[0]; |
@@ -548,16 +547,14 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi | @@ -548,16 +547,14 @@ static void ppc_prep_init (int ram_size, int vga_ram_size, const char *boot_devi | ||
548 | linux_boot = (kernel_filename != NULL); | 547 | linux_boot = (kernel_filename != NULL); |
549 | 548 | ||
550 | /* init CPUs */ | 549 | /* init CPUs */ |
551 | - env = cpu_init(); | ||
552 | if (cpu_model == NULL) | 550 | if (cpu_model == NULL) |
553 | cpu_model = "default"; | 551 | cpu_model = "default"; |
554 | - ppc_find_by_name(cpu_model, &def); | ||
555 | - if (def == NULL) { | ||
556 | - cpu_abort(env, "Unable to find PowerPC CPU definition\n"); | ||
557 | - } | ||
558 | for (i = 0; i < smp_cpus; i++) { | 552 | for (i = 0; i < smp_cpus; i++) { |
559 | - cpu_ppc_register(env, def); | ||
560 | - cpu_ppc_reset(env); | 553 | + env = cpu_init(cpu_model); |
554 | + if (!env) { | ||
555 | + fprintf(stderr, "Unable to find PowerPC CPU definition\n"); | ||
556 | + exit(1); | ||
557 | + } | ||
561 | /* Set time-base frequency to 100 Mhz */ | 558 | /* Set time-base frequency to 100 Mhz */ |
562 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); | 559 | cpu_ppc_tb_init(env, 100UL * 1000UL * 1000UL); |
563 | qemu_register_reset(&cpu_ppc_reset, env); | 560 | qemu_register_reset(&cpu_ppc_reset, env); |
hw/pxa2xx.c
@@ -2023,9 +2023,14 @@ struct pxa2xx_state_s *pxa270_init(unsigned int sdram_size, | @@ -2023,9 +2023,14 @@ struct pxa2xx_state_s *pxa270_init(unsigned int sdram_size, | ||
2023 | fprintf(stderr, "Machine requires a PXA27x processor.\n"); | 2023 | fprintf(stderr, "Machine requires a PXA27x processor.\n"); |
2024 | exit(1); | 2024 | exit(1); |
2025 | } | 2025 | } |
2026 | - | ||
2027 | - s->env = cpu_init(); | ||
2028 | - cpu_arm_set_model(s->env, revision ?: "pxa270"); | 2026 | + if (!revision) |
2027 | + revision = "pxa270"; | ||
2028 | + | ||
2029 | + s->env = cpu_init(revision); | ||
2030 | + if (!s->env) { | ||
2031 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
2032 | + exit(1); | ||
2033 | + } | ||
2029 | register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); | 2034 | register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); |
2030 | 2035 | ||
2031 | /* SDRAM & Internal Memory Storage */ | 2036 | /* SDRAM & Internal Memory Storage */ |
@@ -2132,10 +2137,14 @@ struct pxa2xx_state_s *pxa255_init(unsigned int sdram_size, | @@ -2132,10 +2137,14 @@ struct pxa2xx_state_s *pxa255_init(unsigned int sdram_size, | ||
2132 | struct pxa2xx_state_s *s; | 2137 | struct pxa2xx_state_s *s; |
2133 | struct pxa2xx_ssp_s *ssp; | 2138 | struct pxa2xx_ssp_s *ssp; |
2134 | int iomemtype, i; | 2139 | int iomemtype, i; |
2140 | + | ||
2135 | s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s)); | 2141 | s = (struct pxa2xx_state_s *) qemu_mallocz(sizeof(struct pxa2xx_state_s)); |
2136 | 2142 | ||
2137 | - s->env = cpu_init(); | ||
2138 | - cpu_arm_set_model(s->env, "pxa255"); | 2143 | + s->env = cpu_init("pxa255"); |
2144 | + if (!s->env) { | ||
2145 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
2146 | + exit(1); | ||
2147 | + } | ||
2139 | register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); | 2148 | register_savevm("cpu", 0, 0, cpu_save, cpu_load, s->env); |
2140 | 2149 | ||
2141 | /* SDRAM & Internal Memory Storage */ | 2150 | /* SDRAM & Internal Memory Storage */ |
hw/r2d.c
@@ -35,7 +35,14 @@ static void r2d_init(int ram_size, int vga_ram_size, const char *boot_device, | @@ -35,7 +35,14 @@ static void r2d_init(int ram_size, int vga_ram_size, const char *boot_device, | ||
35 | CPUState *env; | 35 | CPUState *env; |
36 | struct SH7750State *s; | 36 | struct SH7750State *s; |
37 | 37 | ||
38 | - env = cpu_init(); | 38 | + if (!cpu_model) |
39 | + cpu_model = "any"; | ||
40 | + | ||
41 | + env = cpu_init(cpu_model); | ||
42 | + if (!env) { | ||
43 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
44 | + exit(1); | ||
45 | + } | ||
39 | 46 | ||
40 | /* Allocate memory space */ | 47 | /* Allocate memory space */ |
41 | cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, 0); | 48 | cpu_register_physical_memory(SDRAM_BASE, SDRAM_SIZE, 0); |
hw/realview.c
@@ -26,10 +26,14 @@ static void realview_init(int ram_size, int vga_ram_size, | @@ -26,10 +26,14 @@ static void realview_init(int ram_size, int vga_ram_size, | ||
26 | int n; | 26 | int n; |
27 | int done_smc = 0; | 27 | int done_smc = 0; |
28 | 28 | ||
29 | - env = cpu_init(); | ||
30 | if (!cpu_model) | 29 | if (!cpu_model) |
31 | cpu_model = "arm926"; | 30 | cpu_model = "arm926"; |
32 | - cpu_arm_set_model(env, cpu_model); | 31 | + env = cpu_init(cpu_model); |
32 | + if (!env) { | ||
33 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
34 | + exit(1); | ||
35 | + } | ||
36 | + | ||
33 | /* ??? RAM shoud repeat to fill physical memory space. */ | 37 | /* ??? RAM shoud repeat to fill physical memory space. */ |
34 | /* SDRAM at address zero. */ | 38 | /* SDRAM at address zero. */ |
35 | cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); | 39 | cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); |
hw/shix.c
@@ -70,9 +70,12 @@ static void shix_init(int ram_size, int vga_ram_size, const char *boot_device, | @@ -70,9 +70,12 @@ static void shix_init(int ram_size, int vga_ram_size, const char *boot_device, | ||
70 | int ret; | 70 | int ret; |
71 | CPUState *env; | 71 | CPUState *env; |
72 | struct SH7750State *s; | 72 | struct SH7750State *s; |
73 | + | ||
74 | + if (!cpu_model) | ||
75 | + cpu_model = "any"; | ||
73 | 76 | ||
74 | printf("Initializing CPU\n"); | 77 | printf("Initializing CPU\n"); |
75 | - env = cpu_init(); | 78 | + env = cpu_init(cpu_model); |
76 | 79 | ||
77 | /* Allocate memory space */ | 80 | /* Allocate memory space */ |
78 | printf("Allocating ROM\n"); | 81 | printf("Allocating ROM\n"); |
hw/sun4m.c
@@ -313,21 +313,19 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size, | @@ -313,21 +313,19 @@ static void *sun4m_hw_init(const struct hwdef *hwdef, int RAM_size, | ||
313 | CPUState *env, *envs[MAX_CPUS]; | 313 | CPUState *env, *envs[MAX_CPUS]; |
314 | unsigned int i; | 314 | unsigned int i; |
315 | void *iommu, *espdma, *ledma, *main_esp, *nvram; | 315 | void *iommu, *espdma, *ledma, *main_esp, *nvram; |
316 | - const sparc_def_t *def; | ||
317 | qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq, | 316 | qemu_irq *cpu_irqs[MAX_CPUS], *slavio_irq, *slavio_cpu_irq, |
318 | *espdma_irq, *ledma_irq; | 317 | *espdma_irq, *ledma_irq; |
319 | qemu_irq *esp_reset, *le_reset; | 318 | qemu_irq *esp_reset, *le_reset; |
320 | 319 | ||
321 | /* init CPUs */ | 320 | /* init CPUs */ |
322 | - sparc_find_by_name(cpu_model, &def); | ||
323 | - if (def == NULL) { | ||
324 | - fprintf(stderr, "Unable to find Sparc CPU definition\n"); | ||
325 | - exit(1); | ||
326 | - } | ||
327 | 321 | ||
328 | for(i = 0; i < smp_cpus; i++) { | 322 | for(i = 0; i < smp_cpus; i++) { |
329 | - env = cpu_init(); | ||
330 | - cpu_sparc_register(env, def, i); | 323 | + env = cpu_init(cpu_model); |
324 | + if (!env) { | ||
325 | + fprintf(stderr, "Unable to find Sparc CPU definition\n"); | ||
326 | + exit(1); | ||
327 | + } | ||
328 | + cpu_sparc_set_id(env, i); | ||
331 | envs[i] = env; | 329 | envs[i] = env; |
332 | if (i == 0) { | 330 | if (i == 0) { |
333 | qemu_register_reset(main_cpu_reset, env); | 331 | qemu_register_reset(main_cpu_reset, env); |
hw/sun4u.c
@@ -343,7 +343,6 @@ static void sun4u_init(int ram_size, int vga_ram_size, const char *boot_device, | @@ -343,7 +343,6 @@ static void sun4u_init(int ram_size, int vga_ram_size, const char *boot_device, | ||
343 | unsigned int i; | 343 | unsigned int i; |
344 | long prom_offset, initrd_size, kernel_size; | 344 | long prom_offset, initrd_size, kernel_size; |
345 | PCIBus *pci_bus; | 345 | PCIBus *pci_bus; |
346 | - const sparc_def_t *def; | ||
347 | QEMUBH *bh; | 346 | QEMUBH *bh; |
348 | qemu_irq *irq; | 347 | qemu_irq *irq; |
349 | 348 | ||
@@ -352,13 +351,11 @@ static void sun4u_init(int ram_size, int vga_ram_size, const char *boot_device, | @@ -352,13 +351,11 @@ static void sun4u_init(int ram_size, int vga_ram_size, const char *boot_device, | ||
352 | /* init CPUs */ | 351 | /* init CPUs */ |
353 | if (cpu_model == NULL) | 352 | if (cpu_model == NULL) |
354 | cpu_model = "TI UltraSparc II"; | 353 | cpu_model = "TI UltraSparc II"; |
355 | - sparc_find_by_name(cpu_model, &def); | ||
356 | - if (def == NULL) { | 354 | + env = cpu_init(cpu_model); |
355 | + if (!env) { | ||
357 | fprintf(stderr, "Unable to find Sparc CPU definition\n"); | 356 | fprintf(stderr, "Unable to find Sparc CPU definition\n"); |
358 | exit(1); | 357 | exit(1); |
359 | } | 358 | } |
360 | - env = cpu_init(); | ||
361 | - cpu_sparc_register(env, def, 0); | ||
362 | bh = qemu_bh_new(tick_irq, env); | 359 | bh = qemu_bh_new(tick_irq, env); |
363 | env->tick = ptimer_init(bh); | 360 | env->tick = ptimer_init(bh); |
364 | ptimer_set_period(env->tick, 1ULL); | 361 | ptimer_set_period(env->tick, 1ULL); |
hw/versatilepb.c
@@ -167,10 +167,13 @@ static void versatile_init(int ram_size, int vga_ram_size, | @@ -167,10 +167,13 @@ static void versatile_init(int ram_size, int vga_ram_size, | ||
167 | int n; | 167 | int n; |
168 | int done_smc = 0; | 168 | int done_smc = 0; |
169 | 169 | ||
170 | - env = cpu_init(); | ||
171 | if (!cpu_model) | 170 | if (!cpu_model) |
172 | cpu_model = "arm926"; | 171 | cpu_model = "arm926"; |
173 | - cpu_arm_set_model(env, cpu_model); | 172 | + env = cpu_init(cpu_model); |
173 | + if (!env) { | ||
174 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
175 | + exit(1); | ||
176 | + } | ||
174 | /* ??? RAM shoud repeat to fill physical memory space. */ | 177 | /* ??? RAM shoud repeat to fill physical memory space. */ |
175 | /* SDRAM at address zero. */ | 178 | /* SDRAM at address zero. */ |
176 | cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); | 179 | cpu_register_physical_memory(0, ram_size, IO_MEM_RAM); |
linux-user/main.c
@@ -1970,26 +1970,42 @@ int main(int argc, char **argv) | @@ -1970,26 +1970,42 @@ int main(int argc, char **argv) | ||
1970 | /* Scan interp_prefix dir for replacement files. */ | 1970 | /* Scan interp_prefix dir for replacement files. */ |
1971 | init_paths(interp_prefix); | 1971 | init_paths(interp_prefix); |
1972 | 1972 | ||
1973 | -#if defined(TARGET_I386) | ||
1974 | - /* must be done before cpu_init() for x86 XXX: suppress this hack | ||
1975 | - by adding a new parameter to cpu_init and by suppressing | ||
1976 | - cpu_xxx_register() */ | ||
1977 | if (cpu_model == NULL) { | 1973 | if (cpu_model == NULL) { |
1974 | +#if defined(TARGET_I386) | ||
1978 | #ifdef TARGET_X86_64 | 1975 | #ifdef TARGET_X86_64 |
1979 | cpu_model = "qemu64"; | 1976 | cpu_model = "qemu64"; |
1980 | #else | 1977 | #else |
1981 | cpu_model = "qemu32"; | 1978 | cpu_model = "qemu32"; |
1982 | #endif | 1979 | #endif |
1983 | - } | ||
1984 | - if (x86_find_cpu_by_name(cpu_model)) { | ||
1985 | - fprintf(stderr, "Unable to find x86 CPU definition\n"); | ||
1986 | - exit(1); | ||
1987 | - } | 1980 | +#elif defined(TARGET_ARM) |
1981 | + cpu_model = "arm926"; | ||
1982 | +#elif defined(TARGET_M68K) | ||
1983 | + cpu_model = "any"; | ||
1984 | +#elif defined(TARGET_SPARC) | ||
1985 | +#ifdef TARGET_SPARC64 | ||
1986 | + cpu_model = "TI UltraSparc II"; | ||
1987 | +#else | ||
1988 | + cpu_model = "Fujitsu MB86904"; | ||
1988 | #endif | 1989 | #endif |
1989 | - | 1990 | +#elif defined(TARGET_MIPS) |
1991 | +#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) | ||
1992 | + cpu_model = "20Kc"; | ||
1993 | +#else | ||
1994 | + cpu_model = "24Kf"; | ||
1995 | +#endif | ||
1996 | +#elif defined(TARGET_PPC) | ||
1997 | + cpu_model = "750"; | ||
1998 | +#else | ||
1999 | + cpu_model = "any"; | ||
2000 | +#endif | ||
2001 | + } | ||
1990 | /* NOTE: we need to init the CPU at this stage to get | 2002 | /* NOTE: we need to init the CPU at this stage to get |
1991 | qemu_host_page_size */ | 2003 | qemu_host_page_size */ |
1992 | - env = cpu_init(); | 2004 | + env = cpu_init(cpu_model); |
2005 | + if (!env) { | ||
2006 | + fprintf(stderr, "Unable to find CPU definition\n"); | ||
2007 | + exit(1); | ||
2008 | + } | ||
1993 | global_env = env; | 2009 | global_env = env; |
1994 | 2010 | ||
1995 | if(getenv("QEMU_STRACE") ){ | 2011 | if(getenv("QEMU_STRACE") ){ |
@@ -2130,9 +2146,6 @@ int main(int argc, char **argv) | @@ -2130,9 +2146,6 @@ int main(int argc, char **argv) | ||
2130 | #elif defined(TARGET_ARM) | 2146 | #elif defined(TARGET_ARM) |
2131 | { | 2147 | { |
2132 | int i; | 2148 | int i; |
2133 | - if (cpu_model == NULL) | ||
2134 | - cpu_model = "arm926"; | ||
2135 | - cpu_arm_set_model(env, cpu_model); | ||
2136 | cpsr_write(env, regs->uregs[16], 0xffffffff); | 2149 | cpsr_write(env, regs->uregs[16], 0xffffffff); |
2137 | for(i = 0; i < 16; i++) { | 2150 | for(i = 0; i < 16; i++) { |
2138 | env->regs[i] = regs->uregs[i]; | 2151 | env->regs[i] = regs->uregs[i]; |
@@ -2141,20 +2154,6 @@ int main(int argc, char **argv) | @@ -2141,20 +2154,6 @@ int main(int argc, char **argv) | ||
2141 | #elif defined(TARGET_SPARC) | 2154 | #elif defined(TARGET_SPARC) |
2142 | { | 2155 | { |
2143 | int i; | 2156 | int i; |
2144 | - const sparc_def_t *def; | ||
2145 | -#ifdef TARGET_SPARC64 | ||
2146 | - if (cpu_model == NULL) | ||
2147 | - cpu_model = "TI UltraSparc II"; | ||
2148 | -#else | ||
2149 | - if (cpu_model == NULL) | ||
2150 | - cpu_model = "Fujitsu MB86904"; | ||
2151 | -#endif | ||
2152 | - sparc_find_by_name(cpu_model, &def); | ||
2153 | - if (def == NULL) { | ||
2154 | - fprintf(stderr, "Unable to find Sparc CPU definition\n"); | ||
2155 | - exit(1); | ||
2156 | - } | ||
2157 | - cpu_sparc_register(env, def, 0); | ||
2158 | env->pc = regs->pc; | 2157 | env->pc = regs->pc; |
2159 | env->npc = regs->npc; | 2158 | env->npc = regs->npc; |
2160 | env->y = regs->y; | 2159 | env->y = regs->y; |
@@ -2165,19 +2164,8 @@ int main(int argc, char **argv) | @@ -2165,19 +2164,8 @@ int main(int argc, char **argv) | ||
2165 | } | 2164 | } |
2166 | #elif defined(TARGET_PPC) | 2165 | #elif defined(TARGET_PPC) |
2167 | { | 2166 | { |
2168 | - ppc_def_t *def; | ||
2169 | int i; | 2167 | int i; |
2170 | 2168 | ||
2171 | - /* Choose and initialise CPU */ | ||
2172 | - if (cpu_model == NULL) | ||
2173 | - cpu_model = "750"; | ||
2174 | - ppc_find_by_name(cpu_model, &def); | ||
2175 | - if (def == NULL) { | ||
2176 | - cpu_abort(env, | ||
2177 | - "Unable to find PowerPC CPU definition\n"); | ||
2178 | - } | ||
2179 | - cpu_ppc_register(env, def); | ||
2180 | - cpu_ppc_reset(env); | ||
2181 | #if defined(TARGET_PPC64) | 2169 | #if defined(TARGET_PPC64) |
2182 | #if defined(TARGET_ABI32) | 2170 | #if defined(TARGET_ABI32) |
2183 | env->msr &= ~((target_ulong)1 << MSR_SF); | 2171 | env->msr &= ~((target_ulong)1 << MSR_SF); |
@@ -2192,12 +2180,6 @@ int main(int argc, char **argv) | @@ -2192,12 +2180,6 @@ int main(int argc, char **argv) | ||
2192 | } | 2180 | } |
2193 | #elif defined(TARGET_M68K) | 2181 | #elif defined(TARGET_M68K) |
2194 | { | 2182 | { |
2195 | - if (cpu_model == NULL) | ||
2196 | - cpu_model = "any"; | ||
2197 | - if (cpu_m68k_set_model(env, cpu_model)) { | ||
2198 | - cpu_abort(cpu_single_env, | ||
2199 | - "Unable to find m68k CPU definition\n"); | ||
2200 | - } | ||
2201 | env->pc = regs->pc; | 2183 | env->pc = regs->pc; |
2202 | env->dregs[0] = regs->d0; | 2184 | env->dregs[0] = regs->d0; |
2203 | env->dregs[1] = regs->d1; | 2185 | env->dregs[1] = regs->d1; |
@@ -2220,21 +2202,8 @@ int main(int argc, char **argv) | @@ -2220,21 +2202,8 @@ int main(int argc, char **argv) | ||
2220 | } | 2202 | } |
2221 | #elif defined(TARGET_MIPS) | 2203 | #elif defined(TARGET_MIPS) |
2222 | { | 2204 | { |
2223 | - mips_def_t *def; | ||
2224 | int i; | 2205 | int i; |
2225 | 2206 | ||
2226 | - /* Choose and initialise CPU */ | ||
2227 | - if (cpu_model == NULL) | ||
2228 | -#if defined(TARGET_ABI_MIPSN32) || defined(TARGET_ABI_MIPSN64) | ||
2229 | - cpu_model = "20Kc"; | ||
2230 | -#else | ||
2231 | - cpu_model = "24Kf"; | ||
2232 | -#endif | ||
2233 | - mips_find_by_name(cpu_model, &def); | ||
2234 | - if (def == NULL) | ||
2235 | - cpu_abort(env, "Unable to find MIPS CPU definition\n"); | ||
2236 | - cpu_mips_register(env, def); | ||
2237 | - | ||
2238 | for(i = 0; i < 32; i++) { | 2207 | for(i = 0; i < 32; i++) { |
2239 | env->gpr[i][env->current_tc] = regs->regs[i]; | 2208 | env->gpr[i][env->current_tc] = regs->regs[i]; |
2240 | } | 2209 | } |
target-alpha/cpu.h
@@ -396,7 +396,7 @@ enum { | @@ -396,7 +396,7 @@ enum { | ||
396 | IR_ZERO = 31, | 396 | IR_ZERO = 31, |
397 | }; | 397 | }; |
398 | 398 | ||
399 | -CPUAlphaState * cpu_alpha_init (void); | 399 | +CPUAlphaState * cpu_alpha_init (const char *cpu_model); |
400 | int cpu_alpha_exec(CPUAlphaState *s); | 400 | int cpu_alpha_exec(CPUAlphaState *s); |
401 | /* you can call this signal handler from your SIGBUS and SIGSEGV | 401 | /* you can call this signal handler from your SIGBUS and SIGSEGV |
402 | signal handlers to inform the virtual CPU of exceptions. non zero | 402 | signal handlers to inform the virtual CPU of exceptions. non zero |
target-alpha/translate.c
@@ -2095,7 +2095,7 @@ int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) | @@ -2095,7 +2095,7 @@ int gen_intermediate_code_pc (CPUState *env, struct TranslationBlock *tb) | ||
2095 | return gen_intermediate_code_internal(env, tb, 1); | 2095 | return gen_intermediate_code_internal(env, tb, 1); |
2096 | } | 2096 | } |
2097 | 2097 | ||
2098 | -CPUAlphaState * cpu_alpha_init (void) | 2098 | +CPUAlphaState * cpu_alpha_init (const char *cpu_model) |
2099 | { | 2099 | { |
2100 | CPUAlphaState *env; | 2100 | CPUAlphaState *env; |
2101 | uint64_t hwpcb; | 2101 | uint64_t hwpcb; |
@@ -2133,3 +2133,4 @@ CPUAlphaState * cpu_alpha_init (void) | @@ -2133,3 +2133,4 @@ CPUAlphaState * cpu_alpha_init (void) | ||
2133 | 2133 | ||
2134 | return env; | 2134 | return env; |
2135 | } | 2135 | } |
2136 | + |
target-arm/cpu.h
@@ -164,7 +164,7 @@ typedef struct CPUARMState { | @@ -164,7 +164,7 @@ typedef struct CPUARMState { | ||
164 | target_phys_addr_t loader_start; | 164 | target_phys_addr_t loader_start; |
165 | } CPUARMState; | 165 | } CPUARMState; |
166 | 166 | ||
167 | -CPUARMState *cpu_arm_init(void); | 167 | +CPUARMState *cpu_arm_init(const char *cpu_model); |
168 | int cpu_arm_exec(CPUARMState *s); | 168 | int cpu_arm_exec(CPUARMState *s); |
169 | void cpu_arm_close(CPUARMState *s); | 169 | void cpu_arm_close(CPUARMState *s); |
170 | void do_interrupt(CPUARMState *); | 170 | void do_interrupt(CPUARMState *); |
@@ -263,7 +263,6 @@ static inline int arm_feature(CPUARMState *env, int feature) | @@ -263,7 +263,6 @@ static inline int arm_feature(CPUARMState *env, int feature) | ||
263 | } | 263 | } |
264 | 264 | ||
265 | void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); | 265 | void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); |
266 | -void cpu_arm_set_model(CPUARMState *env, const char *name); | ||
267 | 266 | ||
268 | void cpu_arm_set_cp_io(CPUARMState *env, int cpnum, | 267 | void cpu_arm_set_cp_io(CPUARMState *env, int cpnum, |
269 | ARMReadCPFunc *cp_read, ARMWriteCPFunc *cp_write, | 268 | ARMReadCPFunc *cp_read, ARMWriteCPFunc *cp_write, |
target-arm/helper.c
@@ -5,6 +5,8 @@ | @@ -5,6 +5,8 @@ | ||
5 | #include "cpu.h" | 5 | #include "cpu.h" |
6 | #include "exec-all.h" | 6 | #include "exec-all.h" |
7 | 7 | ||
8 | +static uint32_t cpu_arm_find_by_name(const char *name); | ||
9 | + | ||
8 | static inline void set_feature(CPUARMState *env, int feature) | 10 | static inline void set_feature(CPUARMState *env, int feature) |
9 | { | 11 | { |
10 | env->features |= 1u << feature; | 12 | env->features |= 1u << feature; |
@@ -89,14 +91,19 @@ void cpu_reset(CPUARMState *env) | @@ -89,14 +91,19 @@ void cpu_reset(CPUARMState *env) | ||
89 | tlb_flush(env, 1); | 91 | tlb_flush(env, 1); |
90 | } | 92 | } |
91 | 93 | ||
92 | -CPUARMState *cpu_arm_init(void) | 94 | +CPUARMState *cpu_arm_init(const char *cpu_model) |
93 | { | 95 | { |
94 | CPUARMState *env; | 96 | CPUARMState *env; |
97 | + uint32_t id; | ||
95 | 98 | ||
99 | + id = cpu_arm_find_by_name(cpu_model); | ||
100 | + if (id == 0) | ||
101 | + return NULL; | ||
96 | env = qemu_mallocz(sizeof(CPUARMState)); | 102 | env = qemu_mallocz(sizeof(CPUARMState)); |
97 | if (!env) | 103 | if (!env) |
98 | return NULL; | 104 | return NULL; |
99 | cpu_exec_init(env); | 105 | cpu_exec_init(env); |
106 | + env->cp15.c0_cpuid = id; | ||
100 | cpu_reset(env); | 107 | cpu_reset(env); |
101 | return env; | 108 | return env; |
102 | } | 109 | } |
@@ -136,24 +143,20 @@ void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | @@ -136,24 +143,20 @@ void arm_cpu_list(FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | ||
136 | } | 143 | } |
137 | } | 144 | } |
138 | 145 | ||
139 | -void cpu_arm_set_model(CPUARMState *env, const char *name) | 146 | +/* return 0 if not found */ |
147 | +static uint32_t cpu_arm_find_by_name(const char *name) | ||
140 | { | 148 | { |
141 | int i; | 149 | int i; |
142 | uint32_t id; | 150 | uint32_t id; |
143 | 151 | ||
144 | id = 0; | 152 | id = 0; |
145 | - i = 0; | ||
146 | for (i = 0; arm_cpu_names[i].name; i++) { | 153 | for (i = 0; arm_cpu_names[i].name; i++) { |
147 | if (strcmp(name, arm_cpu_names[i].name) == 0) { | 154 | if (strcmp(name, arm_cpu_names[i].name) == 0) { |
148 | id = arm_cpu_names[i].id; | 155 | id = arm_cpu_names[i].id; |
149 | break; | 156 | break; |
150 | } | 157 | } |
151 | } | 158 | } |
152 | - if (!id) { | ||
153 | - cpu_abort(env, "Unknown CPU '%s'", name); | ||
154 | - return; | ||
155 | - } | ||
156 | - cpu_reset_model_id(env, id); | 159 | + return id; |
157 | } | 160 | } |
158 | 161 | ||
159 | void cpu_arm_close(CPUARMState *env) | 162 | void cpu_arm_close(CPUARMState *env) |
target-cris/cpu.h
@@ -147,7 +147,7 @@ typedef struct CPUCRISState { | @@ -147,7 +147,7 @@ typedef struct CPUCRISState { | ||
147 | CPU_COMMON | 147 | CPU_COMMON |
148 | } CPUCRISState; | 148 | } CPUCRISState; |
149 | 149 | ||
150 | -CPUCRISState *cpu_cris_init(void); | 150 | +CPUCRISState *cpu_cris_init(const char *cpu_model); |
151 | int cpu_cris_exec(CPUCRISState *s); | 151 | int cpu_cris_exec(CPUCRISState *s); |
152 | void cpu_cris_close(CPUCRISState *s); | 152 | void cpu_cris_close(CPUCRISState *s); |
153 | void do_interrupt(CPUCRISState *env); | 153 | void do_interrupt(CPUCRISState *env); |
@@ -201,10 +201,6 @@ enum { | @@ -201,10 +201,6 @@ enum { | ||
201 | #define CRIS_SSP 0 | 201 | #define CRIS_SSP 0 |
202 | #define CRIS_USP 1 | 202 | #define CRIS_USP 1 |
203 | 203 | ||
204 | -typedef struct cris_def_t cris_def_t; | ||
205 | - | ||
206 | -int cpu_cris_set_model(CPUCRISState *env, const char * name); | ||
207 | - | ||
208 | void cris_set_irq_level(CPUCRISState *env, int level, uint8_t vector); | 204 | void cris_set_irq_level(CPUCRISState *env, int level, uint8_t vector); |
209 | void cris_set_macsr(CPUCRISState *env, uint32_t val); | 205 | void cris_set_macsr(CPUCRISState *env, uint32_t val); |
210 | void cris_switch_sp(CPUCRISState *env); | 206 | void cris_switch_sp(CPUCRISState *env); |
target-cris/translate.c
@@ -2488,7 +2488,7 @@ void cpu_dump_state (CPUState *env, FILE *f, | @@ -2488,7 +2488,7 @@ void cpu_dump_state (CPUState *env, FILE *f, | ||
2488 | 2488 | ||
2489 | } | 2489 | } |
2490 | 2490 | ||
2491 | -CPUCRISState *cpu_cris_init (void) | 2491 | +CPUCRISState *cpu_cris_init (const char *cpu_model) |
2492 | { | 2492 | { |
2493 | CPUCRISState *env; | 2493 | CPUCRISState *env; |
2494 | 2494 |
target-i386/cpu.h
@@ -585,10 +585,9 @@ typedef struct CPUX86State { | @@ -585,10 +585,9 @@ typedef struct CPUX86State { | ||
585 | struct APICState *apic_state; | 585 | struct APICState *apic_state; |
586 | } CPUX86State; | 586 | } CPUX86State; |
587 | 587 | ||
588 | -CPUX86State *cpu_x86_init(void); | 588 | +CPUX86State *cpu_x86_init(const char *cpu_model); |
589 | int cpu_x86_exec(CPUX86State *s); | 589 | int cpu_x86_exec(CPUX86State *s); |
590 | void cpu_x86_close(CPUX86State *s); | 590 | void cpu_x86_close(CPUX86State *s); |
591 | -int x86_find_cpu_by_name (const unsigned char *name); | ||
592 | void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, | 591 | void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, |
593 | ...)); | 592 | ...)); |
594 | int cpu_get_pic_interrupt(CPUX86State *s); | 593 | int cpu_get_pic_interrupt(CPUX86State *s); |
target-i386/helper2.c
@@ -31,9 +31,7 @@ | @@ -31,9 +31,7 @@ | ||
31 | 31 | ||
32 | //#define DEBUG_MMU | 32 | //#define DEBUG_MMU |
33 | 33 | ||
34 | -static struct x86_def_t *x86_cpu_def; | ||
35 | -typedef struct x86_def_t x86_def_t; | ||
36 | -static int cpu_x86_register (CPUX86State *env, const x86_def_t *def); | 34 | +static int cpu_x86_register (CPUX86State *env, const char *cpu_model); |
37 | 35 | ||
38 | static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, | 36 | static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, |
39 | uint32_t *ext_features, | 37 | uint32_t *ext_features, |
@@ -92,7 +90,7 @@ static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, | @@ -92,7 +90,7 @@ static void add_flagname_to_bitmaps(char *flagname, uint32_t *features, | ||
92 | fprintf(stderr, "CPU feature %s not found\n", flagname); | 90 | fprintf(stderr, "CPU feature %s not found\n", flagname); |
93 | } | 91 | } |
94 | 92 | ||
95 | -CPUX86State *cpu_x86_init(void) | 93 | +CPUX86State *cpu_x86_init(const char *cpu_model) |
96 | { | 94 | { |
97 | CPUX86State *env; | 95 | CPUX86State *env; |
98 | static int inited; | 96 | static int inited; |
@@ -107,7 +105,10 @@ CPUX86State *cpu_x86_init(void) | @@ -107,7 +105,10 @@ CPUX86State *cpu_x86_init(void) | ||
107 | inited = 1; | 105 | inited = 1; |
108 | optimize_flags_init(); | 106 | optimize_flags_init(); |
109 | } | 107 | } |
110 | - cpu_x86_register(env, x86_cpu_def); | 108 | + if (cpu_x86_register(env, cpu_model) < 0) { |
109 | + cpu_x86_close(env); | ||
110 | + return NULL; | ||
111 | + } | ||
111 | cpu_reset(env); | 112 | cpu_reset(env); |
112 | #ifdef USE_KQEMU | 113 | #ifdef USE_KQEMU |
113 | kqemu_init(env); | 114 | kqemu_init(env); |
@@ -115,7 +116,7 @@ CPUX86State *cpu_x86_init(void) | @@ -115,7 +116,7 @@ CPUX86State *cpu_x86_init(void) | ||
115 | return env; | 116 | return env; |
116 | } | 117 | } |
117 | 118 | ||
118 | -struct x86_def_t { | 119 | +typedef struct x86_def_t { |
119 | const char *name; | 120 | const char *name; |
120 | uint32_t vendor1, vendor2, vendor3; | 121 | uint32_t vendor1, vendor2, vendor3; |
121 | int family; | 122 | int family; |
@@ -123,7 +124,7 @@ struct x86_def_t { | @@ -123,7 +124,7 @@ struct x86_def_t { | ||
123 | int stepping; | 124 | int stepping; |
124 | uint32_t features, ext_features, ext2_features, ext3_features; | 125 | uint32_t features, ext_features, ext2_features, ext3_features; |
125 | uint32_t xlevel; | 126 | uint32_t xlevel; |
126 | -}; | 127 | +} x86_def_t; |
127 | 128 | ||
128 | #define PPRO_FEATURES (CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC | \ | 129 | #define PPRO_FEATURES (CPUID_FP87 | CPUID_DE | CPUID_PSE | CPUID_TSC | \ |
129 | CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV | \ | 130 | CPUID_MSR | CPUID_MCE | CPUID_CX8 | CPUID_PGE | CPUID_CMOV | \ |
@@ -194,10 +195,10 @@ static x86_def_t x86_defs[] = { | @@ -194,10 +195,10 @@ static x86_def_t x86_defs[] = { | ||
194 | }, | 195 | }, |
195 | }; | 196 | }; |
196 | 197 | ||
197 | -int x86_find_cpu_by_name(const unsigned char *cpu_model) | 198 | +static int cpu_x86_find_by_name(x86_def_t *x86_cpu_def, const char *cpu_model) |
198 | { | 199 | { |
199 | - int ret; | ||
200 | unsigned int i; | 200 | unsigned int i; |
201 | + x86_def_t *def; | ||
201 | 202 | ||
202 | char *s = strdup(cpu_model); | 203 | char *s = strdup(cpu_model); |
203 | char *featurestr, *name = strtok(s, ","); | 204 | char *featurestr, *name = strtok(s, ","); |
@@ -205,17 +206,16 @@ int x86_find_cpu_by_name(const unsigned char *cpu_model) | @@ -205,17 +206,16 @@ int x86_find_cpu_by_name(const unsigned char *cpu_model) | ||
205 | uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0; | 206 | uint32_t minus_features = 0, minus_ext_features = 0, minus_ext2_features = 0, minus_ext3_features = 0; |
206 | int family = -1, model = -1, stepping = -1; | 207 | int family = -1, model = -1, stepping = -1; |
207 | 208 | ||
208 | - ret = -1; | ||
209 | - x86_cpu_def = NULL; | 209 | + def = NULL; |
210 | for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) { | 210 | for (i = 0; i < sizeof(x86_defs) / sizeof(x86_def_t); i++) { |
211 | if (strcmp(name, x86_defs[i].name) == 0) { | 211 | if (strcmp(name, x86_defs[i].name) == 0) { |
212 | - x86_cpu_def = &x86_defs[i]; | ||
213 | - ret = 0; | 212 | + def = &x86_defs[i]; |
214 | break; | 213 | break; |
215 | } | 214 | } |
216 | } | 215 | } |
217 | - if (!x86_cpu_def) | 216 | + if (!def) |
218 | goto error; | 217 | goto error; |
218 | + memcpy(x86_cpu_def, def, sizeof(*def)); | ||
219 | 219 | ||
220 | featurestr = strtok(NULL, ","); | 220 | featurestr = strtok(NULL, ","); |
221 | 221 | ||
@@ -274,10 +274,12 @@ int x86_find_cpu_by_name(const unsigned char *cpu_model) | @@ -274,10 +274,12 @@ int x86_find_cpu_by_name(const unsigned char *cpu_model) | ||
274 | x86_cpu_def->ext_features &= ~minus_ext_features; | 274 | x86_cpu_def->ext_features &= ~minus_ext_features; |
275 | x86_cpu_def->ext2_features &= ~minus_ext2_features; | 275 | x86_cpu_def->ext2_features &= ~minus_ext2_features; |
276 | x86_cpu_def->ext3_features &= ~minus_ext3_features; | 276 | x86_cpu_def->ext3_features &= ~minus_ext3_features; |
277 | + free(s); | ||
278 | + return 0; | ||
277 | 279 | ||
278 | error: | 280 | error: |
279 | free(s); | 281 | free(s); |
280 | - return ret; | 282 | + return -1; |
281 | } | 283 | } |
282 | 284 | ||
283 | void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | 285 | void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
@@ -288,8 +290,12 @@ void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | @@ -288,8 +290,12 @@ void x86_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | ||
288 | (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name); | 290 | (*cpu_fprintf)(f, "x86 %16s\n", x86_defs[i].name); |
289 | } | 291 | } |
290 | 292 | ||
291 | -int cpu_x86_register (CPUX86State *env, const x86_def_t *def) | 293 | +static int cpu_x86_register (CPUX86State *env, const char *cpu_model) |
292 | { | 294 | { |
295 | + x86_def_t def1, *def = &def1; | ||
296 | + | ||
297 | + if (cpu_x86_find_by_name(def, cpu_model) < 0) | ||
298 | + return -1; | ||
293 | if (def->vendor1) { | 299 | if (def->vendor1) { |
294 | env->cpuid_vendor1 = def->vendor1; | 300 | env->cpuid_vendor1 = def->vendor1; |
295 | env->cpuid_vendor2 = def->vendor2; | 301 | env->cpuid_vendor2 = def->vendor2; |
target-m68k/cpu.h
@@ -100,8 +100,6 @@ typedef struct CPUM68KState { | @@ -100,8 +100,6 @@ typedef struct CPUM68KState { | ||
100 | uint32_t rambar0; | 100 | uint32_t rambar0; |
101 | uint32_t cacr; | 101 | uint32_t cacr; |
102 | 102 | ||
103 | - uint32_t features; | ||
104 | - | ||
105 | /* ??? remove this. */ | 103 | /* ??? remove this. */ |
106 | uint32_t t1; | 104 | uint32_t t1; |
107 | 105 | ||
@@ -118,9 +116,11 @@ typedef struct CPUM68KState { | @@ -118,9 +116,11 @@ typedef struct CPUM68KState { | ||
118 | uint32_t qregs[MAX_QREGS]; | 116 | uint32_t qregs[MAX_QREGS]; |
119 | 117 | ||
120 | CPU_COMMON | 118 | CPU_COMMON |
119 | + | ||
120 | + uint32_t features; | ||
121 | } CPUM68KState; | 121 | } CPUM68KState; |
122 | 122 | ||
123 | -CPUM68KState *cpu_m68k_init(void); | 123 | +CPUM68KState *cpu_m68k_init(const char *cpu_model); |
124 | int cpu_m68k_exec(CPUM68KState *s); | 124 | int cpu_m68k_exec(CPUM68KState *s); |
125 | void cpu_m68k_close(CPUM68KState *s); | 125 | void cpu_m68k_close(CPUM68KState *s); |
126 | void do_interrupt(int is_hw); | 126 | void do_interrupt(int is_hw); |
@@ -174,10 +174,6 @@ enum { | @@ -174,10 +174,6 @@ enum { | ||
174 | #define MACSR_V 0x002 | 174 | #define MACSR_V 0x002 |
175 | #define MACSR_EV 0x001 | 175 | #define MACSR_EV 0x001 |
176 | 176 | ||
177 | -typedef struct m68k_def_t m68k_def_t; | ||
178 | - | ||
179 | -int cpu_m68k_set_model(CPUM68KState *env, const char * name); | ||
180 | - | ||
181 | void m68k_set_irq_level(CPUM68KState *env, int level, uint8_t vector); | 177 | void m68k_set_irq_level(CPUM68KState *env, int level, uint8_t vector); |
182 | void m68k_set_macsr(CPUM68KState *env, uint32_t val); | 178 | void m68k_set_macsr(CPUM68KState *env, uint32_t val); |
183 | void m68k_switch_sp(CPUM68KState *env); | 179 | void m68k_switch_sp(CPUM68KState *env); |
target-m68k/helper.c
@@ -33,6 +33,8 @@ enum m68k_cpuid { | @@ -33,6 +33,8 @@ enum m68k_cpuid { | ||
33 | M68K_CPUID_ANY, | 33 | M68K_CPUID_ANY, |
34 | }; | 34 | }; |
35 | 35 | ||
36 | +typedef struct m68k_def_t m68k_def_t; | ||
37 | + | ||
36 | struct m68k_def_t { | 38 | struct m68k_def_t { |
37 | const char * name; | 39 | const char * name; |
38 | enum m68k_cpuid id; | 40 | enum m68k_cpuid id; |
@@ -51,7 +53,7 @@ static void m68k_set_feature(CPUM68KState *env, int feature) | @@ -51,7 +53,7 @@ static void m68k_set_feature(CPUM68KState *env, int feature) | ||
51 | env->features |= (1u << feature); | 53 | env->features |= (1u << feature); |
52 | } | 54 | } |
53 | 55 | ||
54 | -int cpu_m68k_set_model(CPUM68KState *env, const char * name) | 56 | +static int cpu_m68k_set_model(CPUM68KState *env, const char *name) |
55 | { | 57 | { |
56 | m68k_def_t *def; | 58 | m68k_def_t *def; |
57 | 59 | ||
@@ -60,7 +62,7 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name) | @@ -60,7 +62,7 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name) | ||
60 | break; | 62 | break; |
61 | } | 63 | } |
62 | if (!def->name) | 64 | if (!def->name) |
63 | - return 1; | 65 | + return -1; |
64 | 66 | ||
65 | switch (def->id) { | 67 | switch (def->id) { |
66 | case M68K_CPUID_M5206: | 68 | case M68K_CPUID_M5206: |
@@ -98,8 +100,43 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name) | @@ -98,8 +100,43 @@ int cpu_m68k_set_model(CPUM68KState *env, const char * name) | ||
98 | } | 100 | } |
99 | 101 | ||
100 | register_m68k_insns(env); | 102 | register_m68k_insns(env); |
103 | +} | ||
104 | + | ||
105 | +void cpu_reset(CPUM68KState *env) | ||
106 | +{ | ||
107 | + memset(env, 0, offsetof(CPUM68KState, breakpoints)); | ||
108 | +#if !defined (CONFIG_USER_ONLY) | ||
109 | + env->sr = 0x2700; | ||
110 | +#endif | ||
111 | + m68k_switch_sp(env); | ||
112 | + /* ??? FP regs should be initialized to NaN. */ | ||
113 | + env->cc_op = CC_OP_FLAGS; | ||
114 | + /* TODO: We should set PC from the interrupt vector. */ | ||
115 | + env->pc = 0; | ||
116 | + tlb_flush(env, 1); | ||
117 | +} | ||
101 | 118 | ||
102 | - return 0; | 119 | +CPUM68KState *cpu_m68k_init(const char *cpu_model) |
120 | +{ | ||
121 | + CPUM68KState *env; | ||
122 | + | ||
123 | + env = malloc(sizeof(CPUM68KState)); | ||
124 | + if (!env) | ||
125 | + return NULL; | ||
126 | + cpu_exec_init(env); | ||
127 | + | ||
128 | + if (cpu_m68k_set_model(env, cpu_model) < 0) { | ||
129 | + cpu_m68k_close(env); | ||
130 | + return NULL; | ||
131 | + } | ||
132 | + | ||
133 | + cpu_reset(env); | ||
134 | + return env; | ||
135 | +} | ||
136 | + | ||
137 | +void cpu_m68k_close(CPUM68KState *env) | ||
138 | +{ | ||
139 | + qemu_free(env); | ||
103 | } | 140 | } |
104 | 141 | ||
105 | void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op) | 142 | void cpu_m68k_flush_flags(CPUM68KState *env, int cc_op) |
target-m68k/translate.c
@@ -3279,38 +3279,6 @@ int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb) | @@ -3279,38 +3279,6 @@ int gen_intermediate_code_pc(CPUState *env, TranslationBlock *tb) | ||
3279 | return gen_intermediate_code_internal(env, tb, 1); | 3279 | return gen_intermediate_code_internal(env, tb, 1); |
3280 | } | 3280 | } |
3281 | 3281 | ||
3282 | -void cpu_reset(CPUM68KState *env) | ||
3283 | -{ | ||
3284 | - memset(env, 0, offsetof(CPUM68KState, breakpoints)); | ||
3285 | -#if !defined (CONFIG_USER_ONLY) | ||
3286 | - env->sr = 0x2700; | ||
3287 | -#endif | ||
3288 | - m68k_switch_sp(env); | ||
3289 | - /* ??? FP regs should be initialized to NaN. */ | ||
3290 | - env->cc_op = CC_OP_FLAGS; | ||
3291 | - /* TODO: We should set PC from the interrupt vector. */ | ||
3292 | - env->pc = 0; | ||
3293 | - tlb_flush(env, 1); | ||
3294 | -} | ||
3295 | - | ||
3296 | -CPUM68KState *cpu_m68k_init(void) | ||
3297 | -{ | ||
3298 | - CPUM68KState *env; | ||
3299 | - | ||
3300 | - env = malloc(sizeof(CPUM68KState)); | ||
3301 | - if (!env) | ||
3302 | - return NULL; | ||
3303 | - cpu_exec_init(env); | ||
3304 | - | ||
3305 | - cpu_reset(env); | ||
3306 | - return env; | ||
3307 | -} | ||
3308 | - | ||
3309 | -void cpu_m68k_close(CPUM68KState *env) | ||
3310 | -{ | ||
3311 | - free(env); | ||
3312 | -} | ||
3313 | - | ||
3314 | void cpu_dump_state(CPUState *env, FILE *f, | 3282 | void cpu_dump_state(CPUState *env, FILE *f, |
3315 | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), | 3283 | int (*cpu_fprintf)(FILE *f, const char *fmt, ...), |
3316 | int flags) | 3284 | int flags) |
target-mips/cpu.h
@@ -456,7 +456,7 @@ struct CPUMIPSState { | @@ -456,7 +456,7 @@ struct CPUMIPSState { | ||
456 | 456 | ||
457 | CPU_COMMON | 457 | CPU_COMMON |
458 | 458 | ||
459 | - mips_def_t *cpu_model; | 459 | + const mips_def_t *cpu_model; |
460 | #ifndef CONFIG_USER_ONLY | 460 | #ifndef CONFIG_USER_ONLY |
461 | void *irq[8]; | 461 | void *irq[8]; |
462 | #endif | 462 | #endif |
@@ -474,9 +474,7 @@ void r4k_do_tlbwi (void); | @@ -474,9 +474,7 @@ void r4k_do_tlbwi (void); | ||
474 | void r4k_do_tlbwr (void); | 474 | void r4k_do_tlbwr (void); |
475 | void r4k_do_tlbp (void); | 475 | void r4k_do_tlbp (void); |
476 | void r4k_do_tlbr (void); | 476 | void r4k_do_tlbr (void); |
477 | -int mips_find_by_name (const unsigned char *name, mips_def_t **def); | ||
478 | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); | 477 | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); |
479 | -int cpu_mips_register (CPUMIPSState *env, mips_def_t *def); | ||
480 | 478 | ||
481 | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, | 479 | void do_unassigned_access(target_phys_addr_t addr, int is_write, int is_exec, |
482 | int unused); | 480 | int unused); |
@@ -560,7 +558,7 @@ enum { | @@ -560,7 +558,7 @@ enum { | ||
560 | }; | 558 | }; |
561 | 559 | ||
562 | int cpu_mips_exec(CPUMIPSState *s); | 560 | int cpu_mips_exec(CPUMIPSState *s); |
563 | -CPUMIPSState *cpu_mips_init(void); | 561 | +CPUMIPSState *cpu_mips_init(const char *cpu_model); |
564 | uint32_t cpu_mips_get_clock (void); | 562 | uint32_t cpu_mips_get_clock (void); |
565 | int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); | 563 | int cpu_mips_signal_handler(int host_signum, void *pinfo, void *puc); |
566 | 564 |
target-mips/translate.c
@@ -6725,13 +6725,21 @@ void cpu_dump_state (CPUState *env, FILE *f, | @@ -6725,13 +6725,21 @@ void cpu_dump_state (CPUState *env, FILE *f, | ||
6725 | #endif | 6725 | #endif |
6726 | } | 6726 | } |
6727 | 6727 | ||
6728 | -CPUMIPSState *cpu_mips_init (void) | 6728 | +#include "translate_init.c" |
6729 | + | ||
6730 | +CPUMIPSState *cpu_mips_init (const char *cpu_model) | ||
6729 | { | 6731 | { |
6730 | CPUMIPSState *env; | 6732 | CPUMIPSState *env; |
6733 | + const mips_def_t *def; | ||
6731 | 6734 | ||
6735 | + def = cpu_mips_find_by_name(cpu_model); | ||
6736 | + if (!def) | ||
6737 | + return NULL; | ||
6732 | env = qemu_mallocz(sizeof(CPUMIPSState)); | 6738 | env = qemu_mallocz(sizeof(CPUMIPSState)); |
6733 | if (!env) | 6739 | if (!env) |
6734 | return NULL; | 6740 | return NULL; |
6741 | + env->cpu_model = def; | ||
6742 | + | ||
6735 | cpu_exec_init(env); | 6743 | cpu_exec_init(env); |
6736 | cpu_reset(env); | 6744 | cpu_reset(env); |
6737 | return env; | 6745 | return env; |
@@ -6780,6 +6788,5 @@ void cpu_reset (CPUMIPSState *env) | @@ -6780,6 +6788,5 @@ void cpu_reset (CPUMIPSState *env) | ||
6780 | #else | 6788 | #else |
6781 | env->hflags = MIPS_HFLAG_CP0; | 6789 | env->hflags = MIPS_HFLAG_CP0; |
6782 | #endif | 6790 | #endif |
6791 | + cpu_mips_register(env, env->cpu_model); | ||
6783 | } | 6792 | } |
6784 | - | ||
6785 | -#include "translate_init.c" |
target-mips/translate_init.c
@@ -53,7 +53,6 @@ | @@ -53,7 +53,6 @@ | ||
53 | Define a major version 1, minor version 0. */ | 53 | Define a major version 1, minor version 0. */ |
54 | #define MIPS_FCR0 ((0 << FCR0_S) | (0x1 << FCR0_PRID) | (0x10 << FCR0_REV)) | 54 | #define MIPS_FCR0 ((0 << FCR0_S) | (0x1 << FCR0_PRID) | (0x10 << FCR0_REV)) |
55 | 55 | ||
56 | - | ||
57 | struct mips_def_t { | 56 | struct mips_def_t { |
58 | const unsigned char *name; | 57 | const unsigned char *name; |
59 | int32_t CP0_PRid; | 58 | int32_t CP0_PRid; |
@@ -300,21 +299,16 @@ static mips_def_t mips_defs[] = | @@ -300,21 +299,16 @@ static mips_def_t mips_defs[] = | ||
300 | #endif | 299 | #endif |
301 | }; | 300 | }; |
302 | 301 | ||
303 | -int mips_find_by_name (const unsigned char *name, mips_def_t **def) | 302 | +static const mips_def_t *cpu_mips_find_by_name (const unsigned char *name) |
304 | { | 303 | { |
305 | - int i, ret; | 304 | + int i; |
306 | 305 | ||
307 | - ret = -1; | ||
308 | - *def = NULL; | ||
309 | for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { | 306 | for (i = 0; i < sizeof(mips_defs) / sizeof(mips_defs[0]); i++) { |
310 | if (strcasecmp(name, mips_defs[i].name) == 0) { | 307 | if (strcasecmp(name, mips_defs[i].name) == 0) { |
311 | - *def = &mips_defs[i]; | ||
312 | - ret = 0; | ||
313 | - break; | 308 | + return &mips_defs[i]; |
314 | } | 309 | } |
315 | } | 310 | } |
316 | - | ||
317 | - return ret; | 311 | + return NULL; |
318 | } | 312 | } |
319 | 313 | ||
320 | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | 314 | void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
@@ -328,19 +322,19 @@ void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | @@ -328,19 +322,19 @@ void mips_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | ||
328 | } | 322 | } |
329 | 323 | ||
330 | #ifndef CONFIG_USER_ONLY | 324 | #ifndef CONFIG_USER_ONLY |
331 | -static void no_mmu_init (CPUMIPSState *env, mips_def_t *def) | 325 | +static void no_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
332 | { | 326 | { |
333 | env->tlb->nb_tlb = 1; | 327 | env->tlb->nb_tlb = 1; |
334 | env->tlb->map_address = &no_mmu_map_address; | 328 | env->tlb->map_address = &no_mmu_map_address; |
335 | } | 329 | } |
336 | 330 | ||
337 | -static void fixed_mmu_init (CPUMIPSState *env, mips_def_t *def) | 331 | +static void fixed_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
338 | { | 332 | { |
339 | env->tlb->nb_tlb = 1; | 333 | env->tlb->nb_tlb = 1; |
340 | env->tlb->map_address = &fixed_mmu_map_address; | 334 | env->tlb->map_address = &fixed_mmu_map_address; |
341 | } | 335 | } |
342 | 336 | ||
343 | -static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) | 337 | +static void r4k_mmu_init (CPUMIPSState *env, const mips_def_t *def) |
344 | { | 338 | { |
345 | env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); | 339 | env->tlb->nb_tlb = 1 + ((def->CP0_Config1 >> CP0C1_MMU) & 63); |
346 | env->tlb->map_address = &r4k_map_address; | 340 | env->tlb->map_address = &r4k_map_address; |
@@ -350,7 +344,7 @@ static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) | @@ -350,7 +344,7 @@ static void r4k_mmu_init (CPUMIPSState *env, mips_def_t *def) | ||
350 | env->tlb->do_tlbr = r4k_do_tlbr; | 344 | env->tlb->do_tlbr = r4k_do_tlbr; |
351 | } | 345 | } |
352 | 346 | ||
353 | -static void mmu_init (CPUMIPSState *env, mips_def_t *def) | 347 | +static void mmu_init (CPUMIPSState *env, const mips_def_t *def) |
354 | { | 348 | { |
355 | env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext)); | 349 | env->tlb = qemu_mallocz(sizeof(CPUMIPSTLBContext)); |
356 | 350 | ||
@@ -376,7 +370,7 @@ static void mmu_init (CPUMIPSState *env, mips_def_t *def) | @@ -376,7 +370,7 @@ static void mmu_init (CPUMIPSState *env, mips_def_t *def) | ||
376 | } | 370 | } |
377 | #endif /* CONFIG_USER_ONLY */ | 371 | #endif /* CONFIG_USER_ONLY */ |
378 | 372 | ||
379 | -static void fpu_init (CPUMIPSState *env, mips_def_t *def) | 373 | +static void fpu_init (CPUMIPSState *env, const mips_def_t *def) |
380 | { | 374 | { |
381 | env->fpu = qemu_mallocz(sizeof(CPUMIPSFPUContext)); | 375 | env->fpu = qemu_mallocz(sizeof(CPUMIPSFPUContext)); |
382 | 376 | ||
@@ -389,7 +383,7 @@ static void fpu_init (CPUMIPSState *env, mips_def_t *def) | @@ -389,7 +383,7 @@ static void fpu_init (CPUMIPSState *env, mips_def_t *def) | ||
389 | #endif | 383 | #endif |
390 | } | 384 | } |
391 | 385 | ||
392 | -static void mvp_init (CPUMIPSState *env, mips_def_t *def) | 386 | +static void mvp_init (CPUMIPSState *env, const mips_def_t *def) |
393 | { | 387 | { |
394 | env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext)); | 388 | env->mvp = qemu_mallocz(sizeof(CPUMIPSMVPContext)); |
395 | 389 | ||
@@ -415,13 +409,8 @@ static void mvp_init (CPUMIPSState *env, mips_def_t *def) | @@ -415,13 +409,8 @@ static void mvp_init (CPUMIPSState *env, mips_def_t *def) | ||
415 | (0x1 << CP0MVPC1_PCP1); | 409 | (0x1 << CP0MVPC1_PCP1); |
416 | } | 410 | } |
417 | 411 | ||
418 | -int cpu_mips_register (CPUMIPSState *env, mips_def_t *def) | 412 | +static int cpu_mips_register (CPUMIPSState *env, const mips_def_t *def) |
419 | { | 413 | { |
420 | - if (!def) | ||
421 | - def = env->cpu_model; | ||
422 | - if (!def) | ||
423 | - cpu_abort(env, "Unable to find MIPS CPU definition\n"); | ||
424 | - env->cpu_model = def; | ||
425 | env->CP0_PRid = def->CP0_PRid; | 414 | env->CP0_PRid = def->CP0_PRid; |
426 | env->CP0_Config0 = def->CP0_Config0; | 415 | env->CP0_Config0 = def->CP0_Config0; |
427 | #ifdef TARGET_WORDS_BIGENDIAN | 416 | #ifdef TARGET_WORDS_BIGENDIAN |
target-ppc/cpu.h
@@ -675,7 +675,7 @@ struct mmu_ctx_t { | @@ -675,7 +675,7 @@ struct mmu_ctx_t { | ||
675 | }; | 675 | }; |
676 | 676 | ||
677 | /*****************************************************************************/ | 677 | /*****************************************************************************/ |
678 | -CPUPPCState *cpu_ppc_init (void); | 678 | +CPUPPCState *cpu_ppc_init (const char *cpu_model); |
679 | int cpu_ppc_exec (CPUPPCState *s); | 679 | int cpu_ppc_exec (CPUPPCState *s); |
680 | void cpu_ppc_close (CPUPPCState *s); | 680 | void cpu_ppc_close (CPUPPCState *s); |
681 | /* you can call this signal handler from your SIGBUS and SIGSEGV | 681 | /* you can call this signal handler from your SIGBUS and SIGSEGV |
@@ -719,13 +719,12 @@ void ppc_store_xer (CPUPPCState *env, target_ulong value); | @@ -719,13 +719,12 @@ void ppc_store_xer (CPUPPCState *env, target_ulong value); | ||
719 | void ppc_store_msr (CPUPPCState *env, target_ulong value); | 719 | void ppc_store_msr (CPUPPCState *env, target_ulong value); |
720 | 720 | ||
721 | void cpu_ppc_reset (void *opaque); | 721 | void cpu_ppc_reset (void *opaque); |
722 | -CPUPPCState *cpu_ppc_init (void); | ||
723 | -void cpu_ppc_close(CPUPPCState *env); | ||
724 | 722 | ||
725 | -int ppc_find_by_name (const unsigned char *name, ppc_def_t **def); | ||
726 | -int ppc_find_by_pvr (uint32_t apvr, ppc_def_t **def); | ||
727 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); | 723 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)); |
728 | -int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def); | 724 | + |
725 | +const ppc_def_t *cpu_ppc_find_by_name (const unsigned char *name); | ||
726 | +const ppc_def_t *cpu_ppc_find_by_pvr (uint32_t pvr); | ||
727 | +int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def); | ||
729 | 728 | ||
730 | /* Time-base and decrementer management */ | 729 | /* Time-base and decrementer management */ |
731 | #ifndef NO_CPU_IO_DEFS | 730 | #ifndef NO_CPU_IO_DEFS |
target-ppc/helper.c
@@ -2970,20 +2970,26 @@ void cpu_ppc_reset (void *opaque) | @@ -2970,20 +2970,26 @@ void cpu_ppc_reset (void *opaque) | ||
2970 | tlb_flush(env, 1); | 2970 | tlb_flush(env, 1); |
2971 | } | 2971 | } |
2972 | 2972 | ||
2973 | -CPUPPCState *cpu_ppc_init (void) | 2973 | +CPUPPCState *cpu_ppc_init (const char *cpu_model) |
2974 | { | 2974 | { |
2975 | CPUPPCState *env; | 2975 | CPUPPCState *env; |
2976 | + const ppc_def_t *def; | ||
2977 | + | ||
2978 | + def = cpu_ppc_find_by_name(cpu_model); | ||
2979 | + if (!def) | ||
2980 | + return NULL; | ||
2976 | 2981 | ||
2977 | env = qemu_mallocz(sizeof(CPUPPCState)); | 2982 | env = qemu_mallocz(sizeof(CPUPPCState)); |
2978 | if (!env) | 2983 | if (!env) |
2979 | return NULL; | 2984 | return NULL; |
2980 | cpu_exec_init(env); | 2985 | cpu_exec_init(env); |
2981 | - | 2986 | + cpu_ppc_register_internal(env, def); |
2987 | + cpu_ppc_reset(env); | ||
2982 | return env; | 2988 | return env; |
2983 | } | 2989 | } |
2984 | 2990 | ||
2985 | void cpu_ppc_close (CPUPPCState *env) | 2991 | void cpu_ppc_close (CPUPPCState *env) |
2986 | { | 2992 | { |
2987 | /* Should also remove all opcode tables... */ | 2993 | /* Should also remove all opcode tables... */ |
2988 | - free(env); | 2994 | + qemu_free(env); |
2989 | } | 2995 | } |
target-ppc/translate_init.c
@@ -5931,7 +5931,7 @@ static ppc_def_t ppc_defs[] = { | @@ -5931,7 +5931,7 @@ static ppc_def_t ppc_defs[] = { | ||
5931 | 5931 | ||
5932 | /*****************************************************************************/ | 5932 | /*****************************************************************************/ |
5933 | /* Generic CPU instanciation routine */ | 5933 | /* Generic CPU instanciation routine */ |
5934 | -static void init_ppc_proc (CPUPPCState *env, ppc_def_t *def) | 5934 | +static void init_ppc_proc (CPUPPCState *env, const ppc_def_t *def) |
5935 | { | 5935 | { |
5936 | #if !defined(CONFIG_USER_ONLY) | 5936 | #if !defined(CONFIG_USER_ONLY) |
5937 | int i; | 5937 | int i; |
@@ -6276,7 +6276,7 @@ static void fix_opcode_tables (opc_handler_t **ppc_opcodes) | @@ -6276,7 +6276,7 @@ static void fix_opcode_tables (opc_handler_t **ppc_opcodes) | ||
6276 | } | 6276 | } |
6277 | 6277 | ||
6278 | /*****************************************************************************/ | 6278 | /*****************************************************************************/ |
6279 | -static int create_ppc_opcodes (CPUPPCState *env, ppc_def_t *def) | 6279 | +static int create_ppc_opcodes (CPUPPCState *env, const ppc_def_t *def) |
6280 | { | 6280 | { |
6281 | opcode_t *opc, *start, *end; | 6281 | opcode_t *opc, *start, *end; |
6282 | 6282 | ||
@@ -6351,7 +6351,7 @@ static void dump_ppc_insns (CPUPPCState *env) | @@ -6351,7 +6351,7 @@ static void dump_ppc_insns (CPUPPCState *env) | ||
6351 | } | 6351 | } |
6352 | #endif | 6352 | #endif |
6353 | 6353 | ||
6354 | -int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) | 6354 | +int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def) |
6355 | { | 6355 | { |
6356 | env->msr_mask = def->msr_mask; | 6356 | env->msr_mask = def->msr_mask; |
6357 | env->mmu_model = def->mmu_model; | 6357 | env->mmu_model = def->mmu_model; |
@@ -6514,41 +6514,31 @@ int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) | @@ -6514,41 +6514,31 @@ int cpu_ppc_register (CPUPPCState *env, ppc_def_t *def) | ||
6514 | return 0; | 6514 | return 0; |
6515 | } | 6515 | } |
6516 | 6516 | ||
6517 | -int ppc_find_by_name (const unsigned char *name, ppc_def_t **def) | 6517 | +const ppc_def_t *cpu_ppc_find_by_name (const unsigned char *name) |
6518 | { | 6518 | { |
6519 | - int i, max, ret; | 6519 | + int i, max; |
6520 | 6520 | ||
6521 | - ret = -1; | ||
6522 | - *def = NULL; | ||
6523 | max = sizeof(ppc_defs) / sizeof(ppc_def_t); | 6521 | max = sizeof(ppc_defs) / sizeof(ppc_def_t); |
6524 | for (i = 0; i < max; i++) { | 6522 | for (i = 0; i < max; i++) { |
6525 | if (strcasecmp(name, ppc_defs[i].name) == 0) { | 6523 | if (strcasecmp(name, ppc_defs[i].name) == 0) { |
6526 | - *def = &ppc_defs[i]; | ||
6527 | - ret = 0; | ||
6528 | - break; | 6524 | + return &ppc_defs[i]; |
6529 | } | 6525 | } |
6530 | } | 6526 | } |
6531 | - | ||
6532 | - return ret; | 6527 | + return NULL; |
6533 | } | 6528 | } |
6534 | 6529 | ||
6535 | -int ppc_find_by_pvr (uint32_t pvr, ppc_def_t **def) | 6530 | +const ppc_def_t *cpu_ppc_find_by_pvr (uint32_t pvr) |
6536 | { | 6531 | { |
6537 | - int i, max, ret; | 6532 | + int i, max; |
6538 | 6533 | ||
6539 | - ret = -1; | ||
6540 | - *def = NULL; | ||
6541 | max = sizeof(ppc_defs) / sizeof(ppc_def_t); | 6534 | max = sizeof(ppc_defs) / sizeof(ppc_def_t); |
6542 | for (i = 0; i < max; i++) { | 6535 | for (i = 0; i < max; i++) { |
6543 | if ((pvr & ppc_defs[i].pvr_mask) == | 6536 | if ((pvr & ppc_defs[i].pvr_mask) == |
6544 | (ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) { | 6537 | (ppc_defs[i].pvr & ppc_defs[i].pvr_mask)) { |
6545 | - *def = &ppc_defs[i]; | ||
6546 | - ret = 0; | ||
6547 | - break; | 6538 | + return &ppc_defs[i]; |
6548 | } | 6539 | } |
6549 | } | 6540 | } |
6550 | - | ||
6551 | - return ret; | 6541 | + return NULL; |
6552 | } | 6542 | } |
6553 | 6543 | ||
6554 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | 6544 | void ppc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
target-sh4/cpu.h
@@ -123,7 +123,7 @@ typedef struct CPUSH4State { | @@ -123,7 +123,7 @@ typedef struct CPUSH4State { | ||
123 | tlb_t itlb[ITLB_SIZE]; /* instruction translation table */ | 123 | tlb_t itlb[ITLB_SIZE]; /* instruction translation table */ |
124 | } CPUSH4State; | 124 | } CPUSH4State; |
125 | 125 | ||
126 | -CPUSH4State *cpu_sh4_init(void); | 126 | +CPUSH4State *cpu_sh4_init(const char *cpu_model); |
127 | int cpu_sh4_exec(CPUSH4State * s); | 127 | int cpu_sh4_exec(CPUSH4State * s); |
128 | int cpu_sh4_signal_handler(int host_signum, void *pinfo, | 128 | int cpu_sh4_signal_handler(int host_signum, void *pinfo, |
129 | void *puc); | 129 | void *puc); |
target-sh4/translate.c
@@ -141,7 +141,7 @@ void cpu_sh4_reset(CPUSH4State * env) | @@ -141,7 +141,7 @@ void cpu_sh4_reset(CPUSH4State * env) | ||
141 | env->mmucr = 0; | 141 | env->mmucr = 0; |
142 | } | 142 | } |
143 | 143 | ||
144 | -CPUSH4State *cpu_sh4_init(void) | 144 | +CPUSH4State *cpu_sh4_init(const char *cpu_model) |
145 | { | 145 | { |
146 | CPUSH4State *env; | 146 | CPUSH4State *env; |
147 | 147 |
target-sparc/cpu.h
@@ -165,8 +165,6 @@ | @@ -165,8 +165,6 @@ | ||
165 | /* 2 <= NWINDOWS <= 32. In QEMU it must also be a power of two. */ | 165 | /* 2 <= NWINDOWS <= 32. In QEMU it must also be a power of two. */ |
166 | #define NWINDOWS 8 | 166 | #define NWINDOWS 8 |
167 | 167 | ||
168 | -typedef struct sparc_def_t sparc_def_t; | ||
169 | - | ||
170 | #if !defined(TARGET_SPARC64) | 168 | #if !defined(TARGET_SPARC64) |
171 | #define NB_MMU_MODES 2 | 169 | #define NB_MMU_MODES 2 |
172 | #else | 170 | #else |
@@ -270,14 +268,12 @@ typedef struct CPUSPARCState { | @@ -270,14 +268,12 @@ typedef struct CPUSPARCState { | ||
270 | } while (0) | 268 | } while (0) |
271 | #endif | 269 | #endif |
272 | 270 | ||
273 | -CPUSPARCState *cpu_sparc_init(void); | 271 | +CPUSPARCState *cpu_sparc_init(const char *cpu_model); |
274 | int cpu_sparc_exec(CPUSPARCState *s); | 272 | int cpu_sparc_exec(CPUSPARCState *s); |
275 | int cpu_sparc_close(CPUSPARCState *s); | 273 | int cpu_sparc_close(CPUSPARCState *s); |
276 | -int sparc_find_by_name (const unsigned char *name, const sparc_def_t **def); | ||
277 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, | 274 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, |
278 | ...)); | 275 | ...)); |
279 | -int cpu_sparc_register (CPUSPARCState *env, const sparc_def_t *def, | ||
280 | - unsigned int cpu); | 276 | +void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu); |
281 | 277 | ||
282 | #define GET_PSR(env) (env->version | (env->psr & PSR_ICC) | \ | 278 | #define GET_PSR(env) (env->version | (env->psr & PSR_ICC) | \ |
283 | (env->psref? PSR_EF : 0) | \ | 279 | (env->psref? PSR_EF : 0) | \ |
target-sparc/translate.c
@@ -54,6 +54,8 @@ typedef struct DisasContext { | @@ -54,6 +54,8 @@ typedef struct DisasContext { | ||
54 | struct TranslationBlock *tb; | 54 | struct TranslationBlock *tb; |
55 | } DisasContext; | 55 | } DisasContext; |
56 | 56 | ||
57 | +typedef struct sparc_def_t sparc_def_t; | ||
58 | + | ||
57 | struct sparc_def_t { | 59 | struct sparc_def_t { |
58 | const unsigned char *name; | 60 | const unsigned char *name; |
59 | target_ulong iu_version; | 61 | target_ulong iu_version; |
@@ -62,6 +64,8 @@ struct sparc_def_t { | @@ -62,6 +64,8 @@ struct sparc_def_t { | ||
62 | uint32_t mmu_bm; | 64 | uint32_t mmu_bm; |
63 | }; | 65 | }; |
64 | 66 | ||
67 | +static const sparc_def_t *cpu_sparc_find_by_name(const unsigned char *name); | ||
68 | + | ||
65 | static uint16_t *gen_opc_ptr; | 69 | static uint16_t *gen_opc_ptr; |
66 | static uint32_t *gen_opparam_ptr; | 70 | static uint32_t *gen_opparam_ptr; |
67 | extern FILE *logfile; | 71 | extern FILE *logfile; |
@@ -3489,15 +3493,36 @@ void cpu_reset(CPUSPARCState *env) | @@ -3489,15 +3493,36 @@ void cpu_reset(CPUSPARCState *env) | ||
3489 | #endif | 3493 | #endif |
3490 | } | 3494 | } |
3491 | 3495 | ||
3492 | -CPUSPARCState *cpu_sparc_init(void) | 3496 | +CPUSPARCState *cpu_sparc_init(const char *cpu_model) |
3493 | { | 3497 | { |
3494 | CPUSPARCState *env; | 3498 | CPUSPARCState *env; |
3499 | + const sparc_def_t *def; | ||
3500 | + | ||
3501 | + def = cpu_sparc_find_by_name(cpu_model); | ||
3502 | + if (!def) | ||
3503 | + return NULL; | ||
3495 | 3504 | ||
3496 | env = qemu_mallocz(sizeof(CPUSPARCState)); | 3505 | env = qemu_mallocz(sizeof(CPUSPARCState)); |
3497 | if (!env) | 3506 | if (!env) |
3498 | return NULL; | 3507 | return NULL; |
3499 | cpu_exec_init(env); | 3508 | cpu_exec_init(env); |
3500 | - return (env); | 3509 | + env->version = def->iu_version; |
3510 | + env->fsr = def->fpu_version; | ||
3511 | +#if !defined(TARGET_SPARC64) | ||
3512 | + env->mmu_bm = def->mmu_bm; | ||
3513 | + env->mmuregs[0] |= def->mmu_version; | ||
3514 | + cpu_sparc_set_id(env, 0); | ||
3515 | +#endif | ||
3516 | + cpu_reset(env); | ||
3517 | + | ||
3518 | + return env; | ||
3519 | +} | ||
3520 | + | ||
3521 | +void cpu_sparc_set_id(CPUSPARCState *env, unsigned int cpu) | ||
3522 | +{ | ||
3523 | +#if !defined(TARGET_SPARC64) | ||
3524 | + env->mxccregs[7] = ((cpu + 8) & 0xf) << 24; | ||
3525 | +#endif | ||
3501 | } | 3526 | } |
3502 | 3527 | ||
3503 | static const sparc_def_t sparc_defs[] = { | 3528 | static const sparc_def_t sparc_defs[] = { |
@@ -3744,22 +3769,16 @@ static const sparc_def_t sparc_defs[] = { | @@ -3744,22 +3769,16 @@ static const sparc_def_t sparc_defs[] = { | ||
3744 | #endif | 3769 | #endif |
3745 | }; | 3770 | }; |
3746 | 3771 | ||
3747 | -int sparc_find_by_name(const unsigned char *name, const sparc_def_t **def) | 3772 | +static const sparc_def_t *cpu_sparc_find_by_name(const unsigned char *name) |
3748 | { | 3773 | { |
3749 | - int ret; | ||
3750 | unsigned int i; | 3774 | unsigned int i; |
3751 | 3775 | ||
3752 | - ret = -1; | ||
3753 | - *def = NULL; | ||
3754 | for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) { | 3776 | for (i = 0; i < sizeof(sparc_defs) / sizeof(sparc_def_t); i++) { |
3755 | if (strcasecmp(name, sparc_defs[i].name) == 0) { | 3777 | if (strcasecmp(name, sparc_defs[i].name) == 0) { |
3756 | - *def = &sparc_defs[i]; | ||
3757 | - ret = 0; | ||
3758 | - break; | 3778 | + return &sparc_defs[i]; |
3759 | } | 3779 | } |
3760 | } | 3780 | } |
3761 | - | ||
3762 | - return ret; | 3781 | + return NULL; |
3763 | } | 3782 | } |
3764 | 3783 | ||
3765 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | 3784 | void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) |
@@ -3775,19 +3794,6 @@ void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | @@ -3775,19 +3794,6 @@ void sparc_cpu_list (FILE *f, int (*cpu_fprintf)(FILE *f, const char *fmt, ...)) | ||
3775 | } | 3794 | } |
3776 | } | 3795 | } |
3777 | 3796 | ||
3778 | -int cpu_sparc_register (CPUSPARCState *env, const sparc_def_t *def, unsigned int cpu) | ||
3779 | -{ | ||
3780 | - env->version = def->iu_version; | ||
3781 | - env->fsr = def->fpu_version; | ||
3782 | -#if !defined(TARGET_SPARC64) | ||
3783 | - env->mmu_bm = def->mmu_bm; | ||
3784 | - env->mmuregs[0] |= def->mmu_version; | ||
3785 | - env->mxccregs[7] = ((cpu + 8) & 0xf) << 24; | ||
3786 | -#endif | ||
3787 | - cpu_reset(env); | ||
3788 | - return 0; | ||
3789 | -} | ||
3790 | - | ||
3791 | #define GET_FLAG(a,b) ((env->psr & a)?b:'-') | 3797 | #define GET_FLAG(a,b) ((env->psr & a)?b:'-') |
3792 | 3798 | ||
3793 | void cpu_dump_state(CPUState *env, FILE *f, | 3799 | void cpu_dump_state(CPUState *env, FILE *f, |
tests/qruncom.c
@@ -197,7 +197,7 @@ int main(int argc, char **argv) | @@ -197,7 +197,7 @@ int main(int argc, char **argv) | ||
197 | 197 | ||
198 | // cpu_set_log(CPU_LOG_TB_IN_ASM | CPU_LOG_TB_OUT_ASM | CPU_LOG_EXEC); | 198 | // cpu_set_log(CPU_LOG_TB_IN_ASM | CPU_LOG_TB_OUT_ASM | CPU_LOG_EXEC); |
199 | 199 | ||
200 | - env = cpu_init(); | 200 | + env = cpu_init("qemu32"); |
201 | 201 | ||
202 | /* disable code copy to simplify debugging */ | 202 | /* disable code copy to simplify debugging */ |
203 | code_copy_enabled = 0; | 203 | code_copy_enabled = 0; |