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/>.
30 #include <sys/fcntl.h>
33 #include "sim-config.h"
35 #define VAL(x) strtol(x,(char **)NULL,0)
37 /* Structures and functions from readline library */
44 extern char * readline (char *prompt
);
45 extern void using_history (void);
46 extern void add_history (char *string
);
47 extern HIST_ENTRY
*remove_history (int which
);
51 /* Command history buffer length - MUST be binary */
54 extern struct disassemble_info dinfo
;
55 extern struct pstate sregs
;
56 extern struct estate ebase
;
64 extern int sis_verbose
;
65 extern char *sis_version
;
66 extern struct estate ebase
;
67 extern struct evcell evbuf
[];
68 extern struct irqcell irqarr
[];
69 extern int irqpend
, ext_irl
;
73 extern char uart_dev1
[];
74 extern char uart_dev2
[];
75 extern uint32 last_load_addr
;
82 run_sim(sregs
, icount
, dis
)
87 int irq
, mexc
, deb
, asi
;
89 sregs
->starttime
= time(NULL
);
91 if (sregs
->err_mode
) icount
= 0;
92 deb
= dis
|| sregs
->histlen
|| sregs
->bptnum
;
96 if (sregs
->psr
& 0x080)
100 mexc
= memory_read(asi
, sregs
->pc
, &sregs
->inst
, 2, &sregs
->hold
);
104 sregs
->pc
= sregs
->npc
;
105 sregs
->npc
= sregs
->npc
+ 4;
108 if (ext_irl
) irq
= check_interrupts(sregs
);
111 sregs
->trap
= I_ACC_EXC
;
114 if ((sregs
->bphit
= check_bpt(sregs
)) != 0) {
118 if (sregs
->histlen
) {
119 sregs
->histbuf
[sregs
->histind
].addr
= sregs
->pc
;
120 sregs
->histbuf
[sregs
->histind
].time
= ebase
.simtime
;
122 if (sregs
->histind
>= sregs
->histlen
)
126 printf(" %8u ", ebase
.simtime
);
127 dis_mem(sregs
->pc
, 1, &dinfo
);
130 dispatch_instruction(sregs
);
136 sregs
->err_mode
= execute_trap(sregs
);
137 if (sregs
->err_mode
) {
138 error_mode(sregs
->pc
);
144 if (ctrl_c
|| (sregs
->tlimit
<= ebase
.simtime
)) {
146 if (sregs
->tlimit
<= ebase
.simtime
) sregs
->tlimit
= -1;
149 sregs
->tottime
+= time(NULL
) - sregs
->starttime
;
172 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
]);
223 last_load_addr
= bfd_load(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);
250 bacmd
= (char *) malloc(256);
251 strcpy(bacmd
, "batch ");
252 strcat(bacmd
, cfile
);
253 exec_cmd(&sregs
, bacmd
);
257 if (cmdq
[cmdi
] != 0) {
259 remove_history(cmdq
[cmdi
]);
261 remove_history(cmdi
);
266 cmdq
[cmdi
] = readline("sis> ");
267 if (cmdq
[cmdi
] && *cmdq
[cmdi
])
268 add_history(cmdq
[cmdi
]);
270 stat
= exec_cmd(&sregs
, cmdq
[cmdi
]);
279 printf("\b\bInterrupt!\n");
281 printf(" Stopped at time %d (%.3f ms)\n", ebase
.simtime
,
282 ((double) ebase
.simtime
/ (double) sregs
.freq
) / 1000.0);
285 printf("breakpoint at 0x%08x reached\n", sregs
.pc
);
289 printf("IU in error mode (%d)\n", sregs
.trap
);
291 printf(" %8d ", ebase
.simtime
);
292 dis_mem(sregs
.pc
, 1, &dinfo
);
300 cmdi
= (cmdi
+ 1) & (HIST_LEN
- 1);
This page took 0.034714 seconds and 4 git commands to generate.