25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_ppc.c,v 1.62 2005/04/18 23:00:56 debug Exp $ |
* $Id: cpu_ppc.c,v 1.63 2005/06/26 22:23:42 debug Exp $ |
29 |
* |
* |
30 |
* PowerPC/POWER CPU emulation. |
* PowerPC/POWER CPU emulation. |
31 |
*/ |
*/ |
77 |
* ppc_cpu_new(): |
* ppc_cpu_new(): |
78 |
* |
* |
79 |
* Create a new PPC cpu object. |
* Create a new PPC cpu object. |
80 |
|
* |
81 |
|
* Returns 1 on success, 0 if there was no matching PPC processor with |
82 |
|
* this cpu_type_name. |
83 |
*/ |
*/ |
84 |
struct cpu *ppc_cpu_new(struct memory *mem, struct machine *machine, |
int ppc_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
85 |
int cpu_id, char *cpu_type_name) |
int cpu_id, char *cpu_type_name) |
86 |
{ |
{ |
|
struct cpu *cpu; |
|
87 |
int any_cache = 0; |
int any_cache = 0; |
88 |
int i, found; |
int i, found; |
89 |
struct ppc_cpu_type_def cpu_type_defs[] = PPC_CPU_TYPE_DEFS; |
struct ppc_cpu_type_def cpu_type_defs[] = PPC_CPU_TYPE_DEFS; |
99 |
i++; |
i++; |
100 |
} |
} |
101 |
if (found == -1) |
if (found == -1) |
102 |
return NULL; |
return 0; |
|
|
|
|
cpu = malloc(sizeof(struct cpu)); |
|
|
if (cpu == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
103 |
|
|
|
memset(cpu, 0, sizeof(struct cpu)); |
|
104 |
cpu->memory_rw = ppc_memory_rw; |
cpu->memory_rw = ppc_memory_rw; |
105 |
cpu->cd.ppc.cpu_type = cpu_type_defs[found]; |
cpu->cd.ppc.cpu_type = cpu_type_defs[found]; |
106 |
cpu->name = cpu->cd.ppc.cpu_type.name; |
cpu->name = cpu->cd.ppc.cpu_type.name; |
|
cpu->mem = mem; |
|
|
cpu->machine = machine; |
|
|
cpu->cpu_id = cpu_id; |
|
107 |
cpu->byte_order = EMUL_BIG_ENDIAN; |
cpu->byte_order = EMUL_BIG_ENDIAN; |
108 |
cpu->cd.ppc.mode = MODE_PPC; /* TODO */ |
cpu->cd.ppc.mode = MODE_PPC; /* TODO */ |
109 |
cpu->cd.ppc.of_emul_addr = 0xff000000; /* TODO */ |
cpu->cd.ppc.of_emul_addr = 0xff000000; /* TODO */ |
110 |
|
|
111 |
/* Current operating mode: */ |
/* Current operating mode: */ |
112 |
cpu->cd.ppc.bits = cpu->cd.ppc.cpu_type.bits; |
cpu->cd.ppc.bits = cpu->cd.ppc.cpu_type.bits; |
|
cpu->bootstrap_cpu_flag = 0; |
|
|
cpu->running = 0; |
|
113 |
|
|
114 |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
/* Only show name and caches etc for CPU nr 0 (in SMP machines): */ |
115 |
if (cpu_id == 0) { |
if (cpu_id == 0) { |
140 |
/* Some default stack pointer value. TODO: move this? */ |
/* Some default stack pointer value. TODO: move this? */ |
141 |
cpu->cd.ppc.gpr[1] = machine->physical_ram_in_mb * 1048576 - 4096; |
cpu->cd.ppc.gpr[1] = machine->physical_ram_in_mb * 1048576 - 4096; |
142 |
|
|
143 |
return cpu; |
return 1; |
144 |
} |
} |
145 |
|
|
146 |
|
|