cl_ticker::dump(int nr, double xtal, class cl_console *con)
{
con->dd_printf("timer #%d(\"%s\") %s%s: %g sec (%lu clks)\n",
- nr, get_name("unnamed"),
- (options&TICK_RUN)?"ON":"OFF",
- (options&TICK_INISR)?",ISR":"",
- get_rtime(xtal), ticks);
+ nr, get_name("unnamed"),
+ (options&TICK_RUN)?"ON":"OFF",
+ (options&TICK_INISR)?",ISR":"",
+ get_rtime(xtal), ticks);
}
char *fname= (char *)(sim->app->in_files->at(i));
long l;
if ((l= read_hex_file(fname)) >= 0)
- {
- sim->app->get_commander()->all_printf("%ld words read from %s\n",
- l, fname);
- }
+ {
+ sim->app->get_commander()->all_printf("%ld words read from %s\n",
+ l, fname);
+ }
}
return(0);
}
/*FIXME should we clear user counters?*/
il= (class it_level *)(it_levels->top());
while (il &&
- il->level >= 0)
+ il->level >= 0)
{
il= (class it_level *)(it_levels->pop());
delete il;
{
class cl_address_space *m= (cl_address_space *)(address_spaces->at(i));
if (!m ||
- !m->have_real_name())
- continue;
+ !m->have_real_name())
+ continue;
if (m->is_inamed(id))
- return(m);
+ return(m);
}
return(0);
}
{
class cl_memory *m= (cl_memory *)(address_spaces->at(i));
if (!m ||
- !m->have_real_name())
- continue;
+ !m->have_real_name())
+ continue;
if (m->is_inamed(id))
- return(m);
+ return(m);
}
for (i= 0; i < memchips->count; i++)
{
class cl_memory *m= (cl_memory *)(memchips->at(i));
if (!m ||
- !m->have_real_name())
- continue;
+ !m->have_real_name())
+ continue;
if (m->is_inamed(id))
- return(m);
+ return(m);
}
return(0);
}
while (bytes)
{
if (fscanf(f, "%2c", &s2[0]) == EOF)
- return(0);
+ return(0);
s2[2]= '\0';
l= l*256 + strtol(s2, NULL, 16);
bytes--;
if (!rom)
{
sim->app->get_commander()->
- dd_printf("No ROM address space to read in.\n");
+ dd_printf("No ROM address space to read in.\n");
return(-1);
}
if (!nam)
{
sim->app->get_commander()->
- dd_printf("cl_uc::read_hex_file File name not specified\n");
+ dd_printf("cl_uc::read_hex_file File name not specified\n");
return(-1);
}
else
if ((f= fopen(nam, "r")) == NULL)
{
- fprintf(stderr, "Can't open `%s': %s\n", nam, strerror(errno));
- return(-1);
+ fprintf(stderr, "Can't open `%s': %s\n", nam, strerror(errno));
+ return(-1);
}
//memset(inst_map, '\0', sizeof(inst_map));
ok= DD_TRUE;
while (ok &&
- rtyp != 1)
+ rtyp != 1)
{
while (((c= getc(f)) != ':') &&
- (c != EOF)) ;
+ (c != EOF)) ;
if (c != ':')
- {fprintf(stderr, ": not found\n");break;}
+ {fprintf(stderr, ": not found\n");break;}
recnum++;
dnum= ReadInt(f, &ok, 1);//printf("dnum=%02x",dnum);
chk = dnum;
rtyp= ReadInt(f, &ok, 1);//printf("rtyp=%02x ",rtyp);
chk+= rtyp;
for (i= 0; ok && (i < dnum); i++)
- {
- rec[i]= ReadInt(f, &ok, 1);//printf("%02x",rec[i]);
- chk+= rec[i];
- }
+ {
+ rec[i]= ReadInt(f, &ok, 1);//printf("%02x",rec[i]);
+ chk+= rec[i];
+ }
if (ok)
- {
- sum= ReadInt(f, &ok, 1);//printf(" sum=%02x\n",sum);
- if (ok)
- {
- if (((sum + chk) & 0xff) == 0)
- {
- if (rtyp == 0)
- {
- if (rom->width > 8)
- addr/= 2;
- for (i= 0; i < dnum; i++)
- {
- if (rom->width <= 8)
- {
- rom->set(addr, rec[i]);
- addr++;
- written++;
- }
- else if (rom->width <= 16)
- {
- if (get_low)
- {
- low= rec[i];
- get_low= 0;
- }
- else
- {
- high= rec[i];
- rom->set(addr, (high*256)+low);
- addr++;
- written++;
- get_low= 1;
- }
- }
- }
- }
- else
- if (rtyp != 1)
- application->debug("Unknown record type %d(0x%x)\n",
- rtyp, rtyp);
- }
- else
- application->debug("Checksum error (%x instead of %x) in "
- "record %ld.\n", chk, sum, recnum);
- }
- else
- application->debug("Read error in record %ld.\n", recnum);
- }
+ {
+ sum= ReadInt(f, &ok, 1);//printf(" sum=%02x\n",sum);
+ if (ok)
+ {
+ if (((sum + chk) & 0xff) == 0)
+ {
+ if (rtyp == 0)
+ {
+ if (rom->width > 8)
+ addr/= 2;
+ for (i= 0; i < dnum; i++)
+ {
+ if (rom->width <= 8)
+ {
+ rom->set(addr, rec[i]);
+ addr++;
+ written++;
+ }
+ else if (rom->width <= 16)
+ {
+ if (get_low)
+ {
+ low= rec[i];
+ get_low= 0;
+ }
+ else
+ {
+ high= rec[i];
+ rom->set(addr, (high*256)+low);
+ addr++;
+ written++;
+ get_low= 1;
+ }
+ }
+ }
+ }
+ else
+ if (rtyp != 1)
+ application->debug("Unknown record type %d(0x%x)\n",
+ rtyp, rtyp);
+ }
+ else
+ application->debug("Checksum error (%x instead of %x) in "
+ "record %ld.\n", chk, sum, recnum);
+ }
+ else
+ application->debug("Read error in record %ld.\n", recnum);
+ }
}
if (rom->width > 8 &&
!get_low)
if ((m= (class cl_m*)mems->at(type)))
{
if ((l= m->read_locs->get_loc(addr)) == 0)
- {
- l= new cl_memloc(addr);
- l->init();
- m->read_locs->add(l);
- }
+ {
+ l= new cl_memloc(addr);
+ l->init();
+ m->read_locs->add(l);
+ }
l->hws->add(hw);
}
else
{
hw= (class cl_hw *)(hws->at(i));
if (hw->cathegory == cath)
- break;
+ break;
}
if (i >= hws->count)
return(0);
{
hw= (class cl_hw *)(hws->at(i));
if (strstr(hw->id_string, id_string) == hw->id_string)
- break;
+ break;
}
if (i >= hws->count)
return(0);
i= *idx;
hw= get_hw(cath, &i);
while (hw &&
- hw->id != hwid)
+ hw->id != hwid)
{
i++;
hw= get_hw(cath, &i);
i= *idx;
hw= get_hw(id_string, &i);
while (hw &&
- hw->id != hwid)
+ hw->id != hwid)
{
i++;
hw= get_hw(id_string, &i);
int j;
j= rom->width/4 + ((rom->width%4)?1:0) + 1;
while (j)
- con->dd_printf(" "), j--;
+ con->dd_printf(" "), j--;
i++;
}
con->dd_printf(" %s\n", dis);
int max= 0;
while (de &&
- de->mnemonic)
+ de->mnemonic)
{
if (de->length > max)
- max= de->length;
+ max= de->length;
de++;
}
return(max);
i= 0;
while (tab[i].name &&
- (!(tab[i].cpu_type & type) ||
- (tab[i].addr != addr)))
+ (!(tab[i].cpu_type & type) ||
+ (tab[i].addr != addr)))
i++;
if (tab[i].name)
strcpy(buf, tab[i].name);
bool
cl_uc::symbol2address(char *sym, struct name_entry tab[],
- t_addr *addr)
+ t_addr *addr)
{
int i;
return(DD_FALSE);
i= 0;
while (tab[i].name &&
- (!(tab[i].cpu_type & type) ||
- strcasecmp(sym, tab[i].name) != 0))
+ (!(tab[i].cpu_type & type) ||
+ strcasecmp(sym, tab[i].name) != 0))
i++;
if (tab[i].name)
{
if (addr)
- *addr= tab[i].addr;
+ *addr= tab[i].addr;
return(DD_TRUE);
}
return(DD_FALSE);
char *
cl_uc::symbolic_bit_name(t_addr bit_address,
- class cl_memory *mem,
- t_addr mem_addr,
- t_mem bit_mask)
+ class cl_memory *mem,
+ t_addr mem_addr,
+ t_mem bit_mask)
{
char *sym_name= 0;
int i;
i= 0;
while (bit_tbl()[i].name &&
- (bit_tbl()[i].addr != bit_address))
+ (bit_tbl()[i].addr != bit_address))
i++;
if (bit_tbl()[i].name)
{
{
i= 0;
while (sfr_tbl()[i].name &&
- (sfr_tbl()[i].addr != mem_addr))
- i++;
+ (sfr_tbl()[i].addr != mem_addr))
+ i++;
if (sfr_tbl()[i].name)
- sym_name= strdup(sfr_tbl()[i].name);
+ sym_name= strdup(sfr_tbl()[i].name);
else
- sym_name= 0;
+ sym_name= 0;
}
if (!sym_name)
{
{
case ev_address_space_added:
{
- try {
- class cl_event_address_space_added &e=
- dynamic_cast<class cl_event_address_space_added &>(event);
- address_space_added(e.as);
- e.handle();
- }
- catch (...)
- { break; }
- break;
+ try {
+ class cl_event_address_space_added &e=
+ dynamic_cast<class cl_event_address_space_added &>(event);
+ address_space_added(e.as);
+ e.handle();
+ }
+ catch (...)
+ { break; }
+ break;
}
default:
return(pass_event_down(event));
{
int i;
for (i= 0; i < mems->count; i++)
- {
- }
+ {
+ }
}
}
*/
if (c)
{
for (i= 0; i < errors->count; i++)
- {
- class cl_error *error= (class cl_error *)(errors->at(i));
- if (!error->is_on())
- continue;
- error->print(c);
- must_stop= must_stop || (error->get_type() & err_stop);
- if (error->inst)
- {
- class cl_console *con;
- con= c->actual_console;
- if (!con)
- con= c->frozen_console;
- if (con)
- {
- con->dd_printf("Erronouse instruction: ");
- print_disass(error->PC, con);
- }
- }
- }
+ {
+ class cl_error *error= (class cl_error *)(errors->at(i));
+ if (!error->is_on())
+ continue;
+ error->print(c);
+ must_stop= must_stop || (error->get_type() & err_stop);
+ if (error->inst)
+ {
+ class cl_console *con;
+ con= c->actual_console;
+ if (!con)
+ con= c->frozen_console;
+ if (con)
+ {
+ con->dd_printf("Erronouse instruction: ");
+ print_disass(error->PC, con);
+ }
+ }
+ }
errors->free_all();
}
else
{
hw= (class cl_hw *)(hws->at(i));
if (hw->flags & HWF_INSIDE)
- hw->tick(cycles);
+ hw->tick(cycles);
}
do_extra_hw(cycles);
return(0);
{
class cl_ticker *t= (class cl_ticker *)(counters->at(i));
if (t)
- {
- if ((t->options&TICK_INISR) ||
- il->level < 0)
- t->tick(cycles * cpc);
- }
+ {
+ if ((t->options&TICK_INISR) ||
+ il->level < 0)
+ t->tick(cycles * cpc);
+ }
}
// tick for hardwares
{
class cl_ticker *t= (class cl_ticker *)(counters->at(i));
if (t &&
- t->get_name() &&
- strcmp(t->get_name(), nam) == 0)
- return(t);
+ t->get_name() &&
+ strcmp(t->get_name(), nam) == 0)
+ return(t);
}
return(0);
}
{
class cl_ticker *t= (class cl_ticker *)(counters->at(i));
if (!t)
- {
- counters->put_at(i, ticker);
- return;
- }
+ {
+ counters->put_at(i, ticker);
+ return;
+ }
}
counters->add(ticker);
}
{
class cl_ticker *t= (class cl_ticker *)(counters->at(i));
if (t &&
- t->get_name() &&
- strcmp(t->get_name(), nam) == 0)
- {
- delete t;
- counters->put_at(i, 0);
- return;
- }
+ t->get_name() &&
+ strcmp(t->get_name(), nam) == 0)
+ {
+ delete t;
+ counters->put_at(i, 0);
+ return;
+ }
}
}
rom)
{
if (rom->get_cell_flag(PC, CELL_FETCH_BRK) &&
- (brk= fbrk->get_bp(PC, &idx)) &&
- (brk->do_hit()))
- {
- if (brk->perm == brkDYNAMIC)
- fbrk->del_bp(PC);
- return(1);
- }
+ (brk= fbrk->get_bp(PC, &idx)) &&
+ (brk->do_hit()))
+ {
+ if (brk->perm == brkDYNAMIC)
+ fbrk->del_bp(PC);
+ return(1);
+ }
}
*code= fetch();
return(0);
if (step < 0)
step= 1;
while (step-- &&
- res == resGO)
+ res == resGO)
{
pre_inst();
res= exec_inst();
if (op->get_op() & stack_read_operation)
{
class cl_error_stack_tracker_wrong_handle *e= new
- cl_error_stack_tracker_wrong_handle(DD_FALSE);
+ cl_error_stack_tracker_wrong_handle(DD_FALSE);
//fprintf(stderr, "%06"_A_"x cl_uc::stack_read() should be called for "
//"%s\n", op->get_pc(), op->get_op_name());
e->init();
if (op->get_op() & stack_write_operation)
{
class cl_error_stack_tracker_wrong_handle *e= new
- cl_error_stack_tracker_wrong_handle(DD_TRUE);
+ cl_error_stack_tracker_wrong_handle(DD_TRUE);
e->init();
error(e);
//fprintf(stderr, "%06"_A_"x cl_uc::stack_write() should be called for "
{
class cl_error *e= new cl_error_stack_tracker_empty(op);
/*printf("0x%06"_A_"x %s operation on stack but no operation was before\n
- ",
- op->get_pc(), op->get_op_name());*/
+ ",
+ op->get_pc(), op->get_op_name());*/
e->init();
error(e);
return;
if (top)
{
if (!top->match(op))
- {
- class cl_error *e= new cl_error_stack_tracker_unmatch(top, op);
- e->init();
- error(e);
- /*printf("0x%06"_A_"x %s operation on stack but last was %s\n",
- op->get_pc(), op->get_op_name(), top->get_op_name());*/
- }
+ {
+ class cl_error *e= new cl_error_stack_tracker_unmatch(top, op);
+ e->init();
+ error(e);
+ /*printf("0x%06"_A_"x %s operation on stack but last was %s\n",
+ op->get_pc(), op->get_op_name(), top->get_op_name());*/
+ }
int top_size= top->data_size(), op_size= op->data_size();
if (top_size != op_size)
- {
- application->debug("0x%06"_A_"x %d bytes to read out of stack "
- "but %d was pushed in last operation\n",
- op->get_pc(), op_size, top_size);
- }
+ {
+ application->debug("0x%06"_A_"x %d bytes to read out of stack "
+ "but %d was pushed in last operation\n",
+ op->get_pc(), op_size, top_size);
+ }
}
int removed= 0;
while (top &&
- top->can_removed(op))
+ top->can_removed(op))
{
top= (class cl_stack_op *)stack_ops->pop();
delete top;
if (removed != 1)
{
application->debug("0x%06"_A_"x %d ops removed from stack-tracker "
- "when %s happened, top pc=0x%06"_A_"x "
- "top before=0x%06"_A_"x op after=0x%06"_A_"x\n",
- op->get_pc(), removed, op->get_op_name(),
- top?(top->get_pc()):0, top?(top->get_before()):0,
- op->get_after());
+ "when %s happened, top pc=0x%06"_A_"x "
+ "top before=0x%06"_A_"x op after=0x%06"_A_"x\n",
+ op->get_pc(), removed, op->get_op_name(),
+ top?(top->get_pc()):0, top?(top->get_before()):0,
+ op->get_after());
}
if (top)
{
int ta= top->get_after(), oa= op->get_after();
if (ta != oa)
- {
- application->debug("0x%06"_A_"x stack still inconsistent after %s, "
- "%d byte(s) should be read out; top after"
- "=0x%06"_A_"x op after=0x%06"_A_"x\n",
- op->get_pc(), op->get_op_name(), abs(ta-oa),
- ta, oa);
- class cl_error *e=
- new cl_error_stack_tracker_inconsistent(op, abs(ta-oa));
- e->init();
- error(e);
- }
+ {
+ application->debug("0x%06"_A_"x stack still inconsistent after %s, "
+ "%d byte(s) should be read out; top after"
+ "=0x%06"_A_"x op after=0x%06"_A_"x\n",
+ op->get_pc(), op->get_op_name(), abs(ta-oa),
+ ta, oa);
+ class cl_error *e=
+ new cl_error_stack_tracker_inconsistent(op, abs(ta-oa));
+ e->init();
+ error(e);
+ }
}
delete op;
{
eb= (class cl_ev_brk *)(ebrk->at(i));
if (eb->addr == addr &&
- !strcmp(eb->id, id))
- return(eb);
+ !strcmp(eb->id, id))
+ return(eb);
}
return(0);
}
{
eb= (class cl_ev_brk *)(ebrk->at(i));
if (eb->addr == addr &&
- !strcmp(eb->id, id))
- ebrk->del_bp(i, 0);
+ !strcmp(eb->id, id))
+ ebrk->del_bp(i, 0);
}
}
class cl_ev_brk *
cl_uc::mk_ebrk(enum brk_perm perm, class cl_address_space *mem,
- char op, t_addr addr, int hit)
+ char op, t_addr addr, int hit)
{
class cl_ev_brk *b;
op= toupper(op);
for (i= 0; i < events->count; i++)
{
class cl_ev_brk *brk=
- dynamic_cast<class cl_ev_brk *>(events->object_at(i));
+ dynamic_cast<class cl_ev_brk *>(events->object_at(i));
sim->stop(brk);
}
sim->stop(resBREAKPOINT);
void
cl_error_unknown_code::print(class cl_commander *c)
{
- FILE *f= c->get_out();
- cmd_fprintf(f, "%s: unknown instruction code at ", get_type_name());
+ c->dd_printf("%s: unknown instruction code at ", get_type_name());
if (uc->rom)
{
- cmd_fprintf(f, uc->rom->addr_format, PC);
- cmd_fprintf(f, " (");
- cmd_fprintf(f, uc->rom->data_format, uc->rom->get(PC));
- cmd_fprintf(f, ")");
+ c->dd_printf(uc->rom->addr_format, PC);
+ c->dd_printf(" (");
+ c->dd_printf(uc->rom->data_format, uc->rom->get(PC));
+ c->dd_printf(")");
}
else
- cmd_fprintf(f, "0x%06x", PC);
- cmd_fprintf(f, "\n");
+ c->dd_printf("0x%06x", PC);
+ c->dd_printf("\n");
}
cl_uc_error_registry::cl_uc_error_registry(void)