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"
34 #define VAL(x) strtol(x,(char **)NULL,0)
36 /* Structures and functions from readline library */
38 #include "readline/readline.h"
39 #include "readline/history.h"
41 /* Command history buffer length - MUST be binary */
44 extern struct disassemble_info dinfo
;
45 extern struct pstate sregs
;
46 extern struct estate ebase
;
54 extern int sis_verbose
;
55 extern char *sis_version
;
56 extern struct estate ebase
;
57 extern struct evcell evbuf
[];
58 extern struct irqcell irqarr
[];
59 extern int irqpend
, ext_irl
;
63 extern char uart_dev1
[];
64 extern char uart_dev2
[];
65 extern uint32 last_load_addr
;
72 run_sim(sregs
, icount
, dis
)
77 int irq
, mexc
, deb
, asi
;
79 sregs
->starttime
= get_time();
81 if (sregs
->err_mode
) icount
= 0;
82 deb
= dis
|| sregs
->histlen
|| sregs
->bptnum
;
86 if (sregs
->psr
& 0x080)
90 mexc
= memory_read(asi
, sregs
->pc
, &sregs
->inst
, 2, &sregs
->hold
);
94 sregs
->pc
= sregs
->npc
;
95 sregs
->npc
= sregs
->npc
+ 4;
98 if (ext_irl
) irq
= check_interrupts(sregs
);
101 sregs
->trap
= I_ACC_EXC
;
104 if ((sregs
->bphit
= check_bpt(sregs
)) != 0) {
108 if (sregs
->histlen
) {
109 sregs
->histbuf
[sregs
->histind
].addr
= sregs
->pc
;
110 sregs
->histbuf
[sregs
->histind
].time
= ebase
.simtime
;
112 if (sregs
->histind
>= sregs
->histlen
)
116 printf(" %8u ", ebase
.simtime
);
117 dis_mem(sregs
->pc
, 1, &dinfo
);
120 dispatch_instruction(sregs
);
126 sregs
->err_mode
= execute_trap(sregs
);
127 if (sregs
->err_mode
) {
128 error_mode(sregs
->pc
);
134 if (ctrl_c
|| (sregs
->tlimit
<= ebase
.simtime
)) {
136 if (sregs
->tlimit
<= ebase
.simtime
) sregs
->tlimit
= -1;
139 sregs
->tottime
+= get_time() - sregs
->starttime
;
162 char *cmdq
[HIST_LEN
];
168 for (i
= 0; i
< 64; i
++)
170 printf("\n SIS - SPARC instruction simulator %s, copyright Jiri Gaisler 1995\n", sis_version
);
171 printf(" Bug-reports to jgais@wd.estec.esa.nl\n\n");
172 while (stat
< argc
) {
173 if (argv
[stat
][0] == '-') {
174 if (strcmp(argv
[stat
], "-v") == 0) {
176 } else if (strcmp(argv
[stat
], "-c") == 0) {
177 if ((stat
+ 1) < argc
) {
179 cfile
= argv
[++stat
];
181 } else if (strcmp(argv
[stat
], "-nfp") == 0)
183 else if (strcmp(argv
[stat
], "-ift") == 0)
185 else if (strcmp(argv
[stat
], "-wrp") == 0)
187 else if (strcmp(argv
[stat
], "-rom8") == 0)
189 else if (strcmp(argv
[stat
], "-uben") == 0)
191 else if (strcmp(argv
[stat
], "-uart1") == 0) {
192 if ((stat
+ 1) < argc
)
193 strcpy(uart_dev1
, argv
[++stat
]);
194 } else if (strcmp(argv
[stat
], "-uart2") == 0) {
195 if ((stat
+ 1) < argc
)
196 strcpy(uart_dev2
, argv
[++stat
]);
197 } else if (strcmp(argv
[stat
], "-freq") == 0) {
198 if ((stat
+ 1) < argc
)
199 freq
= VAL(argv
[++stat
]);
200 } else if (strcmp(argv
[stat
], "-sparclite") == 0) {
203 } else if (strcmp(argv
[stat
], "-era") == 0) {
206 } else if (strcmp(argv
[stat
], "-dumbio") == 0) {
209 printf("unknown option %s\n", argv
[stat
]);
219 printf("FPU disabled\n");
222 printf("ERA ECC emulation enabled\n");
226 INIT_DISASSEMBLE_INFO(dinfo
, stdout
, (fprintf_ftype
) fprintf
);
227 dinfo
.endian
= BFD_ENDIAN_BIG
;
229 termsave
= fcntl(0, F_GETFL
, 0);
237 last_load_addr
= bfd_load(argv
[lfile
]);
243 bacmd
= (char *) malloc(256);
244 strcpy(bacmd
, "batch ");
245 strcat(bacmd
, cfile
);
246 exec_cmd(&sregs
, bacmd
);
250 if (cmdq
[cmdi
] != 0) {
252 remove_history(cmdq
[cmdi
]);
254 remove_history(cmdi
);
259 cmdq
[cmdi
] = readline("sis> ");
260 if (cmdq
[cmdi
] && *cmdq
[cmdi
])
261 add_history(cmdq
[cmdi
]);
263 stat
= exec_cmd(&sregs
, cmdq
[cmdi
]);
272 printf("\b\bInterrupt!\n");
274 printf(" Stopped at time %d (%.3f ms)\n", ebase
.simtime
,
275 ((double) ebase
.simtime
/ (double) sregs
.freq
) / 1000.0);
278 printf("breakpoint at 0x%08x reached\n", sregs
.pc
);
282 printf("IU in error mode (%d)\n", sregs
.trap
);
284 printf(" %8d ", ebase
.simtime
);
285 dis_mem(sregs
.pc
, 1, &dinfo
);
293 cmdi
= (cmdi
+ 1) & (HIST_LEN
- 1);
This page took 0.048534 seconds and 5 git commands to generate.