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 */
43 extern char * readline (char *prompt
);
44 extern void using_history (void);
45 extern void add_history (char *string
);
46 extern HIST_ENTRY
*remove_history (int which
);
50 /* Command history buffer length - MUST be binary */
53 extern struct disassemble_info dinfo
;
54 extern struct pstate sregs
;
55 extern struct estate ebase
;
63 extern int sis_verbose
;
64 extern char *sis_version
;
65 extern struct estate ebase
;
66 extern struct evcell evbuf
[];
67 extern struct irqcell irqarr
[];
68 extern int irqpend
, ext_irl
;
72 extern char uart_dev1
[];
73 extern char uart_dev2
[];
74 extern uint32 last_load_addr
;
81 run_sim(sregs
, icount
, dis
)
86 int irq
, mexc
, deb
, asi
;
88 sregs
->starttime
= get_time();
90 if (sregs
->err_mode
) icount
= 0;
91 deb
= dis
|| sregs
->histlen
|| sregs
->bptnum
;
95 if (sregs
->psr
& 0x080)
99 mexc
= memory_read(asi
, sregs
->pc
, &sregs
->inst
, 2, &sregs
->hold
);
103 sregs
->pc
= sregs
->npc
;
104 sregs
->npc
= sregs
->npc
+ 4;
107 if (ext_irl
) irq
= check_interrupts(sregs
);
110 sregs
->trap
= I_ACC_EXC
;
113 if ((sregs
->bphit
= check_bpt(sregs
)) != 0) {
117 if (sregs
->histlen
) {
118 sregs
->histbuf
[sregs
->histind
].addr
= sregs
->pc
;
119 sregs
->histbuf
[sregs
->histind
].time
= ebase
.simtime
;
121 if (sregs
->histind
>= sregs
->histlen
)
125 printf(" %8u ", ebase
.simtime
);
126 dis_mem(sregs
->pc
, 1, &dinfo
);
129 dispatch_instruction(sregs
);
135 sregs
->err_mode
= execute_trap(sregs
);
136 if (sregs
->err_mode
) {
137 error_mode(sregs
->pc
);
143 if (ctrl_c
|| (sregs
->tlimit
<= ebase
.simtime
)) {
145 if (sregs
->tlimit
<= ebase
.simtime
) sregs
->tlimit
= -1;
148 sregs
->tottime
+= get_time() - sregs
->starttime
;
171 char *cmdq
[HIST_LEN
];
177 for (i
= 0; i
< 64; i
++)
179 printf("\n SIS - SPARC instruction simulator %s, copyright Jiri Gaisler 1995\n", sis_version
);
180 printf(" Bug-reports to jgais@wd.estec.esa.nl\n\n");
181 while (stat
< argc
) {
182 if (argv
[stat
][0] == '-') {
183 if (strcmp(argv
[stat
], "-v") == 0) {
185 } else if (strcmp(argv
[stat
], "-c") == 0) {
186 if ((stat
+ 1) < argc
) {
188 cfile
= argv
[++stat
];
190 } else if (strcmp(argv
[stat
], "-nfp") == 0)
192 else if (strcmp(argv
[stat
], "-ift") == 0)
194 else if (strcmp(argv
[stat
], "-wrp") == 0)
196 else if (strcmp(argv
[stat
], "-rom8") == 0)
198 else if (strcmp(argv
[stat
], "-uben") == 0)
200 else if (strcmp(argv
[stat
], "-uart1") == 0) {
201 if ((stat
+ 1) < argc
)
202 strcpy(uart_dev1
, argv
[++stat
]);
203 } else if (strcmp(argv
[stat
], "-uart2") == 0) {
204 if ((stat
+ 1) < argc
)
205 strcpy(uart_dev2
, argv
[++stat
]);
206 } else if (strcmp(argv
[stat
], "-freq") == 0) {
207 if ((stat
+ 1) < argc
)
208 freq
= VAL(argv
[++stat
]);
209 } else if (strcmp(argv
[stat
], "-sparclite") == 0) {
212 } else if (strcmp(argv
[stat
], "-era") == 0) {
215 } else if (strcmp(argv
[stat
], "-dumbio") == 0) {
218 printf("unknown option %s\n", argv
[stat
]);
228 printf("FPU disabled\n");
231 printf("ERA ECC emulation enabled\n");
235 INIT_DISASSEMBLE_INFO(dinfo
, stdout
, (fprintf_ftype
) fprintf
);
236 dinfo
.endian
= BFD_ENDIAN_BIG
;
238 termsave
= fcntl(0, F_GETFL
, 0);
246 last_load_addr
= bfd_load(argv
[lfile
]);
252 bacmd
= (char *) malloc(256);
253 strcpy(bacmd
, "batch ");
254 strcat(bacmd
, cfile
);
255 exec_cmd(&sregs
, bacmd
);
259 if (cmdq
[cmdi
] != 0) {
261 remove_history(cmdq
[cmdi
]);
263 remove_history(cmdi
);
268 cmdq
[cmdi
] = readline("sis> ");
269 if (cmdq
[cmdi
] && *cmdq
[cmdi
])
270 add_history(cmdq
[cmdi
]);
272 stat
= exec_cmd(&sregs
, cmdq
[cmdi
]);
281 printf("\b\bInterrupt!\n");
283 printf(" Stopped at time %d (%.3f ms)\n", ebase
.simtime
,
284 ((double) ebase
.simtime
/ (double) sregs
.freq
) / 1000.0);
287 printf("breakpoint at 0x%08x reached\n", sregs
.pc
);
291 printf("IU in error mode (%d)\n", sregs
.trap
);
293 printf(" %8d ", ebase
.simtime
);
294 dis_mem(sregs
.pc
, 1, &dinfo
);
302 cmdi
= (cmdi
+ 1) & (HIST_LEN
- 1);
This page took 0.036814 seconds and 5 git commands to generate.