+2006-08-16 Borut Razem <borut.razem AT siol.net>
+
+ * sim/ucsim/cmd.src/newcmd.cc, sim/ucsim/cmd.src/newcmdcl.h,
+ sim/ucsim/cmd.src/cmdutil.cc, sim/ucsim/cmd.src/cmdutil.h,
+ sim/ucsim/sim.src/mem.cc, sim/ucsim/sim.src/uc.cc: code cleaning
+
2006-08-14 Borut Razem <borut.razem AT siol.net>
* support/regression/Makefile.in,
return(0);
for (p= name; *p; *p= toupper(*p), p++);
while (tabl[i].name &&
- (!(tabl[i].cpu_type & uc->type) ||
- (strcmp(tabl[i].name, name) != 0)))
+ (!(tabl[i].cpu_type & uc->type) ||
+ (strcmp(tabl[i].name, name) != 0)))
{
//printf("tabl[%d].name=%s <-> %s\n",i,tabl[i].name,name);
i++;
/*bool
interpret_bitname(char *name, class cl_uc *uc,
- uchar **cell, uchar *celladdr,
- uchar *bitaddr, uchar *bitmask,
- char **symname)
+ uchar **cell, uchar *celladdr,
+ uchar *bitaddr, uchar *bitmask,
+ char **symname)
{
char *dot, *p;
char *sym, bitnumstr[2];
{
*dot++= '\0';
if ((ne= get_name_entry(uc->sfr_tbl(), name, uc)) == NULL)
- {
- *celladdr= strtol(name, &p, 0);
- if (p && *p)
- {
- dot--;
- *dot= '.';
- return(DD_FALSE);
- }
- }
+ {
+ *celladdr= strtol(name, &p, 0);
+ if (p && *p)
+ {
+ dot--;
+ *dot= '.';
+ return(DD_FALSE);
+ }
+ }
else
- *celladdr= ne->addr;
+ *celladdr= ne->addr;
if ((*celladdr < 0x20) ||
- ((*celladdr > 0x2f) && (*celladdr < 0x80)) ||
- ((*celladdr > 0x7f) && (*celladdr & 0x07)))
- return(DD_FALSE);
+ ((*celladdr > 0x2f) && (*celladdr < 0x80)) ||
+ ((*celladdr > 0x7f) && (*celladdr & 0x07)))
+ return(DD_FALSE);
bitnum= strtol(dot, &p, 0);
if ((p && *p) ||
- (bitnum < 0) ||
- (bitnum > 7))
- return(DD_FALSE);
+ (bitnum < 0) ||
+ (bitnum > 7))
+ return(DD_FALSE);
if (*celladdr > 0x7f)
- *bitaddr= *celladdr + bitnum;
+ *bitaddr= *celladdr + bitnum;
else
- *bitaddr= (*celladdr - 0x20)*8 + bitnum;
+ *bitaddr= (*celladdr - 0x20)*8 + bitnum;
dot--;
*dot= '.';
}
else
{
if ((ne= get_name_entry(uc->bit_tbl(), name, uc)) == NULL)
- {
- *bitaddr= strtol(name, &p, 0);
- if ((p && *p) ||
- (*bitaddr > 0xff))
- return(DD_FALSE);
- }
+ {
+ *bitaddr= strtol(name, &p, 0);
+ if ((p && *p) ||
+ (*bitaddr > 0xff))
+ return(DD_FALSE);
+ }
else
- *bitaddr= ne->addr;
+ *bitaddr= ne->addr;
if (*bitaddr > 0x7f)
- *celladdr= *bitaddr & 0xf8;
+ *celladdr= *bitaddr & 0xf8;
else
- *celladdr= (*bitaddr >> 3) + 0x20;
+ *celladdr= (*bitaddr >> 3) + 0x20;
}
// *bitaddr, *celladdr now OK
*cell= uc->get_bit//FIXME
return(DD_TRUE);
i= 0;
while (uc->bit_tbl()[i].name &&
- (uc->bit_tbl()[i].addr != *bitaddr))
+ (uc->bit_tbl()[i].addr != *bitaddr))
i++;
if (uc->bit_tbl()[i].name)
{
}
i= 0;
while (uc->sfr_tbl()[i].name &&
- (uc->sfr_tbl()[i].addr != *celladdr))
+ (uc->sfr_tbl()[i].addr != *celladdr))
i++;
if (uc->sfr_tbl()[i].name)
sym= strdup(uc->sfr_tbl()[i].name);
char *spec_c;
if (*s == '\\' &&
- *(s+1))
- {
- s++;
- if (*s == '0')
- {
- if (!isdigit(*(s+1)))
- {
- *p++= '\0';
- s++;
- }
- else
- {
- char *octal, *chk, data;
- int i, j;
- i= strspn(s, "01234567");
- octal= (char *)malloc(i+1);
- j= 0;
- while (*s &&
- (j < i))
- octal[j++]= *s++;
- octal[j]= '\0';
- data= strtol(octal, &chk, 8);
- if (!chk || !(*chk))
- *p++= data;
- }
- }
- else
- if ((spec_c= strchr(spec_chars, *s)) != NULL)
- {
- *p++= spec[spec_c-spec_chars];
- s++;
- }
- else
- *p++= *s++;
- }
+ *(s+1))
+ {
+ s++;
+ if (*s == '0')
+ {
+ if (!isdigit(*(s+1)))
+ {
+ *p++= '\0';
+ s++;
+ }
+ else
+ {
+ char *octal, *chk, data;
+ int i, j;
+ i= strspn(s, "01234567");
+ octal= (char *)malloc(i+1);
+ j= 0;
+ while (*s &&
+ (j < i))
+ octal[j++]= *s++;
+ octal[j]= '\0';
+ data= strtol(octal, &chk, 8);
+ if (!chk || !(*chk))
+ *p++= data;
+ }
+ }
+ else
+ if ((spec_c= strchr(spec_chars, *s)) != NULL)
+ {
+ *p++= spec[spec_c-spec_chars];
+ s++;
+ }
+ else
+ *p++= *s++;
+ }
else
- *p++= *s++;
+ *p++= *s++;
}
*p= '\0';
*len= p-str;
}
-
-extern "C" int vasprintf(char **strp, const char *format, va_list ap);
-extern "C" int vsnprintf(char *str, size_t size,const char *format,va_list ap);
-
-int
-cmd_vfprintf(FILE *f, char *format, va_list ap)
-{
- int ret;
- if (!f)
- return(0);
-#ifdef HAVE_VASPRINTF
- char *msg= NULL;
- vasprintf(&msg, format, ap);
- ret= fprintf(f, "%s", msg);
- free(msg);
-#else
-# ifdef HAVE_VSNPRINTF
- char msg[80*25];
- vsnprintf(msg, 80*25, format, ap);
- ret= fprintf(f, "%s", msg);
-# else
-# ifdef HAVE_VPRINTF
- char msg[80*25];
- vsprintf(msg, format, ap); /* Dangerous */
- ret= fprintf(f, "%s", msg);
-# else
-# ifdef HAVE_DOPRNT
- /* ??? */
- /*strcpy(msg, "Unimplemented printf has called.\n");*/
-# else
- /*strcpy(msg, "printf can not be implemented, upgrade your libc.\n");*/
-# endif
-# endif
-# endif
-#endif
- fflush(f);
- return(ret);
-}
-
-int
-cmd_fprintf(FILE *f, char *format, ...)
-{
- va_list ap;
- va_start(ap, format);
- int ret= cmd_vfprintf(f, format, ap);
- va_end(ap);
- return(ret);
-}
-
-
/* End of cmd.src/cmdutil.cc */
extern int make_server_socket(unsigned short int port);
//extern void print_bin(long data, int bits, class cl_console *con);
extern struct name_entry *get_name_entry(struct name_entry tabl[],
- char *name,
- class cl_uc *uc);
+ char *name,
+ class cl_uc *uc);
/*extern bool interpret_bitname(char *name, class cl_uc *uc,
- uchar **cell, uchar *celladdr,
- uchar *bitaddr, uchar *bitmask,
- char **symname);*/
+ uchar **cell, uchar *celladdr,
+ uchar *bitaddr, uchar *bitmask,
+ char **symname);*/
extern char *proc_escape(char *string, int *len);
-extern int cmd_vfprintf(FILE *f, char *format, va_list ap);
-extern int cmd_fprintf(FILE *f, char *format, ...);
#endif
if (out)
{
if (flags & CONS_PROMPT)
- fprintf(out, "\n");
+ fprintf(out, "\n");
fflush(out);
fclose(out);
}
void
cl_console::welcome(void)
{
- FILE *Out= rout?rout:out;
-
- if (!Out ||
- (flags & CONS_NOWELCOME))
- return;
- fprintf(Out, "uCsim %s, Copyright (C) 1997 Daniel Drotos, Talker Bt.\n"
- "uCsim comes with ABSOLUTELY NO WARRANTY; for details type "
- "`show w'.\n"
- "This is free software, and you are welcome to redistribute it\n"
- "under certain conditions; type `show c' for details.\n",
- VERSIONSTR);
- fflush(Out);
+ if (!(flags & CONS_NOWELCOME))
+ {
+ dd_printf("uCsim %s, Copyright (C) 1997 Daniel Drotos, Talker Bt.\n"
+ "uCsim comes with ABSOLUTELY NO WARRANTY; for details type "
+ "`show w'.\n"
+ "This is free software, and you are welcome to redistribute it\n"
+ "under certain conditions; type `show c' for details.\n",
+ VERSIONSTR);
+ }
}
void
{
if ((rout= fopen(fname, mode)) == NULL)
dd_printf("Unable to open file '%s' for %s: %s\n",
- fname, (mode[0]=='w')?"write":"append", strerror(errno));
+ fname, (mode[0]=='w')?"write":"append", strerror(errno));
}
void
int
-cl_console::cmd_do_print(FILE *f, char *format, va_list ap)
+cl_console::cmd_do_print(char *format, va_list ap)
{
- int ret;
-#ifdef HAVE_VASPRINTF
- char *msg= NULL;
- vasprintf(&msg, format, ap);
- ret= fprintf(f, "%s", msg);
- free(msg);
-#else
-# ifdef HAVE_VSNPRINTF
- char msg[80*25];
- vsnprintf(msg, 80*25, format, ap);
- ret= fprintf(f, "%s", msg);
-# else
-# ifdef HAVE_VPRINTF
- char msg[80*25];
- vsprintf(msg, format, ap); /* Dangerous */
- ret= fprintf(f, "%s", msg);
-# else
-# ifdef HAVE_DOPRNT
- /* ??? */
- /*strcpy(msg, "Unimplemented printf has called.\n");*/
-# else
- /*strcpy(msg, "printf can not be implemented, upgrade your libc.\n");*/
-# endif
-# endif
-# endif
-#endif
- fflush(f);
+ FILE *f = get_out();
+ int ret = 0;
+
+ if (f)
+ {
+ vfprintf(f, format, ap);
+ fflush(f);
+ }
+
return(ret);
}
void
cl_console::print_prompt(void)
{
- //char *p;
- FILE *Out= rout?rout:out;
-
if (flags & (CONS_PROMPT|CONS_FROZEN|CONS_INACTIVE))
return;
flags|= CONS_PROMPT;
- if (!Out)
- return;
if (/*app->args->arg_avail('P')*/null_prompt_option->get_value(bool(0)))
- putc('\0', Out);
+ {
+ FILE *Out = get_out();
+ if (Out)
+ {
+ putc('\0', Out);
+ fflush(Out);
+ }
+ }
else
{
- fprintf(Out, "%d", id);
- fprintf(Out, "%s", (prompt && prompt[0])?prompt:"> ");
- // ((p= app->args->get_sarg(0, "prompt"))?p:"> "));
+ dd_printf("%d%s", id, (prompt && prompt[0])?prompt:"> ");
+ // ((p= app->args->get_sarg(0, "prompt"))?p:"> "));
}
- fflush(Out);
}
int
{
va_list ap;
int ret= 0;
- FILE *Out= rout?rout:out;
- if (Out)
- {
- va_start(ap, format);
- ret= cmd_do_print(Out, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret= cmd_do_print(format, ap);
+ va_end(ap);
+
return(ret);
}
va_list ap;
int ret= 0;
- FILE *Out= rout?rout:out;
- if (Out)
- {
- va_start(ap, format);
- ret= cmd_do_print(Out, format, ap);
- va_end(ap);
- }
+ va_start(ap, format);
+ ret= cmd_do_print(format, ap);
+ va_end(ap);
+
return(ret);
}
cl_console::print_bin(long data, int bits)
{
long mask= 1;
- FILE *Out= rout?rout:out;
- if (!Out)
- return;
mask= mask << ((bits >= 1)?(bits-1):0);
while (bits--)
{
- fprintf(Out, "%c", (data&mask)?'1':'0');
+ dd_printf("%c", (data&mask)?'1':'0');
mask>>= 1;
}
}
void
cl_console::print_char_octal(char c)
{
- FILE *Out= rout?rout:out;
+ FILE *Out= get_out();
if (Out)
::print_char_octal(c, Out);
else
{
if (cmdstr &&
- *cmdstr == '\004')
- retval= 1;
+ *cmdstr == '\004')
+ retval= 1;
else
- {
- class cl_cmdline *cmdline= 0;
- class cl_cmd *cm= 0;
- if (flags & CONS_ECHO)
- dd_printf("%s\n", cmdstr);
- cmdline= new cl_cmdline(app, cmdstr, this);
- cmdline->init();
- if (cmdline->repeat() &&
- accept_last() &&
- last_command)
- {
- cm= last_command;
- delete cmdline;
- cmdline= last_cmdline;
- }
- else
- {
- cm= cmdset->get_cmd(cmdline, accept_last());
- if (last_cmdline)
- {
- delete last_cmdline;
- last_cmdline= 0;
- }
- last_command= 0;
- }
- if (cm)
- {
- retval= cm->work(app, cmdline, this);
- if (cm->can_repeat)
- {
- last_command= cm;
- last_cmdline= cmdline;
- }
- else
- delete cmdline;
- }
- else
- {
- class YY_cl_ucsim_parser_CLASS *pars;
- class cl_ucsim_lexer *lexer;
- lexer= new cl_ucsim_lexer(cmdstr);
- pars= new YY_cl_ucsim_parser_CLASS(lexer);
- pars->yyparse();
- delete cmdline;
- delete pars;
- }
- /*if (!cm)
- retval= interpret(cmdstr);*/
- }
+ {
+ class cl_cmdline *cmdline= 0;
+ class cl_cmd *cm= 0;
+ if (flags & CONS_ECHO)
+ dd_printf("%s\n", cmdstr);
+ cmdline= new cl_cmdline(app, cmdstr, this);
+ cmdline->init();
+ if (cmdline->repeat() &&
+ accept_last() &&
+ last_command)
+ {
+ cm= last_command;
+ delete cmdline;
+ cmdline= last_cmdline;
+ }
+ else
+ {
+ cm= cmdset->get_cmd(cmdline, accept_last());
+ if (last_cmdline)
+ {
+ delete last_cmdline;
+ last_cmdline= 0;
+ }
+ last_command= 0;
+ }
+ if (cm)
+ {
+ retval= cm->work(app, cmdline, this);
+ if (cm->can_repeat)
+ {
+ last_command= cm;
+ last_cmdline= cmdline;
+ }
+ else
+ delete cmdline;
+ }
+ else
+ {
+ class YY_cl_ucsim_parser_CLASS *pars;
+ class cl_ucsim_lexer *lexer;
+ lexer= new cl_ucsim_lexer(cmdstr);
+ pars= new YY_cl_ucsim_parser_CLASS(lexer);
+ pars->yyparse();
+ delete cmdline;
+ delete pars;
+ }
+ /*if (!cm)
+ retval= interpret(cmdstr);*/
+ }
}
//retval= sim->do_cmd(cmd, this);
un_redirect();
int
cl_console::interpret(char *cmd)
{
- FILE *Out= rout?rout:out;
-
- fprintf(Out, "Unknown command\n");
+ dd_printf("Unknown command\n");
return(0);
}
if ((sock= make_server_socket(serverport)) >= 0)
{
if (listen(sock, 10) < 0)
- fprintf(stderr, "Listen on port %d: %s\n",
- serverport, strerror(errno));
+ fprintf(stderr, "Listen on port %d: %s\n",
+ serverport, strerror(errno));
}
in= out= 0;
}
*/
cl_sub_console::cl_sub_console(class cl_console *the_parent,
- FILE *fin, FILE *fout, class cl_app *the_app):
+ FILE *fin, FILE *fout, class cl_app *the_app):
cl_console(fin, fout, the_app)
{
parent= the_parent;
*/
cl_commander::cl_commander(class cl_app *the_app, class cl_cmdset *acmdset
- /*, class cl_sim *asim*/):
+ /*, class cl_sim *asim*/):
cl_base()
{
app= the_app;
{
FILE *fc= fopen(Config, "r");
if (!fc)
- fprintf(stderr, "Can't open `%s': %s\n", Config, strerror(errno));
+ fprintf(stderr, "Can't open `%s': %s\n", Config, strerror(errno));
else
- {
- con= mk_console(fc, stderr);
- con->flags|= CONS_NOWELCOME|CONS_ECHO;
- add_console(con);
- }
+ {
+ con= mk_console(fc, stderr);
+ con->flags|= CONS_NOWELCOME|CONS_ECHO;
+ add_console(con);
+ }
}
return(0);
}
UCSOCKET_T fd;
class cl_console *c= (class cl_console*)(cons->at(i));
if ((fd= c->get_in_fd()) >= 0)
- {
- if ((c->flags & CONS_FROZEN) == 0 ||
- (c->flags & CONS_INTERACTIVE) != 0)
- {
- FD_SET(fd, &read_set);
- if (fd > fd_num)
- fd_num= fd;
- }
- }
+ {
+ if ((c->flags & CONS_FROZEN) == 0 ||
+ (c->flags & CONS_INTERACTIVE) != 0)
+ {
+ FD_SET(fd, &read_set);
+ if (fd > fd_num)
+ fd_num= fd;
+ }
+ }
else
- ;//fprintf(stderr, "** Skipping console %p\n",c);
+ ;//fprintf(stderr, "** Skipping console %p\n",c);
}
fd_num++;
}
for (i= 0; i < cons->count; i++)
{
class cl_console *c= (class cl_console*)(cons->at(i));
- FILE *Out= c->get_out();
- if (Out)
- {
- va_start(ap, format);
- ret= c->cmd_do_print(Out, format, ap);
- va_end(ap);
- }
+
+ va_start(ap, format);
+ ret= c->cmd_do_print(format, ap);
+ va_end(ap);
}
return(ret);
}
}
}
-int
-cl_commander::all_print(char *string, int length)
-{
- int i;
-
- for (i= 0; i < cons->count; i++)
- {
- class cl_console *c= (class cl_console*)(cons->at(i));
- FILE *Out= c->get_out();
- if (Out)
- {
- for (int j= 0; j < length; j++)
- putc(string[j], Out);
- }
- }
- return(0);
-}
-
/*
* Printing to actual_console
*/
-FILE *
-cl_commander::get_out(void)
-{
- if (actual_console)
- return(actual_console->get_out());
- else if (frozen_console)
- return(frozen_console->get_out());
- return(0);
-}
-
int
cl_commander::dd_printf(char *format, ...)
{
va_list ap;
int ret= 0;
- FILE *f;
class cl_console *con;
if (actual_console)
{
- f= actual_console->get_out();
con= actual_console;
}
else if (frozen_console)
{
- f= frozen_console->get_out();
con= frozen_console;
}
else
{
- f= 0;
con= 0;
}
- if (/*actual_console &&
- actual_console->out*/f &&
- con)
+ if (con)
{
va_start(ap, format);
- ret= con->cmd_do_print(f/*actual_console->out*/, format, ap);
+ ret= con->cmd_do_print(format, ap);
va_end(ap);
}
return(ret);
}
-int
-cl_commander::dd_printf(char *format, va_list ap)
-{
- int ret= 0;
- FILE *f;
- class cl_console *con;
-
- if (actual_console)
- {
- f= actual_console->get_out();
- con= actual_console;
- }
- else if (frozen_console)
- {
- f= frozen_console->get_out();
- con= frozen_console;
- }
- else
- {
- f= 0;
- con= 0;
- }
- if (/*actual_console &&
- actual_console->out*/f &&
- con)
- {
- ret= con->cmd_do_print(f/*actual_console->out*/, format, ap);
- }
- return(ret);
-}
-
/*
* Printing to consoles which have CONS_DEBUG flag set
*/
for (i= 0; i < cons->count; i++)
{
class cl_console *c= (class cl_console*)(cons->at(i));
- FILE *Out= c->get_out();
- if (Out &&
- c->flags & CONS_DEBUG)
- {
- va_start(ap, format);
- ret= c->cmd_do_print(Out, format, ap);
- va_end(ap);
- }
+ if (c->flags & CONS_DEBUG)
+ {
+ va_start(ap, format);
+ ret= c->cmd_do_print(format, ap);
+ va_end(ap);
+ }
}
return(ret);
}
for (i= 0; i < cons->count; i++)
{
class cl_console *c= (class cl_console*)(cons->at(i));
- FILE *Out= c->get_out();
- if (Out &&
- c->flags & CONS_DEBUG)
- {
- ret= c->cmd_do_print(Out, format, ap);
- }
+ if (c->flags & CONS_DEBUG)
+ {
+ ret= c->cmd_do_print(format, ap);
+ }
}
return(ret);
}
for (i= 0; i < cons->count; i++)
{
class cl_console *c= (class cl_console*)(cons->at(i));
- FILE *Out= c->get_out();
- if (Out &&
- (c->flags & iflags) == iflags)
- {
- va_start(ap, format);
- ret= c->cmd_do_print(Out, format, ap);
- va_end(ap);
- }
+ if ((c->flags & iflags) == iflags)
+ {
+ va_start(ap, format);
+ ret= c->cmd_do_print(format, ap);
+ va_end(ap);
+ }
}
return(ret);
}
for (i= 0; i < fd_num; i++)
if (FD_ISSET(i, &active_set))
{
- class cl_console *c;
- int j;
- for (j= 0; j < cons->count; j++)
- {
- c= (class cl_console*)(cons->at(j));
- if (c->match(i))
- {
- actual_console= c;
- int retval= c->proc_input(cmdset);
- if (retval)
- {
- del_console(c);
- delete c;
- }
- actual_console= 0;
- return(cons->count == 0);
- }
- }
+ class cl_console *c;
+ int j;
+ for (j= 0; j < cons->count; j++)
+ {
+ c= (class cl_console*)(cons->at(j));
+ if (c->match(i))
+ {
+ actual_console= c;
+ int retval= c->proc_input(cmdset);
+ if (retval)
+ {
+ del_console(c);
+ delete c;
+ }
+ actual_console= 0;
+ return(cons->count == 0);
+ }
+ }
}
return(0);
}
// Flags of consoles
-#define CONS_NONE 0
-#define CONS_DEBUG 0x01 // Print debug messages on this console
-#define CONS_FROZEN 0x02 // Console is frozen (g command issued)
-#define CONS_PROMPT 0x04 // Prompt is out, waiting for input
-#define CONS_INTERACTIVE 0x08 // Interactive console
-#define CONS_NOWELCOME 0x10 // Do not print welcome message
-#define CONS_INACTIVE 0x20 // Do not do any action
-#define CONS_ECHO 0x40 // Echo commands
-
-#define SY_ADDR 'a'
-#define ADDRESS "a"
-#define SY_NUMBER 'n'
-#define NUMBER "n"
-#define SY_DATA 'd'
-#define DATA "d"
-#define SY_STRING 's'
-#define STRING "s"
-#define SY_MEMORY 'm'
-#define MEMORY "m"
-#define SY_HW 'h'
-#define HW "h"
-#define SY_DATALIST 'D'
-#define DATALIST "D"
-#define SY_BIT 'b'
-#define BIT "b"
+#define CONS_NONE 0
+#define CONS_DEBUG 0x01 // Print debug messages on this console
+#define CONS_FROZEN 0x02 // Console is frozen (g command issued)
+#define CONS_PROMPT 0x04 // Prompt is out, waiting for input
+#define CONS_INTERACTIVE 0x08 // Interactive console
+#define CONS_NOWELCOME 0x10 // Do not print welcome message
+#define CONS_INACTIVE 0x20 // Do not do any action
+#define CONS_ECHO 0x40 // Echo commands
+
+#define SY_ADDR 'a'
+#define ADDRESS "a"
+#define SY_NUMBER 'n'
+#define NUMBER "n"
+#define SY_DATA 'd'
+#define DATA "d"
+#define SY_STRING 's'
+#define STRING "s"
+#define SY_MEMORY 'm'
+#define MEMORY "m"
+#define SY_HW 'h'
+#define HW "h"
+#define SY_DATALIST 'D'
+#define DATALIST "D"
+#define SY_BIT 'b'
+#define BIT "b"
class cl_prompt_option: public cl_optref
virtual void welcome(void);
virtual void redirect(char *fname, char *mode);
virtual void un_redirect(void);
- virtual FILE *get_out(void) { return(rout?rout:out); }
- int cmd_do_print(FILE *f, char *format, va_list ap);
+ int cmd_do_print(char *format, va_list ap);
virtual void print_prompt(void);
virtual int dd_printf(char *format, ...);
virtual int debug(char *format, ...);
virtual void set_id(int new_id);
virtual int get_id(void) { return(id); }
virtual void set_prompt(char *p);
+private:
+ FILE *get_out(void) { return(rout?rout:out); }
};
#ifdef SOCKET_AVAIL
cl_listen_console(int serverport, class cl_app *the_app);
virtual void welcome(void) {}
- virtual void prompt(void) {}
virtual int match(int fdnum);
virtual int get_in_fd(void);
class cl_console *parent;
public:
cl_sub_console(class cl_console *the_parent,
- FILE *fin, FILE *fout, class cl_app *the_app);
+ FILE *fin, FILE *fout, class cl_app *the_app);
virtual ~cl_sub_console(void);
virtual int init(void);
};
class cl_list *cons;
fd_set read_set, active_set;
UCSOCKET_T fd_num;
- //class cl_sim *sim;
class cl_console *actual_console, *frozen_console;
class cl_cmdset *cmdset;
public:
cl_commander(class cl_app *the_app,
- class cl_cmdset *acmdset/*, class cl_sim *asim*/);
+ class cl_cmdset *acmdset/*, class cl_sim *asim*/);
virtual ~cl_commander(void);
virtual int init(void);
void set_fd_set(void);
void prompt(void);
- FILE *get_out(void);
- int all_printf(char *format, ...); // print to all consoles
- int all_print(char *string, int length);
- int dd_printf(char *format, ...); // print to actual_console
- int dd_printf(char *format, va_list ap);// print to actual_console
- int debug(char *format, ...); // print consoles with debug flag set
- int debug(char *format, va_list ap); // print consoles with debug flag set
+ int all_printf(char *format, ...); // print to all consoles
+ int dd_printf(char *format, ...); // print to actual_console
+ int debug(char *format, ...); // print consoles with debug flag set
+ int debug(char *format, va_list ap); // print consoles with debug flag set
int flag_printf(int iflags, char *format, ...);
int input_avail(void);
int input_avail_on_frozen(void);
{
addr_format= (char *)malloc(10);
sprintf(addr_format, "0x%%0%dx",
- size-1<=0xf?1:
- (size-1<=0xff?2:
- (size-1<=0xfff?3:
- (size-1<=0xffff?4:
- (size-1<=0xfffff?5:
- (size-1<=0xffffff?6:12))))));
+ size-1<=0xf?1:
+ (size-1<=0xff?2:
+ (size-1<=0xfff?3:
+ (size-1<=0xffff?4:
+ (size-1<=0xfffff?5:
+ (size-1<=0xffffff?6:12))))));
data_format= (char *)malloc(10);
sprintf(data_format, "%%0%dx", width/4+((width%4)?1:0));
data_mask= 1;
cl_memory::valid_address(t_addr addr)
{
return(addr >= start_address &&
- addr < start_address+size);
+ addr < start_address+size);
}
t_addr
if (stop > hva)
stop= hva;
while ((start <= stop) &&
- (start < hva))
+ (start < hva))
{
con->dd_printf(addr_format, start); con->dd_printf(" ");
for (i= 0;
- (i < bpl) &&
- (start+i < hva) &&
- (start+i <= stop);
- i++)
- {
- con->dd_printf(data_format, /*read*/get(start+i)); con->dd_printf(" ");
- }
+ (i < bpl) &&
+ (start+i < hva) &&
+ (start+i <= stop);
+ i++)
+ {
+ con->dd_printf(data_format, /*read*/get(start+i)); con->dd_printf(" ");
+ }
while (i < bpl)
- {
- int j;
- j= width/4 + ((width%4)?1:0) + 1;
- while (j)
- {
- con->dd_printf(" ");
- j--;
- }
- i++;
- }
+ {
+ int j;
+ j= width/4 + ((width%4)?1:0) + 1;
+ while (j)
+ {
+ con->dd_printf(" ");
+ j--;
+ }
+ i++;
+ }
for (i= 0; (i < bpl) &&
- (start+i < hva) &&
- (start+i <= stop);
- i++)
- {
- long c= read(start+i);
- con->dd_printf("%c", isprint(255&c)?(255&c):'.');
- if (width > 8)
- con->dd_printf("%c", isprint(255&(c>>8))?(255&(c>>8)):'.');
- if (width > 16)
- con->dd_printf("%c", isprint(255&(c>>16))?(255&(c>>16)):'.');
- if (width > 24)
- con->dd_printf("%c", isprint(255&(c>>24))?(255&(c>>24)):'.');
- }
+ (start+i < hva) &&
+ (start+i <= stop);
+ i++)
+ {
+ long c= read(start+i);
+ con->dd_printf("%c", isprint(255&c)?(255&c):'.');
+ if (width > 8)
+ con->dd_printf("%c", isprint(255&(c>>8))?(255&(c>>8)):'.');
+ if (width > 16)
+ con->dd_printf("%c", isprint(255&(c>>16))?(255&(c>>16)):'.');
+ if (width > 24)
+ con->dd_printf("%c", isprint(255&(c>>24))?(255&(c>>24)):'.');
+ }
con->dd_printf("\n");
dump_finished= start+i;
start+= bpl;
bool
cl_memory::search_next(bool case_sensitive,
- t_mem *array, int len, t_addr *addr)
+ t_mem *array, int len, t_addr *addr)
{
t_addr a;
int i;
found= DD_FALSE;
while (!found &&
- a+len <= size)
+ a+len <= size)
{
bool match= DD_TRUE;
for (i= 0; i < len && match; i++)
- {
- t_mem d1, d2;
- d1= get(a+i);
- d2= array[i];
- if (!case_sensitive)
- {
- if (/*d1 < 128*/isalpha(d1))
- d1= toupper(d1);
- if (/*d2 < 128*/isalpha(d2))
- d2= toupper(d2);
- }
- match= d1 == d2;
- }
+ {
+ t_mem d1, d2;
+ d1= get(a+i);
+ d2= array[i];
+ if (!case_sensitive)
+ {
+ if (/*d1 < 128*/isalpha(d1))
+ d1= toupper(d1);
+ if (/*d2 < 128*/isalpha(d2))
+ d2= toupper(d2);
+ }
+ match= d1 == d2;
+ }
found= match;
if (!found)
- a++;
+ a++;
}
if (addr)
*/
cl_memory_operator::cl_memory_operator(class cl_memory_cell *acell,
- t_addr addr):
+ t_addr addr):
cl_base()
{
cell= acell;
}
cl_memory_operator::cl_memory_operator(class cl_memory_cell *acell,
- t_addr addr,
- t_mem *data_place, t_mem the_mask):
+ t_addr addr,
+ t_mem *data_place, t_mem the_mask):
cl_base()
{
cell= acell;
/* Memory operator for hw callbacks */
cl_hw_operator::cl_hw_operator(class cl_memory_cell *acell, t_addr addr,
- t_mem *data_place, t_mem the_mask,
- class cl_hw *ahw):
+ t_mem *data_place, t_mem the_mask,
+ class cl_hw *ahw):
cl_memory_operator(acell, addr, data_place, the_mask)
{
hw= ahw;
/* Write event break on cell */
cl_write_operator::cl_write_operator(class cl_memory_cell *acell, t_addr addr,
- t_mem *data_place, t_mem the_mask,
- class cl_uc *auc, class cl_brk *the_bp):
+ t_mem *data_place, t_mem the_mask,
+ class cl_uc *auc, class cl_brk *the_bp):
cl_event_break_operator(acell, addr, data_place, the_mask, auc, the_bp)
{
uc= auc;
/* Read event break on cell */
cl_read_operator::cl_read_operator(class cl_memory_cell *acell, t_addr addr,
- t_mem *data_place, t_mem the_mask,
- class cl_uc *auc, class cl_brk *the_bp):
+ t_mem *data_place, t_mem the_mask,
+ class cl_uc *auc, class cl_brk *the_bp):
cl_event_break_operator(acell, addr, data_place, the_mask, auc, the_bp)
{
uc= auc;
class cl_memory_operator *o= operators, *n;
n= o->get_next();
while (n)
- {
- o= n;
- n= o->get_next();
- }
+ {
+ o= n;
+ n= o->get_next();
+ }
o->set_next(op);
}
}
else
{
while (op->get_next() &&
- !op->get_next()->match(brk))
- op= op->get_next();
+ !op->get_next()->match(brk))
+ op= op->get_next();
if (op->get_next())
- {
- class cl_memory_operator *m= op->get_next();
- op->set_next(m->get_next());;
- delete m;
- }
+ {
+ class cl_memory_operator *m= op->get_next();
+ op->set_next(m->get_next());;
+ delete m;
+ }
}
}
*/
cl_address_space::cl_address_space(char *id,
- t_addr astart, t_addr asize, int awidth):
+ t_addr astart, t_addr asize, int awidth):
cl_memory(id, asize, awidth)
{
start_address= astart;
for (i= 0; i < decoders->count; i++)
{
class cl_address_decoder *d=
- dynamic_cast<class cl_address_decoder *>(decoders->object_at(i));
+ dynamic_cast<class cl_address_decoder *>(decoders->object_at(i));
if (!d)
- continue;
+ continue;
if (d->covers(addr, addr))
- {
- return d;
- }
+ {
+ return d;
+ }
}
return NULL;
}
bool
cl_address_space::decode_cell(t_addr addr,
- class cl_memory_chip *chip, t_addr chipaddr)
+ class cl_memory_chip *chip, t_addr chipaddr)
{
cl_memory_cell *cell = get_cell(addr);
if (cell == dummy)
void
cl_address_space::undecode_area(class cl_address_decoder *skip,
- t_addr begin, t_addr end,class cl_console *con)
+ t_addr begin, t_addr end,class cl_console *con)
{
#define D if (con) con->debug
D("Undecoding area 0x%x-0x%x of %s\n", begin, end, get_name());
for (i= 0; i < decoders->count; i++)
{
class cl_address_decoder *d=
- dynamic_cast<class cl_address_decoder *>(decoders->object_at(i));
+ dynamic_cast<class cl_address_decoder *>(decoders->object_at(i));
if (!d ||
- d == skip)
- continue;
+ d == skip)
+ continue;
D(" Checking decoder 0x%x-0x%x -> %s[0x%x]\n",
- d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
+ d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
if (d->fully_covered_by(begin, end))
- {
- // decoder can be removed
- D(" Can be removed\n");
- decoders->disconn(d);
- i--;
- delete d;
- if (decoders->count == 0)
- break;
- }
+ {
+ // decoder can be removed
+ D(" Can be removed\n");
+ decoders->disconn(d);
+ i--;
+ delete d;
+ if (decoders->count == 0)
+ break;
+ }
else if (d->covers(begin, end))
- {
- // decoder must be split
- D(" Must be split\n");
- class cl_address_decoder *nd= d->split(begin, end);
- D(" After split:\n");
- D(" 0x%x-0x%x -> %s[0x%x]\n",
- d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
- if (nd)
- {
- decoders->add(nd);
- D(" 0x%x-0x%x -> %s[0x%x]\n",
- nd->as_begin, nd->as_end, nd->memchip->get_name(), nd->chip_begin);
- nd->activate(con);
- }
- }
+ {
+ // decoder must be split
+ D(" Must be split\n");
+ class cl_address_decoder *nd= d->split(begin, end);
+ D(" After split:\n");
+ D(" 0x%x-0x%x -> %s[0x%x]\n",
+ d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
+ if (nd)
+ {
+ decoders->add(nd);
+ D(" 0x%x-0x%x -> %s[0x%x]\n",
+ nd->as_begin, nd->as_end, nd->memchip->get_name(), nd->chip_begin);
+ nd->activate(con);
+ }
+ }
else if (d->is_in(begin, end))
- {
- // decoder sould shrink
- D(" Sould shrink\n");
- if (d->shrink_out_of(begin, end))
- {
- D(" Can be removed after shrink\n");
- decoders->disconn(d);
- i--;
- delete d;
- if (decoders->count == 0)
- break;
- }
- else
- {
- D(" Shrinked to 0x%x-0x%x -> %s[0x%x]\n",
- d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
- }
- }
+ {
+ // decoder sould shrink
+ D(" Sould shrink\n");
+ if (d->shrink_out_of(begin, end))
+ {
+ D(" Can be removed after shrink\n");
+ decoders->disconn(d);
+ i--;
+ delete d;
+ if (decoders->count == 0)
+ break;
+ }
+ else
+ {
+ D(" Shrinked to 0x%x-0x%x -> %s[0x%x]\n",
+ d->as_begin, d->as_end, d->memchip->get_name(), d->chip_begin);
+ }
+ }
}
#undef D
}
class cl_memory_cell *
cl_address_space::register_hw(t_addr addr, class cl_hw *hw,
- int *ith,
- bool announce)
+ int *ith,
+ bool announce)
{
cl_memory_cell *cell = get_cell(addr);
if (cell == dummy)
case brkWRITE: case brkWXRAM: case brkWIRAM: case brkWSFR:
//e= 'W';
op= new cl_write_operator(cell, addr, cell->get_data(), cell->get_mask(),
- uc, brk);
+ uc, brk);
break;
case brkREAD: case brkRXRAM: case brkRCODE: case brkRIRAM: case brkRSFR:
//e= 'R';
op= new cl_read_operator(cell, addr, cell->get_data(), cell->get_mask(),
- uc, brk);
+ uc, brk);
break;
case brkNONE:
set_cell_flag(addr, DD_TRUE, CELL_FETCH_BRK);
int i;
for (i= 0; i < size; i++)
set(i,
- (init_value<0)?rand():(init_value));
+ (init_value<0)?rand():(init_value));
return(0);
}
*/
cl_address_decoder::cl_address_decoder(class cl_memory *as,
- class cl_memory *chip,
- t_addr asb, t_addr ase, t_addr cb)
+ class cl_memory *chip,
+ t_addr asb, t_addr ase, t_addr cb)
{
if (as->is_address_space())
address_space= (class cl_address_space *)as;
if (begin > a)
a= begin;
while (a <= end &&
- a <= as_end)
+ a <= as_end)
{
address_space->undecode_cell(a);
a++;
if (begin > as_begin)
{
if (as_end > end)
- nd= new cl_address_decoder(address_space, memchip,
- end+1, as_end, chip_begin+(end-as_begin)+1);
+ nd= new cl_address_decoder(address_space, memchip,
+ end+1, as_end, chip_begin+(end-as_begin)+1);
shrink_out_of(begin, as_end);
}
else if (end < as_end)
{
if (as_begin < begin)
- nd= new cl_address_decoder(address_space, memchip,
- as_begin, begin-1, chip_begin);
+ nd= new cl_address_decoder(address_space, memchip,
+ as_begin, begin-1, chip_begin);
shrink_out_of(end+1, as_end);
}
if (nd)
void
cl_error_mem_invalid_address::print(class cl_commander *c)
{
- FILE *f= c->get_out();
- cmd_fprintf(f, "%s: invalid address ", get_type_name());
- cmd_fprintf(f, mem->addr_format, addr);
- cmd_fprintf(f, " in memory %s.\n", mem->get_name());
+ c->dd_printf("%s: invalid address ", get_type_name());
+ c->dd_printf(mem->addr_format, addr);
+ c->dd_printf(" in memory %s.\n", mem->get_name());
}
/* Non-decoded address space access */
void
cl_error_mem_non_decoded::print(class cl_commander *c)
{
- FILE *f= c->get_out();
- cmd_fprintf(f, "%s: access of non-decoded address ", get_type_name());
- cmd_fprintf(f, mem->addr_format, addr);
- cmd_fprintf(f, " in memory %s.\n", mem->get_name());
+ c->dd_printf("%s: access of non-decoded address ", get_type_name());
+ c->dd_printf(mem->addr_format, addr);
+ c->dd_printf(" in memory %s.\n", mem->get_name());
}
cl_mem_error_registry::cl_mem_error_registry(void)
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)