-
Notifications
You must be signed in to change notification settings - Fork 0
/
scp.c
17659 lines (16263 loc) · 702 KB
/
scp.c
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
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
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
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
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* scp.c: simulator control program
Copyright (c) 1993-2022, Robert M Supnik
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
ROBERT M SUPNIK BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Except as contained in this notice, the name of Robert M Supnik shall not be
used in advertising or otherwise to promote the sale, use or other dealings
in this Software without prior written authorization from Robert M Supnik.
21-Oct-21 RMS Fixed bug in byte deposits if aincr > 1
16-Feb-21 JDB Rewrote get_rval, put_rval to support arrays of structures
25-Jan-21 JDB REG "size" field now determines access size
REG "maxval" field now determines maximum allowed value
08-Mar-16 RMS Added shutdown flag for detach_all
20-Mar-12 MP Fixes to "SHOW <x> SHOW" commands
06-Jan-12 JDB Fixed "SHOW DEVICE" with only one enabled unit (Dave Bryan)
25-Sep-11 MP Added the ability for a simulator built with
SIM_ASYNCH_IO to change whether I/O is actually done
asynchronously by the new scp command SET ASYNCH and
SET NOASYNCH
22-Sep-11 MP Added signal catching of SIGHUP and SIGTERM to cause
simulator STOP. This allows an externally signalled
event (i.e. system shutdown, or logoff) to signal a
running simulator of these events and to allow
reasonable actions to be taken. This will facilitate
running a simulator as a 'service' on *nix platforms,
given a sufficiently flexible simulator .ini file.
20-Apr-11 MP Added expansion of %STATUS% and %TSTATUS% in do command
arguments. STATUS is the numeric value of the last
command error status and TSTATUS is the text message
relating to the last command error status
17-Apr-11 MP Changed sim_rest to defer attaching devices until after
device register contents have been restored since some
attach activities may reference register contained info.
29-Jan-11 MP Adjusted sim_debug to:
- include the simulator timestamp (sim_gtime)
as part of the prefix for each line of output
- write complete lines at a time (avoid asynch I/O issues).
05-Jan-11 MP Added Asynch I/O support
22-Jan-11 MP Added SET ON, SET NOON, ON, GOTO and RETURN command support
13-Jan-11 MP Added "SHOW SHOW" and "SHOW <dev> SHOW" commands
05-Jan-11 RMS Fixed bug in deposit stride for numeric input (John Dundas)
23-Dec-10 RMS Clarified some help messages (Mark Pizzolato)
08-Nov-10 RMS Fixed handling of DO with no arguments (Dave Bryan)
22-May-10 RMS Added *nix READLINE support (Mark Pizzolato)
08-Feb-09 RMS Fixed warnings in help printouts
29-Dec-08 RMS Fixed implementation of MTAB_NC
24-Nov-08 RMS Revised RESTORE unit logic for consistency
05-Sep-08 JDB "detach_all" ignores error status returns if shutting down
17-Aug-08 RMS Revert RUN/BOOT to standard, rather than powerup, reset
25-Jul-08 JDB DO cmd missing params now default to null string
29-Jun-08 JDB DO cmd sub_args now allows "\\" to specify literal backslash
04-Jun-08 JDB label the patch delta more clearly
31-Mar-08 RMS Fixed bug in local/global register search (Mark Pizzolato)
Fixed bug in restore of RO units (Mark Pizzolato)
06-Feb-08 RMS Added SET/SHO/NO BR with default argument
18-Jul-07 RMS Modified match_ext for VMS ext;version support
28-Apr-07 RMS Modified sim_instr invocation to call sim_rtcn_init_all
Fixed bug in get_sim_opt
Fixed bug in restoration with changed memory size
08-Mar-07 JDB Fixed breakpoint actions in DO command file processing
30-Jan-07 RMS Fixed bugs in get_ipaddr
17-Oct-06 RMS Added idle support
04-Oct-06 JDB DO cmd failure now echoes cmd unless -q
30-Aug-06 JDB detach_unit returns SCPE_UNATT if not attached
14-Jul-06 RMS Added sim_activate_abs
02-Jun-06 JDB Fixed do_cmd to exit nested files on assertion failure
Added -E switch to do_cmd to exit on any error
14-Feb-06 RMS Upgraded save file format to V3.5
18-Jan-06 RMS Added fprint_stopped_gen
Added breakpoint spaces
Fixed unaligned register access (Doug Carman)
22-Sep-05 RMS Fixed declarations (Sterling Garwood)
30-Aug-05 RMS Revised to trim trailing spaces on file names
25-Aug-05 RMS Added variable default device support
23-Aug-05 RMS Added Linux line history support
16-Aug-05 RMS Fixed C++ declaration and cast problems
01-May-05 RMS Revised syntax for SET DEBUG (Dave Bryan)
22-Mar-05 JDB Modified DO command to allow ten-level nesting
18-Mar-05 RMS Moved DETACH tests into detach_unit (Dave Bryan)
Revised interface to fprint_sym, fparse_sym
13-Mar-05 JDB ASSERT now requires a conditional operator
07-Feb-05 RMS Added ASSERT command (Dave Bryan)
02-Feb-05 RMS Fixed bug in global register search
26-Dec-04 RMS Qualified SAVE examine, RESTORE deposit with SIM_SW_REST
10-Nov-04 JDB Fixed logging of errors from cmds in "do" file
05-Nov-04 RMS Moved SET/SHOW DEBUG under CONSOLE hierarchy
Renamed unit OFFLINE/ONLINE to DISABLED/ENABLED (Dave Bryan)
Revised to flush output files after simulation stop (Dave Bryan)
15-Oct-04 RMS Fixed HELP to suppress duplicate descriptions
27-Sep-04 RMS Fixed comma-separation options in set (David Bryan)
09-Sep-04 RMS Added -p option for RESET
13-Aug-04 RMS Qualified RESTORE detach with SIM_SW_REST
17-Jul-04 JDB DO cmd file open failure retries with ".sim" appended
17-Jul-04 RMS Added ECHO command (Dave Bryan)
12-Jul-04 RMS Fixed problem ATTACHing to read only files
(John Dundas)
28-May-04 RMS Added SET/SHOW CONSOLE
14-Feb-04 RMS Updated SAVE/RESTORE (V3.2)
RMS Added debug print routines (Dave Hittner)
RMS Added sim_vm_parse_addr and sim_vm_fprint_addr
RMS Added REG_VMAD support
RMS Split out libraries
RMS Moved logging function to SCP
RMS Exposed step counter interface(s)
RMS Fixed double logging of SHOW BREAK (Mark Pizzolato)
RMS Fixed implementation of REG_VMIO
RMS Added SET/SHOW DEBUG, SET/SHOW <device> DEBUG,
SHOW <device> MODIFIERS, SHOW <device> RADIX
RMS Changed sim_fsize to take uptr argument
29-Dec-03 RMS Added Telnet console output stall support
01-Nov-03 RMS Cleaned up implicit detach on attach/restore
Fixed bug in command line read while logging (Mark Pizzolato)
01-Sep-03 RMS Fixed end-of-file problem in dep, idep
Fixed error on trailing spaces in dep, idep
15-Jul-03 RMS Removed unnecessary test in reset_all
15-Jun-03 RMS Added register flag REG_VMIO
25-Apr-03 RMS Added extended address support (V3.0)
Fixed bug in SAVE (Peter Schorn)
Added u5, u6 fields
Added logical name support
03-Mar-03 RMS Added sim_fsize
27-Feb-03 RMS Fixed bug in multiword deposits to files
08-Feb-03 RMS Changed sim_os_sleep to void, match_ext to char*
Added multiple actions, .ini file support
Added multiple switch evaluations per line
07-Feb-03 RMS Added VMS support for ! (Mark Pizzolato)
01-Feb-03 RMS Added breakpoint table extension, actions
14-Jan-03 RMS Added missing function prototypes
10-Jan-03 RMS Added attach/restore flag, dynamic memory size support,
case sensitive SET options
22-Dec-02 RMS Added ! (OS command) feature (Mark Pizzolato)
17-Dec-02 RMS Added get_ipaddr
02-Dec-02 RMS Added EValuate command
16-Nov-02 RMS Fixed bug in register name match algorithm
13-Oct-02 RMS Fixed Borland compiler warnings (Hans Pufal)
05-Oct-02 RMS Fixed bugs in set_logon, ssh_break (David Hittner)
Added support for fixed buffer devices
Added support for Telnet console, removed VT support
Added help <command>
Added VMS file optimizations (Robert Alan Byer)
Added quiet mode, DO with parameters, GUI interface,
extensible commands (Brian Knittel)
Added device enable/disable commands
14-Jul-02 RMS Fixed exit bug in do, added -v switch (Brian Knittel)
17-May-02 RMS Fixed bug in fxread/fxwrite error usage (found by
Norm Lastovic)
02-May-02 RMS Added VT emulation interface, changed {NO}LOG to SET {NO}LOG
22-Apr-02 RMS Fixed laptop sleep problem in clock calibration, added
magtape record length error (Jonathan Engdahl)
26-Feb-02 RMS Fixed initialization bugs in do_cmd, get_aval
(Brian Knittel)
10-Feb-02 RMS Fixed problem in clock calibration
06-Jan-02 RMS Moved device enable/disable to simulators
30-Dec-01 RMS Generalized timer packaged, added circular arrays
19-Dec-01 RMS Fixed DO command bug (John Dundas)
07-Dec-01 RMS Implemented breakpoint package
05-Dec-01 RMS Fixed bug in universal register logic
03-Dec-01 RMS Added read-only units, extended SET/SHOW, universal registers
24-Nov-01 RMS Added unit-based registers
16-Nov-01 RMS Added DO command
28-Oct-01 RMS Added relative range addressing
08-Oct-01 RMS Added SHOW VERSION
30-Sep-01 RMS Relaxed attach test in BOOT
27-Sep-01 RMS Added queue count routine, fixed typo in ex/mod
17-Sep-01 RMS Removed multiple console support
07-Sep-01 RMS Removed conditional externs on function prototypes
Added special modifier print
31-Aug-01 RMS Changed int64 to t_int64 for Windoze (V2.7)
18-Jul-01 RMS Minor changes for Macintosh port
12-Jun-01 RMS Fixed bug in big-endian I/O (Dave Conroy)
27-May-01 RMS Added multiple console support
16-May-01 RMS Added logging
15-May-01 RMS Added features from Tim Litt
12-May-01 RMS Fixed missing return in disable_cmd
25-Mar-01 RMS Added ENABLE/DISABLE
14-Mar-01 RMS Revised LOAD/DUMP interface (again)
05-Mar-01 RMS Added clock calibration support
05-Feb-01 RMS Fixed bug, DETACH buffered unit with hwmark = 0
04-Feb-01 RMS Fixed bug, RESTORE not using device's attach routine
21-Jan-01 RMS Added relative time
22-Dec-00 RMS Fixed find_device for devices ending in numbers
08-Dec-00 RMS V2.5a changes
30-Oct-00 RMS Added output file option to examine
11-Jul-99 RMS V2.5 changes
13-Apr-99 RMS Fixed handling of 32b addresses
04-Oct-98 RMS V2.4 changes
20-Aug-98 RMS Added radix commands
05-Jun-98 RMS Fixed bug in ^D handling for UNIX
10-Apr-98 RMS Added switches to all commands
26-Oct-97 RMS Added search capability
25-Jan-97 RMS Revised data types
23-Jan-97 RMS Added bi-endian I/O
06-Sep-96 RMS Fixed bug in variable length IEXAMINE
16-Jun-96 RMS Changed interface to parse/print_sym
06-Apr-96 RMS Added error checking in reset all
07-Jan-96 RMS Added register buffers in save/restore
11-Dec-95 RMS Fixed ordering bug in save/restore
22-May-95 RMS Added symbolic input
13-Apr-95 RMS Added symbolic printouts
*/
/* Macros and data structures */
#define NOT_MUX_USING_CODE /* sim_tmxr library provider or agnostic */
#define IN_SCP_C 1 /* Include from scp.c */
#include "sim_defs.h"
#include "sim_scp_private.h"
#include "sim_rev.h"
#include "sim_disk.h"
#include "sim_tape.h"
#include "sim_ether.h"
#include "sim_card.h"
#include "sim_serial.h"
#include "sim_video.h"
#include "sim_sock.h"
#include "sim_frontpanel.h"
#include <signal.h>
#if defined(_WIN32)
#include <io.h>
#include <fcntl.h>
#endif
#ifndef MAX
#define MAX(a,b) (((a) >= (b)) ? (a) : (b))
#endif
#ifndef MIN
#define MIN(a,b) (((a) <= (b)) ? (a) : (b))
#endif
/* Max width of a value expressed as a formatted string */
#define MAX_WIDTH ((int) ((CHAR_BIT * sizeof (t_value) * 4 + 3)/3))
/* search logical and boolean ops */
#define SCH_OR 0 /* search logicals */
#define SCH_AND 1
#define SCH_XOR 2
#define SCH_E 0 /* search booleans */
#define SCH_N 1
#define SCH_G 2
#define SCH_L 3
#define SCH_EE 4
#define SCH_NE 5
#define SCH_GE 6
#define SCH_LE 7
#define MAX_DO_NEST_LVL 20 /* DO cmd nesting level limit */
#define SRBSIZ 1024 /* save/restore buffer */
#define SIM_BRK_INILNT 4096 /* bpt tbl length */
#define SIM_BRK_ALLTYP 0xFFFFFFFB
#define UPDATE_SIM_TIME \
if (1) { \
int32 _x; \
AIO_LOCK; \
if (sim_clock_queue == QUEUE_LIST_END) \
_x = noqueue_time; \
else \
_x = sim_clock_queue->time; \
sim_time = sim_time + (_x - sim_interval); \
sim_rtime = sim_rtime + ((uint32) (_x - sim_interval)); \
if (sim_clock_queue == QUEUE_LIST_END) \
noqueue_time = sim_interval; \
else \
sim_clock_queue->time = sim_interval; \
AIO_UNLOCK; \
} \
else \
(void)0
/* Size of a DEVICE's data element */
#define SZ_D(dp) (size_map[((dp)->dwidth + CHAR_BIT - 1) / CHAR_BIT])
/* Size of a REGister's data element */
#define SZ_R(rp) \
(size_map[((rp)->width + (rp)->offset + CHAR_BIT - 1) / CHAR_BIT])
#if defined (USE_INT64)
#define SZ_LOAD(sz,v,mb,j) \
if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \
else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \
else if (sz == sizeof (uint32)) v = *(((uint32 *) mb) + ((uint32) j)); \
else v = *(((t_uint64 *) mb) + ((uint32) j));
#define SZ_STORE(sz,v,mb,j) \
if (sz == sizeof (uint8)) *(((uint8 *) mb) + j) = (uint8) v; \
else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \
else if (sz == sizeof (uint32)) *(((uint32 *) mb) + ((uint32) j)) = (uint32) v; \
else *(((t_uint64 *) mb) + ((uint32) j)) = v;
#else
#define SZ_LOAD(sz,v,mb,j) \
if (sz == sizeof (uint8)) v = *(((uint8 *) mb) + ((uint32) j)); \
else if (sz == sizeof (uint16)) v = *(((uint16 *) mb) + ((uint32) j)); \
else v = *(((uint32 *) mb) + ((uint32) j));
#define SZ_STORE(sz,v,mb,j) \
if (sz == sizeof (uint8)) *(((uint8 *) mb) + ((uint32) j)) = (uint8) v; \
else if (sz == sizeof (uint16)) *(((uint16 *) mb) + ((uint32) j)) = (uint16) v; \
else *(((uint32 *) mb) + ((uint32) j)) = v;
#endif
#define SIM_DBG_EVENT_NEG 0x80000000 /* negative event dispatch activities */
#define SIM_DBG_EVENT 0x40000000 /* event dispatch activities */
#define SIM_DBG_ACTIVATE 0x20000000 /* queue insertion activities */
#define SIM_DBG_AIO_QUEUE 0x10000000 /* asynch event queue activities */
#define SIM_DBG_EXP_STACK 0x08000000 /* expression stack activities */
#define SIM_DBG_EXP_EVAL 0x04000000 /* expression evaluation activities */
#define SIM_DBG_BRK_ACTION 0x02000000 /* action activities */
#define SIM_DBG_DO 0x01000000 /* do activities */
#define SIM_DBG_SAVE 0x00800000 /* save activities */
#define SIM_DBG_RESTORE 0x00400000 /* restore activities */
static DEBTAB scp_debug[] = {
{"EVENT", SIM_DBG_EVENT, "Event Dispatch Activities"},
{"NEGATIVE", SIM_DBG_EVENT_NEG, "Negative Event Dispatch Activities"},
{"ACTIVATE", SIM_DBG_ACTIVATE, "Event Queue Insertion Activities"},
{"QUEUE", SIM_DBG_AIO_QUEUE, "Asynch Event Queue Activities"},
{"EXPSTACK", SIM_DBG_EXP_STACK, "Expression Stack Activities"},
{"EXPEVAL", SIM_DBG_EXP_EVAL, "Expression Evaluation Activities"},
{"ACTION", SIM_DBG_BRK_ACTION, "If/Breakpoint/Expect Action Activities"},
{"DO", SIM_DBG_DO, "Do Command/Expansion Activities"},
{"SAVE", SIM_DBG_SAVE, "Save Activities"},
{"RESTORE", SIM_DBG_RESTORE, "Restore Activities"},
{"INIT", SIM_DBG_INIT, "Initialization Activities"},
{0}
};
static const char *sim_scp_description (DEVICE *dptr)
{
return "SCP Event and Internal Command Processing and Testing";
}
static UNIT scp_test_units[4];
DEVICE sim_scp_dev = {
"SCP-PROCESS", scp_test_units, NULL, NULL,
4, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, DEV_NOSAVE|DEV_DEBUG, 0,
scp_debug, NULL, NULL, NULL, NULL, NULL,
sim_scp_description};
static volatile t_uint64 sim_asynch_event_count = 0;
static t_uint64 sim_processed_event_count = 0;
/* Asynch I/O support */
#if defined (SIM_ASYNCH_IO)
pthread_mutex_t sim_asynch_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t sim_asynch_wake = PTHREAD_COND_INITIALIZER;
pthread_mutex_t sim_timer_lock = PTHREAD_MUTEX_INITIALIZER;
pthread_cond_t sim_timer_wake = PTHREAD_COND_INITIALIZER;
pthread_t sim_asynch_main_threadid;
UNIT * volatile sim_asynch_queue;
t_bool sim_asynch_enabled = TRUE;
//volatile int32 sim_asynch_check;
int32 sim_asynch_check;
int32 sim_asynch_latency = 4000; /* 4 usec interrupt latency */
int32 sim_asynch_inst_latency = 20; /* assume 5 mip simulator */
int sim_aio_update_queue (void)
{
int migrated = 0;
AIO_ILOCK;
if (AIO_QUEUE_VAL != QUEUE_LIST_END) { /* List !Empty */
UNIT *q, *uptr;
int32 a_event_time;
do { /* Grab current queue */
q = AIO_QUEUE_VAL;
} while (q != AIO_QUEUE_SET(QUEUE_LIST_END, q));
while (q != QUEUE_LIST_END) { /* List !Empty */
sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Migrating Asynch event for %s after %d %s\n", sim_uname(q), q->a_event_time, sim_vm_interval_units);
++migrated;
uptr = q;
q = q->a_next;
uptr->a_next = NULL; /* hygiene */
if (uptr->a_activate_call != &sim_activate_notbefore) {
a_event_time = uptr->a_event_time-((sim_asynch_inst_latency+1)/2);
if (a_event_time < 0)
a_event_time = 0;
}
else
a_event_time = uptr->a_event_time;
AIO_IUNLOCK;
uptr->a_activate_call (uptr, a_event_time);
if (uptr->a_check_completion) {
sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Calling Completion Check for asynch event on %s\n", sim_uname(uptr));
uptr->a_check_completion (uptr);
}
AIO_ILOCK;
}
}
AIO_IUNLOCK;
return migrated;
}
void sim_aio_activate (ACTIVATE_API caller, UNIT *uptr, int32 event_time)
{
AIO_ILOCK;
if (sim_asynch_enabled == FALSE) {
char buf[128];
snprintf (buf, sizeof (buf), "sim_aio_activate() called with ASYNCH Disabled for %s\n", sim_uname(uptr));
SIM_SCP_ABORT (buf);
}
++sim_asynch_event_count;
sim_debug (SIM_DBG_AIO_QUEUE, &sim_scp_dev, "Lock Free Queueing Asynch event for %s after %d %s\n", sim_uname(uptr), event_time, sim_vm_interval_units);
if (uptr->a_next) {
uptr->a_activate_call = sim_activate_abs;
uptr->a_event_time = MIN (uptr->a_event_time, event_time);
}
else {
UNIT *q;
uptr->a_event_time = event_time;
uptr->a_activate_call = caller;
do {
q = AIO_QUEUE_VAL;
uptr->a_next = q; /* Mark as on list */
} while (q != AIO_QUEUE_SET(uptr, q));
}
AIO_IUNLOCK;
sim_asynch_check = 0; /* try to force check */
if (sim_idle_wait) {
sim_debug (TIMER_DBG_IDLE, &sim_timer_dev, "wakeup from idle due to async event on %s after %d %s\n", sim_uname(uptr), event_time, sim_vm_interval_units);
pthread_cond_signal (&sim_asynch_wake);
}
}
void sim_aio_check_event (void)
{
if (0 > --sim_asynch_check) {
AIO_UPDATE_QUEUE;
sim_asynch_check = sim_asynch_inst_latency;
}
}
void sim_aio_set_interrupt_latency (int32 instpersec)
{
sim_asynch_inst_latency = (int32)((((double)(instpersec))*sim_asynch_latency)/1000000000);
if (sim_asynch_inst_latency == 0)
sim_asynch_inst_latency = 1;
}
#else /* !defined (SIM_ASYNCH_IO) */
t_bool sim_asynch_enabled = FALSE;
#endif
/* The per-simulator init routine is a weak global that defaults to NULL
The other per-simulator pointers can be overridden by the init routine
WEAK void (*sim_vm_init) (void);
This routine is no longer invoked this way since it doesn't work reliably
on all simh supported compile environments. A simulator that needs these
initializations can perform them in the CPU device reset routine which will
always be called before anything else can be processed.
*/
char* (*sim_vm_read) (char *ptr, int32 size, FILE *stream) = NULL;
void (*sim_vm_post) (t_bool from_scp) = NULL;
CTAB *sim_vm_cmd = NULL;
void (*sim_vm_sprint_addr) (char *buf, DEVICE *dptr, t_addr addr) = NULL;
void (*sim_vm_fprint_addr) (FILE *st, DEVICE *dptr, t_addr addr) = NULL;
t_addr (*sim_vm_parse_addr) (DEVICE *dptr, CONST char *cptr, CONST char **tptr) = NULL;
t_value (*sim_vm_pc_value) (void) = NULL;
t_bool (*sim_vm_is_subroutine_call) (t_addr **ret_addrs) = NULL;
void (*sim_vm_reg_update) (REG *rptr, uint32 idx, t_value prev_val, t_value new_val) = NULL;
t_bool (*sim_vm_fprint_stopped) (FILE *st, t_stat reason) = NULL;
const char *sim_vm_release = NULL;
const char *sim_vm_release_message = NULL;
const char **sim_clock_precalibrate_commands = NULL;
/* Prototypes */
/* Set and show command processors */
t_stat set_dev_radix (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat set_dev_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat set_dev_debug (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat set_unit_enbdis (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat set_unit_append (DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat ssh_break (FILE *st, const char *cptr, int32 flg);
t_stat show_cmd_fi (FILE *ofile, int32 flag, CONST char *cptr);
t_stat show_config (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_queue (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_time (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_mod_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_log_names (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_radix (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_debug (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_logicals (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_modifiers (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_dev_show_commands (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_version (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_default (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_break (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_on (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_do (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_runlimit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat sim_show_send (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat sim_show_expect (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat show_device (FILE *st, DEVICE *dptr, int32 flag);
t_stat show_unit (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag);
t_stat show_all_mods (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flg, int32 *toks);
t_stat show_one_mod (FILE *st, DEVICE *dptr, UNIT *uptr, MTAB *mptr, CONST char *cptr, int32 flag);
t_stat sim_save (FILE *sfile);
t_stat sim_rest (FILE *rfile);
/* Breakpoint package */
t_stat sim_brk_init (void);
t_stat sim_brk_set (t_addr loc, int32 sw, int32 ncnt, CONST char *act);
t_stat sim_brk_clr (t_addr loc, int32 sw);
t_stat sim_brk_clrall (int32 sw);
t_stat sim_brk_show (FILE *st, t_addr loc, int32 sw);
t_stat sim_brk_showall (FILE *st, int32 sw);
CONST char *sim_brk_getact (char *buf, int32 size);
BRKTAB *sim_brk_new (t_addr loc, uint32 btyp);
char *sim_brk_clract (void);
FILE *stdnul;
/* Command support routines */
SCHTAB *get_rsearch (CONST char *cptr, int32 radix, SCHTAB *schptr);
SCHTAB *get_asearch (CONST char *cptr, int32 radix, SCHTAB *schptr);
int32 test_search (t_value *val, SCHTAB *schptr);
static const char *get_glyph_gen (const char *iptr, char *optr, char mchar, t_bool ws_match, t_bool uc, t_bool quote, char escape_char);
typedef enum {
SW_ERROR, /* Parse Error */
SW_BITMASK, /* Bitmask Value or Not a switch */
SW_NUMBER /* Numeric Value */
} SWITCH_PARSE;
SWITCH_PARSE get_switches (const char *cptr, int32 *sw_val, int32 *sw_number);
void put_rval_pcchk (REG *rptr, uint32 idx, t_value val, t_bool pc_chk);
void put_rval (REG *rptr, uint32 idx, t_value val);
void fprint_help (FILE *st);
void fprint_stopped (FILE *st, t_stat r);
void fprint_capac (FILE *st, DEVICE *dptr, UNIT *uptr);
void fprint_sep (FILE *st, int32 *tokens, int32 flag);
REG *find_reg_glob (CONST char *ptr, CONST char **optr, DEVICE **gdptr);
REG *find_reg_glob_reason (CONST char *cptr, CONST char **optr, DEVICE **gdptr, t_stat *stat);
const char *sim_eval_expression (const char *cptr, t_svalue *value, t_bool parens_required, t_stat *stat);
/* Forward references */
t_stat scp_attach_unit (DEVICE *dptr, UNIT *uptr, const char *cptr);
t_stat scp_detach_unit (DEVICE *dptr, UNIT *uptr);
t_bool qdisable (DEVICE *dptr);
t_stat attach_err (UNIT *uptr, t_stat stat);
t_stat detach_all (int32 start_device, t_bool shutdown);
t_stat assign_device (DEVICE *dptr, const char *cptr);
t_stat assign_unit (UNIT *uptr, const char *cptr);
t_stat deassign_device (DEVICE *dptr);
t_stat deassign_unit (UNIT *uptr);
t_stat ssh_break_one (FILE *st, int32 flg, t_addr lo, int32 cnt, CONST char *aptr);
t_stat exdep_reg_loop (FILE *ofile, SCHTAB *schptr, int32 flag, CONST char *cptr,
REG *lowr, REG *highr, uint32 lows, uint32 highs);
t_stat ex_reg (FILE *ofile, t_value val, int32 flag, REG *rptr, uint32 idx);
t_stat dep_reg (int32 flag, CONST char *cptr, REG *rptr, uint32 idx);
t_stat exdep_addr_loop (FILE *ofile, SCHTAB *schptr, int32 flag, const char *cptr,
t_addr low, t_addr high, DEVICE *dptr, UNIT *uptr);
t_stat ex_addr (FILE *ofile, int32 flag, t_addr addr, DEVICE *dptr, UNIT *uptr, int32 dfltinc);
t_stat dep_addr (int32 flag, const char *cptr, t_addr addr, DEVICE *dptr,
UNIT *uptr, int32 dfltinc);
void fprint_fields (FILE *stream, t_value before, t_value after, BITFIELD* bitdefs);
t_stat step_svc (UNIT *ptr);
t_stat runlimit_svc (UNIT *ptr);
t_stat expect_svc (UNIT *ptr);
t_stat flush_svc (UNIT *ptr);
t_stat shift_args (char *do_arg[], size_t arg_count);
t_stat set_on (int32 flag, CONST char *cptr);
t_stat set_verify (int32 flag, CONST char *cptr);
t_stat set_message (int32 flag, CONST char *cptr);
t_stat set_quiet (int32 flag, CONST char *cptr);
t_stat set_asynch (int32 flag, CONST char *cptr);
t_stat sim_show_asynch (FILE *st, DEVICE *dptr, UNIT *uptr, int32 flag, CONST char *cptr);
t_stat do_cmd_label (int32 flag, CONST char *cptr, CONST char *label);
void int_handler (int signal);
t_stat set_prompt (int32 flag, CONST char *cptr);
t_stat set_runlimit (int32 flag, CONST char *cptr);
t_stat sim_set_asynch (int32 flag, CONST char *cptr);
static const char *_get_dbg_verb (uint32 dbits, DEVICE* dptr, UNIT *uptr);
static t_stat sim_sanity_check_register_declarations (DEVICE **devices);
static t_stat sim_device_unit_tests (const char *cptr);
static void fix_writelock_mtab (DEVICE *dptr);
static t_stat _sim_debug_flush (void);
static const char *_get_runlimit (void);
/* Global data */
const char *sim_prog_name = NULL; /* pointer to the executable name */
DEVICE *sim_dflt_dev = NULL;
UNIT *sim_clock_queue = QUEUE_LIST_END;
int32 sim_interval = 0;
const char *sim_vm_interval_units = "instructions"; /* Simulator can change to "cycles" as needed */
const char *sim_vm_step_unit = "instruction"; /* Simulator can change */
int32 sim_switches = 0;
int32 sim_switch_number = 0;
FILE *sim_ofile = NULL;
TMLN *sim_oline = NULL;
MEMFILE *sim_mfile = NULL;
SCHTAB *sim_schrptr = FALSE;
SCHTAB *sim_schaptr = FALSE;
DEVICE *sim_dfdev = NULL;
UNIT *sim_dfunit = NULL;
DEVICE **sim_internal_devices = NULL;
uint32 sim_internal_device_count = 0;
int32 sim_opt_out = 0;
volatile t_bool sim_is_running = FALSE;
t_bool sim_processing_event = FALSE;
uint32 sim_brk_summ = 0;
uint32 sim_brk_types = 0;
BRKTYPTAB *sim_brk_type_desc = NULL; /* type descriptions */
uint32 sim_brk_dflt = 0;
uint32 sim_brk_match_type;
t_addr sim_brk_match_addr;
char *sim_brk_act[MAX_DO_NEST_LVL];
char *sim_brk_act_buf[MAX_DO_NEST_LVL];
BRKTAB **sim_brk_tab = NULL;
int32 sim_brk_ent = 0;
int32 sim_brk_lnt = 0;
int32 sim_brk_ins = 0;
int32 sim_quiet = 0;
int32 sim_show_message = 1; /* the message display status of the currently open do file */
int32 sim_step = 0;
int32 sim_runlimit = 0;
int32 sim_runlimit_initial = 0;
double sim_runlimit_d = 0.0;
double sim_runlimit_d_initial = 0.0;
int32 sim_runlimit_switches = 0;
t_bool sim_runlimit_enabled = FALSE;
char *sim_sub_instr = NULL; /* Copy of pre-substitution buffer contents */
char *sim_sub_instr_buf = NULL; /* Buffer address that substitutions were saved in */
size_t sim_sub_instr_size = 0; /* substitution buffer size */
size_t *sim_sub_instr_off = NULL; /* offsets in substitution buffer where original data started */
static double sim_time;
static uint32 sim_rtime;
static int32 noqueue_time;
volatile t_bool stop_cpu = FALSE;
volatile t_bool sigterm_received = FALSE;
static unsigned int sim_stop_sleep_ms = 250;
static char **sim_argv;
static int sim_exit_status = EXIT_SUCCESS; /* optionally set by EXIT command */
t_value *sim_eval = NULL;
static char sim_last_val[CBUFSIZE];
static t_addr sim_last_addr;
FILE *sim_log = NULL; /* log file */
FILEREF *sim_log_ref = NULL; /* log file file reference */
FILE *sim_deb = NULL; /* debug file */
FILEREF *sim_deb_ref = NULL; /* debug file file reference */
int32 sim_deb_switches = 0; /* debug switches */
size_t sim_deb_buffer_size = 0; /* debug memory buffer size */
char *sim_deb_buffer = NULL; /* debug memory buffer */
size_t sim_debug_buffer_offset = 0; /* debug memory buffer insertion offset */
size_t sim_debug_buffer_inuse = 0; /* debug memory buffer inuse count */
char *sim_prompt = NULL; /* prompt string */
static FILE *sim_gotofile; /* the currently open do file */
static int32 sim_goto_line[MAX_DO_NEST_LVL+1]; /* the current line number in the currently open do file */
static int32 sim_do_echo = 0; /* the echo status of the currently open do file */
static int32 sim_on_inherit = 0; /* the inherit status of on state and conditions when executing do files */
static int32 sim_do_depth = 0;
static t_bool sim_cmd_echoed = FALSE; /* Command was emitted already prior to message output */
static char **sim_exp_argv = NULL;
static int32 sim_on_check[MAX_DO_NEST_LVL+1];
static char *sim_on_actions[MAX_DO_NEST_LVL+1][SCPE_MAX_ERR+2];
#define ON_SIGINT_ACTION (SCPE_MAX_ERR+1)
static char sim_do_filename[MAX_DO_NEST_LVL+1][CBUFSIZE];
static const char *sim_do_ocptr[MAX_DO_NEST_LVL+1];
static const char *sim_do_label[MAX_DO_NEST_LVL+1];
static t_bool sim_if_cmd[MAX_DO_NEST_LVL+1];
static t_bool sim_if_cmd_last[MAX_DO_NEST_LVL+1];
static t_bool sim_if_result[MAX_DO_NEST_LVL+1];
static t_bool sim_if_result_last[MAX_DO_NEST_LVL+1];
static t_bool sim_cptr_is_action[MAX_DO_NEST_LVL+1];
static DEVICE *sim_failed_reset_dptr = NULL;
static struct deleted_env_var {
char *name;
char *value;
} *sim_external_env = NULL;
static int sim_external_env_count = 0;
static char *sim_tmpnam;
static FILE *sim_tmpfile = NULL;
static int sim_editline_version = 0;
static t_bool sim_pcre_regex_available = FALSE;
/* Dynamically loaded pcre support */
#if !defined(HAVE_PCRE_H)
pcre *(*pcre_compile) (const char *, int, const char **, int *, const unsigned char *);
const char *(*pcre_version) (void);
void (*pcre_free) (void *);
int (*pcre_fullinfo) (const pcre *, const pcre_extra *, int, void *);
int (*pcre_exec) (const pcre *, const pcre_extra *, const char *, int, int, int, int *, int);
#endif
static void sim_exp_initialize (void);
t_stat sim_last_cmd_stat; /* Command Status */
struct timespec cmd_time; /* */
static SCHTAB sim_stabr; /* Register search specifier */
static SCHTAB sim_staba; /* Memory search specifier */
static const char *sim_int_step_description (DEVICE *dptr)
{
return "Step/Next facility";
}
static UNIT sim_step_unit = { UDATA (&step_svc, UNIT_IDLE, 0) };
DEVICE sim_step_dev = {
"INT-STEP", &sim_step_unit, NULL, NULL,
1, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, DEV_NOSAVE, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
sim_int_step_description};
static const char *sim_int_runlimit_description (DEVICE *dptr)
{
return "Run time limit facility";
}
static t_stat sim_int_runlimit_reset (DEVICE *dptr)
{
if (sim_runlimit_enabled) {
if (sim_runlimit_switches & SWMASK ('T'))
return sim_activate_after_d (dptr->units, sim_runlimit_d);
else
return sim_activate (dptr->units, sim_runlimit);
}
return SCPE_OK;
}
static UNIT sim_runlimit_unit = { UDATA (&runlimit_svc, UNIT_IDLE, 0) };
DEVICE sim_runlimit_dev = {
"INT-RUNLIMIT", &sim_runlimit_unit, NULL, NULL,
1, 0, 0, 0, 0, 0,
NULL, NULL, &sim_int_runlimit_reset, NULL, NULL, NULL,
NULL, DEV_NOSAVE, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
sim_int_runlimit_description};
static const char *sim_int_expect_description (DEVICE *dptr)
{
return "Expect facility";
}
static UNIT sim_expect_unit = { UDATA (&expect_svc, 0, 0) };
DEVICE sim_expect_dev = {
"INT-EXPECT", &sim_expect_unit, NULL, NULL,
1, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, DEV_NOSAVE, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
sim_int_expect_description};
static const char *sim_int_flush_description (DEVICE *dptr)
{
return "Open File Flush facility";
}
static uint32 sim_flush_interval = 30; /* Flush I/O buffers every 30 seconds */
static REG sim_flush_reg[] = {
{ DRDATAD(FLUSH_INTERVAL, sim_flush_interval, 32, "Periodic Buffer Flush Interval (seconds)") },
{ NULL}
};
static UNIT sim_flush_unit = { UDATA (&flush_svc, UNIT_IDLE, 0) };
DEVICE sim_flush_dev = {
"INT-FLUSH", &sim_flush_unit, sim_flush_reg, NULL,
1, 0, 0, 0, 0, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
NULL, DEV_NOSAVE, 0,
NULL, NULL, NULL, NULL, NULL, NULL,
sim_int_flush_description};
#if defined USE_INT64
static const char *sim_si64 = "64b data";
#else
static const char *sim_si64 = "32b data";
#endif
#if defined USE_ADDR64
static const char *sim_sa64 = "64b addresses";
#else
static const char *sim_sa64 = "32b addresses";
#endif
const char *sim_savename = sim_name; /* Simulator Name used in SAVE/RESTORE images */
/* Tables and strings */
const char save_vercur[] = "V4.0";
const char save_ver40[] = "V4.0";
const char save_ver35[] = "V3.5";
const char save_ver32[] = "V3.2";
const char save_ver30[] = "V3.0";
const struct scp_error {
const char *code;
const char *message;
} scp_errors[1+SCPE_MAX_ERR-SCPE_BASE] =
{{"NXM", "Address space exceeded"},
{"UNATT", "Unit not attached"},
{"IOERR", "I/O error"},
{"CSUM", "Checksum error"},
{"FMT", "Format error"},
{"NOATT", "Unit not attachable"},
{"OPENERR", "File open error"},
{"MEM", "Memory exhausted"},
{"ARG", "Invalid argument"},
{"STEP", "Step expired"},
{"UNK", "Unknown command"},
{"RO", "Read only argument"},
{"INCOMP", "Command not completed"},
{"STOP", "Simulation stopped"},
{"EXIT", "Goodbye"},
{"TTIERR", "Console input I/O error"},
{"TTOERR", "Console output I/O error"},
{"EOF", "End of file"},
{"REL", "Relocation error"},
{"NOPARAM", "No settable parameters"},
{"ALATT", "Unit already attached"},
{"TIMER", "Hardware timer error"},
{"SIGERR", "Signal handler setup error"},
{"TTYERR", "Console terminal setup error"},
{"SUB", "Subscript out of range"},
{"NOFNC", "Command not allowed"},
{"UDIS", "Unit disabled"},
{"NORO", "Read only operation not allowed"},
{"INVSW", "Invalid switch"},
{"MISVAL", "Missing value"},
{"2FARG", "Too few arguments"},
{"2MARG", "Too many arguments"},
{"NXDEV", "Non-existent device"},
{"NXUN", "Non-existent unit"},
{"NXREG", "Non-existent register"},
{"NXPAR", "Non-existent parameter"},
{"NEST", "Nested DO command limit exceeded"},
{"IERR", "Internal error"},
{"MTRLNT", "Invalid magtape record length"},
{"LOST", "Console Telnet connection lost"},
{"TTMO", "Console Telnet connection timed out"},
{"STALL", "Console Telnet output stall"},
{"AFAIL", "Assertion failed"},
{"INVREM", "Invalid remote console command"},
{"EXPECT", "Expect matched"},
{"AMBREG", "Ambiguous register name"},
{"REMOTE", "remote console command"},
{"INVEXPR", "invalid expression"},
{"SIGTERM", "SIGTERM received"},
{"FSSIZE", "File System size larger than disk size"},
{"RUNTIME", "Run time limit exhausted"},
{"INCOMPDSK", "Incompatible Disk Container"},
{"AMBASSIGN", "Ambiguous logical name"},
};
const size_t size_map[] = { sizeof (int8),
sizeof (int8), sizeof (int16), sizeof (int32), sizeof (int32)
#if defined (USE_INT64)
, sizeof (t_int64), sizeof (t_int64), sizeof (t_int64), sizeof (t_int64)
#endif
};
const t_value width_mask[] = { 0,
0x1, 0x3, 0x7, 0xF,
0x1F, 0x3F, 0x7F, 0xFF,
0x1FF, 0x3FF, 0x7FF, 0xFFF,
0x1FFF, 0x3FFF, 0x7FFF, 0xFFFF,
0x1FFFF, 0x3FFFF, 0x7FFFF, 0xFFFFF,
0x1FFFFF, 0x3FFFFF, 0x7FFFFF, 0xFFFFFF,
0x1FFFFFF, 0x3FFFFFF, 0x7FFFFFF, 0xFFFFFFF,
0x1FFFFFFF, 0x3FFFFFFF, 0x7FFFFFFF, 0xFFFFFFFF
#if defined (USE_INT64)
, 0x1FFFFFFFF, 0x3FFFFFFFF, 0x7FFFFFFFF, 0xFFFFFFFFF,
0x1FFFFFFFFF, 0x3FFFFFFFFF, 0x7FFFFFFFFF, 0xFFFFFFFFFF,
0x1FFFFFFFFFF, 0x3FFFFFFFFFF, 0x7FFFFFFFFFF, 0xFFFFFFFFFFF,
0x1FFFFFFFFFFF, 0x3FFFFFFFFFFF, 0x7FFFFFFFFFFF, 0xFFFFFFFFFFFF,
0x1FFFFFFFFFFFF, 0x3FFFFFFFFFFFF, 0x7FFFFFFFFFFFF, 0xFFFFFFFFFFFFF,
0x1FFFFFFFFFFFFF, 0x3FFFFFFFFFFFFF, 0x7FFFFFFFFFFFFF, 0xFFFFFFFFFFFFFF,
0x1FFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFF,
0x7FFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFF,
0x1FFFFFFFFFFFFFFF, 0x3FFFFFFFFFFFFFFF,
0x7FFFFFFFFFFFFFFF, 0xFFFFFFFFFFFFFFFF
#endif
};
static char *simh_help = NULL; /* First invocation of HELP command appends the help pieces */
static const char simh_help1[] =
/***************** 80 character line width template *************************/
"1Commands\n"
#define HLP_RESET "*Commands Resetting Devices"
/***************** 80 character line width template *************************/
"2Resetting Devices\n"
" The RESET command (abbreviation RE) resets a device or the entire simulator\n"
" to a predefined condition. If switch -p is specified, the device is reset\n"
" to its power-up state:\n\n"
"++RESET reset all devices\n"
"++RESET -p powerup all devices\n"
"++RESET ALL reset all devices\n"
"++RESET <device> reset specified device\n\n"
" Typically, RESET stops any in-progress I/O operation, clears any interrupt\n"
" request, and returns the device to a quiescent state. It does not clear\n"
" main memory or affect I/O connections.\n"
#define HLP_EXAMINE "*Commands Examining_and_Changing_State"
#define HLP_IEXAMINE "*Commands Examining_and_Changing_State"
#define HLP_DEPOSIT "*Commands Examining_and_Changing_State"
#define HLP_IDEPOSIT "*Commands Examining_and_Changing_State"
/***************** 80 character line width template *************************/
"2Examining and Changing State\n"
" There are four commands to examine and change state:\n\n"
"++EXAMINE (abbreviated E) examines state\n"
"++DEPOSIT (abbreviated D) changes state\n"
"++IEXAMINE (interactive examine, abbreviated IE) examines state and allows\n"
"++++the user to interactively change it\n"
"++IDEPOSIT (interactive deposit, abbreviated ID) allows the user to\n"
"++++interactively change state\n\n"
" All four commands take the form\n\n"
"++command {modifiers} <object list>\n\n"
" Deposit must also include a deposit value at the end of the command.\n\n"
" There are four kinds of modifiers: switches, device/unit name, search\n"
" specifier, and for EXAMINE, output file. Switches have been described\n"
" previously. A device/unit name identifies the device and unit whose\n"
" address space is to be examined or modified. If no device is specified,\n"
" the CPU (main memory)is selected; if a device but no unit is specified,\n"
" unit 0 of the device is selected.\n\n"
" The search specifier provides criteria for testing addresses or registers\n"
" to see if they should be processed. A specifier consists of a logical\n"
" operator, a relational operator, or both, optionally separated by spaces.\n\n"
"++{<logical op> <value>} <relational op> <value>\n\n"
/***************** 80 character line width template *************************/
" where the logical operator is & (and), | (or), or ^ (exclusive or), and the\n"
" relational operator is = or == (equal), ! or != (not equal), >= (greater\n"
" than or equal), > (greater than), <= (less than or equal), or < (less than).\n"
" If a logical operator is specified without a relational operator, it is\n"
" ignored. If a relational operator is specified without a logical operator,\n"
" no logical operation is performed. All comparisons are unsigned.\n\n"
" The output file modifier redirects command output to a file instead of the\n"
" console. An output file modifier consists of @ followed by a valid file\n"
" name.\n\n"
" Modifiers may be specified in any order. If multiple modifiers of the\n"
" same type are specified, later modifiers override earlier modifiers. Note\n"
" that if the device/unit name comes after the search specifier, the search\n"
" values will interpreted in the radix of the CPU, rather than of the\n"
" device/unit.\n\n"
" The \"object list\" consists of one or more of the following, separated by\n"
" commas:\n\n"
/***************** 80 character line width template *************************/
"++register the specified register\n"
"++register[sub1-sub2] the specified register array locations,\n"
"++++++++ starting at location sub1 up to and\n"
"++++++++ including location sub2\n"
"++register[sub1/length] the specified register array locations,\n"
"++++++++ starting at location sub1 up to but\n"
"++++++++ not including sub1+length\n"
"++register[ALL] all locations in the specified register\n"
"++++++++ array\n"
"++register1-register2 all the registers starting at register1\n"
"++++++++ up to and including register2\n"
"++address the specified location\n"
"++address1-address2 all locations starting at address1 up to\n"
"++++++++ and including address2\n"
"++address/length all location starting at address up to\n"
"++++++++ but not including address+length\n"
"++STATE all registers in the device\n"
"++ALL all locations in the unit\n"
"++$ the last value displayed by an EXAMINE\n"
"++++++++ command\n"
"3Switches\n"
" Switches can be used to control the format of display information.\n"
" The actual interpretation and format of examine and deposit data is\n"
" specific to each simulator, so HELP CPU or other documentation for\n"
" this simulator might provide more details about how these details\n"
" are interpreted in this simulator. The default switch interpretations\n"
" are:\n\n"
/***************** 80 character line width template *************************/
"++-a display as ASCII\n"
"++-c display as character string\n"
"++-m display as instruction mnemonics\n"
"++-o or -8 display as octal\n"
"++-d or -10 display as decimal\n"
"++-h or -16 display as hexadecimal\n"
"++-2 display as binary\n"
"++-q suppress examine output\n\n"
" The simulators typically accept symbolic input (see documentation with\n"
" each simulator).\n\n"
"3Examples\n"
" Examples:\n\n"
"++ex 1000-1100 examine 1000 to 1100\n"
"++de PC 1040 set PC to 1040\n"