25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_alpha.c,v 1.24 2006/12/30 13:30:53 debug Exp $ |
* $Id: cpu_alpha.c,v 1.25 2007/03/26 02:01:35 debug Exp $ |
29 |
* |
* |
30 |
* Alpha CPU emulation. |
* Alpha CPU emulation. |
31 |
* |
* |
195 |
} |
} |
196 |
|
|
197 |
|
|
|
static void add_response_word(struct cpu *cpu, char *r, uint64_t value, |
|
|
size_t maxlen, int len) |
|
|
{ |
|
|
char *format = (len == 4)? "%08"PRIx64 : "%016"PRIx64; |
|
|
if (len == 4) |
|
|
value &= 0xffffffffULL; |
|
|
if (cpu->byte_order == EMUL_LITTLE_ENDIAN) { |
|
|
if (len == 4) { |
|
|
value = ((value & 0xff) << 24) + |
|
|
((value & 0xff00) << 8) + |
|
|
((value & 0xff0000) >> 8) + |
|
|
((value & 0xff000000) >> 24); |
|
|
} else { |
|
|
value = ((value & 0xff) << 56) + |
|
|
((value & 0xff00) << 40) + |
|
|
((value & 0xff0000) << 24) + |
|
|
((value & 0xff000000ULL) << 8) + |
|
|
((value & 0xff00000000ULL) >> 8) + |
|
|
((value & 0xff0000000000ULL) >> 24) + |
|
|
((value & 0xff000000000000ULL) >> 40) + |
|
|
((value & 0xff00000000000000ULL) >> 56); |
|
|
} |
|
|
} |
|
|
snprintf(r + strlen(r), maxlen - strlen(r), format, (uint64_t)value); |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* alpha_cpu_gdb_stub(): |
|
|
* |
|
|
* Execute a "remote GDB" command. Returns a newly allocated response string |
|
|
* on success, NULL on failure. |
|
|
*/ |
|
|
char *alpha_cpu_gdb_stub(struct cpu *cpu, char *cmd) |
|
|
{ |
|
|
if (strcmp(cmd, "g") == 0) { |
|
|
int i; |
|
|
char *r; |
|
|
size_t wlen = cpu->is_32bit? |
|
|
sizeof(uint32_t) : sizeof(uint64_t); |
|
|
size_t len = 1 + 76 * wlen; |
|
|
r = malloc(len); |
|
|
if (r == NULL) { |
|
|
fprintf(stderr, "out of memory\n"); |
|
|
exit(1); |
|
|
} |
|
|
r[0] = '\0'; |
|
|
for (i=0; i<128; i++) |
|
|
add_response_word(cpu, r, i, len, wlen); |
|
|
return r; |
|
|
} |
|
|
|
|
|
if (cmd[0] == 'p') { |
|
|
int regnr = strtol(cmd + 1, NULL, 16); |
|
|
size_t wlen = cpu->is_32bit? |
|
|
sizeof(uint32_t) : sizeof(uint64_t); |
|
|
size_t len = 2 * wlen + 1; |
|
|
char *r = malloc(len); |
|
|
r[0] = '\0'; |
|
|
if (regnr >= 0 && regnr <= 31) { |
|
|
add_response_word(cpu, r, |
|
|
cpu->cd.alpha.r[regnr], len, wlen); |
|
|
} else if (regnr >= 32 && regnr <= 62) { |
|
|
add_response_word(cpu, r, |
|
|
cpu->cd.alpha.f[regnr - 32], len, wlen); |
|
|
} else if (regnr == 0x3f) { |
|
|
add_response_word(cpu, r, cpu->cd.alpha.fpcr, |
|
|
len, wlen); |
|
|
} else if (regnr == 0x40) { |
|
|
add_response_word(cpu, r, cpu->pc, len, wlen); |
|
|
} else { |
|
|
/* Unimplemented: */ |
|
|
add_response_word(cpu, r, 0xcc000 + regnr, len, wlen); |
|
|
} |
|
|
return r; |
|
|
} |
|
|
|
|
|
fatal("alpha_cpu_gdb_stub(): TODO\n"); |
|
|
return NULL; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* alpha_cpu_interrupt(): |
|
|
*/ |
|
|
int alpha_cpu_interrupt(struct cpu *cpu, uint64_t irq_nr) |
|
|
{ |
|
|
fatal("alpha_cpu_interrupt(): TODO\n"); |
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
|
/* |
|
|
* alpha_cpu_interrupt_ack(): |
|
|
*/ |
|
|
int alpha_cpu_interrupt_ack(struct cpu *cpu, uint64_t irq_nr) |
|
|
{ |
|
|
/* fatal("alpha_cpu_interrupt_ack(): TODO\n"); */ |
|
|
return 0; |
|
|
} |
|
|
|
|
|
|
|
198 |
/* |
/* |
199 |
* alpha_print_imm16_disp(): |
* alpha_print_imm16_disp(): |
200 |
* |
* |