2 * This file is part of SIS.
4 * SIS, SPARC instruction simulator. Copyright (C) 1995 Jiri Gaisler, European
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU General Public License as published by the Free
9 * Software Foundation; either version 3 of the License, or (at your option)
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
17 * You should have received a copy of the GNU General Public License along with
18 * this program; if not, see <http://www.gnu.org/licenses/>.
29 #include <sys/fcntl.h>
32 #include "sim-config.h"
35 #define VAL(x) strtol(x,(char **)NULL,0)
37 /* Structures and functions from readline library */
39 #include "readline/readline.h"
40 #include "readline/history.h"
42 /* Command history buffer length - MUST be binary */
45 extern struct disassemble_info dinfo
;
46 extern struct pstate sregs
;
47 extern struct estate ebase
;
55 extern int sis_verbose
;
56 extern char *sis_version
;
57 extern struct estate ebase
;
58 extern struct evcell evbuf
[];
59 extern struct irqcell irqarr
[];
60 extern int irqpend
, ext_irl
;
64 extern char uart_dev1
[];
65 extern char uart_dev2
[];
66 extern uint32 last_load_addr
;
73 run_sim(sregs
, icount
, dis
)
80 sregs
->starttime
= get_time();
82 if (sregs
->err_mode
) icount
= 0;
83 deb
= dis
|| sregs
->histlen
|| sregs
->bptnum
;
87 mexc
= memory_iread (sregs
->pc
, &sregs
->inst
, &sregs
->hold
);
91 sregs
->pc
= sregs
->npc
;
92 sregs
->npc
= sregs
->npc
+ 4;
95 if (ext_irl
) irq
= check_interrupts(sregs
);
98 sregs
->trap
= I_ACC_EXC
;
101 if ((sregs
->bphit
= check_bpt(sregs
)) != 0) {
105 if (sregs
->histlen
) {
106 sregs
->histbuf
[sregs
->histind
].addr
= sregs
->pc
;
107 sregs
->histbuf
[sregs
->histind
].time
= ebase
.simtime
;
109 if (sregs
->histind
>= sregs
->histlen
)
113 printf(" %8" PRIu64
" ", ebase
.simtime
);
114 dis_mem(sregs
->pc
, 1, &dinfo
);
117 dispatch_instruction(sregs
);
123 sregs
->err_mode
= execute_trap(sregs
);
124 if (sregs
->err_mode
) {
125 error_mode(sregs
->pc
);
131 if (ctrl_c
|| (sregs
->tlimit
<= ebase
.simtime
)) {
133 if (sregs
->tlimit
<= ebase
.simtime
) sregs
->tlimit
= -1;
136 sregs
->tottime
+= get_time() - sregs
->starttime
;
159 char *cmdq
[HIST_LEN
];
165 for (i
= 0; i
< 64; i
++)
167 printf("\n SIS - SPARC instruction simulator %s, copyright Jiri Gaisler 1995\n", sis_version
);
168 printf(" Bug-reports to jgais@wd.estec.esa.nl\n\n");
169 while (stat
< argc
) {
170 if (argv
[stat
][0] == '-') {
171 if (strcmp(argv
[stat
], "-v") == 0) {
173 } else if (strcmp(argv
[stat
], "-c") == 0) {
174 if ((stat
+ 1) < argc
) {
176 cfile
= argv
[++stat
];
178 } else if (strcmp(argv
[stat
], "-nfp") == 0)
180 else if (strcmp(argv
[stat
], "-ift") == 0)
182 else if (strcmp(argv
[stat
], "-wrp") == 0)
184 else if (strcmp(argv
[stat
], "-rom8") == 0)
186 else if (strcmp(argv
[stat
], "-uben") == 0)
188 else if (strcmp(argv
[stat
], "-uart1") == 0) {
189 if ((stat
+ 1) < argc
)
190 strcpy(uart_dev1
, argv
[++stat
]);
191 } else if (strcmp(argv
[stat
], "-uart2") == 0) {
192 if ((stat
+ 1) < argc
)
193 strcpy(uart_dev2
, argv
[++stat
]);
194 } else if (strcmp(argv
[stat
], "-freq") == 0) {
195 if ((stat
+ 1) < argc
)
196 freq
= VAL(argv
[++stat
]);
197 } else if (strcmp(argv
[stat
], "-sparclite") == 0) {
200 } else if (strcmp(argv
[stat
], "-era") == 0) {
203 } else if (strcmp(argv
[stat
], "-dumbio") == 0) {
205 } else if (strcmp(argv
[stat
], "-v") == 0) {
208 printf("unknown option %s\n", argv
[stat
]);
218 printf("FPU disabled\n");
221 printf("ERA ECC emulation enabled\n");
225 INIT_DISASSEMBLE_INFO(dinfo
, stdout
, (fprintf_ftype
) fprintf
);
226 dinfo
.endian
= BFD_ENDIAN_BIG
;
228 termsave
= fcntl(0, F_GETFL
, 0);
236 last_load_addr
= bfd_load(argv
[lfile
]);
242 bacmd
= (char *) malloc(256);
243 strcpy(bacmd
, "batch ");
244 strcat(bacmd
, cfile
);
245 exec_cmd(&sregs
, bacmd
);
249 if (cmdq
[cmdi
] != 0) {
251 remove_history(cmdq
[cmdi
]);
253 remove_history(cmdi
);
258 cmdq
[cmdi
] = readline("sis> ");
259 if (cmdq
[cmdi
] && *cmdq
[cmdi
])
260 add_history(cmdq
[cmdi
]);
262 stat
= exec_cmd(&sregs
, cmdq
[cmdi
]);
271 printf("\b\bInterrupt!\n");
273 printf(" Stopped at time %" PRIu64
" (%.3f ms)\n", ebase
.simtime
,
274 ((double) ebase
.simtime
/ (double) sregs
.freq
) / 1000.0);
277 printf("breakpoint at 0x%08x reached\n", sregs
.pc
);
281 printf("IU in error mode (%d)\n", sregs
.trap
);
283 printf(" %8" PRIu64
" ", ebase
.simtime
);
284 dis_mem(sregs
.pc
, 1, &dinfo
);
292 cmdi
= (cmdi
+ 1) & (HIST_LEN
- 1);
This page took 0.075777 seconds and 4 git commands to generate.