25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: cpu_avr.c,v 1.20 2006/07/16 13:32:26 debug Exp $ |
* $Id: cpu_avr.c,v 1.21 2006/09/19 10:50:08 debug Exp $ |
29 |
* |
* |
30 |
* Atmel AVR (8-bit) CPU emulation. |
* Atmel AVR (8-bit) CPU emulation. |
31 |
*/ |
*/ |
39 |
#include "machine.h" |
#include "machine.h" |
40 |
#include "memory.h" |
#include "memory.h" |
41 |
#include "misc.h" |
#include "misc.h" |
42 |
|
#include "settings.h" |
43 |
#include "symbol.h" |
#include "symbol.h" |
44 |
|
|
45 |
|
|
59 |
int avr_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
int avr_cpu_new(struct cpu *cpu, struct memory *mem, struct machine *machine, |
60 |
int cpu_id, char *cpu_type_name) |
int cpu_id, char *cpu_type_name) |
61 |
{ |
{ |
62 |
int type = 0; |
int type = 0, i; |
63 |
|
|
64 |
if (strcasecmp(cpu_type_name, "AVR") == 0 || |
if (strcasecmp(cpu_type_name, "AVR") == 0 || |
65 |
strcasecmp(cpu_type_name, "AVR16") == 0 || |
strcasecmp(cpu_type_name, "AVR16") == 0 || |
93 |
debug("%s", cpu->name); |
debug("%s", cpu->name); |
94 |
} |
} |
95 |
|
|
96 |
|
CPU_SETTINGS_ADD_REGISTER64("pc", cpu->pc); |
97 |
|
CPU_SETTINGS_ADD_REGISTER16("sp", cpu->cd.avr.sp); |
98 |
|
CPU_SETTINGS_ADD_REGISTER8("sreg", cpu->cd.avr.sreg); |
99 |
|
for (i=0; i<N_AVR_REGS; i++) { |
100 |
|
char tmpstr[5]; |
101 |
|
snprintf(tmpstr, sizeof(tmpstr), "r%i", i); |
102 |
|
CPU_SETTINGS_ADD_REGISTER8(tmpstr, cpu->cd.avr.r[i]); |
103 |
|
} |
104 |
|
|
105 |
return 1; |
return 1; |
106 |
} |
} |
107 |
|
|
165 |
int r = (i >> 3) + ((i & 7) << 2); |
int r = (i >> 3) + ((i & 7) << 2); |
166 |
if ((i % 8) == 0) |
if ((i % 8) == 0) |
167 |
debug("cpu%i:", x); |
debug("cpu%i:", x); |
168 |
debug(" r%02i=0x%02x", r, cpu->cd.avr.r[r]); |
debug(" r%-2i=0x%02x", r, cpu->cd.avr.r[r]); |
169 |
if ((i % 8) == 7) |
if ((i % 8) == 7) |
170 |
debug("\n"); |
debug("\n"); |
171 |
} |
} |
184 |
} |
} |
185 |
|
|
186 |
|
|
|
/* |
|
|
* avr_cpu_register_match(): |
|
|
*/ |
|
|
void avr_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; |
|
|
} else if (name[0] == 'r' && isdigit((int)name[1])) { |
|
|
int nr = atoi(name + 1); |
|
|
if (nr >= 0 && nr < N_AVR_REGS) { |
|
|
if (writeflag) |
|
|
m->cpus[cpunr]->cd.avr.r[nr] = *valuep; |
|
|
else |
|
|
*valuep = m->cpus[cpunr]->cd.avr.r[nr]; |
|
|
*match_register = 1; |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
187 |
/* |
/* |
188 |
* avr_cpu_tlbdump(): |
* avr_cpu_tlbdump(): |
189 |
* |
* |