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 #if !defined(SIM_DEFS_H_)
59 # define SIM_DEFS_H_ 0
60
61 # include <stddef.h>
62 # include <stdlib.h>
63 # include <stdio.h>
64 # if defined(_MSC_VER) && (_MSC_VER < 1900)
65 # define snprintf _snprintf
66 # endif
67 # include <stdarg.h>
68 # include <string.h>
69 # include <errno.h>
70 # include <limits.h>
71 # include <ctype.h>
72 # include <math.h>
73 # include <setjmp.h>
74
75 # if defined(_WIN32)
76 # include <winsock2.h>
77 # undef PACKED
78 # undef ERROR
79 # undef MEM_MAPPED
80 # include <process.h>
81 # endif
82
83 # include <sys/param.h>
84
85
86
87 # if defined(PMASK)
88 # undef PMASK
89 # endif
90
91 # if defined(RS)
92 # undef RS
93 # endif
94
95 # if defined(PAGESIZE)
96 # undef PAGESIZE
97 # endif
98
99 # if !defined(TRUE)
100 # define TRUE 1
101 # endif
102
103 # if !defined(FALSE)
104 # undef FALSE
105 # define FALSE 0
106 # endif
107
108 # if defined(__CYGWIN__)
109 # if !defined(USE_FLOCK)
110 # define USE_FLOCK 1
111 # endif
112 # if !defined(USE_FCNTL)
113 # define USE_FCNTL 1
114 # endif
115 # endif
116
117
118
119
120
121
122
123
124
125
126
127 # if !defined(CONST)
128 # define CONST const
129 # endif
130
131
132
133 typedef signed char int8;
134 typedef signed short int16;
135 typedef signed int int32;
136 typedef unsigned char uint8;
137 typedef unsigned short uint16;
138 typedef unsigned int uint32;
139 typedef int t_stat;
140 typedef int t_bool;
141
142
143
144 # if defined (__GNUC__)
145 typedef signed long long t_int64;
146 typedef unsigned long long t_uint64;
147 # elif defined (_WIN32)
148 typedef signed __int64 t_int64;
149 typedef unsigned __int64 t_uint64;
150 # else
151 # define t_int64 signed long long
152 # define t_uint64 unsigned long long
153 # endif
154 # include <stdint.h>
155 # if !defined(INT64_C)
156 # define INT64_C(x) x ## LL
157 # endif
158
159 typedef t_int64 t_svalue;
160 typedef t_uint64 t_value;
161 typedef uint32 t_addr;
162 # define T_ADDR_W 32
163 # define T_ADDR_FMT ""
164
165 # if defined (_WIN32)
166 # undef vsnprintf
167 # define vsnprintf _vsnprintf
168 # endif
169 # define STACKBUFSIZE 2048
170
171 # if defined (_WIN32)
172 # define LL_FMT "I64"
173 # else
174 # define LL_FMT "ll"
175 # endif
176
177 # if defined (_WIN32)
178 # define NULL_DEVICE "NUL:"
179 # else
180 # define NULL_DEVICE "/dev/null"
181 # endif
182
183
184
185 # if defined(_MSC_VER)
186 # define SIM_INLINE _inline
187 # elif defined(__GNUC__) || defined(__clang_version__) || defined(__xlc__)
188 # define SIM_INLINE inline
189 # else
190 # define SIM_INLINE
191 # endif
192
193
194
195 # define FLIP_SIZE (1 << 16)
196 # if !defined (PATH_MAX)
197 # define PATH_MAX 512
198 # endif
199 # if (PATH_MAX >= 128)
200 # define CBUFSIZE (4096 + PATH_MAX)
201 # else
202 # define CBUFSIZE 4224
203 # endif
204
205
206
207 # define SIM_BKPT_N_SPC (1 << (32 - SIM_BKPT_V_SPC))
208 # define SIM_BKPT_V_SPC (BRK_TYP_MAX + 1)
209
210
211
212 # define SIM_SW_HIDE (1u << 26)
213 # define SIM_SW_REST (1u << 27)
214 # define SIM_SW_REG (1u << 28)
215 # define SIM_SW_STOP (1u << 29)
216 # define SIM_SW_SHUT (1u << 30)
217
218
219
220
221
222
223
224
225
226 # define SCPE_OK 0
227 # define SCPE_BASE 64
228 # define SCPE_NXM (SCPE_BASE + 0)
229 # define SCPE_UNATT (SCPE_BASE + 1)
230 # define SCPE_IOERR (SCPE_BASE + 2)
231 # define SCPE_CSUM (SCPE_BASE + 3)
232 # define SCPE_FMT (SCPE_BASE + 4)
233 # define SCPE_NOATT (SCPE_BASE + 5)
234 # define SCPE_OPENERR (SCPE_BASE + 6)
235 # define SCPE_MEM (SCPE_BASE + 7)
236 # define SCPE_ARG (SCPE_BASE + 8)
237 # define SCPE_STEP (SCPE_BASE + 9)
238 # define SCPE_UNK (SCPE_BASE + 10)
239 # define SCPE_RO (SCPE_BASE + 11)
240 # define SCPE_INCOMP (SCPE_BASE + 12)
241 # define SCPE_STOP (SCPE_BASE + 13)
242 # define SCPE_EXIT (SCPE_BASE + 14)
243 # define SCPE_TTIERR (SCPE_BASE + 15)
244 # define SCPE_TTOERR (SCPE_BASE + 16)
245 # define SCPE_EOF (SCPE_BASE + 17)
246 # define SCPE_REL (SCPE_BASE + 18)
247 # define SCPE_NOPARAM (SCPE_BASE + 19)
248 # define SCPE_ALATT (SCPE_BASE + 20)
249 # define SCPE_TIMER (SCPE_BASE + 21)
250 # define SCPE_SIGERR (SCPE_BASE + 22)
251 # define SCPE_TTYERR (SCPE_BASE + 23)
252 # define SCPE_SUB (SCPE_BASE + 24)
253 # define SCPE_NOFNC (SCPE_BASE + 25)
254 # define SCPE_UDIS (SCPE_BASE + 26)
255 # define SCPE_NORO (SCPE_BASE + 27)
256 # define SCPE_INVSW (SCPE_BASE + 28)
257 # define SCPE_MISVAL (SCPE_BASE + 29)
258 # define SCPE_2FARG (SCPE_BASE + 30)
259 # define SCPE_2MARG (SCPE_BASE + 31)
260 # define SCPE_NXDEV (SCPE_BASE + 32)
261 # define SCPE_NXUN (SCPE_BASE + 33)
262 # define SCPE_NXREG (SCPE_BASE + 34)
263 # define SCPE_NXPAR (SCPE_BASE + 35)
264 # define SCPE_NEST (SCPE_BASE + 36)
265 # define SCPE_IERR (SCPE_BASE + 37)
266 # define SCPE_MTRLNT (SCPE_BASE + 38)
267 # define SCPE_LOST (SCPE_BASE + 39)
268 # define SCPE_TTMO (SCPE_BASE + 40)
269 # define SCPE_STALL (SCPE_BASE + 41)
270 # define SCPE_AFAIL (SCPE_BASE + 42)
271 # define SCPE_INVREM (SCPE_BASE + 43)
272 # define SCPE_NOTATT (SCPE_BASE + 44)
273 # define SCPE_EXPECT (SCPE_BASE + 45)
274 # define SCPE_REMOTE (SCPE_BASE + 46)
275
276 # define SCPE_MAX_ERR (SCPE_BASE + 47)
277 # define SCPE_KFLAG 0x1000
278 # define SCPE_BREAK 0x2000
279 # define SCPE_NOMESSAGE 0x10000000
280 # define SCPE_BARE_STATUS(stat) ((stat) & ~(SCPE_NOMESSAGE|SCPE_KFLAG|SCPE_BREAK))
281
282
283
284 # define PV_RZRO 0
285 # define PV_LEFT 3
286
287
288
289 # define KBD_POLL_WAIT 5000
290 # define KBD_MAX_WAIT 500000
291 # define SERIAL_IN_WAIT 100
292 # define SERIAL_OUT_WAIT 100
293 # define NOQUEUE_WAIT 1000000
294 # define KBD_LIM_WAIT(x) (((x) > KBD_MAX_WAIT)? KBD_MAX_WAIT: (x))
295 # define KBD_WAIT(w,s) ((w)? w: KBD_LIM_WAIT (s))
296
297
298
299 # define SWMASK(x) (1u << (((int) (x)) - ((int) 'A')))
300
301
302
303 # define MATCH_CMD(ptr,cmd) ((NULL == (ptr)) || (!*(ptr)) || strncmp ((ptr), (cmd), strlen (ptr)))
304
305
306
307
308
309
310
311 # define QUEUE_LIST_END ((UNIT *)1)
312
313
314
315 typedef struct DEVICE DEVICE;
316 typedef struct UNIT UNIT;
317 typedef struct REG REG;
318 typedef struct CTAB CTAB;
319 typedef struct C1TAB C1TAB;
320 typedef struct SHTAB SHTAB;
321 typedef struct MTAB MTAB;
322 typedef struct SCHTAB SCHTAB;
323 typedef struct BRKTAB BRKTAB;
324 typedef struct BRKTYPTAB BRKTYPTAB;
325 typedef struct EXPTAB EXPTAB;
326 typedef struct EXPECT EXPECT;
327 typedef struct SEND SEND;
328 typedef struct DEBTAB DEBTAB;
329 typedef struct FILEREF FILEREF;
330 typedef struct BITFIELD BITFIELD;
331
332 typedef t_stat (*ACTIVATE_API)(UNIT *unit, int32 interval);
333
334
335
336 struct DEVICE {
337 const char *name;
338 UNIT *units;
339 REG *registers;
340 MTAB *modifiers;
341 uint32 numunits;
342 uint32 aradix;
343 uint32 awidth;
344 uint32 aincr;
345 uint32 dradix;
346 uint32 dwidth;
347 t_stat (*examine)(t_value *v, t_addr a, UNIT *up,
348 int32 sw);
349 t_stat (*deposit)(t_value v, t_addr a, UNIT *up,
350 int32 sw);
351 t_stat (*reset)(DEVICE *dp);
352 t_stat (*boot)(int32 u, DEVICE *dp);
353
354 t_stat (*attach)(UNIT *up, CONST char *cp);
355
356 t_stat (*detach)(UNIT *up);
357 void *ctxt;
358 uint32 flags;
359 uint32 dctrl;
360 DEBTAB *debflags;
361 t_stat (*msize)(UNIT *up, int32 v, CONST char *cp, void *dp);
362
363 char *lname;
364 t_stat (*help)(FILE *st, DEVICE *dptr,
365 UNIT *uptr, int32 flag, const char *cptr);
366
367 t_stat (*attach_help)(FILE *st, DEVICE *dptr,
368 UNIT *uptr, int32 flag, const char *cptr);
369
370 void *help_ctx;
371 const char *(*description)(DEVICE *dptr);
372 BRKTYPTAB *brk_types;
373 };
374
375
376
377 # define DEV_V_DIS 0
378 # define DEV_V_DISABLE 1
379 # define DEV_V_DYNM 2
380 # define DEV_V_DEBUG 3
381 # define DEV_V_TYPE 4
382 # define DEV_S_TYPE 3
383 # define DEV_V_SECTORS 7
384 # define DEV_V_DONTAUTO 8
385 # define DEV_V_FLATHELP 9
386 # define DEV_V_NOSAVE 10
387 # define DEV_V_UF_31 12
388 # define DEV_V_UF 16
389 # define DEV_V_RSV 31
390
391 # define DEV_DIS (1 << DEV_V_DIS)
392 # define DEV_DISABLE (1 << DEV_V_DISABLE)
393 # define DEV_DYNM (1 << DEV_V_DYNM)
394 # define DEV_DEBUG (1 << DEV_V_DEBUG)
395 # define DEV_SECTORS (1 << DEV_V_SECTORS)
396 # define DEV_DONTAUTO (1 << DEV_V_DONTAUTO)
397 # define DEV_FLATHELP (1 << DEV_V_FLATHELP)
398 # define DEV_NOSAVE (1 << DEV_V_NOSAVE)
399 # define DEV_NET 0
400
401 # define DEV_TYPEMASK (((1 << DEV_S_TYPE) - 1) << DEV_V_TYPE)
402 # define DEV_DISK (1 << DEV_V_TYPE)
403 # define DEV_TAPE (2 << DEV_V_TYPE)
404 # define DEV_MUX (3 << DEV_V_TYPE)
405 # define DEV_ETHER (4 << DEV_V_TYPE)
406 # define DEV_DISPLAY (5 << DEV_V_TYPE)
407 # define DEV_TYPE(dptr) ((dptr)->flags & DEV_TYPEMASK)
408
409 # define DEV_UFMASK_31 (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF_31) - 1))
410 # define DEV_UFMASK (((1u << DEV_V_RSV) - 1) & ~((1u << DEV_V_UF) - 1))
411 # define DEV_RFLAGS (DEV_UFMASK|DEV_DIS)
412
413
414
415
416
417
418
419
420
421
422 struct UNIT {
423 UNIT *next;
424 t_stat (*action)(UNIT *up);
425 char *filename;
426 FILE *fileref;
427 void *filebuf;
428 uint32 hwmark;
429 int32 time;
430 uint32 flags;
431 uint32 dynflags;
432 t_addr capac;
433 t_addr pos;
434 void (*io_flush)(UNIT *up);
435 uint32 iostarttime;
436 int32 buf;
437 int32 wait;
438 int32 u3;
439 int32 u4;
440 int32 u5;
441 int32 u6;
442 void *up7;
443 void *up8;
444 void *tmxr;
445 void (*cancel)(UNIT *);
446 };
447
448
449
450 # define UNIT_V_UF_31 12
451 # define UNIT_V_UF 16
452 # define UNIT_V_RSV 31
453
454 # define UNIT_ATTABLE 0000001
455 # define UNIT_RO 0000002
456 # define UNIT_FIX 0000004
457 # define UNIT_SEQ 0000010
458 # define UNIT_ATT 0000020
459 # define UNIT_BINK 0000040
460 # define UNIT_BUFABLE 0000100
461 # define UNIT_MUSTBUF 0000200
462 # define UNIT_BUF 0000400
463 # define UNIT_ROABLE 0001000
464 # define UNIT_DISABLE 0002000
465 # define UNIT_DIS 0004000
466 # define UNIT_IDLE 0040000
467
468
469 # define UNIT_TEXT 0000000
470
471 # define UNIT_UFMASK_31 (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF_31) - 1))
472 # define UNIT_UFMASK (((1u << UNIT_V_RSV) - 1) & ~((1u << UNIT_V_UF) - 1))
473 # define UNIT_RFLAGS (UNIT_UFMASK|UNIT_DIS)
474
475
476
477
478
479 # define UNIT_ATTMULT 0000001
480 # define UNIT_TM_POLL 0000002
481 # define UNIT_NO_FIO 0000004
482 # define UNIT_DISK_CHK 0000010
483 # define UNIT_TMR_UNIT 0000020
484 # define UNIT_V_DF_TAPE 5
485 # define UNIT_S_DF_TAPE 3
486
487 struct BITFIELD {
488 const char *name;
489 uint32 offset;
490 uint32 width;
491 const char **valuenames;
492 const char *format;
493 };
494
495
496
497 struct REG {
498 CONST char *name;
499 void *loc;
500 uint32 radix;
501 uint32 width;
502 uint32 offset;
503 uint32 depth;
504 const char *desc;
505 BITFIELD *fields;
506 uint32 flags;
507 uint32 qptr;
508 size_t str_size;
509 };
510
511
512
513 # define REG_FMT 00003
514 # define REG_RO 00004
515 # define REG_HIDDEN 00010
516 # define REG_NZ 00020
517 # define REG_UNIT 00040
518 # define REG_STRUCT 00100
519 # define REG_CIRC 00200
520 # define REG_VMIO 00400
521 # define REG_VMAD 01000
522 # define REG_FIT 02000
523 # define REG_HRO (REG_RO | REG_HIDDEN)
524
525 # define REG_V_UF 16
526 # define REG_UFMASK (~((1u << REG_V_UF) - 1))
527 # define REG_VMFLAGS (REG_VMIO | REG_UFMASK)
528
529
530
531 struct CTAB {
532 const char *name;
533 t_stat (*action)(int32 flag, CONST char *cptr);
534
535 int32 arg;
536 const char *help;
537 const char *help_base;
538 void (*message)(const char *unechoed_cmdline, t_stat stat);
539
540 };
541
542 struct C1TAB {
543 const char *name;
544 t_stat (*action)(DEVICE *dptr, UNIT *uptr,
545 int32 flag, CONST char *cptr);
546 int32 arg;
547 const char *help;
548 };
549
550 struct SHTAB {
551 const char *name;
552 t_stat (*action)(FILE *st, DEVICE *dptr,
553 UNIT *uptr, int32 flag, CONST char *cptr);
554 int32 arg;
555 const char *help;
556 };
557
558
559
560 struct MTAB {
561 uint32 mask;
562 uint32 match;
563 const char *pstring;
564 const char *mstring;
565 t_stat (*valid)(UNIT *up, int32 v, CONST char *cp, void *dp);
566
567 t_stat (*disp)(FILE *st, UNIT *up, int32 v, CONST void *dp);
568
569 void *desc;
570
571
572 const char *help;
573 };
574
575
576
577 # define MTAB_XTD (1u << UNIT_V_RSV)
578 # define MTAB_VDV (0001 | MTAB_XTD)
579 # define MTAB_VUN (0002 | MTAB_XTD)
580 # define MTAB_VALR (0004 | MTAB_XTD)
581 # define MTAB_VALO (0010 | MTAB_XTD)
582 # define MTAB_NMO (0020 | MTAB_XTD)
583 # define MTAB_NC (0040 | MTAB_XTD)
584 # define MTAB_QUOTE (0100 | MTAB_XTD)
585 # define MTAB_SHP (0200 | MTAB_XTD)
586 # define MODMASK(mptr,flag) (((mptr)->mask & (uint32)(flag)) == (uint32)(flag))
587
588
589
590 struct SCHTAB {
591 size_t logic;
592 size_t boolop;
593 uint32 count;
594 t_value *mask;
595 t_value *comp;
596 };
597
598
599
600 struct BRKTAB {
601 t_addr addr;
602 uint32 typ;
603 # define BRK_TYP_USR_TYPES ((1 << ('Z'-'A'+1)) - 1)
604 # define BRK_TYP_DYN_STEPOVER (SWMASK ('Z'+1))
605 # define BRK_TYP_DYN_USR (SWMASK ('Z'+2))
606 # define BRK_TYP_DYN_ALL (BRK_TYP_DYN_USR|BRK_TYP_DYN_STEPOVER)
607 # define BRK_TYP_TEMP (SWMASK ('Z'+3))
608 # define BRK_TYP_MAX (('Z'-'A')+3)
609 int32 cnt;
610 char *act;
611 double time_fired[SIM_BKPT_N_SPC];
612 BRKTAB *next;
613 };
614
615
616
617 struct BRKTYPTAB {
618 uint32 btyp;
619 const char *desc;
620 };
621 # define BRKTYPE(typ,descrip) {SWMASK(typ), descrip}
622
623
624
625 struct EXPTAB {
626 uint8 *match;
627 size_t size;
628 char *match_pattern;
629 int32 cnt;
630 int32 switches;
631 # define EXP_TYP_PERSIST (SWMASK ('P'))
632 # define EXP_TYP_CLEARALL (SWMASK ('C'))
633 # define EXP_TYP_REGEX (SWMASK ('R'))
634 # define EXP_TYP_REGEX_I (SWMASK ('I'))
635 # define EXP_TYP_TIME (SWMASK ('T'))
636 char *act;
637 };
638
639
640
641 struct EXPECT {
642 DEVICE *dptr;
643 uint32 dbit;
644 EXPTAB *rules;
645 size_t size;
646 uint32 after;
647 uint8 *buf;
648 size_t buf_ins;
649 size_t buf_size;
650 };
651
652
653
654 struct SEND {
655 uint32 delay;
656 # define SEND_DEFAULT_DELAY 1000
657 DEVICE *dptr;
658 uint32 dbit;
659 uint32 after;
660 double next_time;
661 uint8 *buffer;
662 size_t bufsize;
663 size_t insoff;
664 size_t extoff;
665 };
666
667
668
669 struct DEBTAB {
670 const char *name;
671 uint32 mask;
672 const char *desc;
673 };
674
675
676
677 # define DEBUG_PRS(d) (sim_deb && d.dctrl)
678 # define DEBUG_PRD(d) (sim_deb && d->dctrl)
679 # define DEBUG_PRI(d,m) (sim_deb && (d.dctrl & (m)))
680 # define DEBUG_PRJ(d,m) (sim_deb && ((d)->dctrl & (m)))
681
682 # define SIM_DBG_EVENT 0x10000
683 # define SIM_DBG_ACTIVATE 0x20000
684 # define SIM_DBG_AIO_QUEUE 0x40000
685
686
687 struct FILEREF {
688 char name[CBUFSIZE];
689 FILE *file;
690 int32 refcount;
691 };
692
693
694
695
696
697
698
699
700
701 # define UDATA(act,fl,cap) NULL,act,NULL,NULL,NULL,0,0,(fl),0,(cap),0,NULL,0,0
702
703 # if defined (__STDC__) || defined (_WIN32)
704
705
706
707 # define REGDATA(nm,loc,rdx,wd,off,dep,desc,flds,fl,qptr,siz) \
708 #nm, &(loc), (rdx), (wd), (off), (dep), (desc), (flds), (fl), (qptr), (siz)
709
710 # define ORDATA(nm,loc,wd) #nm, &(loc), 8, (wd), 0, 1, NULL, NULL
711
712 # define DRDATA(nm,loc,wd) #nm, &(loc), 10, (wd), 0, 1, NULL, NULL
713
714 # define HRDATA(nm,loc,wd) #nm, &(loc), 16, (wd), 0, 1, NULL, NULL
715
716 # define BINRDATA(nm,loc,wd) #nm, &(loc), 2, (wd), 0, 1, NULL, NULL
717
718 # define FLDATA(nm,loc,pos) #nm, &(loc), 2, 1, (pos), 1, NULL, NULL
719
720 # define GRDATA(nm,loc,rdx,wd,pos) #nm, &(loc), (rdx), (wd), (pos), 1, NULL, NULL
721
722 # define BRDATA(nm,loc,rdx,wd,dep) #nm, (loc), (rdx), (wd), 0, (dep), NULL, NULL
723
724 # define ORDATAD(nm,loc,wd,desc) #nm, &(loc), 8, (wd), 0, 1, (desc), NULL
725 # define DRDATAD(nm,loc,wd,desc) #nm, &(loc), 10, (wd), 0, 1, (desc), NULL
726 # define HRDATAD(nm,loc,wd,desc) #nm, &(loc), 16, (wd), 0, 1, (desc), NULL
727 # define BINRDATAD(nm,loc,wd,desc) #nm, &(loc), 2, (wd), 0, 1, (desc), NULL
728 # define FLDATAD(nm,loc,pos,desc) #nm, &(loc), 2, 1, (pos), 1, (desc), NULL
729 # define GRDATAD(nm,loc,rdx,wd,pos,desc) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), NULL
730 # define BRDATAD(nm,loc,rdx,wd,dep,desc) #nm, (loc), (rdx), (wd), 0, (dep), (desc), NULL
731
732 # define ORDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 8, (wd), 0, 1, (desc), (flds)
733 # define DRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 10, (wd), 0, 1, (desc), (flds)
734 # define HRDATADF(nm,loc,wd,desc,flds) #nm, &(loc), 16, (wd), 0, 1, (desc), (flds)
735 # define BINRDATADF(nm,loc,wd) #nm, &(loc), 2, (wd), 0, 1, NULL, NULL
736 # define FLDATADF(nm,loc,pos,desc,flds) #nm, &(loc), 2, 1, (pos), 1, (desc), (flds)
737 # define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) #nm, &(loc), (rdx), (wd), (pos), 1, (desc), (flds)
738 # define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) #nm, (loc), (rdx), (wd), 0, (dep), (desc), (flds)
739 # define BIT(nm) {#nm, 0xffffffff, 1}
740 # define BITNC {"", 0xffffffff, 1}
741 # define BITF(nm,sz) {#nm, 0xffffffff, sz}
742 # define BITNCF(sz) {"", 0xffffffff, sz}
743 # define BITFFMT(nm,sz,fmt) {#nm, 0xffffffff, sz, NULL, #fmt}
744 # define BITFNAM(nm,sz,names) {#nm, 0xffffffff, sz, names}
745 # else
746 # define REGDATA(nm,loc,rdx,wd,off,dep,desc,flds,fl,qptr,siz) \
747 "nm", &(loc), (rdx), (wd), (off), (dep), (desc), (flds), (fl), (qptr), (siz)
748 # define ORDATA(nm,loc,wd) "nm", &(loc), 8, (wd), 0, 1, NULL, NULL
749 # define DRDATA(nm,loc,wd) "nm", &(loc), 10, (wd), 0, 1, NULL, NULL
750 # define HRDATA(nm,loc,wd) "nm", &(loc), 16, (wd), 0, 1, NULL, NULL
751 # define BINRDATA(nm,loc,wd) "nm", &(loc), 2, (wd), 0, 1, NULL, NULL
752 # define FLDATA(nm,loc,pos) "nm", &(loc), 2, 1, (pos), 1, NULL, NULL
753 # define GRDATA(nm,loc,rdx,wd,pos) "nm", &(loc), (rdx), (wd), (pos), 1, NULL, NULL
754 # define BRDATA(nm,loc,rdx,wd,dep) "nm", (loc), (rdx), (wd), 0, (dep), NULL, NULL
755 # define ORDATAD(nm,loc,wd,desc) "nm", &(loc), 8, (wd), 0, 1, (desc), NULL
756 # define DRDATAD(nm,loc,wd,desc) "nm", &(loc), 10, (wd), 0, 1, (desc), NULL
757 # define HRDATAD(nm,loc,wd,desc) "nm", &(loc), 16, (wd), 0, 1, (desc), NULL
758 # define BINRDATAD(nm,loc,wd,desc) "nm", &(loc), 2, (wd), 0, 1, (desc), NULL
759 # define FLDATAD(nm,loc,pos,desc) "nm", &(loc), 2, 1, (pos), 1, (desc), NULL
760 # define GRDATAD(nm,loc,rdx,wd,pos,desc) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), NULL
761 # define BRDATAD(nm,loc,rdx,wd,dep,desc) "nm", (loc), (rdx), (wd), 0, (dep), (desc), NULL
762 # define ORDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 8, (wd), 0, 1, (desc), (flds)
763 # define DRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 10, (wd), 0, 1, (desc), (flds)
764 # define HRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 16, (wd), 0, 1, (desc), (flds)
765 # define BINRDATADF(nm,loc,wd,desc,flds) "nm", &(loc), 2, (wd), 0, 1, (desc), (flds)
766 # define FLDATADF(nm,loc,pos,desc,flds) "nm", &(loc), 2, 1, (pos), 1, (desc), (flds)
767 # define GRDATADF(nm,loc,rdx,wd,pos,desc,flds) "nm", &(loc), (rdx), (wd), (pos), 1, (desc), (flds)
768 # define BRDATADF(nm,loc,rdx,wd,dep,desc,flds) "nm", (loc), (rdx), (wd), 0, (dep), (desc), (flds)
769 # define BIT(nm) {"nm", 0xffffffff, 1}
770 # define BITNC {"", 0xffffffff, 1}
771 # define BITF(nm,sz) {"nm", 0xffffffff, sz}
772 # define BITNCF(sz) {"", 0xffffffff, sz}
773 # define BITFFMT(nm,sz,fmt) {"nm", 0xffffffff, sz, NULL, "fmt"}
774 # define BITFNAM(nm,sz,names) {"nm", 0xffffffff, sz, names}
775 # endif
776 # define ENDBITS {NULL}
777
778
779 # define URDATA(nm,loc,rdx,wd,off,dep,fl) \
780 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),NULL,NULL,((fl) | REG_UNIT),0,0)
781
782 # define STRDATA(nm,loc,rdx,wd,off,dep,siz,fl) \
783 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),NULL,NULL,((fl) | REG_STRUCT),0,(siz))
784
785 # define URDATAD(nm,loc,rdx,wd,off,dep,fl,desc) \
786 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),(desc),NULL,((fl) | REG_UNIT),0,0)
787 # define STRDATAD(nm,loc,rdx,wd,off,dep,siz,fl,desc) \
788 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),(desc),NULL,((fl) | REG_STRUCT),0,(siz))
789
790 # define URDATADF(nm,loc,rdx,wd,off,dep,fl,desc,flds) \
791 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),(desc),(flds),((fl) | REG_UNIT),0,0)
792 # define STRDATADF(nm,loc,rdx,wd,off,dep,siz,fl,desc,flds) \
793 REGDATA(nm,(loc),(rdx),(wd),(off),(dep),(desc),(flds),((fl) | REG_STRUCT),0,(siz))
794
795
796
797 # include "scp.h"
798 # include "sim_console.h"
799 # include "sim_timer.h"
800 # include "sim_fio.h"
801
802 # if defined(FREE)
803 # undef FREE
804 # endif
805 # define FREE(p) do \
806 { \
807 free((p)); \
808 (p) = NULL; \
809 } while(0)
810
811
812
813 # if !defined(MAXPATHLEN)
814 # if defined(PATH_MAX) && PATH_MAX > 1024
815 # define MAXPATHLEN PATH_MAX
816 # else
817 # define MAXPATHLEN 1024
818 # endif
819 # endif
820
821 # if !defined(PATH_MAX)
822 # define PATH_MAX MAXPATHLEN
823 # endif
824
825
826
827
828
829
830
831 # define ASSURE(_Expression) while (!(_Expression)) \
832 { \
833 fprintf(stderr, "%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
834 sim_printf("%s failed at %s line %d\n", #_Expression, __FILE__, __LINE__); \
835 abort();\
836 }
837 #endif