1 |
/* |
/* |
2 |
* Copyright (C) 2005 Anders Gavare. All rights reserved. |
* Copyright (C) 2005-2006 Anders Gavare. All rights reserved. |
3 |
* |
* |
4 |
* Redistribution and use in source and binary forms, with or without |
* Redistribution and use in source and binary forms, with or without |
5 |
* modification, are permitted provided that the following conditions are met: |
* modification, are permitted provided that the following conditions are met: |
25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_ia64.c,v 1.1 2005/08/29 14:36:41 debug Exp $ |
* $Id: cpu_ia64.c,v 1.14 2006/09/19 10:50:08 debug Exp $ |
29 |
* |
* |
30 |
* IA64 CPU emulation. |
* IA64 CPU emulation. |
31 |
* |
* |
41 |
#include "machine.h" |
#include "machine.h" |
42 |
#include "memory.h" |
#include "memory.h" |
43 |
#include "misc.h" |
#include "misc.h" |
44 |
|
#include "settings.h" |
45 |
#include "symbol.h" |
#include "symbol.h" |
46 |
|
|
47 |
#include "tmp_ia64_head.c" |
#include "tmp_ia64_head.c" |
56 |
int ia64_cpu_new(struct cpu *cpu, struct memory *mem, |
int ia64_cpu_new(struct cpu *cpu, struct memory *mem, |
57 |
struct machine *machine, int cpu_id, char *cpu_type_name) |
struct machine *machine, int cpu_id, char *cpu_type_name) |
58 |
{ |
{ |
|
int i; |
|
|
|
|
59 |
if (strcasecmp(cpu_type_name, "IA64") != 0) |
if (strcasecmp(cpu_type_name, "IA64") != 0) |
60 |
return 0; |
return 0; |
61 |
|
|
62 |
|
cpu->run_instr = ia64_run_instr; |
63 |
cpu->memory_rw = ia64_memory_rw; |
cpu->memory_rw = ia64_memory_rw; |
64 |
cpu->update_translation_table = ia64_update_translation_table; |
cpu->update_translation_table = ia64_update_translation_table; |
65 |
cpu->invalidate_translation_caches_paddr = |
cpu->invalidate_translation_caches = |
66 |
ia64_invalidate_translation_caches_paddr; |
ia64_invalidate_translation_caches; |
67 |
cpu->invalidate_code_translation = ia64_invalidate_code_translation; |
cpu->invalidate_code_translation = ia64_invalidate_code_translation; |
68 |
cpu->is_32bit = 0; |
cpu->is_32bit = 0; |
69 |
|
|
72 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
73 |
} |
} |
74 |
|
|
75 |
/* Create the default virtual->physical->host translation: */ |
/* Add all register names to the settings: */ |
76 |
cpu->cd.ia64.vph_default_page = malloc(sizeof(struct ia64_vph_page)); |
CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); |
|
if (cpu->cd.ia64.vph_default_page == NULL) { |
|
|
fprintf(stderr, "out of memory in ia64_cpu_new()\n"); |
|
|
exit(1); |
|
|
} |
|
|
memset(cpu->cd.ia64.vph_default_page, 0, sizeof(struct ia64_vph_page)); |
|
|
for (i=0; i<IA64_LEVEL0; i++) |
|
|
cpu->cd.ia64.vph_table0[i] = cpu->cd.ia64.vph_table0_kernel[i] |
|
|
= cpu->cd.ia64.vph_default_page; |
|
77 |
|
|
78 |
return 1; |
return 1; |
79 |
} |
} |
103 |
|
|
104 |
|
|
105 |
/* |
/* |
|
* ia64_cpu_register_match(): |
|
|
*/ |
|
|
void ia64_cpu_register_match(struct machine *m, char *name, |
|
|
int writeflag, uint64_t *valuep, int *match_register) |
|
|
{ |
|
|
int cpunr = 0; |
|
|
|
|
|
/* CPU number: */ |
|
|
|
|
|
/* TODO */ |
|
|
|
|
|
if (strcasecmp(name, "pc") == 0) { |
|
|
if (writeflag) { |
|
|
m->cpus[cpunr]->pc = *valuep; |
|
|
} else |
|
|
*valuep = m->cpus[cpunr]->pc; |
|
|
*match_register = 1; |
|
|
} |
|
|
|
|
|
/* TODO */ |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
106 |
* ia64_cpu_register_dump(): |
* ia64_cpu_register_dump(): |
107 |
* |
* |
108 |
* Dump cpu registers in a relatively readable format. |
* Dump cpu registers in a relatively readable format. |
119 |
if (gprs) { |
if (gprs) { |
120 |
symbol = get_symbol_name(&cpu->machine->symbol_context, |
symbol = get_symbol_name(&cpu->machine->symbol_context, |
121 |
cpu->pc, &offset); |
cpu->pc, &offset); |
122 |
debug("cpu%i:\t pc = 0x%016llx", x, (long long)cpu->pc); |
debug("cpu%i:\t pc = 0x%016"PRIx64, x, (uint64_t)cpu->pc); |
123 |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
debug(" <%s>\n", symbol != NULL? symbol : " no symbol "); |
124 |
|
|
125 |
/* TODO */ |
/* TODO */ |
128 |
|
|
129 |
|
|
130 |
/* |
/* |
131 |
* ia64_cpu_show_full_statistics(): |
* mips_cpu_tlbdump(): |
132 |
|
* |
133 |
|
* Called from the debugger to dump the TLB in a readable format. |
134 |
|
* x is the cpu number to dump, or -1 to dump all CPUs. |
135 |
* |
* |
136 |
* Show detailed statistics on opcode usage on each cpu. |
* If rawflag is nonzero, then the TLB contents isn't formated nicely, |
137 |
|
* just dumped. |
138 |
*/ |
*/ |
139 |
void ia64_cpu_show_full_statistics(struct machine *m) |
void ia64_cpu_tlbdump(struct machine *m, int x, int rawflag) |
140 |
{ |
{ |
|
fatal("ia64_cpu_show_full_statistics(): TODO\n"); |
|
141 |
} |
} |
142 |
|
|
143 |
|
|
144 |
/* |
/* |
145 |
* ia64_cpu_tlbdump(): |
* ia64_cpu_gdb_stub(): |
146 |
* |
* |
147 |
* Called from the debugger to dump the TLB in a readable format. |
* Execute a "remote GDB" command. Returns a newly allocated response string |
148 |
* x is the cpu number to dump, or -1 to dump all CPUs. |
* on success, NULL on failure. |
|
* |
|
|
* If rawflag is nonzero, then the TLB contents isn't formated nicely, |
|
|
* just dumped. |
|
149 |
*/ |
*/ |
150 |
void ia64_cpu_tlbdump(struct machine *m, int x, int rawflag) |
char *ia64_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
151 |
{ |
{ |
152 |
fatal("ia64_cpu_tlbdump(): TODO\n"); |
fatal("ia64_cpu_gdb_stub(): TODO\n"); |
153 |
|
return NULL; |
154 |
} |
} |
155 |
|
|
156 |
|
|
187 |
* cpu->pc for relative addresses. |
* cpu->pc for relative addresses. |
188 |
*/ |
*/ |
189 |
int ia64_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
int ia64_cpu_disassemble_instr(struct cpu *cpu, unsigned char *ib, |
190 |
int running, uint64_t dumpaddr, int bintrans) |
int running, uint64_t dumpaddr) |
191 |
{ |
{ |
192 |
uint64_t offset; |
uint64_t offset; |
193 |
char *symbol; |
char *symbol; |
203 |
if (cpu->machine->ncpus > 1 && running) |
if (cpu->machine->ncpus > 1 && running) |
204 |
debug("cpu%i:\t", cpu->cpu_id); |
debug("cpu%i:\t", cpu->cpu_id); |
205 |
|
|
206 |
debug("%016llx: ", (long long)dumpaddr); |
debug("%016"PRIx64": ", (uint64_t) dumpaddr); |
207 |
|
|
208 |
debug("TODO\n"); |
debug("TODO\n"); |
209 |
|
|