1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40 #if !defined(SIM_SCP_H_)
41 # define SIM_SCP_H_ 0
42
43 # include <stdbool.h>
44
45
46
47 # define RU_RUN 0
48 # define RU_GO 1
49 # define RU_STEP 2
50 # define RU_NEXT 3
51 # define RU_CONT 4
52 # define RU_BOOT 5
53
54
55
56 # define EX_D 0
57 # define EX_E 1
58 # define EX_I 2
59
60
61
62 # define SSH_ST 0
63 # define SSH_SH 1
64 # define SSH_CL 2
65
66
67
68 # define CMD_OPT_SW 001
69 # define CMD_OPT_OF 002
70 # define CMD_OPT_SCH 004
71 # define CMD_OPT_DFT 010
72
73
74
75 t_stat reset_cmd (int32 flag, CONST char *ptr);
76 t_stat exdep_cmd (int32 flag, CONST char *ptr);
77 t_stat eval_cmd (int32 flag, CONST char *ptr);
78 t_stat load_cmd (int32 flag, CONST char *ptr);
79 t_stat run_cmd (int32 flag, CONST char *ptr);
80 void run_cmd_message (const char *unechod_cmdline, t_stat r);
81 t_stat attach_cmd (int32 flag, CONST char *ptr);
82 t_stat detach_cmd (int32 flag, CONST char *ptr);
83
84
85
86
87 t_stat exit_cmd (int32 flag, CONST char *ptr);
88 t_stat set_cmd (int32 flag, CONST char *ptr);
89 t_stat show_cmd (int32 flag, CONST char *ptr);
90 t_stat brk_cmd (int32 flag, CONST char *ptr);
91 t_stat do_cmd (int32 flag, CONST char *ptr);
92 t_stat goto_cmd (int32 flag, CONST char *ptr);
93 t_stat return_cmd (int32 flag, CONST char *ptr);
94 t_stat shift_cmd (int32 flag, CONST char *ptr);
95 t_stat call_cmd (int32 flag, CONST char *ptr);
96 t_stat on_cmd (int32 flag, CONST char *ptr);
97 t_stat noop_cmd (int32 flag, CONST char *ptr);
98 t_stat assert_cmd (int32 flag, CONST char *ptr);
99 t_stat send_cmd (int32 flag, CONST char *ptr);
100 t_stat expect_cmd (int32 flag, CONST char *ptr);
101 t_stat help_cmd (int32 flag, CONST char *ptr);
102 t_stat screenshot_cmd (int32 flag, CONST char *ptr);
103 t_stat spawn_cmd (int32 flag, CONST char *ptr);
104 t_stat echo_cmd (int32 flag, CONST char *ptr);
105
106
107 # if !defined (__GNUC__)
108 # define GCC_FMT_ATTR(n, m)
109 # endif
110
111 # if !defined(GCC_FMT_ATTR)
112 # define GCC_FMT_ATTR(n, m) __attribute__ ((format (__printf__, n, m)))
113 # endif
114
115
116 t_stat sim_process_event (void);
117 t_stat sim_activate (UNIT *uptr, int32 interval);
118 t_stat _sim_activate (UNIT *uptr, int32 interval);
119 t_stat sim_activate_abs (UNIT *uptr, int32 interval);
120 t_stat sim_activate_after (UNIT *uptr, uint32 usecs_walltime);
121 t_stat _sim_activate_after (UNIT *uptr, uint32 usecs_walltime);
122 t_stat sim_cancel (UNIT *uptr);
123 t_bool sim_is_active (UNIT *uptr);
124 int32 sim_activate_time (UNIT *uptr);
125 t_stat sim_run_boot_prep (int32 flag);
126 double sim_gtime (void);
127 uint32 sim_grtime (void);
128 int32 sim_qcount (void);
129 t_stat attach_unit (UNIT *uptr, CONST char *cptr);
130 t_stat detach_unit (UNIT *uptr);
131 t_stat assign_device (DEVICE *dptr, const char *cptr);
132 t_stat deassign_device (DEVICE *dptr);
133 t_stat reset_all (uint32 start_device);
134 t_stat reset_all_p (uint32 start_device);
135 const char *sim_dname (DEVICE *dptr);
136 const char *sim_uname (UNIT *dptr);
137 int sim_isspace (char c);
138 int sim_islower (char c);
139 int sim_isalpha (char c);
140 int sim_isprint (char c);
141 int sim_isdigit (char c);
142 int sim_isgraph (char c);
143 int sim_isalnum (char c);
144 CONST char *get_sim_opt (int32 opt, CONST char *cptr, t_stat *st);
145 const char *put_switches (char *buf, size_t bufsize, uint32 sw);
146 CONST char *get_glyph (const char *iptr, char *optr, char mchar);
147 CONST char *get_glyph_nc (const char *iptr, char *optr, char mchar);
148 CONST char *get_glyph_quoted (const char *iptr, char *optr, char mchar);
149 CONST char *get_glyph_cmd (const char *iptr, char *optr);
150 t_value get_uint (const char *cptr, uint32 radix, t_value max, t_stat *status);
151 CONST char *get_range (DEVICE *dptr, CONST char *cptr, t_addr *lo, t_addr *hi,
152 uint32 rdx, t_addr max, char term);
153 t_stat sim_decode_quoted_string (const char *iptr, uint8 *optr, uint32 *osize);
154 char *sim_encode_quoted_string (const uint8 *iptr, size_t size);
155 void fprint_buffer_string (FILE *st, const uint8 *buf, size_t size);
156 t_value strtotv (CONST char *cptr, CONST char **endptr, uint32 radix);
157 int Fprintf (FILE *f, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
158 t_stat fprint_val (FILE *stream, t_value val, uint32 rdx, uint32 wid, uint32 fmt);
159 t_stat sprint_val (char *buf, t_value val, uint32 rdx, size_t wid, uint32 fmt);
160 const char *sim_fmt_secs (double seconds);
161 const char *sprint_capac (DEVICE *dptr, UNIT *uptr);
162 char *read_line (char *cptr, int32 size, FILE *stream);
163 void fprint_reg_help (FILE *st, DEVICE *dptr);
164 void fprint_set_help (FILE *st, DEVICE *dptr);
165 void fprint_show_help (FILE *st, DEVICE *dptr);
166 CTAB *find_cmd (const char *gbuf);
167 DEVICE *find_dev (const char *ptr);
168 DEVICE *find_unit (const char *ptr, UNIT **uptr);
169 DEVICE *find_dev_from_unit (UNIT *uptr);
170 t_stat sim_register_internal_device (DEVICE *dptr);
171 void sim_sub_args (char *in_str, size_t in_str_size, char *do_arg[]);
172 REG *find_reg (CONST char *ptr, CONST char **optr, DEVICE *dptr);
173 CTAB *find_ctab (CTAB *tab, const char *gbuf);
174 C1TAB *find_c1tab (C1TAB *tab, const char *gbuf);
175 SHTAB *find_shtab (SHTAB *tab, const char *gbuf);
176 t_stat get_aval (t_addr addr, DEVICE *dptr, UNIT *uptr);
177 BRKTAB *sim_brk_fnd (t_addr loc);
178 uint32 sim_brk_test (t_addr bloc, uint32 btyp);
179 void sim_brk_clrspc (uint32 spc, uint32 btyp);
180 void sim_brk_npc (uint32 cnt);
181 void sim_brk_setact (const char *action);
182 const char *sim_brk_message(void);
183 t_stat sim_send_input (SEND *snd, uint8 *data, size_t size, uint32 after, uint32 delay);
184 t_stat sim_show_send_input (FILE *st, const SEND *snd);
185 t_bool sim_send_poll_data (SEND *snd, t_stat *stat);
186 t_stat sim_send_clear (SEND *snd);
187 t_stat sim_set_expect (EXPECT *exp, CONST char *cptr);
188 t_stat sim_set_noexpect (EXPECT *exp, const char *cptr);
189 t_stat sim_exp_set (EXPECT *exp, const char *match, int32 cnt, uint32 after, int32 switches, const char *act);
190 t_stat sim_exp_clr (EXPECT *exp, const char *match);
191 t_stat sim_exp_clrall (EXPECT *exp);
192 t_stat sim_exp_show (FILE *st, CONST EXPECT *exp, const char *match);
193 t_stat sim_exp_showall (FILE *st, const EXPECT *exp);
194 t_stat sim_exp_check (EXPECT *exp, uint8 data);
195 t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
196 t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
197 t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
198 const char *sim_error_text (t_stat stat);
199 t_stat sim_string_to_stat (const char *cptr, t_stat *cond);
200 void sim_printf (const char *fmt, ...) GCC_FMT_ATTR(1, 2);
201 t_stat sim_messagef (t_stat stat, const char *fmt, ...) GCC_FMT_ATTR(2, 3);
202 void sim_data_trace(DEVICE *dptr, UNIT *uptr, const uint8 *data, const char *position, size_t len, const char *txt, uint32 reason);
203 void sim_debug_bits_hdr (uint32 dbits, DEVICE* dptr, const char *header,
204 BITFIELD* bitdefs, uint32 before, uint32 after, int terminate);
205 void sim_debug_bits (uint32 dbits, DEVICE* dptr, BITFIELD* bitdefs,
206 uint32 before, uint32 after, int terminate);
207 void _sim_debug (uint32 dbits, DEVICE* dptr, const char *fmt, ...) GCC_FMT_ATTR(3, 4);
208 # define sim_debug(dbits, dptr, ...) \
209 do { \
210 if ((sim_deb != NULL) && ((dptr != NULL) && ((dptr)->dctrl & dbits))) \
211 _sim_debug (dbits, dptr, __VA_ARGS__); \
212 } \
213 while (0)
214 void fprint_stopped_gen (FILE *st, t_stat v, REG *pc, DEVICE *dptr);
215 # define SCP_HELP_FLAT (1u << 31)
216 # define SCP_HELP_ONECMD (1u << 30)
217 # define SCP_HELP_ATTACH (1u << 29)
218 t_stat scp_help (FILE *st, DEVICE *dptr,
219 UNIT *uptr, int32 flag, const char *help, const char *cptr, ...);
220 t_stat scp_vhelp (FILE *st, DEVICE *dptr,
221 UNIT *uptr, int32 flag, const char *help, const char *cptr, va_list ap);
222 t_stat scp_helpFromFile (FILE *st, DEVICE *dptr,
223 UNIT *uptr, int32 flag, const char *help, const char *cptr, ...);
224 t_stat scp_vhelpFromFile (FILE *st, DEVICE *dptr,
225 UNIT *uptr, int32 flag, const char *help, const char *cptr, va_list ap);
226
227
228
229 extern DEVICE *sim_dflt_dev;
230 extern int32 sim_interval;
231 extern int32 sim_switches;
232 extern int32 sim_iglock;
233 extern int32 sim_nolock;
234 extern int32 sim_randompst;
235 extern int32 sim_quiet;
236 extern int32 sim_localopc;
237 extern int32 sim_randstate;
238 extern int32 sim_nostate;
239 extern int32 sim_step;
240 extern t_stat sim_last_cmd_stat;
241 extern FILE *sim_log;
242 extern FILEREF *sim_log_ref;
243 extern FILE *sim_deb;
244 extern FILEREF *sim_deb_ref;
245 extern int32 sim_deb_switches;
246 extern struct timespec sim_deb_basetime;
247 extern DEVICE **sim_internal_devices;
248 extern uint32 sim_internal_device_count;
249 extern UNIT *sim_clock_queue;
250 extern int32 sim_is_running;
251 extern t_bool sim_processing_event;
252 extern char *sim_prompt;
253 extern const char *sim_savename;
254 extern t_value *sim_eval;
255 extern volatile int32 stop_cpu;
256 extern uint32 sim_brk_types;
257 extern uint32 sim_brk_dflt;
258 extern uint32 sim_brk_summ;
259 extern uint32 sim_brk_match_type;
260 extern t_addr sim_brk_match_addr;
261 extern BRKTYPTAB *sim_brk_type_desc;
262 extern FILE *stdnul;
263 extern t_bool sim_asynch_enabled;
264 extern bool mlock_failure;
265 extern char* sim_appfilename;
266 extern uint64_t sim_free_memory;
267
268
269
270 extern const char* appname;
271 extern char sim_name[];
272 extern DEVICE *sim_devices[];
273 extern REG *sim_PC;
274 extern const char *sim_stop_messages[];
275 extern t_stat sim_instr (void);
276 extern int32 sim_emax;
277 extern t_stat fprint_sym (FILE *ofile, t_addr addr, t_value *val,
278 UNIT *uptr, int32 sw);
279 extern t_stat parse_sym (CONST char *cptr, t_addr addr, UNIT *uptr, t_value *val,
280 int32 sw);
281
282
283
284
285 extern void (*sim_vm_init) (void);
286 extern char *(*sim_vm_read) (char *ptr, int32 size, FILE *stream);
287 extern void (*sim_vm_post) (t_bool from_scp);
288 extern CTAB *sim_vm_cmd;
289 extern void (*sim_vm_sprint_addr) (char *buf, DEVICE *dptr, t_addr addr);
290 extern void (*sim_vm_fprint_addr) (FILE *st, DEVICE *dptr, t_addr addr);
291 extern t_addr (*sim_vm_parse_addr) (DEVICE *dptr, CONST char *cptr, CONST char **tptr);
292 extern t_bool (*sim_vm_fprint_stopped) (FILE *st, t_stat reason);
293 extern t_value (*sim_vm_pc_value) (void);
294 extern t_bool (*sim_vm_is_subroutine_call) (t_addr **ret_addrs);
295 # if !defined(NO_LOCALE)
296 extern const char *xstrerror_l(int errnum);
297 # else
298 # define xstrerror_l strerror
299 # endif
300
301 # define SIM_FRONTPANEL_VERSION 2
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325 typedef struct PANEL PANEL;
326
327 PANEL *
328 sim_panel_start_simulator (const char *sim_path,
329 const char *sim_config,
330 size_t device_panel_count);
331
332 PANEL *
333 sim_panel_start_simulator_debug (const char *sim_path,
334 const char *sim_config,
335 size_t device_panel_count,
336 const char *debug_file);
337
338
339
340
341
342
343
344
345
346
347 PANEL *
348 sim_panel_add_device_panel (PANEL *simulator_panel,
349 const char *device_name);
350
351
352
353
354
355
356
357
358
359 int
360 sim_panel_destroy (PANEL *panel);
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390 int
391 sim_panel_add_register (PANEL *panel,
392 const char *name,
393 const char *device_name,
394 size_t size,
395 void *addr);
396
397 int
398 sim_panel_add_register_array (PANEL *panel,
399 const char *name,
400 const char *device_name,
401 size_t element_count,
402 size_t size,
403 void *addr);
404
405 int
406 sim_panel_add_register_indirect (PANEL *panel,
407 const char *name,
408 const char *device_name,
409 size_t size,
410 void *addr);
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434 int
435 sim_panel_get_registers (PANEL *panel, unsigned long long *simulation_time);
436
437 typedef void (*PANEL_DISPLAY_PCALLBACK)(PANEL *panel,
438 unsigned long long simulation_time,
439 void *context);
440
441 int
442 sim_panel_set_display_callback (PANEL *panel,
443 PANEL_DISPLAY_PCALLBACK callback,
444 void *context,
445 int callbacks_per_second);
446
447
448
449
450
451
452
453
454
455
456
457
458
459 int
460 sim_panel_exec_halt (PANEL *panel);
461
462 int
463 sim_panel_exec_boot (PANEL *panel, const char *device);
464
465 int
466 sim_panel_exec_run (PANEL *panel);
467
468 int
469 sim_panel_exec_step (PANEL *panel);
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491 int
492 sim_panel_break_set (PANEL *panel, const char *condition);
493
494 int
495 sim_panel_break_clear (PANEL *panel, const char *condition);
496
497 int
498 sim_panel_break_output_set (PANEL *panel, const char *condition);
499
500 int
501 sim_panel_break_output_clear (PANEL *panel, const char *condition);
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529 int
530 sim_panel_gen_examine (PANEL *panel,
531 const char *name_or_addr,
532 size_t size,
533 void *value);
534
535
536
537
538
539
540
541
542
543
544
545 int
546 sim_panel_gen_deposit (PANEL *panel,
547 const char *name_or_addr,
548 size_t size,
549 const void *value);
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566 int
567 sim_panel_mem_examine (PANEL *panel,
568 size_t addr_size,
569 const void *addr,
570 size_t value_size,
571 void *value);
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588 int
589 sim_panel_mem_deposit (PANEL *panel,
590 size_t addr_size,
591 const void *addr,
592 size_t value_size,
593 const void *value);
594
595
596
597
598
599
600
601
602
603
604
605 int
606 sim_panel_set_register_value (PANEL *panel,
607 const char *name,
608 const char *value);
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630 int
631 sim_panel_mount (PANEL *panel,
632 const char *device,
633 const char *switches,
634 const char *path);
635
636
637
638
639
640
641
642 int
643 sim_panel_dismount (PANEL *panel,
644 const char *device);
645
646 typedef enum {
647 Halt,
648 Run,
649 Error
650
651
652 } OperationalState;
653
654 OperationalState
655 sim_panel_get_state (PANEL *panel);
656
657
658
659
660
661
662
663
664
665
666
667
668
669 const char *sim_panel_get_error (void);
670 void sim_panel_clear_error (void);
671
672
673
674
675
676
677
678
679
680
681 void
682 sim_panel_set_debug_file (PANEL *panel, const char *debug_file);
683
684 void
685 sim_panel_set_debug_mode (PANEL *panel, int debug_bits);
686
687 void
688 sim_panel_flush_debug (PANEL *panel);
689
690 #endif