25 |
* SUCH DAMAGE. |
* SUCH DAMAGE. |
26 |
* |
* |
27 |
* |
* |
28 |
* $Id: emul.c,v 1.247 2006/02/04 12:27:12 debug Exp $ |
* $Id: emul.c,v 1.254 2006/06/22 13:22:40 debug Exp $ |
29 |
* |
* |
30 |
* Emulation startup and misc. routines. |
* Emulation startup and misc. routines. |
31 |
*/ |
*/ |
39 |
#include <unistd.h> |
#include <unistd.h> |
40 |
|
|
41 |
#include "arcbios.h" |
#include "arcbios.h" |
|
#include "bintrans.h" |
|
42 |
#include "cpu.h" |
#include "cpu.h" |
43 |
#include "emul.h" |
#include "emul.h" |
44 |
#include "console.h" |
#include "console.h" |
104 |
uint64_t addr; |
uint64_t addr; |
105 |
int res = get_symbol_addr(&m->symbol_context, |
int res = get_symbol_addr(&m->symbol_context, |
106 |
m->breakpoint_string[i], &addr); |
m->breakpoint_string[i], &addr); |
107 |
if (!res) |
if (!res) { |
108 |
fprintf(stderr, |
fprintf(stderr, |
109 |
"WARNING! Breakpoint '%s' could not be" |
"ERROR! Breakpoint '%s' could not be" |
110 |
" parsed\n", |
" parsed\n", |
111 |
m->breakpoint_string[i]); |
m->breakpoint_string[i]); |
112 |
else { |
} else { |
113 |
dp = addr; |
dp = addr; |
114 |
string_flag = 1; |
string_flag = 1; |
115 |
} |
} |
939 |
if (m->arch == ARCH_ALPHA) |
if (m->arch == ARCH_ALPHA) |
940 |
m->arch_pagesize = 8192; |
m->arch_pagesize = 8192; |
941 |
|
|
|
if (m->arch != ARCH_MIPS) |
|
|
m->bintrans_enable = 0; |
|
|
|
|
942 |
machine_memsize_fix(m); |
machine_memsize_fix(m); |
943 |
|
|
944 |
/* |
/* |
986 |
} |
} |
987 |
memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus); |
memset(m->cpus, 0, sizeof(struct cpu *) * m->ncpus); |
988 |
|
|
|
/* Initialize dynamic binary translation, if available: */ |
|
|
if (m->bintrans_enable) |
|
|
bintrans_init(m, m->memory); |
|
|
|
|
989 |
debug("cpu0"); |
debug("cpu0"); |
990 |
if (m->ncpus > 1) |
if (m->ncpus > 1) |
991 |
debug(" .. cpu%i", m->ncpus - 1); |
debug(" .. cpu%i", m->ncpus - 1); |
992 |
debug(": "); |
debug(": "); |
993 |
for (i=0; i<m->ncpus; i++) { |
for (i=0; i<m->ncpus; i++) { |
994 |
m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name); |
m->cpus[i] = cpu_new(m->memory, m, i, m->cpu_name); |
995 |
if (m->bintrans_enable) |
if (m->cpus[i] == NULL) { |
996 |
bintrans_init_cpu(m->cpus[i]); |
fprintf(stderr, "Unable to create CPU object. " |
997 |
|
"Aborting."); |
998 |
|
exit(1); |
999 |
|
} |
1000 |
} |
} |
1001 |
debug("\n"); |
debug("\n"); |
1002 |
|
|
1007 |
m->cpus[m->ncpus] = cpu_new(m->memory, m, |
m->cpus[m->ncpus] = cpu_new(m->memory, m, |
1008 |
0 /* use 0 here to show info with debug() */, |
0 /* use 0 here to show info with debug() */, |
1009 |
"Allegrex" /* TODO */); |
"Allegrex" /* TODO */); |
|
if (m->bintrans_enable) |
|
|
bintrans_init_cpu(m->cpus[m->ncpus]); |
|
1010 |
debug("\n"); |
debug("\n"); |
1011 |
m->ncpus ++; |
m->ncpus ++; |
1012 |
} |
} |
1348 |
|
|
1349 |
symbol_recalc_sizes(&m->symbol_context); |
symbol_recalc_sizes(&m->symbol_context); |
1350 |
|
|
|
if (m->max_random_cycles_per_chunk > 0) |
|
|
debug("using random cycle chunks (1 to %i cycles)\n", |
|
|
m->max_random_cycles_per_chunk); |
|
|
|
|
1351 |
/* Special hack for ARC/SGI emulation: */ |
/* Special hack for ARC/SGI emulation: */ |
1352 |
if ((m->machine_type == MACHINE_ARC || |
if ((m->machine_type == MACHINE_ARC || |
1353 |
m->machine_type == MACHINE_SGI) && m->prom_emulation) |
m->machine_type == MACHINE_SGI) && m->prom_emulation) |
1482 |
{ |
{ |
1483 |
int iadd = DEBUG_INDENTATION; |
int iadd = DEBUG_INDENTATION; |
1484 |
struct emul *e = emul_new(fname); |
struct emul *e = emul_new(fname); |
|
FILE *f; |
|
|
char buf[128]; |
|
|
size_t len; |
|
1485 |
|
|
1486 |
debug("Creating emulation from configfile \"%s\":\n", fname); |
debug("Creating emulation from configfile \"%s\":\n", fname); |
1487 |
debug_indentation(iadd); |
debug_indentation(iadd); |
1488 |
|
|
1489 |
f = fopen(fname, "r"); |
emul_parse_config(e, fname); |
|
if (f == NULL) { |
|
|
perror(fname); |
|
|
exit(1); |
|
|
} |
|
|
|
|
|
/* Read header: (must be !!gxemul) */ |
|
|
len = fread(buf, 1, 8, f); |
|
|
if (len != 8 || strncmp(buf, "!!gxemul", 8) != 0) { |
|
|
fprintf(stderr, "%s: must start with '!!gxemul'\n", fname); |
|
|
exit(1); |
|
|
} |
|
1490 |
|
|
|
/* Restart from beginning: */ |
|
|
rewind(f); |
|
|
|
|
|
emul_parse_config(e, f); |
|
|
|
|
|
fclose(f); |
|
1491 |
debug_indentation(-iadd); |
debug_indentation(-iadd); |
1492 |
return e; |
return e; |
1493 |
} |
} |
1585 |
continue; |
continue; |
1586 |
|
|
1587 |
for (j=0; j<e->n_machines; j++) { |
for (j=0; j<e->n_machines; j++) { |
1588 |
|
if (e->machines[j]->gdb.port > 0) |
1589 |
|
debugger_gdb_check_incoming( |
1590 |
|
e->machines[j]); |
1591 |
|
|
1592 |
/* TODO: cpu_run() is a strange name, since |
/* TODO: cpu_run() is a strange name, since |
1593 |
there can be multiple cpus in a machine */ |
there can be multiple cpus in a machine */ |
1594 |
anything = cpu_run(e, e->machines[j]); |
anything = cpu_run(e, e->machines[j]); |