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