Revision c227f099 target-ppc/translate_init.c
b/target-ppc/translate_init.c | ||
---|---|---|
32 | 32 |
#define TODO_USER_ONLY 1 |
33 | 33 |
#endif |
34 | 34 |
|
35 |
struct ppc_def { |
|
35 |
struct ppc_def_t {
|
|
36 | 36 |
const char *name; |
37 | 37 |
uint32_t pvr; |
38 | 38 |
uint32_t svr; |
39 | 39 |
uint64_t insns_flags; |
40 | 40 |
uint64_t msr_mask; |
41 |
e_powerpc_mmu mmu_model;
|
|
42 |
e_powerpc_excp excp_model;
|
|
43 |
e_powerpc_input bus_model;
|
|
41 |
powerpc_mmu_t mmu_model;
|
|
42 |
powerpc_excp_t excp_model;
|
|
43 |
powerpc_input_t bus_model;
|
|
44 | 44 |
uint32_t flags; |
45 | 45 |
int bfd_mach; |
46 | 46 |
void (*init_proc)(CPUPPCState *env); |
... | ... | |
531 | 531 |
target_ulong initial_value) |
532 | 532 |
#endif |
533 | 533 |
{ |
534 |
a_ppc_spr *spr;
|
|
534 |
ppc_spr_t *spr;
|
|
535 | 535 |
|
536 | 536 |
spr = &env->spr_cb[num]; |
537 | 537 |
if (spr->name != NULL ||env-> spr[num] != 0x00000000 || |
... | ... | |
7228 | 7228 |
#define POWERPC_DEF(_name, _pvr, _type) \ |
7229 | 7229 |
POWERPC_DEF_SVR(_name, _pvr, POWERPC_SVR_NONE, _type) |
7230 | 7230 |
|
7231 |
static const a_ppc_def ppc_defs[] = {
|
|
7231 |
static const ppc_def_t ppc_defs[] = {
|
|
7232 | 7232 |
/* Embedded PowerPC */ |
7233 | 7233 |
/* PowerPC 401 family */ |
7234 | 7234 |
/* Generic PowerPC 401 */ |
... | ... | |
8882 | 8882 |
|
8883 | 8883 |
/*****************************************************************************/ |
8884 | 8884 |
/* Generic CPU instanciation routine */ |
8885 |
static void init_ppc_proc (CPUPPCState *env, const a_ppc_def *def)
|
|
8885 |
static void init_ppc_proc (CPUPPCState *env, const ppc_def_t *def)
|
|
8886 | 8886 |
{ |
8887 | 8887 |
#if !defined(CONFIG_USER_ONLY) |
8888 | 8888 |
int i; |
... | ... | |
9022 | 9022 |
int nb_tlb = env->nb_tlb; |
9023 | 9023 |
if (env->id_tlbs != 0) |
9024 | 9024 |
nb_tlb *= 2; |
9025 |
env->tlb = qemu_mallocz(nb_tlb * sizeof(union ppc_tlb));
|
|
9025 |
env->tlb = qemu_mallocz(nb_tlb * sizeof(ppc_tlb_t));
|
|
9026 | 9026 |
/* Pre-compute some useful values */ |
9027 | 9027 |
env->tlb_per_way = env->nb_tlb / env->nb_ways; |
9028 | 9028 |
} |
... | ... | |
9093 | 9093 |
return ((unsigned long)handler & 0x03) == PPC_INDIRECT; |
9094 | 9094 |
} |
9095 | 9095 |
|
9096 |
static inline an_opc_handler **ind_table(void *handler)
|
|
9096 |
static inline opc_handler_t **ind_table(void *handler)
|
|
9097 | 9097 |
{ |
9098 |
return (an_opc_handler **)((unsigned long)handler & ~3);
|
|
9098 |
return (opc_handler_t **)((unsigned long)handler & ~3);
|
|
9099 | 9099 |
} |
9100 | 9100 |
|
9101 | 9101 |
/* Instruction table creation */ |
9102 | 9102 |
/* Opcodes tables creation */ |
9103 |
static void fill_new_table (an_opc_handler **table, int len)
|
|
9103 |
static void fill_new_table (opc_handler_t **table, int len)
|
|
9104 | 9104 |
{ |
9105 | 9105 |
int i; |
9106 | 9106 |
|
... | ... | |
9108 | 9108 |
table[i] = &invalid_handler; |
9109 | 9109 |
} |
9110 | 9110 |
|
9111 |
static int create_new_table (an_opc_handler **table, unsigned char idx)
|
|
9111 |
static int create_new_table (opc_handler_t **table, unsigned char idx)
|
|
9112 | 9112 |
{ |
9113 |
an_opc_handler **tmp;
|
|
9113 |
opc_handler_t **tmp;
|
|
9114 | 9114 |
|
9115 |
tmp = malloc(0x20 * sizeof(an_opc_handler));
|
|
9115 |
tmp = malloc(0x20 * sizeof(opc_handler_t));
|
|
9116 | 9116 |
fill_new_table(tmp, 0x20); |
9117 |
table[idx] = (an_opc_handler *)((unsigned long)tmp | PPC_INDIRECT);
|
|
9117 |
table[idx] = (opc_handler_t *)((unsigned long)tmp | PPC_INDIRECT);
|
|
9118 | 9118 |
|
9119 | 9119 |
return 0; |
9120 | 9120 |
} |
9121 | 9121 |
|
9122 |
static int insert_in_table (an_opc_handler **table, unsigned char idx,
|
|
9123 |
an_opc_handler *handler)
|
|
9122 |
static int insert_in_table (opc_handler_t **table, unsigned char idx,
|
|
9123 |
opc_handler_t *handler)
|
|
9124 | 9124 |
{ |
9125 | 9125 |
if (table[idx] != &invalid_handler) |
9126 | 9126 |
return -1; |
... | ... | |
9129 | 9129 |
return 0; |
9130 | 9130 |
} |
9131 | 9131 |
|
9132 |
static int register_direct_insn (an_opc_handler **ppc_opcodes,
|
|
9133 |
unsigned char idx, an_opc_handler *handler)
|
|
9132 |
static int register_direct_insn (opc_handler_t **ppc_opcodes,
|
|
9133 |
unsigned char idx, opc_handler_t *handler)
|
|
9134 | 9134 |
{ |
9135 | 9135 |
if (insert_in_table(ppc_opcodes, idx, handler) < 0) { |
9136 | 9136 |
printf("*** ERROR: opcode %02x already assigned in main " |
... | ... | |
9145 | 9145 |
return 0; |
9146 | 9146 |
} |
9147 | 9147 |
|
9148 |
static int register_ind_in_table (an_opc_handler **table,
|
|
9148 |
static int register_ind_in_table (opc_handler_t **table,
|
|
9149 | 9149 |
unsigned char idx1, unsigned char idx2, |
9150 |
an_opc_handler *handler)
|
|
9150 |
opc_handler_t *handler)
|
|
9151 | 9151 |
{ |
9152 | 9152 |
if (table[idx1] == &invalid_handler) { |
9153 | 9153 |
if (create_new_table(table, idx1) < 0) { |
... | ... | |
9180 | 9180 |
return 0; |
9181 | 9181 |
} |
9182 | 9182 |
|
9183 |
static int register_ind_insn (an_opc_handler **ppc_opcodes,
|
|
9183 |
static int register_ind_insn (opc_handler_t **ppc_opcodes,
|
|
9184 | 9184 |
unsigned char idx1, unsigned char idx2, |
9185 |
an_opc_handler *handler)
|
|
9185 |
opc_handler_t *handler)
|
|
9186 | 9186 |
{ |
9187 | 9187 |
int ret; |
9188 | 9188 |
|
... | ... | |
9191 | 9191 |
return ret; |
9192 | 9192 |
} |
9193 | 9193 |
|
9194 |
static int register_dblind_insn (an_opc_handler **ppc_opcodes,
|
|
9194 |
static int register_dblind_insn (opc_handler_t **ppc_opcodes,
|
|
9195 | 9195 |
unsigned char idx1, unsigned char idx2, |
9196 |
unsigned char idx3, an_opc_handler *handler)
|
|
9196 |
unsigned char idx3, opc_handler_t *handler)
|
|
9197 | 9197 |
{ |
9198 | 9198 |
if (register_ind_in_table(ppc_opcodes, idx1, idx2, NULL) < 0) { |
9199 | 9199 |
printf("*** ERROR: unable to join indirect table idx " |
... | ... | |
9210 | 9210 |
return 0; |
9211 | 9211 |
} |
9212 | 9212 |
|
9213 |
static int register_insn (an_opc_handler **ppc_opcodes, an_opcode *insn)
|
|
9213 |
static int register_insn (opc_handler_t **ppc_opcodes, opcode_t *insn)
|
|
9214 | 9214 |
{ |
9215 | 9215 |
if (insn->opc2 != 0xFF) { |
9216 | 9216 |
if (insn->opc3 != 0xFF) { |
... | ... | |
9230 | 9230 |
return 0; |
9231 | 9231 |
} |
9232 | 9232 |
|
9233 |
static int test_an_opcodeable (an_opc_handler **table, int len)
|
|
9233 |
static int test_opcode_table (opc_handler_t **table, int len)
|
|
9234 | 9234 |
{ |
9235 | 9235 |
int i, count, tmp; |
9236 | 9236 |
|
... | ... | |
9240 | 9240 |
table[i] = &invalid_handler; |
9241 | 9241 |
if (table[i] != &invalid_handler) { |
9242 | 9242 |
if (is_indirect_opcode(table[i])) { |
9243 |
tmp = test_an_opcodeable(ind_table(table[i]), 0x20);
|
|
9243 |
tmp = test_opcode_table(ind_table(table[i]), 0x20);
|
|
9244 | 9244 |
if (tmp == 0) { |
9245 | 9245 |
free(table[i]); |
9246 | 9246 |
table[i] = &invalid_handler; |
... | ... | |
9256 | 9256 |
return count; |
9257 | 9257 |
} |
9258 | 9258 |
|
9259 |
static void fix_an_opcodeables (an_opc_handler **ppc_opcodes)
|
|
9259 |
static void fix_opcode_tables (opc_handler_t **ppc_opcodes)
|
|
9260 | 9260 |
{ |
9261 |
if (test_an_opcodeable(ppc_opcodes, 0x40) == 0)
|
|
9261 |
if (test_opcode_table(ppc_opcodes, 0x40) == 0)
|
|
9262 | 9262 |
printf("*** WARNING: no opcode defined !\n"); |
9263 | 9263 |
} |
9264 | 9264 |
|
9265 | 9265 |
/*****************************************************************************/ |
9266 |
static int create_ppc_opcodes (CPUPPCState *env, const a_ppc_def *def)
|
|
9266 |
static int create_ppc_opcodes (CPUPPCState *env, const ppc_def_t *def)
|
|
9267 | 9267 |
{ |
9268 |
an_opcode *opc;
|
|
9268 |
opcode_t *opc;
|
|
9269 | 9269 |
|
9270 | 9270 |
fill_new_table(env->opcodes, 0x40); |
9271 | 9271 |
for (opc = opcodes; opc < &opcodes[ARRAY_SIZE(opcodes)]; opc++) { |
... | ... | |
9278 | 9278 |
} |
9279 | 9279 |
} |
9280 | 9280 |
} |
9281 |
fix_an_opcodeables(env->opcodes);
|
|
9281 |
fix_opcode_tables(env->opcodes);
|
|
9282 | 9282 |
fflush(stdout); |
9283 | 9283 |
fflush(stderr); |
9284 | 9284 |
|
... | ... | |
9288 | 9288 |
#if defined(PPC_DUMP_CPU) |
9289 | 9289 |
static void dump_ppc_insns (CPUPPCState *env) |
9290 | 9290 |
{ |
9291 |
an_opc_handler **table, *handler;
|
|
9291 |
opc_handler_t **table, *handler;
|
|
9292 | 9292 |
const char *p, *q; |
9293 | 9293 |
uint8_t opc1, opc2, opc3; |
9294 | 9294 |
|
... | ... | |
9475 | 9475 |
return 0; |
9476 | 9476 |
} |
9477 | 9477 |
|
9478 |
int cpu_ppc_register_internal (CPUPPCState *env, const a_ppc_def *def)
|
|
9478 |
int cpu_ppc_register_internal (CPUPPCState *env, const ppc_def_t *def)
|
|
9479 | 9479 |
{ |
9480 | 9480 |
env->msr_mask = def->msr_mask; |
9481 | 9481 |
env->mmu_model = def->mmu_model; |
... | ... | |
9667 | 9667 |
return 0; |
9668 | 9668 |
} |
9669 | 9669 |
|
9670 |
static const a_ppc_def *ppc_find_by_pvr (uint32_t pvr)
|
|
9670 |
static const ppc_def_t *ppc_find_by_pvr (uint32_t pvr)
|
|
9671 | 9671 |
{ |
9672 |
const a_ppc_def *ret;
|
|
9672 |
const ppc_def_t *ret;
|
|
9673 | 9673 |
uint32_t pvr_rev; |
9674 | 9674 |
int i, best, match, best_match, max; |
9675 | 9675 |
|
... | ... | |
9707 | 9707 |
|
9708 | 9708 |
#include <ctype.h> |
9709 | 9709 |
|
9710 |
const a_ppc_def *cpu_ppc_find_by_name (const char *name)
|
|
9710 |
const ppc_def_t *cpu_ppc_find_by_name (const char *name)
|
|
9711 | 9711 |
{ |
9712 |
const a_ppc_def *ret;
|
|
9712 |
const ppc_def_t *ret;
|
|
9713 | 9713 |
const char *p; |
9714 | 9714 |
int i, max, len; |
9715 | 9715 |
|
Also available in: Unified diff