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