source: buchla-68k/orig/MT/MTROMP.C@ 4810254

Last change on this file since 4810254 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 8 years ago

Imported original source code.

  • Property mode set to 100755
File size: 84.2 KB
RevLine 
[3ae31e9]1/*
2 ============================================================================
3 mtromp.c -- ROMP multi-tasking debug monitor for the Buchla 700
4 (c) Copyright 1988 -- D.N. Lynx Crowe
5
6 See ROMPVER, below, for version number and date.
7
8 CAUTION: This code is designed to live in PROM, so initialized
9 variables are PERMANENTLY initialized, since the compiler assigns
10 initialized variables to the data segment, which ends up in PROM.
11
12 Un-initialized variables go into the bss segment, which ends up in RAM.
13 ============================================================================
14*/
15
16#define ROMPVER "24.04 -- 1988-04-17"
17
18#include "ascii.h"
19#include "biosdefs.h"
20#include "ctype.h"
21#include "errdefs.h"
22#include "glcfns.h"
23#include "glcdefs.h"
24#include "hwdefs.h"
25#include "memory.h"
26#include "mtdefs.h"
27#include "mtfuncs.h"
28#include "rawio.h"
29#include "regs.h"
30#include "stddefs.h"
31#include "strings.h"
32#include "vsdd.h"
33#include "graphdef.h"
34#include "vsddsw.h"
35#include "vsddvars.h"
36#include "debug.h"
37
38typedef unsigned short UWORD16; /* unsigned 16 bit word */
39
40/*
41
42*/
43
44#define BOOTKEY 39 /* Boot panel key */
45#define ROMPKEY 40 /* ROMP panel key */
46
47#define BOOTFILE "midas.abs" /* Boot file name */
48
49#define BOOT_PRI (MT_DfPri/2) /* default boot priority */
50#define DFRUNPRI (MT_DfPri/2) /* default 'run' priority */
51
52#define KB_EI 2 /* Enable level for panel */
53#define DEFIPL 2 /* Default internal processor level */
54#define INITSR 0x2200 /* Default initial status register */
55
56#define LED_TIME 100 /* LED scan timer value (loops) */
57#define FIFOLIM 60000 /* FIFO clear limit */
58
59#define NSTAX 5 /* Number of interrupt stacks */
60#define STKLEN 256 /* Default / Int. stack size (words) */
61
62#define USER_RAM 0x00010000L /* Start of user RAM (TPA) */
63#define RAM_TOP 0x000FFFFEL /* Default top word of memory */
64#define ISTACK 0x000FFFFEL /* Default initial stack */
65
66#define ROMADDR 0x00100000L /* Start of PROM */
67#define PRM_DATE 0x00100008L /* PROM date address */
68#define PRM_VERS 0x00100002L /* PROM version address */
69#define PDATELN 14 /* PROM date length */
70
71#define BARBASE 5120L /* Base of bar display in VSDD RAM */
72#define SWBASE 38400L /* Base of switch display in VSDD RAM */
73
74#define BAR_ON P_WHT /* color of bar when on */
75#define BAR_OFF P_BRN /* color of bar when off */
76#define SW_ON P_DKGRN /* color of switch when on */
77#define SW_OFF P_RED /* color of switch when off */
78
79/*
80
81*/
82
83#define I_TABX 53 /* Tablet X */
84#define I_TABY 54 /* Tablet Y */
85#define I_CURX 55 /* Cursor X */
86#define I_CURY 56 /* Cursor Y */
87#define I_LONGL 57 /* LongPot Left */
88#define I_LONGR 58 /* LongPot Right */
89#define I_SCROLL 59 /* Scroll */
90#define I_TEMPO 73 /* Tempo Multiplier */
91#define I_TIME 74 /* Time Scaling */
92#define I_TUNE 75 /* Fine Tuning */
93#define I_LEVEL 76 /* Amplitude */
94
95#define MARGIN 4 /* Offset from left edge of screen */
96
97#define MAXFNLN 13 /* xxxxxxxx.xxx + CR */
98#define MAXARGLN 80 /* maximum argument length */
99#define MAXCMDLN 128 /* maximum command line length */
100#define MAXHS 80 /* maximum help string length */
101#define MAXID 90 /* maximum ID string length */
102
103#define BPINST 0x4E4F /* breakpoint instruction */
104
105#define CRLF "\r\n" /* CR/LF constant */
106
107#define TACK "K\r" /* good response from load command */
108#define NACK "?\r" /* bad response from load command */
109#define SREC9 "04000000FB" /* tail of a type 9 Motorola S-Record */
110
111#define MON_C 1 /* monitor code - character */
112#define MON_S 2 /* monitor code - short */
113#define MON_L 4 /* monitor code - long */
114
115/*
116
117*/
118
119/*
120 ============================================================================
121 Externals and forward references
122 ============================================================================
123*/
124
125extern UWORD16 setipl();
126
127extern short _MTInt1(), _MTInt2(), _MTInt3(), _MTInt4(), _MTInt5();
128
129extern int rjumpto(), halt(), getln(), sjumpto();
130extern int trap15(), xtrap15();
131extern int hdvini(), booter(), vsndpal();
132
133extern char *MTPrFlg();
134
135/* external variables */
136
137extern TCB *MT_ITT[]; /* interrupt TCB pointer table */
138
139extern short wzcrsh, *crshpc, *crshsp, *crshus;
140
141extern int B_log_s, B_dbg_s, _bpbin;
142
143extern char *B_buf_a;
144
145extern short dfltpal[16][3], crshst[16];
146
147extern UWORD16 crshsr;
148extern long crshrg[16];
149extern char crshvc[4];
150
151extern MBOX MSG_Vid;
152extern SEM SemQuit;
153
154/* forward references */
155
156int cp_dump(), cp_fill(), cp_copy(), cp_null(), cp_ilev(), cp_ldmp();
157int cp_go(), cp_read(), cp_mset(), cp_rset(), cp_wset(), cp_mtst();
158int cp_wdmp(), cp_wfil(), cp_vrst(), cp_monc(), cp_mons(), cp_monl();
159int cp_chek(), cx_dini(), cx_mlod(), cp_boot(), cx_boot(), cx_adsp();
160int cx_mtsn(), cp_run(), cx_run(), cx_wait(), cx_copy(), cx_rset();
161int cx_dump(), cx_fill(), cx_load(), cx_go(), cx_read(), cx_help();
162int cx_exit(), cx_writ(), cx_regs(), cx_mset(), cx_omap(), cx_chek();
163int cx_bpb(), cx_wset(), cx_wdmp(), cx_wfil(), cx_rest(), cx_mtid();
164int cx_vrst(), cx_vreg(), cx_mon(), cx_next(), cx_ilev(), cp_mtsd();
165int do_srec(), cx_crsh(), cx_mtst(), cx_zap(), cx_ldmp(), cx_mtsd();
166int cx_mtcb(), cp_mstp(), cx_mstp(), cx_mzap(), cp_mpri(), cx_mpri();
167int cx_mtsk(), cx_mqry(), cx_mtcs(), cx_mtrq();
168
169char hs_mtst[];
170
171/*
172
173*/
174
175/*
176 ============================================================================
177 error message string definitions
178 ============================================================================
179*/
180
181#define EMSG1 "\r\n** Command error **\r\n"
182#define EMSG2 "\r\n** Invalid parameter **\r\n"
183#define EMSG3 "\r\n** Unrecognized command **\r\n"
184
185#define EMSG5 "\r\n** Command not repeatable **\r\n"
186#define EMSG6 "\r\n** Invalid line terminator **\r\n"
187#define EMSG7 "\r\n** do_cmd() switch failed **\r\n"
188
189#define CANNED "\r\n----- Cancelled -----\r\n"
190
191/*
192
193*/
194
195/*
196 ============================================================================
197 initialized variables (These end up in the data segment in PROM)
198 ============================================================================
199*/
200
201struct cmdent { /* command table entry */
202
203 char *cname; /* command name pointer */
204 int (*cp)(); /* command parser function pointer */
205 int (*cx)(); /* command execution function pointer */
206 char *hstr; /* help string pointer */
207};
208
209struct cmdent cmtab[] = {
210
211 {"adisp", cp_null, cx_adsp, ""},
212 {"boot", cp_boot, cx_boot, ""},
213 {"bpb", cp_null, cx_bpb, ""},
214 {"check", cp_chek, cx_chek, "start,end"},
215 {"copy", cp_copy, cx_copy, "from,to,len"},
216 {"crash", cp_null, cx_crsh, ""},
217 {"dinit", cp_null, cx_dini, ""},
218 {"dump", cp_dump, cx_dump, "from[,[to=from][,width=16]]"},
219 {"fill", cp_fill, cx_fill, "start,count,byte"},
220 {"go", cp_go, cx_go, "[addr][,[brk1][,brk2]]"},
221 {"help", cp_null, cx_help, ""},
222 {"ipl", cp_ilev, cx_ilev, "level"},
223 {"ldump", cp_ldmp, cx_ldmp, "from[,[to=from][,width=4]]"},
224 {"load", cp_null, cx_load, ""},
225 {"midas", cp_null, cx_mlod, ""},
226 {"monc", cp_monc, cx_mon, "addr"},
227 {"mons", cp_mons, cx_mon, "addr"},
228 {"monl", cp_monl, cx_mon, "addr"},
229 {"mset", cp_mset, cx_mset, "addr,b1[,...,bn]"},
230 {"mtidump", cp_null, cx_mtid, ""},
231 {"mtsetp", cp_mpri, cx_mpri, "priority"},
232 {"mtsnap", cp_null, cx_mtsn, ""},
233 {"mtstat", cp_mstp, cx_mqry, "taskid"},
234 {"mtstop", cp_mstp, cx_mstp, "taskid"},
235 {"mtzap", cp_mstp, cx_mzap, "taskid"},
236 {"next", cp_null, cx_next, ""},
237 {"obmap", cp_null, cx_omap, ""},
238 {"ramtest", cp_mtst, cx_mtst, hs_mtst},
239 {"read", cp_read, cx_read, "sector,buffer,count"},
240 {"readyq", cp_null, cx_mtrq, ""},
241 {"regs", cp_null, cx_regs, ""},
242 {"reset", cp_null, cx_rest, ""},
243 {"rset", cp_rset, cx_rset, "register,value"},
244 {"run", cp_run, cx_run, "addr[,pri]"},
245 {"sem", cp_mtsd, cx_mtsd, "addr"},
246 {"tasks", cp_null, cx_mtsk, "",},
247 {"tcb", cp_mtsd, cx_mtcb, "addr"},
248 {"tcbs", cp_null, cx_mtcs, ""},
249 {"vregs", cp_null, cx_vreg, ""},
250 {"vrset", cp_vrst, cx_vrst, "register,value"},
251 {"wait", cp_null, cx_wait, ""},
252 {"wdump", cp_wdmp, cx_wdmp, "from[,[to=from][,width=8]]"},
253 {"wfill", cp_wfil, cx_wfil, "loc,count,word"},
254 {"write", cp_read, cx_writ, "sector,buffer,count"},
255 {"wset", cp_wset, cx_wset, "addr,w1[,...,wn]"},
256 {"zap", cp_null, cx_zap, ""}
257};
258
259#define NCMDS ((sizeof cmtab) / (sizeof cmtab[0]))
260
261/*
262
263*/
264
265char ahex[] = "0123456789abcdefABCDEF";
266
267char *rlist[] = { /* register name list */
268
269 "d0", "d1", "d2", "d3", "d4", "d5", "d6", "d7",
270 "a0", "a1", "a2", "a3", "a4", "a5", "a6", "a7",
271 "sr", "pc", "sp",
272 (char *)0
273};
274
275char *vrlist[] = { /* video register name list */
276
277 "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
278 "r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
279 "h0", "h1", "h2", "h3", "v0", "v1", "v2", "v3",
280 (char *)0
281};
282
283int sigadr[] = { /* display offsets for signals */
284
285 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, /* keys */
286 2, 2, 2, 2, 2, 3, 3, 3, 3, 3,
287 4, 4, 4, 4,
288 7, 7, 7, 7, 7, 8, 8, 8, 8, 8, /* sliders */
289 9, 9, 9, 9,
290 12, 12, 12, 12, 12, 13, 13, 13, 13, 13, /* switches */
291 14, 14, 14, 14,
292 17, 17, /* tablet */
293 20, 20, /* cursor */
294 23, 23, /* longpot */
295 26, /* scrollpot */
296 29, 29, 29, 29, 29, 30, 30, 30, 30, 30, /* digits */
297 32, 32, 32, /* x, e, m */
298 35, 35, 35, 35, /* pots */
299 37, 37, /* pedals */
300 39, 39, 39, 39 /* analog in */
301};
302
303/*
304
305*/
306
307char *tsmsg[] = {
308
309 /* -3 */ "stopped, waiting on a semaphore",
310 /* -2 */ "stopped, not waiting",
311 /* -1 */ "not found",
312 /* 0 */ "running (current task)",
313 /* 1 */ "ready to run",
314 /* 2 */ "waiting on a semaphore"
315};
316
317/*
318
319*/
320
321/*
322 ============================================================================
323 un-initialized variables (These end up in the bss segment in RAM)
324 ============================================================================
325*/
326
327char argsep; /* argument separator */
328
329char *aptr, /* argument pointer */
330 *monptr, /* monitored variable pointer */
331 *d_cur, /* dump current from */
332 *d_next, /* dump next from */
333 *d_last, /* dump next to */
334 *p_end, /* end parameter */
335 *p_from, /* from parameter */
336 *p_goto, /* goto parameter */
337 *p_to, /* to parameter */
338 *sptr; /* string scan pointer */
339
340short argln, /* argument length */
341 b0flag, /* breakpoint 0 flag */
342 b1flag, /* breakpoint 1 flag */
343 cmdunit, /* command unit */
344 dflag, /* dump limit flag */
345 exflag, /* exit do_cmd flag */
346 first1, /* first time flag */
347 goflag, /* pc set flag */
348 ilast, /* index of last command */
349 inext, /* command index for "next" command */
350 iplev, /* ROMP IPL level */
351 monsw, /* monitor switch */
352 redo, /* re-doable command flag */
353 rnum, /* register number */
354 taskid, /* task ID */
355 taskpri, /* task priority */
356 vrnum; /* video register number */
357
358/*
359
360*/
361
362short asig, /* signal number */
363 aval, /* signal value */
364 astat, /* signal status */
365 aflag, /* signal activity flag */
366 baseled, /* base LED for scan */
367 ledcntr; /* LED scan counter */
368
369short sigtab[128][2]; /* signal table */
370
371long afi, /* analog FIFO input */
372 ftimer; /* analog FIFO clear timer */
373
374unsigned baron, /* bar 'on' color */
375 baroff, /* bar 'off' color */
376 swon, /* switch 'on' color */
377 swoff, /* switch 'off' color */
378 *obj0; /* object pointer */
379
380UWORD16 *tba0, /* breakpoint 0 temporary */
381 *tba1; /* breakpoint 1 temporary */
382
383UWORD16 p_bv0, /* breakpoint 0 value */
384 p_bv1; /* breakpoint 1 value */
385
386UWORD16 *p_ba0, /* breakpoint 0 address */
387 *p_ba1; /* breakpoint 1 address */
388
389long p_len, /* length parameter */
390 p_value, /* value parameter */
391 p_width, /* width parameter */
392 p_pri, /* task priority */
393 p_task; /* task ID */
394
395struct regs *regptr; /* register save area pointer */
396
397char argstr[MAXARGLN+1], /* argument string */
398 cmdline[MAXCMDLN+1], /* command line */
399 bfname[MAXFNLN+1], /* boot file name */
400 hs_mtst[MAXHS+1], /* mtest help string */
401 idbuf[MAXID+1], /* ID string */
402 promdate[PDATELN+1]; /* PROM date area */
403
404unsigned runstak[STKLEN], /* initial 'run' stack */
405 stax[NSTAX][STKLEN]; /* stacks for interrupt tasks */
406
407struct _mt_def *_MT_; /* pointer to MTStruct */
408
409TCB runtcb, /* 'run' TCB */
410 ipltcb; /* MIDAS boot TCB */
411
412/*
413
414*/
415
416/*
417 ============================================================================
418 cx_rest -- execute the reset command
419 ============================================================================
420*/
421
422int
423cx_rest()
424{
425 setipl(7);
426 rjumpto(ROMADDR);
427}
428
429/*
430 ============================================================================
431 cx_mtsn -- execute the mtsnap command
432 ============================================================================
433*/
434
435int
436cx_mtsn()
437{
438 MTSnap();
439 return(TRUE);
440}
441
442/*
443 ============================================================================
444 cx_mtid -- execute the mtidump command
445 ============================================================================
446*/
447
448int
449cx_mtid()
450{
451 MTIDump();
452 return(TRUE);
453}
454
455/*
456
457*/
458
459/*
460 ============================================================================
461 cx_mlod() -- execute the midas command
462 ============================================================================
463*/
464
465int
466cx_mlod()
467{
468 register short i;
469
470 B_log_s = TRUE;
471 B_dbg_s = FALSE;
472 redo = FALSE;
473
474 hdvini();
475 _bpbin = FALSE;
476
477 if (booter(BOOTFILE, 0L)) {
478
479 return(FALSE);
480
481 } else {
482
483 for (i = 0; i < 8; i++) /* clear d0..d7 */
484 regptr->d_reg[i] = 0L;
485
486 for (i = 0; i < 7; i++) /* clear a0..a6 */
487 regptr->a_reg[i] = (char *)0L;
488
489 regptr->a_reg[7] = ISTACK; /* setup initial stack */
490 regptr->reg_sr = INITSR; /* setup sr */
491 regptr->reg_pc = B_buf_a; /* setup pc */
492
493 return(TRUE);
494 }
495}
496
497/*
498
499*/
500
501/*
502 ============================================================================
503 cp_boot() -- parse boot command
504 ============================================================================
505*/
506
507int
508cp_boot()
509{
510 register int i;
511 register char endc;
512
513 redo = FALSE;
514
515 for (;;) {
516
517 writeln(cmdunit, "File name: ");
518 endc = getln(cmdunit, MAXFNLN+1, bfname);
519 writeln(cmdunit, CRLF);
520
521 if (endc EQ A_CR)
522 break;
523
524 if (endc EQ CTL('X')) {
525
526 writeln(cmdunit, CANNED);
527 return(FALSE);
528 }
529
530 if (endc EQ ERR01)
531 writeln(cmdunit, EMSG2);
532 }
533
534 for (i = 0; i < MAXFNLN+1; i++)
535 if (bfname[i] EQ A_CR)
536 bfname[i] = '\0';
537
538 return(TRUE);
539}
540
541/*
542
543*/
544
545/*
546 ============================================================================
547 cx_boot() -- execute boot command
548 ============================================================================
549*/
550
551int
552cx_boot()
553{
554 register short i;
555
556 B_log_s = TRUE;
557 B_dbg_s = FALSE;
558
559 hdvini();
560 _bpbin = FALSE;
561
562 if (booter(bfname, 0L)) {
563
564 return(FALSE);
565
566 } else {
567
568 for (i = 0; i < 8; i++) /* clear d0..d7 */
569 regptr->d_reg[i] = 0L;
570
571 for (i = 0; i < 7; i++) /* clear a0..a6 */
572 regptr->a_reg[i] = (char *)0L;
573
574 regptr->a_reg[7] = ISTACK; /* setup initial stack */
575
576 regptr->reg_sr = INITSR; /* setup sr */
577 regptr->reg_pc = B_buf_a; /* setup pc */
578
579 return(TRUE);
580 }
581}
582
583/*
584
585*/
586
587/*
588 =============================================================================
589 dobar(nb, bv) -- draw bar 'nb' with value 'bv'
590 =============================================================================
591*/
592
593dobar(nb, bv)
594register int nb, bv;
595{
596 register unsigned *bp;
597 register int i;
598
599 if ((nb LT 1) OR (nb GT 82))
600 return;
601
602 --nb;
603 bp = obj0 + BARBASE + (long)(sigadr[nb] + MARGIN + nb);
604
605 for (i = 127; i GE 0; --i) {
606
607 if (i GT bv) {
608
609 *bp = baroff;
610 bp += 128L;
611 *bp = baroff;
612
613 } else {
614
615 *bp = baron;
616 bp += 128L;
617 *bp = baron;
618 }
619
620 bp += 128L;
621 }
622}
623
624/*
625
626*/
627
628/*
629 =============================================================================
630 dosw(nb, sv) -- display value 'sv' of switch 'nb'
631 =============================================================================
632*/
633
634dosw(nb, sv)
635register int nb, sv;
636{
637 register unsigned *bp;
638 register int i, j;
639
640 if ((nb LT 1) OR (nb GT 82))
641 return;
642
643 --nb;
644 bp = obj0 + SWBASE + (long)(sigadr[nb] + MARGIN + nb);
645
646 if (sv)
647 j = swon;
648 else
649 j = swoff;
650
651 for (i = 0; i < 8; i++) {
652
653 *bp = j;
654 bp += 128L;
655 }
656}
657
658/*
659
660*/
661
662/*
663 =============================================================================
664 exp_c() -- expand a 4 bit color into a 16 bit word
665 =============================================================================
666*/
667
668unsigned
669exp_c(c)
670unsigned c;
671{
672 c &= 0x000F;
673 c |= c << 4;
674 c |= c << 8;
675
676 return(c);
677}
678
679/*
680
681*/
682
683/*
684 =============================================================================
685 cx_adsp() -- display values of analog processor variables as a bar graph
686 =============================================================================
687*/
688
689cx_adsp()
690{
691 register int xasig, xastat, xaval;
692 register long xafi;
693 register long lc;
694 register unsigned *bp;
695 int i, j, k;
696 int oldi;
697
698 memsetw(sigtab, 0, sizeof sigtab / 2);
699
700 VHinit();
701 VSinit();
702 vsndpal(dfltpal);
703
704 obj0 = 0x200400L;
705
706 SetObj(0, 0, 0, obj0, 512, 350, 0, 0, (V_RES3| V_TDE), -1);
707
708 bp = obj0;
709
710 for (lc = 0; lc < 44800; lc++)
711 *bp++ = 0x0000;
712
713 baron = 0x0FFF & exp_c(BAR_ON);
714 baroff = 0x0FFF & exp_c(BAR_OFF);
715 swon = 0x0FFF & exp_c(SW_ON);
716 swoff = 0x0FFF & exp_c(SW_OFF);
717
718 SetPri(0, 7);
719
720 for (i = 1; i < 83; i++) {
721
722 dobar(i, 0);
723 dosw(i, 0);
724 }
725
726 oldi = setipl(2);
727
728/*
729
730*/
731
732 while (0L EQ BIOS(B_RDAV, CON_DEV)) {
733
734 if (-1L NE (xafi = XBIOS(X_ANALOG))) {
735
736 xasig = 0x007F & (xafi >> 8);
737 xastat = 0x0001 & (xafi >> 7);
738 xaval = 0x007F & xafi;
739
740 if (xasig) {
741
742 sigtab[xasig][0] = xaval;
743 sigtab[xasig][1] = xastat;
744
745 if (xasig LT 83) {
746
747 dobar(xasig, xaval);
748 dosw(xasig, xastat);
749 }
750
751 } else {
752
753 for (i = 0; i < 83; i++)
754 sigtab[i][1] = 0;
755 }
756 }
757 }
758
759/*
760
761*/
762
763 BIOS(B_GETC, CON_DEV);
764
765 for (j = 1; j < 83; j++) {
766
767 dobar(j, sigtab[j][0]);
768 dosw(j, sigtab[j][1]);
769 }
770
771 k = 0;
772
773 printf("\n");
774 printf(" x0 x1 x2 x3 x4 x5 x6 x7 x8 x9\r\n");
775 printf(" ----- ----- ----- ----- ----- ----- ----- ----- ----- -----\r\n");
776
777 for (i = 0; i < 9; i++ ) {
778
779 printf("%01dx ", k/10);
780
781 for (j = 0; j < 10; j++) {
782
783 if (k)
784 printf("%1d:%3d ", sigtab[k][1], sigtab[k][0]);
785 else
786 printf(" ");
787
788 if (++k EQ 83)
789 goto outofit;
790 }
791
792 printf("\n");
793 }
794
795outofit:
796
797 printf("\nTempo = %3d, Time = %3d, Tuning = %3d, Level = %3d\n",
798 sigtab[I_TEMPO][0], sigtab[I_TIME][0],
799 sigtab[I_TUNE][0], sigtab[I_LEVEL][0]);
800
801 printf("LongPot L = %3d, LongPot R = %3d, Scroll = %3d\n",
802 sigtab[I_LONGL][0], sigtab[I_LONGR][0],
803 sigtab[I_SCROLL][0]);
804
805 printf("Tablet X = %3d, Tablet Y = %3d\n",
806 sigtab[I_TABX][0], sigtab[I_TABY][0]);
807
808 printf("Cursor X = %3d, Cursor Y = %3d\n",
809 sigtab[I_CURX][0], sigtab[I_CURY][0]);
810
811 setipl(oldi);
812 return(TRUE);
813}
814
815/*
816
817*/
818
819/*
820 =============================================================================
821 waitcr() -- wait for a CR from CON_DEV
822 Returns: 0 = continue
823 1 = ^G hit - abort
824 =============================================================================
825*/
826
827int
828waitcr()
829{
830 char c;
831
832 BIOS(B_PUTC, CON_DEV, '\007');
833
834 while ('\r' NE (c = (0x7F & BIOS(B_GETC, CON_DEV)))) {
835
836 if (c EQ '\007')
837 return(1);
838 }
839
840 return(0);
841}
842
843/*
844
845*/
846
847/*
848 ============================================================================
849 xdtoi -- convert hex ASCII to an int digit
850 ============================================================================
851*/
852
853int
854xdtoi(c)
855register int c;
856{
857 register int i;
858 register char *ap = &ahex[0];
859
860 for (i = 0; i < 22; i++)
861 if (c EQ *ap++)
862 if (i >15)
863 return(i - 6);
864 else
865 return(i);
866
867 return(-1);
868}
869
870/*
871
872*/
873
874/*
875 ============================================================================
876 getcmd -- parse command from input line
877 ============================================================================
878*/
879
880int
881getcmd()
882{
883 register int c;
884
885 sptr = cmdline;
886 argln = 0;
887 aptr = argstr;
888 memset(argstr, 0, MAXARGLN+1);
889
890 do {
891
892 switch (c = 0x00FF & *sptr) {
893
894 case '\0':
895 case A_CR:
896 case A_LF:
897
898 argsep = c;
899 return(argln);
900
901 case ' ':
902
903 ++sptr;
904
905 while (*sptr EQ ' ')
906 ++sptr;
907
908 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
909 c = 0x00FF & *sptr;
910
911 argsep = c;
912 return(argln);
913
914/*
915
916*/
917
918 default:
919
920 if (isupper(c))
921 c = _tolower(c);
922
923 *aptr++ = c;
924 ++sptr;
925 ++argln;
926 }
927
928 } while (*sptr);
929
930 argsep = 0;
931 return(argln);
932}
933
934/*
935
936*/
937
938/*
939 ============================================================================
940 getarg -- parse out an argument to analyze
941
942 Parses the string at sptr for the next argument, if any.
943
944 Returns the length of the parsed argument as the function value.
945
946 Leaves the character that stopped the scan in argsep,
947 argstr points at the parsed argument.
948
949 Leaves sptr updated.
950 ============================================================================
951*/
952
953int
954getarg()
955{
956 register int c;
957
958 argln = 0;
959 aptr = argstr;
960 memset(argstr, 0, MAXARGLN+1);
961
962 do {
963
964 switch (c = 0x00FF & *sptr) {
965
966 case '\0':
967 case A_CR:
968 case A_LF:
969
970 argsep = c;
971 return(argln);
972
973 case ' ':
974
975 ++sptr;
976
977 while (*sptr EQ ' ')
978 ++sptr;
979
980 if (*sptr EQ A_CR OR *sptr EQ A_LF OR *sptr EQ '\0')
981 c = 0x00FF & *sptr;
982
983 argsep = c;
984 return(argln);
985
986 case ',':
987
988 ++sptr;
989 argsep = c;
990 return(argln);
991
992/*
993
994*/
995
996 default:
997
998 *aptr++ = c;
999 ++sptr;
1000 ++argln;
1001 }
1002
1003 } while (*sptr);
1004
1005 argsep = 0;
1006 return(argln);
1007}
1008
1009/*
1010
1011*/
1012
1013/*
1014 ============================================================================
1015 getlong -- get a long integer (either hex or decimal)
1016
1017 Stops on first non-digit (past leading $ if present).
1018 Returns the character that stopped the scan.
1019 ============================================================================
1020*/
1021
1022int
1023getlong(var)
1024long *var;
1025{
1026 register long temp = 0L;
1027 register int csw = FALSE,
1028 c;
1029
1030 if (*aptr EQ '$') { /* leading $ makes it HEX */
1031
1032 ++aptr;
1033
1034 while (isxdigit(c = *aptr++)) {
1035
1036 temp = (temp << 4) + xdtoi(c);
1037 csw = TRUE;
1038 }
1039
1040 } else { /* otherwise, it's decimal */
1041
1042 while (isdigit(c = *aptr++)) {
1043
1044 temp = (temp * 10) + (c - '0');
1045 csw = TRUE;
1046 }
1047 }
1048
1049 if (csw) /* set the new value if we got one */
1050 *var = temp;
1051
1052 return(c); /* return character that stopped us */
1053}
1054
1055/*
1056
1057*/
1058
1059/*
1060 ============================================================================
1061 setvar -- parse an expression and set a long variable
1062 ============================================================================
1063*/
1064
1065int
1066setvar(var, deflt)
1067long *var, deflt;
1068{
1069 int rc;
1070 long temp;
1071
1072 *var = deflt; /* initialize with default value */
1073 aptr = argstr;
1074
1075 rc = getlong(var); /* get first number in expression */
1076
1077 if (rc) {
1078
1079 do {
1080
1081 switch (rc) {
1082
1083 case '+': /* var + num */
1084
1085 temp = 0L;
1086 rc = getlong(&temp);
1087 *var = *var + temp;
1088 continue;
1089
1090 case '-': /* var - num */
1091
1092 temp = 0L;
1093 rc = getlong(&temp);
1094 *var = *var - temp;
1095 continue;
1096
1097 default: /* something else is an error */
1098
1099 *var = deflt;
1100 return(FALSE);
1101 }
1102
1103 } while (rc);
1104
1105 return(TRUE);
1106 }
1107
1108 return(TRUE);
1109}
1110
1111/*
1112
1113*/
1114
1115/*
1116 ============================================================================
1117 putn -- output a decimal number
1118 ============================================================================
1119*/
1120
1121putn(num, cw, unit)
1122long num;
1123int cw, unit;
1124{
1125 register int d;
1126
1127 if (!cw)
1128 return;
1129
1130 putn(num/10, cw-1, unit);
1131
1132 d = num % 10;
1133
1134 BIOS(B_PUTC, unit, (d + '0'));
1135
1136 return;
1137}
1138
1139/*
1140
1141*/
1142
1143/*
1144 ============================================================================
1145 puthn -- output a hex number
1146 ============================================================================
1147*/
1148
1149puthn(num, cw, unit)
1150long num;
1151int cw, unit;
1152{
1153 register int d;
1154
1155 if (!cw)
1156 return;
1157
1158 puthn(num >> 4, cw-1, unit);
1159
1160 d = 0x0F & num;
1161
1162 if (d > 9)
1163 BIOS(B_PUTC, unit, (d - 10 + 'A'));
1164 else
1165 BIOS(B_PUTC, unit, (d + '0'));
1166
1167 return;
1168}
1169
1170/*
1171
1172*/
1173
1174/*
1175 ============================================================================
1176 ddump -- do the hex portion of a dump
1177 ============================================================================
1178*/
1179
1180int
1181ddump(loc, lastloc, nwide, unit)
1182register char *loc, *lastloc;
1183register int nwide, unit;
1184{
1185 while (nwide--) {
1186
1187 puthn((long)(0xFF & *loc), 2, unit);
1188 BIOS(B_PUTC, unit, ' ');
1189
1190 if (BIOS(B_RDAV, unit)) {
1191
1192 BIOS(B_GETC, unit);
1193 return(TRUE);
1194 }
1195
1196 if (loc EQ lastloc) {
1197
1198 dflag = TRUE;
1199 return(FALSE);
1200 }
1201
1202 ++loc;
1203 }
1204
1205
1206 return(FALSE);
1207}
1208
1209/*
1210
1211*/
1212
1213/*
1214 ============================================================================
1215 padr -- print dump address
1216 ============================================================================
1217*/
1218
1219padr(adr, unit)
1220long adr;
1221int unit;
1222{
1223 puthn(adr, 8, unit);
1224 BIOS(B_PUTC, unit, ' ');
1225 BIOS(B_PUTC, unit, '-');
1226 BIOS(B_PUTC, unit, ' ');
1227}
1228
1229/*
1230
1231*/
1232
1233/*
1234 ============================================================================
1235 dtext -- do the text portion of a dump
1236 ============================================================================
1237*/
1238
1239int
1240dtext(loc, lastloc, nwide, unit)
1241register char *loc, *lastloc;
1242register int nwide, unit;
1243{
1244 register int c;
1245
1246 BIOS(B_PUTC, unit, ' ');
1247 BIOS(B_PUTC, unit, '|');
1248
1249 while (nwide--) {
1250
1251 c = 0xFF & *loc;
1252
1253 if (isascii(c) AND isprint(c))
1254 BIOS(B_PUTC, unit, c);
1255 else
1256 BIOS(B_PUTC, unit, '.');
1257
1258 if (BIOS(B_RDAV, unit)) {
1259
1260 BIOS(B_GETC, unit);
1261 BIOS(B_PUTC, unit, '|');
1262 return(TRUE);
1263 }
1264
1265 if (loc EQ lastloc) {
1266
1267 BIOS(B_PUTC, unit, '|');
1268 return(FALSE);
1269 }
1270
1271 ++loc;
1272 }
1273
1274 BIOS(B_PUTC, unit, '|');
1275 return(FALSE);
1276}
1277
1278/*
1279
1280*/
1281
1282/*
1283 ============================================================================
1284 cp_mset -- parse parameters for mset command
1285 ============================================================================
1286*/
1287
1288int
1289cp_mset()
1290{
1291 redo = FALSE;
1292
1293 if (0 EQ getarg())
1294 return(FALSE);
1295
1296 if (argsep NE ',')
1297 return(FALSE);
1298
1299 if (setvar(&p_from, p_from) EQ FALSE)
1300 return(FALSE);
1301
1302 return(TRUE);
1303}
1304
1305/*
1306 ============================================================================
1307 cx_mset -- execute the mset command
1308 ============================================================================
1309*/
1310
1311int
1312cx_mset()
1313{
1314 while (TRUE) {
1315
1316 if (getarg())
1317 if (setvar(&p_value, p_value) EQ FALSE)
1318 return(FALSE);
1319
1320 if (p_value & ~0xFFL)
1321 return(FALSE);
1322
1323 *p_from++ = 0xFF & p_value;
1324
1325 if (argsep EQ A_CR)
1326 return(TRUE);
1327 }
1328}
1329/*
1330
1331*/
1332
1333/*
1334 ============================================================================
1335 cp_wset -- parse parameters for wset command
1336 ============================================================================
1337*/
1338
1339int
1340cp_wset()
1341{
1342 redo = FALSE;
1343
1344 if (0 EQ getarg())
1345 return(FALSE);
1346
1347 if (argsep NE ',')
1348 return(FALSE);
1349
1350 if (setvar(&p_from, p_from) EQ FALSE)
1351 return(FALSE);
1352
1353 if ((long)p_from & 1L)
1354 return(FALSE);
1355
1356 return(TRUE);
1357}
1358
1359/*
1360
1361*/
1362
1363/*
1364 ============================================================================
1365 cx_wset -- execute the wset command
1366 ============================================================================
1367*/
1368
1369int
1370cx_wset()
1371{
1372 UWORD16 *p_uint;
1373
1374 p_uint = (UWORD16 *)p_from;
1375
1376 while (TRUE) {
1377
1378 if (getarg())
1379 if (setvar(&p_value, p_value) EQ FALSE)
1380 return(FALSE);
1381
1382 if (p_value & ~0xFFFFL)
1383 return(FALSE);
1384
1385 *p_uint++ = 0xFFFF & p_value;
1386
1387 if (argsep EQ A_CR)
1388 return(TRUE);
1389 }
1390}
1391
1392/*
1393
1394*/
1395
1396/*
1397 ============================================================================
1398 cp_mtst -- parse mtest command arguments
1399 ============================================================================
1400*/
1401
1402int
1403cp_mtst()
1404{
1405 inext = ilast;
1406
1407 if (argsep EQ A_CR OR argsep EQ '\0') {
1408
1409 p_from = (char *)0x00000008L;
1410 p_to = (char *)USER_RAM - 2L;
1411 return(TRUE);
1412 }
1413
1414 if (getarg())
1415 if (setvar(&p_from, USER_RAM) EQ FALSE)
1416 return(FALSE);
1417
1418 if (argsep NE ',')
1419 return(FALSE);
1420
1421 if (getarg())
1422 if (setvar(&p_to, RAM_TOP) EQ FALSE)
1423 return(FALSE);
1424
1425 if ((long)p_from & 1L)
1426 return(FALSE);
1427
1428 if ((long)p_to & 1L)
1429 return(FALSE);
1430
1431 if (p_from GT p_to)
1432 return(FALSE);
1433
1434 return(TRUE);
1435}
1436
1437/*
1438
1439*/
1440
1441/*
1442 ============================================================================
1443 cx_mtst -- execute the mtest command
1444 ============================================================================
1445*/
1446
1447int
1448cx_mtst()
1449{
1450 register short mask, was, *loc, *eloc, *oldloc;
1451
1452 mask = 0x0001;
1453 loc = (short *)p_from;
1454 eloc = (short *)p_to;
1455 oldloc = loc;
1456
1457 if (p_from LT (char *)USER_RAM)
1458 setipl(7);
1459
1460 do {
1461
1462 while (mask) {
1463
1464 *loc = mask;
1465
1466 if (mask NE (was = *loc))
1467 if (p_from LT (char *)USER_RAM)
1468 halt();
1469 else
1470 printf("%08lX was %04X, expected %04X\r\n",
1471 loc, was, mask);
1472
1473 *loc = ~mask;
1474
1475 if (~mask NE (was = *loc))
1476 if (p_from LT (char *)USER_RAM)
1477 halt();
1478 else
1479 printf("%08lX was %04X, expected %04X\r\n",
1480 loc, was, ~mask);
1481
1482 mask <<= 1;
1483 }
1484
1485 mask = 0x0001;
1486 loc++;
1487
1488 } while (loc LE eloc);
1489
1490 if (oldloc LT (short *)USER_RAM)
1491 rjumpto((long)ROMADDR);
1492
1493 return(TRUE);
1494}
1495
1496/*
1497
1498*/
1499
1500/*
1501 ============================================================================
1502 cp_go -- parse parameters for go command
1503 ============================================================================
1504*/
1505
1506int
1507cp_go()
1508{
1509 redo = FALSE;
1510 b0flag = FALSE;
1511 b1flag = FALSE;
1512 goflag = FALSE;
1513
1514 if (getarg()) {
1515
1516 if (setvar(&p_goto, p_goto) EQ FALSE)
1517 return(FALSE);
1518
1519 if (1L & (long)p_goto)
1520 return(FALSE);
1521
1522 goflag = TRUE;
1523
1524 }
1525
1526 if (getarg()) {
1527
1528 if (setvar(&tba0, 0L) EQ FALSE)
1529 return(FALSE);
1530
1531 if (1L & (long)tba0)
1532 return(FALSE);
1533
1534 b0flag = TRUE;
1535 }
1536
1537 if (getarg()) {
1538
1539 if (setvar(&tba1, 0L) EQ FALSE)
1540 return(FALSE);
1541
1542 if (1L & (long)tba1)
1543 return(FALSE);
1544
1545 b1flag = TRUE;
1546 }
1547
1548 return(TRUE);
1549}
1550
1551/*
1552
1553*/
1554
1555/*
1556 ============================================================================
1557 cp_mtsd -- parse parameters for mtsdump command
1558 ============================================================================
1559*/
1560
1561int
1562cp_mtsd()
1563{
1564 redo = TRUE;
1565
1566 if (getarg()) {
1567
1568 if (setvar(&p_from, p_from) EQ FALSE)
1569 return(FALSE);
1570
1571 if (1L & (long)p_from)
1572 return(FALSE);
1573 }
1574
1575 return(TRUE);
1576}
1577
1578/*
1579
1580*/
1581
1582/*
1583 ============================================================================
1584 cp_mpri -- parse parameters for mtsetp command
1585 ============================================================================
1586*/
1587
1588int
1589cp_mpri()
1590{
1591 redo = FALSE;
1592
1593 if (getarg()) {
1594
1595 if (setvar(&p_pri, p_pri) EQ FALSE)
1596 return(FALSE);
1597
1598 taskpri = (unsigned)p_pri;
1599 return(TRUE);
1600 }
1601
1602 return(FALSE);
1603}
1604
1605/*
1606 ============================================================================
1607 cp_mstp -- parse parameters for mtstop command
1608 ============================================================================
1609*/
1610
1611int
1612cp_mstp()
1613{
1614 redo = FALSE;
1615
1616 if (getarg()) {
1617
1618 if (setvar(&p_task, p_task) EQ FALSE)
1619 return(FALSE);
1620
1621 taskid = (unsigned)p_task;
1622 return(TRUE);
1623 }
1624
1625 return(FALSE);
1626}
1627
1628/*
1629
1630*/
1631
1632/*
1633 ============================================================================
1634 cx_mpri -- execute the mtsetp command
1635 ============================================================================
1636*/
1637
1638int
1639cx_mpri()
1640{
1641 MTSetP(taskpri);
1642 return(TRUE);
1643}
1644
1645/*
1646 ============================================================================
1647 cx_mqry -- execute the mtstat command
1648 ============================================================================
1649*/
1650
1651int
1652cx_mqry()
1653{
1654 short rc;
1655
1656 rc = MTStat(taskid);
1657
1658 if ((rc < -3) OR (rc > 2)) {
1659
1660 printf("unrecognized return code from MTStat: %d\n", rc);
1661 return(TRUE);
1662 }
1663
1664 printf("task %d status: %s\n", taskid, tsmsg[rc + 3]);
1665 return(TRUE);
1666}
1667
1668/*
1669
1670*/
1671
1672/*
1673 ============================================================================
1674 cx_mzap -- execute the mtzap command
1675 ============================================================================
1676*/
1677
1678int
1679cx_mzap()
1680{
1681 short rc;
1682
1683 rc = MTZap(taskid);
1684
1685 switch (rc) {
1686
1687 case -1:
1688
1689 printf("task %d not deleted: active or waiting\n", taskid);
1690 break;
1691
1692 case 0:
1693
1694 printf("task %d deleted\n", taskid);
1695 break;
1696
1697 case 1:
1698
1699 printf("task %d not found\n", taskid);
1700 break;
1701
1702 default:
1703
1704 printf("unrecognized return code from MTZap: %d\n", rc);
1705 break;
1706 }
1707
1708 return(TRUE);
1709}
1710
1711/*
1712
1713*/
1714
1715/*
1716 ============================================================================
1717 cx_mstp -- execute the mtstop command
1718 ============================================================================
1719*/
1720
1721int
1722cx_mstp()
1723{
1724 short rc;
1725
1726 rc = MTStop(taskid);
1727
1728 switch (rc) {
1729
1730 case -3:
1731
1732 printf("task %d not stopped: current task\n", taskid);
1733 break;
1734
1735 case -2:
1736
1737 printf("task %d not stopped: can't find it on the ready queue\n",
1738 taskid);
1739 break;
1740
1741 case -1:
1742
1743 printf("task %d not stopped: can't find its TCB\n", taskid);
1744 break;
1745
1746 case 0:
1747
1748 printf("task %d stopped\n", taskid);
1749 break;
1750
1751 case 1:
1752
1753 printf("task %d already stopped\n", taskid);
1754 break;
1755
1756 case 2:
1757
1758 printf("task %d flagged to stop\n", taskid);
1759 break;
1760
1761 default:
1762
1763 printf("unrecognized return code from MTStop: %d\n", rc);
1764 break;
1765 }
1766
1767 return(TRUE);
1768}
1769
1770/*
1771
1772*/
1773
1774/*
1775 ============================================================================
1776 cx_mtsk -- execute the tasks command
1777 ============================================================================
1778*/
1779
1780int
1781cx_mtsk()
1782{
1783 MTPrTS();
1784 return(TRUE);
1785}
1786
1787/*
1788 ============================================================================
1789 cx_mtcs -- execute the tcbs command
1790 ============================================================================
1791*/
1792
1793int
1794cx_mtcs()
1795{
1796 MTPrTL();
1797 return(TRUE);
1798}
1799
1800/*
1801 ============================================================================
1802 cx_mtrq -- execute the readyq command
1803 ============================================================================
1804*/
1805
1806int
1807cx_mtrq()
1808{
1809 MTPrRq();
1810 return(TRUE);
1811}
1812
1813/*
1814
1815*/
1816
1817/*
1818 ============================================================================
1819 cx_mtsd -- execute the sem command
1820 ============================================================================
1821*/
1822
1823int
1824cx_mtsd()
1825{
1826 MTSDump(p_from, (char *)0L);
1827 return(TRUE);
1828}
1829
1830/*
1831 ============================================================================
1832 cx_mtcb -- execute the tcb command
1833 ============================================================================
1834*/
1835
1836int
1837cx_mtcb()
1838{
1839 MTPrTCB(p_from, (char *)0L);
1840 return(TRUE);
1841}
1842
1843/*
1844
1845*/
1846
1847/*
1848 ============================================================================
1849 cp_run -- parse parameters for run command
1850 ============================================================================
1851*/
1852
1853int
1854cp_run()
1855{
1856 redo = FALSE;
1857
1858 if (getarg()) {
1859
1860 if (setvar(&p_goto, p_goto) EQ FALSE)
1861 return(FALSE);
1862
1863 if (1L & (long)p_goto)
1864 return(FALSE);
1865 }
1866
1867 if (getarg()) {
1868
1869 if (setvar(&p_pri, (long)DFRUNPRI) EQ FALSE)
1870 return(FALSE);
1871
1872 if (0xFFFF0000L & (long)p_pri)
1873 return(FALSE);
1874 }
1875
1876 return(TRUE);
1877}
1878
1879/*
1880
1881*/
1882
1883/*
1884 ============================================================================
1885 cx_run() -- execute the run command
1886 ============================================================================
1887*/
1888
1889int
1890cx_run()
1891{
1892 register unsigned task;
1893
1894 if ((struct _mt_def *)NIL EQ _MT_)
1895 _MT_ = (struct _mt_def *)XBIOS(X_MTDEFS);
1896
1897 task = MTID();
1898
1899 MTSetT(&runtcb, task, (unsigned)(0x0000FFFFL & p_pri), 0x2200, -1L,
1900 &runstak[STKLEN], p_goto, _MT_);
1901
1902 printf("TCB setup - TID = %d ... Swapping ...\n", task);
1903
1904 MTSwap();
1905
1906 printf("Task %d initiated\n", task);
1907 return(TRUE);
1908}
1909
1910
1911/*
1912 ============================================================================
1913 cx_wait() -- execute the wait command
1914 ============================================================================
1915*/
1916
1917int
1918cx_wait()
1919{
1920 printf("Waiting on \"SemQuit\" ...\n");
1921 SMWait(&SemQuit);
1922 printf("Task signalled \"SemQuit\"\n");
1923 return(TRUE);
1924}
1925
1926/*
1927
1928*/
1929
1930/*
1931 ============================================================================
1932 cx_dini() -- execute the dinit command
1933 ============================================================================
1934*/
1935
1936int
1937cx_dini()
1938{
1939 redo = TRUE;
1940 hdvini();
1941 return(TRUE);
1942}
1943
1944/*
1945 ============================================================================
1946 cx_zap -- execute the zap command
1947 ============================================================================
1948*/
1949
1950int
1951cx_zap()
1952{
1953 register short *p, *q;
1954
1955 p = (short *)USER_RAM;
1956 q = (short *)RAM_TOP;
1957
1958 setipl(7);
1959
1960 while (p LE q)
1961 *p++ = 0;
1962
1963 rjumpto(ROMADDR);
1964}
1965
1966/*
1967
1968*/
1969
1970/*
1971 ============================================================================
1972 cx_omap() -- execute the omap command
1973 ============================================================================
1974*/
1975
1976int
1977cx_omap()
1978{
1979 register short i, width, xloc;
1980
1981 printf("Pr B/C Locn Wd Xloc Flags\r\n");
1982
1983 for (i = 0; i < 16; i++) {
1984
1985 xloc = v_odtab[i][1] & 0x03FF;
1986
1987 if (xloc & 0x0200) /* sign extend xloc */
1988 xloc |= 0xFC00;
1989
1990 width = (v_odtab[i][1] >> 10) & 0x003F;
1991
1992 printf("%2d %s ",
1993 i, ((v_odtab[i][0] & V_CBS) ? "Chr" : "Bit"));
1994
1995 printf("$%08lX %2d %4d ",
1996 ((long)v_odtab[i][2] << 1), width, xloc);
1997
1998 printf("$%04X\r\n", v_odtab[i][0]);
1999 }
2000
2001 return(TRUE);
2002}
2003
2004/*
2005
2006*/
2007
2008/*
2009 ============================================================================
2010 cx_help -- execute the help command
2011 ============================================================================
2012*/
2013
2014int
2015cx_help()
2016{
2017 int i, j;
2018
2019 j = 0;
2020
2021 writeln(cmdunit, CRLF);
2022
2023 for (i = 0; i < NCMDS; i++) {
2024
2025 if (j++ EQ 22) {
2026
2027 j = 0;
2028
2029 if (waitcr())
2030 return(TRUE);
2031 }
2032
2033 writeln(cmdunit, " ");
2034 writeln(cmdunit, cmtab[i].cname);
2035 writeln(cmdunit, " ");
2036 writeln(cmdunit, cmtab[i].hstr);
2037 writeln(cmdunit, CRLF);
2038 }
2039
2040 writeln(cmdunit, CRLF);
2041 return(TRUE);
2042}
2043
2044/*
2045
2046* /
2047
2048/*
2049 ============================================================================
2050 cx_bpb -- execute bpb command
2051 ============================================================================
2052*/
2053
2054int
2055cx_bpb()
2056{
2057 register struct bpb *bpp;
2058
2059 if (0L EQ (bpp = (struct bpb *)BIOS(B_GBPB, 0) ) ) {
2060
2061 writeln(cmdunit, "\r\n\nERROR -- Unable to read BPB\r\n\n");
2062 return(FALSE);
2063
2064 } else {
2065
2066 writeln(cmdunit, "\r\n\nBPB values:\r\n");
2067 writeln(cmdunit, "\r\n recsiz ");
2068 putn((long)bpp->recsiz, 5, cmdunit);
2069 writeln(cmdunit, "\r\n clsiz ");
2070 putn((long)bpp->clsiz, 4, cmdunit);
2071 writeln(cmdunit, "\r\n clsizb ");
2072 putn((long)bpp->clsizb, 5, cmdunit);
2073 writeln(cmdunit, "\r\n rdlen ");
2074 putn((long)bpp->rdlen, 4, cmdunit);
2075 writeln(cmdunit, "\r\n fsiz ");
2076 putn((long)bpp->fsiz, 4, cmdunit);
2077 writeln(cmdunit, "\r\n fatrec ");
2078 putn((long)bpp->fatrec, 5, cmdunit);
2079 writeln(cmdunit, "\r\n datrec ");
2080 putn((long)bpp->datrec, 5, cmdunit);
2081 writeln(cmdunit, "\r\n numcl ");
2082 putn((long)bpp->numcl, 5, cmdunit);
2083 writeln(cmdunit, "\r\n bflags ");
2084 puthn((long)bpp->bflags, 4, cmdunit);
2085 writeln(cmdunit, "\r\n ntracks ");
2086 putn((long)bpp->ntracks, 4, cmdunit);
2087 writeln(cmdunit, "\r\n nsides ");
2088 putn((long)bpp->nsides, 4, cmdunit);
2089 writeln(cmdunit, "\r\n sec/cyl ");
2090 putn((long)bpp->dspc, 5, cmdunit);
2091 writeln(cmdunit, "\r\n sec/trk ");
2092 putn((long)bpp->dspt, 5, cmdunit);
2093 writeln(cmdunit, "\r\n hidden ");
2094 putn((long)bpp->hidden, 4, cmdunit);
2095 writeln(cmdunit, "\r\n\n");
2096 return(TRUE);
2097 }
2098}
2099
2100/*
2101
2102*/
2103
2104/*
2105 ============================================================================
2106 cx_go -- execute the go command
2107 ============================================================================
2108*/
2109
2110int
2111cx_go()
2112{
2113 redo = FALSE;
2114 exflag = TRUE;
2115 wzcrsh = FALSE;
2116
2117 if (goflag)
2118 regptr->reg_pc = p_goto;
2119
2120 if (b0flag ) {
2121
2122 if (p_ba0) {
2123
2124 if (*p_ba0 NE (UWORD16)BPINST) {
2125
2126 writeln(cmdunit, "\r\n\n** Breakpoint 0 at ");
2127 puthn((long)p_ba0, 8, cmdunit);
2128 writeln(cmdunit, " was ");
2129 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
2130 writeln(cmdunit, " instead of ");
2131 puthn(0xFFFFL & (long)BPINST, 4, cmdunit);
2132 writeln(cmdunit, " **\r\n\n");
2133 }
2134
2135 *p_ba0 = p_bv0;
2136 }
2137
2138 p_ba0 = tba0;
2139 p_bv0 = *p_ba0;
2140 *p_ba0 = (UWORD16)BPINST;
2141 }
2142
2143/*
2144
2145*/
2146
2147 if (b1flag ) {
2148
2149 if (p_ba1) {
2150
2151 if (*p_ba1 NE (UWORD16)BPINST) {
2152
2153 writeln(cmdunit, "\r\n\n** Breakpoint 1 at ");
2154 puthn((long)p_ba1, 8, cmdunit);
2155 writeln(cmdunit, " was ");
2156 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
2157 writeln(cmdunit, " instead of ");
2158 puthn(0xFFFFL & (long)BPINST, 4, cmdunit);
2159 writeln(cmdunit, " **\r\n\n");
2160 }
2161
2162 *p_ba1 = p_bv1;
2163 }
2164
2165 p_ba1 = tba1;
2166 p_bv1 = *p_ba1;
2167 *p_ba1 = (UWORD16)BPINST;
2168 }
2169
2170 return(TRUE);
2171}
2172
2173/*
2174
2175*/
2176
2177/*
2178 ============================================================================
2179 cp_dump -- parse dump parameters
2180 ============================================================================
2181*/
2182
2183int
2184cp_dump()
2185{
2186 inext = ilast;
2187
2188 if (getarg())
2189 if (setvar(&p_from, p_from) EQ FALSE) {
2190
2191 redo = FALSE;
2192 return(FALSE);
2193 }
2194
2195 if (argsep EQ A_CR OR argsep EQ '\0') {
2196
2197 p_to = p_from;
2198 p_width = 16L;
2199 redo = TRUE;
2200 return(TRUE);
2201 }
2202
2203 if (getarg())
2204 if (setvar(&p_to, p_to) EQ FALSE) {
2205
2206 redo = FALSE;
2207 return(FALSE);
2208 }
2209
2210 if (argsep EQ A_CR OR argsep EQ '\0') {
2211
2212 p_width = 16L;
2213 redo = TRUE;
2214 return(TRUE);
2215 }
2216
2217 if (getarg())
2218 if (setvar(&p_width, p_width) EQ FALSE) {
2219
2220 redo = FALSE;
2221 return(FALSE);
2222 }
2223
2224 if ((p_width LE 0L) OR (p_width GT 16L)) {
2225
2226 p_width = 16L;
2227 redo = FALSE;
2228 return(FALSE);
2229 }
2230
2231 redo = TRUE;
2232 return(TRUE);
2233}
2234
2235/*
2236
2237*/
2238
2239/*
2240 ============================================================================
2241 cp_fill -- parse parameters for fill command
2242 ============================================================================
2243*/
2244
2245int
2246cp_fill()
2247{
2248 redo = FALSE;
2249
2250 if (getarg())
2251 if (setvar(&p_from, p_from) EQ FALSE)
2252 return(FALSE);
2253
2254 if (getarg())
2255 if (setvar(&p_len, p_len) EQ FALSE)
2256 return(FALSE);
2257
2258 if (getarg())
2259 if (setvar(&p_value, p_value) EQ FALSE)
2260 return(FALSE);
2261
2262 if (p_value & ~0xFFL)
2263 return(FALSE);
2264
2265 return(TRUE);
2266}
2267
2268/*
2269
2270*/
2271
2272/*
2273 ============================================================================
2274 cp_wfil -- parse parameters for wfill command
2275 ============================================================================
2276*/
2277
2278int
2279cp_wfil()
2280{
2281 redo = FALSE;
2282
2283 if (getarg())
2284 if (setvar(&p_from, p_from) EQ FALSE)
2285 return(FALSE);
2286
2287 if (getarg())
2288 if (setvar(&p_len, p_len) EQ FALSE)
2289 return(FALSE);
2290
2291 if (getarg())
2292 if (setvar(&p_value, p_value) EQ FALSE)
2293 return(FALSE);
2294
2295 if ((long)p_from & 1L)
2296 return(FALSE);
2297
2298 if (p_value & ~0xFFFFL)
2299 return(FALSE);
2300
2301 return(TRUE);
2302}
2303
2304/*
2305
2306*/
2307
2308/*
2309 ============================================================================
2310 cp_copy -- parse parameters for copy command
2311 ============================================================================
2312*/
2313
2314int
2315cp_copy()
2316{
2317 redo = FALSE;
2318
2319 if (getarg())
2320 if (setvar(&p_from, p_from) EQ FALSE)
2321 return(FALSE);
2322
2323 if (getarg())
2324 if (setvar(&p_to, p_to) EQ FALSE)
2325 return(FALSE);
2326
2327 if (getarg())
2328 if (setvar(&p_len, p_len) EQ FALSE)
2329 return(FALSE);
2330
2331 return(TRUE);
2332}
2333/*
2334
2335*/
2336
2337/*
2338 ============================================================================
2339 cp_chek -- parse parameters for chek command
2340 ============================================================================
2341*/
2342
2343int
2344cp_chek()
2345{
2346 redo = FALSE;
2347
2348 if (getarg())
2349 if (setvar(&p_from, p_from) EQ FALSE)
2350 return(FALSE);
2351
2352 if (getarg())
2353 if (setvar(&p_to, p_to) EQ FALSE)
2354 return(FALSE);
2355
2356 return(TRUE);
2357}
2358
2359/*
2360
2361*/
2362
2363/*
2364 ============================================================================
2365 cp_read -- parse parameters for read command
2366 ============================================================================
2367*/
2368
2369int
2370cp_read()
2371{
2372 redo = FALSE;
2373
2374 if (getarg())
2375 if (setvar(&p_from, p_from) EQ FALSE)
2376 return(FALSE);
2377
2378 if (getarg())
2379 if (setvar(&p_to, p_to) EQ FALSE)
2380 return(FALSE);
2381
2382 if (getarg())
2383 if (setvar(&p_len, p_len) EQ FALSE)
2384 return(FALSE);
2385
2386 if ((~0x7FFFL) & p_len)
2387 return(FALSE);
2388
2389 if ((~0xFFFFL) & (long)p_from)
2390 return(FALSE);
2391
2392 return(TRUE);
2393}
2394
2395/*
2396 ============================================================================
2397 cp_null -- parse null parameter line
2398 ============================================================================
2399*/
2400
2401int
2402cp_null()
2403{
2404 return(TRUE);
2405}
2406
2407/*
2408
2409*/
2410
2411/*
2412 ============================================================================
2413 cp_rset -- parse rset command parameters
2414 ============================================================================
2415*/
2416
2417int
2418cp_rset()
2419{
2420 int rc;
2421
2422 rc = 0;
2423 redo = FALSE;
2424
2425 if (0 EQ getarg())
2426 return(FALSE);
2427
2428 str2lc(argstr);
2429
2430 if (0 EQ (rc = strlcmp(argstr, rlist)))
2431 return(FALSE);
2432
2433 if (0 EQ getarg())
2434 return(FALSE);
2435
2436 if (FALSE EQ setvar(&p_value, 0L))
2437 return(FALSE);
2438
2439 rnum = rc;
2440 return(TRUE);
2441}
2442
2443/*
2444
2445*/
2446/*
2447 ============================================================================
2448 cx_chek -- process chek command
2449 ============================================================================
2450*/
2451
2452int
2453cx_chek()
2454{
2455 register long csum;
2456 register char *cp;
2457
2458 redo = FALSE;
2459 csum = 0L;
2460
2461 for (cp = p_from; cp LE p_to; cp++)
2462 csum += 0x000000FFL & *cp;
2463
2464 printf("Checksum = 0x%08lX\r\n", csum);
2465
2466 return(TRUE);
2467}
2468
2469/*
2470
2471*/
2472
2473/*
2474 ============================================================================
2475 cx_rset -- process rset command
2476 ============================================================================
2477*/
2478
2479int
2480cx_rset()
2481{
2482 redo = FALSE;
2483
2484 if (rnum < 1)
2485 return(FALSE);
2486
2487 if (rnum < 9) { /* d0..d7 -- data register */
2488
2489 regptr->d_reg[rnum-1] = p_value;
2490 return(TRUE);
2491 }
2492
2493 if (rnum < 17) { /* a0..a7 -- address register */
2494
2495 regptr->a_reg[rnum-9] = (char *)p_value;
2496 return(TRUE);
2497 }
2498
2499/*
2500
2501*/
2502
2503 if (rnum EQ 17) { /* sr -- status register */
2504
2505 if ((~0xFFFFL) & p_value)
2506 return(FALSE);
2507
2508 regptr->reg_sr = (UWORD16)p_value;
2509 return(TRUE);
2510 }
2511
2512 if (rnum EQ 18) { /* pc -- program counter */
2513
2514 if (1L & p_value)
2515 return(FALSE);
2516
2517 regptr->reg_pc = (char *)p_value;
2518 return(TRUE);
2519 }
2520
2521 if (rnum EQ 19) { /* sp -- stack pointer */
2522
2523 if (1L & p_value)
2524 return(FALSE);
2525
2526 regptr->a_reg[7] = (char *)p_value;
2527 return(TRUE);
2528 }
2529
2530 return(FALSE);
2531}
2532
2533/*
2534
2535*/
2536
2537/*
2538 ============================================================================
2539 cp_vrst -- parse vrset command parameters
2540 ============================================================================
2541*/
2542
2543int
2544cp_vrst()
2545{
2546 int rc;
2547
2548 rc = 0;
2549 redo = FALSE;
2550
2551 if (0 EQ getarg())
2552 return(FALSE);
2553
2554 str2lc(argstr);
2555
2556 if (0 EQ (rc = strlcmp(argstr, vrlist)))
2557 return(FALSE);
2558
2559 if (0 EQ getarg())
2560 return(FALSE);
2561
2562 if (FALSE EQ setvar(&p_value, 0L))
2563 return(FALSE);
2564
2565 if (vrnum < 17) { /* complete register */
2566
2567 vrnum = rc;
2568 return(TRUE);
2569 }
2570
2571 if (vrnum < 21) { /* horizontal register */
2572
2573 if (p_value & ~0x003F)
2574 return(FALSE);
2575
2576 vrnum = rc;
2577 return(TRUE);
2578 }
2579
2580 if (vrnum < 25) { /* vertical register */
2581
2582 if (p_value & ~0x03FF)
2583 return(FALSE);
2584
2585 vrnum = rc;
2586 return(TRUE);
2587 }
2588
2589 return(FALSE);
2590}
2591
2592/*
2593
2594*/
2595
2596/*
2597 ============================================================================
2598 cx_vrst -- process vrset command
2599 ============================================================================
2600*/
2601
2602int
2603cx_vrst()
2604{
2605 redo = FALSE;
2606
2607 if (vrnum < 1)
2608 return(FALSE);
2609
2610 if (vrnum < 17) { /* 1..16 -- r0..r15 -- complete register */
2611
2612 v_regs[vrnum-1] = p_value;
2613 return(TRUE);
2614 }
2615
2616 if (vrnum < 21) { /* 17..20 -- h0..h3 -- horizontal register */
2617
2618 v_regs[vrnum-5] = (v_regs[vrnum-5] & 0x03FF) |
2619 ((p_value << 10) & 0xFC00);
2620 return(TRUE);
2621 }
2622
2623 if (vrnum < 25) { /* 21..24 -- v0..v3 -- vertical register */
2624
2625 v_regs[vrnum-9] = (v_regs[vrnum-9] & 0xFC00) | p_value;
2626 return(TRUE);
2627 }
2628
2629 return(FALSE);
2630}
2631
2632/*
2633
2634*/
2635
2636/*
2637 ============================================================================
2638 cx_vreg -- process vregs command
2639 ============================================================================
2640*/
2641
2642int
2643cx_vreg()
2644{
2645 register int i, j, k, l;
2646 register unsigned *rp;
2647
2648 rp = &v_regs[0];
2649 l = 0;
2650
2651 for (i = 0; i < 2; i++) {
2652
2653 for (j = 0; j < 2; j++) {
2654
2655 for (k = 0; k < 4; k++) {
2656
2657 writeln(cmdunit, " ");
2658 putn((long)l++, 2, cmdunit);
2659 writeln(cmdunit, ":");
2660 puthn((long)*rp++, 4, cmdunit);
2661 }
2662
2663 writeln(cmdunit, " ");
2664 }
2665
2666 writeln(cmdunit, "\r\n");
2667 }
2668
2669 return(TRUE);
2670}
2671
2672/*
2673
2674*/
2675
2676/*
2677 ============================================================================
2678 do_srec -- load a Motorola S record
2679 ============================================================================
2680*/
2681
2682int
2683do_srec(line)
2684register char *line;
2685{
2686 register char *ldadr;
2687 register int c, csum, i, len;
2688 register unsigned val;
2689
2690 if ('S' NE (c = *line++))
2691 return(-1); /* error 1 = missing initial S */
2692
2693 switch (c = *line++) {
2694
2695 case '2':
2696
2697 csum = 0;
2698
2699 if (isxdigit(c = *line++))
2700 len = xdtoi(c);
2701 else
2702 return(-2); /* error 2 = bad length byte */
2703
2704 if (isxdigit(c = *line++))
2705 len = (len << 4) + xdtoi(c);
2706 else
2707 return(-2);
2708
2709 csum += (len & 0xFF);
2710 ldadr = (char *)0;
2711 len -= 4;
2712
2713 for (i = 0; i < 3; i++) {
2714
2715 if (isxdigit(c = *line++))
2716 val = xdtoi(c);
2717 else
2718 return(-3); /* error 3 = bad address byte */
2719
2720 if (isxdigit(c = *line++))
2721 val = (val << 4) + xdtoi(c);
2722 else
2723 return(-3);
2724
2725 ldadr = (char *)(((long)ldadr << 8) + (long)val);
2726 csum += (val & 0xFF);
2727 }
2728
2729 for (i = 0; i < len; i++) {
2730
2731 if (isxdigit(c = *line++))
2732 val = xdtoi(c);
2733 else
2734 return(-4); /* error 4 = bad data byte */
2735
2736 if (isxdigit(c = *line++))
2737 val = (val << 4) + xdtoi(c);
2738 else
2739 return(-4);
2740
2741 csum += (val & 0xFF);
2742 *ldadr = val & 0xFF;
2743
2744 if ((*ldadr & 0xFF) NE (val & 0xFF))
2745 return(-5); /* error 5 = store failed */
2746
2747 ldadr++;
2748 }
2749
2750 csum = 0xFF & ~csum;
2751
2752 if (isxdigit(c = *line++))
2753 val = xdtoi(c);
2754 else
2755 return(-6); /* error 6 = bad checksum byte */
2756
2757 if (isxdigit(c = *line++))
2758 val = (val << 4) + xdtoi(c);
2759 else
2760 return(-6);
2761
2762 if (csum NE (val & 0xFF))
2763 return(-7); /* error 7 = bad checksum */
2764
2765 return(1);
2766
2767 case '9':
2768
2769 if (memcmpu(line, SREC9, 10) EQ 0)
2770 return(0);
2771 else
2772 return(-8); /* error 8 = bad end record */
2773
2774 default:
2775
2776 return(-9); /* error 9 = unknown s type */
2777 }
2778
2779 return(-10); /* error 10 = switch failed */
2780}
2781
2782/*
2783
2784*/
2785
2786/*
2787 ============================================================================
2788 cx_load -- process load command
2789 ============================================================================
2790*/
2791
2792int
2793cx_load()
2794{
2795 register int rc;
2796
2797 do {
2798
2799 rc = getrln(cmdunit, MAXCMDLN, cmdline);
2800
2801 switch (rc) {
2802
2803 case A_CR:
2804
2805 rc = do_srec(cmdline);
2806
2807 if (rc LT 0) {
2808
2809 rc = -rc;
2810 writeln(cmdunit, NACK);
2811 writeln(cmdunit, "** Load error ");
2812 putn((long)rc, 3, cmdunit);
2813 writeln(cmdunit, " **\r\n\n");
2814 return(FALSE);
2815
2816 } else {
2817
2818 writeln(cmdunit, TACK);
2819 }
2820
2821 continue;
2822
2823 case CTL('X'):
2824
2825 rc = 1;
2826 writeln(cmdunit, TACK);
2827 continue;
2828
2829/*
2830
2831*/
2832
2833 default:
2834
2835 writeln(cmdunit, NACK);
2836 writeln(cmdunit, "** Load aborted on ");
2837 puthn(rc, 2, cmdunit);
2838 writeln(cmdunit, " **\r\n\n");
2839 return(FALSE);
2840 }
2841
2842 } while (rc);
2843
2844 return(TRUE);
2845}
2846
2847/*
2848
2849*/
2850
2851/*
2852 ============================================================================
2853 cx_fill -- execute the fill command
2854 ============================================================================
2855*/
2856
2857int
2858cx_fill()
2859{
2860 register char *cp = p_from;
2861 register long count;
2862
2863 redo = FALSE;
2864
2865 for (count = p_len; count > 0L; count--) {
2866
2867 *cp = (char)(0xFFL & p_value);
2868
2869 if (*cp NE (char)(0xFFL & p_value)) {
2870
2871 writeln(cmdunit, "\r\n** FILL failed at ");
2872 puthn((long)cp, 8, cmdunit);
2873 writeln(cmdunit, " **\r\n");
2874 return(FALSE);
2875 }
2876
2877 ++cp;
2878 }
2879
2880 return(TRUE);
2881}
2882
2883/*
2884
2885*/
2886
2887/*
2888 ============================================================================
2889 cx_wfill -- execute the wfill command
2890 ============================================================================
2891*/
2892
2893int
2894cx_wfil()
2895{
2896 register UWORD16 *cp = (UWORD16 *)p_from;
2897 register long count;
2898
2899 redo = FALSE;
2900
2901 for (count = p_len; count > 0L; count--)
2902 *cp++ = (UWORD16)(0xFFFFL & p_value);
2903
2904 return(TRUE);
2905}
2906
2907/*
2908
2909*/
2910
2911/*
2912 ============================================================================
2913 cx_copy -- execute the copy command
2914 ============================================================================
2915*/
2916
2917int
2918cx_copy()
2919{
2920 register char *from = p_from,
2921 *to = p_to;
2922 register long count = p_len;
2923
2924 redo = FALSE;
2925
2926 if (to GT from) {
2927
2928 from = from + count;
2929 to = to + count;
2930
2931 while (count--) {
2932
2933 --from;
2934 --to;
2935 *to = *from;
2936
2937 if (*from NE *to) {
2938
2939 writeln(cmdunit, "\r\n** COPY failed from ");
2940 puthn((long)from, 8, cmdunit);
2941 writeln(cmdunit, " to ");
2942 puthn((long)to, 8, cmdunit);
2943 writeln(cmdunit, " with (from) = ");
2944 puthn((long)(*from), 2, cmdunit);
2945 writeln(cmdunit, " and (to) = ");
2946 puthn((long)(*to), 2, cmdunit);
2947 writeln(cmdunit, " **\r\n");
2948 return(FALSE);
2949 }
2950 }
2951
2952/*
2953
2954*/
2955
2956 } else {
2957
2958 while (count--) {
2959
2960 *to = *from;
2961
2962 if (*from NE *to) {
2963
2964 writeln(cmdunit, "\r\n** COPY failed from ");
2965 puthn((long)from, 8, cmdunit);
2966 writeln(cmdunit, " to ");
2967 puthn((long)to, 8, cmdunit);
2968 writeln(cmdunit, " with (from) = ");
2969 puthn((long)(*from), 2, cmdunit);
2970 writeln(cmdunit, " and (to) = ");
2971 puthn((long)(*to), 2, cmdunit);
2972 writeln(cmdunit, " **\r\n");
2973 return(FALSE);
2974 }
2975
2976 ++from;
2977 ++to;
2978 }
2979 }
2980
2981 return(TRUE);
2982}
2983
2984/*
2985
2986*/
2987
2988/*
2989 ============================================================================
2990 cx_dump -- execute the dump command
2991 ============================================================================
2992*/
2993
2994int
2995cx_dump()
2996{
2997 register int nw, rc;
2998
2999 redo= TRUE;
3000 d_cur = p_from;
3001 d_next = p_to + 1;
3002 d_last = ((long)p_to - (long)p_from) + d_next;
3003 nw = p_width;
3004 rc = TRUE;
3005
3006 do {
3007
3008 writeln(cmdunit, CRLF);
3009 padr(p_from, cmdunit);
3010
3011 dflag = FALSE;
3012
3013 if (ddump(p_from, p_to, nw, cmdunit))
3014 rc = FALSE;
3015
3016 if (rc)
3017 if (dtext(p_from, p_to, nw, cmdunit))
3018 rc = FALSE;
3019
3020 p_from = p_from + p_width;
3021
3022 if (dflag)
3023 rc = FALSE;
3024
3025 } while (rc);
3026
3027 p_from = d_cur;
3028
3029 writeln(cmdunit, CRLF);
3030 writeln(cmdunit, CRLF);
3031
3032 return(TRUE);
3033}
3034
3035/*
3036
3037*/
3038
3039/*
3040 ============================================================================
3041 wdump -- dump words in hex (no ASCII)
3042 ============================================================================
3043*/
3044
3045int
3046wdump(loc, lastloc, nwide, unit)
3047register UWORD16 *loc, *lastloc;
3048int nwide, unit;
3049{
3050 while (nwide--) {
3051
3052 puthn((long)(0xFFFFL & *loc), 4, unit);
3053 BIOS(B_PUTC,unit, ' ');
3054
3055 if (BIOS(B_RDAV, unit))
3056 return(TRUE);
3057
3058 if (loc EQ lastloc) {
3059
3060 dflag = TRUE;
3061 return(FALSE);
3062 }
3063
3064 ++loc;
3065 }
3066
3067 return(FALSE);
3068}
3069
3070/*
3071
3072*/
3073
3074/*
3075 ============================================================================
3076 ldump -- dump longs in hex (no ASCII)
3077 ============================================================================
3078*/
3079
3080int
3081ldump(loc, lastloc, nwide, unit)
3082register long *loc, *lastloc;
3083int nwide, unit;
3084{
3085 while (nwide--) {
3086
3087 puthn(*loc, 8, unit);
3088 BIOS(B_PUTC,unit, ' ');
3089
3090 if (BIOS(B_RDAV, unit))
3091 return(TRUE);
3092
3093 if (loc EQ lastloc) {
3094
3095 dflag = TRUE;
3096 return(FALSE);
3097 }
3098
3099 ++loc;
3100 }
3101
3102 return(FALSE);
3103}
3104
3105/*
3106
3107*/
3108
3109/*
3110 ============================================================================
3111 cp_wdmp -- process parameters for wdump command
3112 ============================================================================
3113*/
3114
3115int
3116cp_wdmp()
3117{
3118 inext = ilast;
3119
3120 if (getarg())
3121 if (setvar(&p_from, p_from) EQ FALSE) {
3122
3123 redo = FALSE;
3124 return(FALSE);
3125 }
3126
3127 if ((long)p_from & 1L) {
3128
3129 redo = FALSE;
3130 return(FALSE);
3131 }
3132
3133 if (argsep EQ A_CR OR argsep EQ '\0') {
3134
3135 p_to = p_from;
3136 p_width = 8;
3137 redo = TRUE;
3138 return(TRUE);
3139 }
3140
3141 if (getarg())
3142 if (setvar(&p_to, p_to) EQ FALSE) {
3143
3144 redo = FALSE;
3145 return(FALSE);
3146 }
3147
3148 if ((long)p_to & 1L) {
3149
3150 redo = FALSE;
3151 return(FALSE);
3152 }
3153
3154 if (argsep EQ A_CR OR argsep EQ '\0') {
3155
3156 p_width = 8;
3157 redo = TRUE;
3158 return(TRUE);
3159 }
3160
3161 if (getarg())
3162 if (setvar(&p_width, p_width) EQ FALSE) {
3163
3164 redo = FALSE;
3165 return(FALSE);
3166 }
3167
3168 redo = TRUE;
3169 return(TRUE);
3170}
3171
3172/*
3173
3174*/
3175
3176/*
3177 ============================================================================
3178 cp_ldmp -- process parameters for ldump command
3179 ============================================================================
3180*/
3181
3182int
3183cp_ldmp()
3184{
3185 inext = ilast;
3186
3187 if (getarg())
3188 if (setvar(&p_from, p_from) EQ FALSE) {
3189
3190 redo = FALSE;
3191 return(FALSE);
3192 }
3193
3194 if ((long)p_from & 1L) {
3195
3196 redo = FALSE;
3197 return(FALSE);
3198 }
3199
3200 if (argsep EQ A_CR OR argsep EQ '\0') {
3201
3202 p_to = p_from;
3203 p_width = 4;
3204 redo = TRUE;
3205 return(TRUE);
3206 }
3207
3208 if (getarg())
3209 if (setvar(&p_to, p_to) EQ FALSE) {
3210
3211 redo = FALSE;
3212 return(FALSE);
3213 }
3214
3215 if ((long)p_to & 1L) {
3216
3217 redo = FALSE;
3218 return(FALSE);
3219 }
3220
3221 if (argsep EQ A_CR OR argsep EQ '\0') {
3222
3223 p_width = 4;
3224 redo = TRUE;
3225 return(TRUE);
3226 }
3227
3228 if (getarg())
3229 if (setvar(&p_width, p_width) EQ FALSE) {
3230
3231 redo = FALSE;
3232 return(FALSE);
3233 }
3234
3235 redo = TRUE;
3236 return(TRUE);
3237}
3238
3239/*
3240
3241*/
3242
3243/*
3244 ============================================================================
3245 cp_ilev -- parse the ipl command
3246 ============================================================================
3247*/
3248
3249int
3250cp_ilev()
3251{
3252 long iplevl;
3253
3254 if (argsep EQ A_CR OR argsep EQ '\0')
3255 return(TRUE);
3256
3257 if (getarg())
3258 if (setvar(&iplevl, iplevl) EQ FALSE)
3259 return(FALSE);
3260
3261 if (iplevl GT 7)
3262 return(FALSE);
3263
3264 iplev = iplevl;
3265
3266 return(TRUE);
3267}
3268
3269/*
3270 ============================================================================
3271 cx_ilev -- execute ipl command
3272 ============================================================================
3273*/
3274
3275int
3276cx_ilev()
3277{
3278 if (-1 EQ setipl(iplev)) {
3279
3280 printf("ERROR -- Could not set IPL to %d\r\n", iplev);
3281 return(FALSE);
3282 } else
3283 printf("ROMP IPL now set to %d\r\n", iplev);
3284
3285 return(TRUE);
3286}
3287
3288/*
3289
3290*/
3291
3292/*
3293 ============================================================================
3294 cp_monc() -- parse the monc command
3295 ============================================================================
3296*/
3297
3298int
3299cp_monc()
3300{
3301 if (getarg())
3302 if (setvar(&monptr, monptr) EQ FALSE)
3303 return(FALSE);
3304
3305 monsw = MON_C;
3306 redo = TRUE;
3307 return(TRUE);
3308}
3309
3310/*
3311 ============================================================================
3312 cp_mons() -- parse the mons command
3313 ============================================================================
3314*/
3315
3316int
3317cp_mons()
3318{
3319 if (getarg())
3320 if (setvar(&monptr, monptr) EQ FALSE)
3321 return(FALSE);
3322
3323 monsw = MON_S;
3324 redo = TRUE;
3325 return(TRUE);
3326}
3327
3328/*
3329
3330*/
3331
3332/*
3333 ============================================================================
3334 cp_monl() -- parse the monl command
3335 ============================================================================
3336*/
3337
3338int
3339cp_monl()
3340{
3341 if (getarg())
3342 if (setvar(&monptr, monptr) EQ FALSE)
3343 return(FALSE);
3344
3345 monsw = MON_L;
3346 redo = TRUE;
3347 return(TRUE);
3348}
3349
3350/*
3351
3352*/
3353
3354/*
3355 ============================================================================
3356 cx_mon() -- process the mon commands
3357 ============================================================================
3358*/
3359
3360int
3361cx_mon()
3362{
3363 register char vc, vcc;
3364 register short vs, vss, *vsp;
3365 register long vl, vll, *vlp;
3366
3367 switch (monsw) {
3368
3369 case MON_C:
3370
3371 vc = *monptr & 0x0FF;
3372 puthn((long)vc, 2, cmdunit);
3373 writeln(cmdunit, "\r\n");
3374
3375 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
3376
3377 vcc = *monptr & 0x0FF;
3378
3379 if (vc NE vcc) {
3380
3381 vc = vcc;
3382 puthn((long)vc, 2, cmdunit);
3383 writeln(cmdunit, "\r\n");
3384 }
3385 }
3386
3387 BIOS(B_GETC, CON_DEV);
3388 return(TRUE);
3389
3390 case MON_S:
3391
3392 vsp = (short *)monptr;
3393 vs = *vsp;
3394 puthn((long)vs, 4, cmdunit);
3395 writeln(cmdunit, "\r\n");
3396
3397 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
3398
3399 vss = *vsp;
3400
3401 if (vs NE vss) {
3402
3403 vs = vss;
3404 puthn((long)vs, 4, cmdunit);
3405 writeln(cmdunit, "\r\n");
3406 }
3407 }
3408
3409 BIOS(B_GETC, CON_DEV);
3410 return(TRUE);
3411
3412/*
3413
3414*/
3415 case MON_L:
3416
3417 vlp = (long *)monptr;
3418 vl = *vlp;
3419 puthn(vl, 8, cmdunit);
3420 writeln(cmdunit, "\r\n");
3421
3422 while (!(0xFFFFL & BIOS(B_RDAV, CON_DEV))) {
3423
3424 vll = *vlp;
3425
3426 if (vl NE vll) {
3427
3428 vl = vll;
3429 puthn(vl, 8, cmdunit);
3430 writeln(cmdunit, "\r\n");
3431 }
3432 }
3433
3434 BIOS(B_GETC, CON_DEV);
3435 return(TRUE);
3436
3437 default:
3438 return(FALSE);
3439 }
3440}
3441
3442/*
3443
3444*/
3445
3446/*
3447 ============================================================================
3448 cx_wdmp -- process wdump command
3449 ============================================================================
3450*/
3451
3452int
3453cx_wdmp()
3454{
3455 int nw, rc;
3456
3457 d_cur = p_from;
3458 d_next = p_to + 2;
3459 d_last = ((long)p_to - (long)p_from) + d_next;
3460 nw = p_width;
3461 rc = TRUE;
3462
3463 do {
3464
3465 writeln(cmdunit, CRLF);
3466 padr(p_from, cmdunit);
3467 dflag = FALSE;
3468
3469 if (wdump(p_from, p_to, nw, cmdunit))
3470 rc = FALSE;
3471
3472 p_from = p_from + (p_width << 1);
3473
3474 if (dflag)
3475 rc = FALSE;
3476
3477 } while (rc);
3478
3479 p_from = d_cur;
3480
3481 writeln(cmdunit, CRLF);
3482 writeln(cmdunit, CRLF);
3483 return(TRUE);
3484}
3485
3486/*
3487
3488*/
3489
3490/*
3491 ============================================================================
3492 cx_ldmp -- process ldump command
3493 ============================================================================
3494*/
3495
3496int
3497cx_ldmp()
3498{
3499 int nw, rc;
3500
3501 d_cur = p_from;
3502 d_next = p_to + 4;
3503 d_last = ((long)p_to - (long)p_from) + d_next;
3504 nw = p_width;
3505 rc = TRUE;
3506
3507 do {
3508
3509 writeln(cmdunit, CRLF);
3510 padr(p_from, cmdunit);
3511 dflag = FALSE;
3512
3513 if (ldump(p_from, p_to, nw, cmdunit))
3514 rc = FALSE;
3515
3516 p_from = p_from + (p_width << 2);
3517
3518 if (dflag)
3519 rc = FALSE;
3520
3521 } while (rc);
3522
3523 p_from = d_cur;
3524
3525 writeln(cmdunit, CRLF);
3526 writeln(cmdunit, CRLF);
3527 return(TRUE);
3528}
3529
3530/*
3531
3532*/
3533
3534/*
3535 ============================================================================
3536 do_cmd -- process a command line
3537 ============================================================================
3538*/
3539
3540do_cmd()
3541{
3542 int rc, i;
3543
3544 /* prompt for a command line */
3545
3546 writeln(cmdunit, "ROMP: ");
3547
3548 /* get a command line */
3549
3550 rc = getln(cmdunit, MAXCMDLN, cmdline);
3551
3552/*
3553
3554*/
3555
3556 /* dispatch based on rc */
3557
3558 switch (rc) {
3559
3560 case A_CR:
3561
3562 writeln(cmdunit, CRLF);
3563
3564 if (getcmd()) {
3565
3566 for (i = 0; i < NCMDS; i++) {
3567
3568 if (0 EQ strcmp(argstr, cmtab[i].cname)) {
3569
3570 ilast = i;
3571
3572 if ((*cmtab[i].cp)()) {
3573
3574 if (FALSE EQ (*cmtab[i].cx)())
3575 writeln(cmdunit, EMSG1);
3576
3577 } else {
3578
3579 writeln(cmdunit, EMSG2);
3580 }
3581
3582 return;
3583 }
3584 }
3585
3586 writeln(cmdunit, EMSG3);
3587 return;
3588
3589 } else {
3590
3591/*
3592
3593*/
3594
3595 if (redo) {
3596
3597 if (FALSE EQ (*cmtab[ilast].cx)())
3598 writeln(cmdunit, EMSG1);
3599
3600 } else {
3601
3602 writeln(cmdunit, EMSG5);
3603 }
3604
3605 return;
3606 }
3607
3608 case CTL('X'):
3609
3610 writeln(cmdunit, CANNED);
3611 return;
3612
3613 default:
3614
3615 writeln(cmdunit, EMSG6);
3616 return;
3617 }
3618
3619 writeln(cmdunit, EMSG7);
3620 return;
3621}
3622
3623/*
3624
3625*/
3626
3627/*
3628 ============================================================================
3629 cx_next -- process the next command
3630 ============================================================================
3631*/
3632
3633int
3634cx_next()
3635{
3636 p_to = d_last;
3637 p_from = d_next;
3638 return((*cmtab[inext].cx)());
3639}
3640
3641/*
3642
3643*/
3644
3645/*
3646 ============================================================================
3647 cx_read() -- process the read command
3648 ============================================================================
3649*/
3650
3651int
3652cx_read()
3653{
3654 long rc;
3655 int ns, recno;
3656
3657 ns = p_len & 0x7FFFL;
3658 recno = (long)p_from & 0xFFFFL;
3659
3660 rc = BIOS(B_RDWR, 2, p_to, ns, recno, 0);
3661
3662 if (rc & 0xFFFFL) {
3663
3664 writeln(cmdunit, "\r\nERROR reading disk: ");
3665 puthn(rc, 8, cmdunit);
3666 writeln(cmdunit, "\r\n\n");
3667 return(FALSE);
3668
3669 } else {
3670
3671 return(TRUE);
3672 }
3673}
3674
3675/*
3676
3677*/
3678
3679/*
3680 ============================================================================
3681 cx_writ() -- process the write command
3682 ============================================================================
3683*/
3684
3685int
3686cx_writ()
3687{
3688 long rc;
3689 int ns, recno;
3690
3691 ns = p_len & 0x7FFFL;
3692 recno = (long)p_from & 0xFFFFL;
3693
3694 rc = BIOS(B_RDWR, 3, p_to, ns, recno, 0);
3695
3696 if (rc & 0xFFFFL) {
3697
3698 writeln(cmdunit, "\r\nERROR writing disk: ");
3699 puthn(rc, 8, cmdunit);
3700 writeln(cmdunit, "\r\n\n");
3701 return(FALSE);
3702
3703 } else {
3704
3705 return(TRUE);
3706 }
3707}
3708
3709/*
3710
3711*/
3712
3713/*
3714 ============================================================================
3715 showrs() -- show registers
3716 ============================================================================
3717*/
3718
3719showrs(rp)
3720struct regs *rp;
3721{
3722 int i;
3723 UWORD16 srtemp;
3724
3725 writeln(cmdunit, " ");
3726
3727 for (i = 0; i < 8; i++) {
3728
3729 BIOS(B_PUTC, cmdunit, ' ');
3730 BIOS(B_PUTC, cmdunit, '0'+i);
3731 writeln(cmdunit, "_______");
3732 }
3733
3734 writeln(cmdunit, "\r\nd0..d7 ");
3735
3736 for (i = 0; i < 8; i++) {
3737
3738 BIOS(B_PUTC, cmdunit, ' ');
3739 puthn(rp->d_reg[i], 8, cmdunit);
3740 }
3741
3742 writeln(cmdunit, "\r\na0..a7 ");
3743
3744 for (i = 0; i < 8; i++) {
3745
3746 BIOS(B_PUTC, cmdunit, ' ');
3747 puthn(rp->a_reg[i], 8, cmdunit);
3748 }
3749
3750 writeln(cmdunit, "\r\nPC = ");
3751 puthn((long)rp->reg_pc, 8, cmdunit);
3752
3753 srtemp = rp->reg_sr;
3754 writeln(cmdunit, ", SR = ");
3755 puthn( (long)srtemp & 0xFFFFL, 4, cmdunit);
3756
3757/*
3758
3759*/
3760
3761 writeln(cmdunit, " (IPL = ");
3762 puthn( (long)(srtemp >> 8) & 0x7L, 1, cmdunit);
3763 writeln(cmdunit, ", ");
3764
3765 if (srtemp & 0x8000)
3766 BIOS(B_PUTC, cmdunit, 'T');
3767 else
3768 BIOS(B_PUTC, cmdunit, '-');
3769
3770 if (srtemp & 0x2000)
3771 BIOS(B_PUTC, cmdunit, 'S');
3772 else
3773 BIOS(B_PUTC, cmdunit, '-');
3774
3775 BIOS(B_PUTC, cmdunit, ' ');
3776
3777 if (srtemp & 0x10)
3778 BIOS(B_PUTC, cmdunit, 'X');
3779 else
3780 BIOS(B_PUTC, cmdunit, '-');
3781
3782 if (srtemp & 0x8)
3783 BIOS(B_PUTC, cmdunit, 'N');
3784 else
3785 BIOS(B_PUTC, cmdunit, '-');
3786
3787 if (srtemp & 0x4)
3788 BIOS(B_PUTC, cmdunit, 'Z');
3789 else
3790 BIOS(B_PUTC, cmdunit, '-');
3791
3792 if (srtemp & 0x2)
3793 BIOS(B_PUTC, cmdunit, 'V');
3794 else
3795 BIOS(B_PUTC, cmdunit, '-');
3796
3797 if (srtemp & 0x1)
3798 BIOS(B_PUTC, cmdunit, 'C');
3799 else
3800 BIOS(B_PUTC, cmdunit, '-');
3801
3802 writeln(cmdunit, " )\r\n");
3803}
3804
3805/*
3806
3807*/
3808
3809/*
3810 ============================================================================
3811 showcr() -- show crash registers
3812 ============================================================================
3813*/
3814
3815showcr()
3816{
3817 register int i;
3818 register char *cause;
3819 register UWORD16 srtemp;
3820
3821 writeln(cmdunit, "BIOS Crash Area Dump\r\n");
3822 writeln(cmdunit, " ");
3823
3824 for (i = 0; i < 8; i++) {
3825
3826 BIOS(B_PUTC, cmdunit, ' ');
3827 BIOS(B_PUTC, cmdunit, '0'+i);
3828 writeln(cmdunit, "_______");
3829 }
3830
3831 writeln(cmdunit, "\r\nd0..d7 ");
3832
3833 for (i = 0; i < 8; i++) {
3834
3835 BIOS(B_PUTC, cmdunit, ' ');
3836 puthn(crshrg[i], 8, cmdunit);
3837 }
3838
3839 writeln(cmdunit, "\r\na0..a7 ");
3840
3841 for (i = 8; i < 16; i++) {
3842
3843 BIOS(B_PUTC, cmdunit, ' ');
3844 puthn(crshrg[i], 8, cmdunit);
3845 }
3846
3847 writeln(cmdunit, "\r\n\nPC = ");
3848 puthn((long)crshpc, 8, cmdunit);
3849
3850 srtemp = crshsr;
3851 writeln(cmdunit, ", SR = ");
3852 puthn((long)srtemp & 0xFFFFL, 4, cmdunit);
3853
3854/*
3855
3856*/
3857
3858 writeln(cmdunit, " (IPL = ");
3859 puthn((long)(srtemp >> 8) & 0x7L, 1, cmdunit);
3860 writeln(cmdunit, ", ");
3861
3862 if (srtemp & 0x8000)
3863 BIOS(B_PUTC, cmdunit, 'T');
3864 else
3865 BIOS(B_PUTC, cmdunit, '-');
3866
3867 if (srtemp & 0x2000)
3868 BIOS(B_PUTC, cmdunit, 'S');
3869 else
3870 BIOS(B_PUTC, cmdunit, '-');
3871
3872 BIOS(B_PUTC, cmdunit, ' ');
3873
3874 if (srtemp & 0x10)
3875 BIOS(B_PUTC, cmdunit, 'X');
3876 else
3877 BIOS(B_PUTC, cmdunit, '-');
3878
3879 if (srtemp & 0x8)
3880 BIOS(B_PUTC, cmdunit, 'N');
3881 else
3882 BIOS(B_PUTC, cmdunit, '-');
3883
3884 if (srtemp & 0x4)
3885 BIOS(B_PUTC, cmdunit, 'Z');
3886 else
3887 BIOS(B_PUTC, cmdunit, '-');
3888
3889 if (srtemp & 0x2)
3890 BIOS(B_PUTC, cmdunit, 'V');
3891 else
3892 BIOS(B_PUTC, cmdunit, '-');
3893
3894 if (srtemp & 0x1)
3895 BIOS(B_PUTC, cmdunit, 'C');
3896 else
3897 BIOS(B_PUTC, cmdunit, '-');
3898
3899 writeln(cmdunit, " )\r\n");
3900
3901/*
3902
3903*/
3904 writeln(cmdunit, "TRAP vector number = ");
3905 putn((long)crshvc[0], 2, cmdunit);
3906
3907 cause = " (no handler for interrupt)";
3908
3909 switch (crshvc[0] & 0xFF) {
3910
3911 case 2: /* 2: bus error */
3912
3913 cause = " (Bus error)";
3914 break;
3915
3916 case 3: /* 3: address error */
3917
3918 cause = " (Address error)";
3919 break;
3920
3921 case 4: /* 4: illegal instruction */
3922
3923 cause = " (Illegal instruction)";
3924 break;
3925
3926 case 5: /* 5: zero divide */
3927
3928 cause = " (Zero divide)";
3929 break;
3930
3931 case 6: /* 6: CHK instruction */
3932
3933 cause = " (CHK instruction)";
3934 break;
3935
3936 case 7: /* 7: TRAPV instruction */
3937
3938 cause = " (TRAPV instruction)";
3939 break;
3940
3941 case 8: /* 8: privilege violation */
3942
3943 cause = " (Privilege violation)";
3944 break;
3945
3946 case 9: /* 9: trace */
3947
3948 cause = " (Trace -- not implemented)";
3949 break;
3950
3951 case 10: /* 10: line 1010 emulator */
3952
3953 cause = " (Line 1010 Emulator -- not implemented)";
3954 break;
3955
3956 case 11: /* 11: line 1111 emulator */
3957
3958 cause = " (Line 1111 Emulator -- not implemented";
3959 break;
3960
3961 case 15: /* 15: uninitialized interrupt vector */
3962
3963 cause = " (Uninitialized interrupt)";
3964 break;
3965
3966 case 24: /* 24: spurious interrupt */
3967
3968 cause = " (Spurious interrupt)";
3969 break;
3970
3971 case 25: /* 25: Autovector Level 1*/
3972
3973 cause = " (Level 1 Interrupt -- unimplmented)";
3974 break;
3975
3976 case 26: /* 26: Autovector Level 2 */
3977
3978 cause = " (Level 2 Interrupt -- unimplmented)";
3979 break;
3980
3981 case 27: /* 27: Autovector Level 3 */
3982
3983 cause = " (Level 3 Interrupt -- unimplmented)";
3984 break;
3985
3986 case 28: /* 28: Autovector Level 4 */
3987
3988 cause = " (Level 4 Interrupt -- unimplmented)";
3989 break;
3990
3991 case 29: /* 29: Autovector Level 5 */
3992
3993 cause = " (Level 5 Interrupt -- unimplmented)";
3994 break;
3995
3996 case 30: /* 30: Autovector Level 6 */
3997
3998 cause = " (Level 6 Interrupt -- unimplmented)";
3999 break;
4000
4001 case 31: /* 31: Autovector Level 7 */
4002
4003 cause = " (Level 7 Interrupt -- unimplmented)";
4004 break;
4005
4006 }
4007
4008 writeln(cmdunit, cause);
4009 writeln(cmdunit, "\r\n");
4010}
4011
4012/*
4013
4014*/
4015
4016/*
4017 ============================================================================
4018 cx_crsh -- process the crash command
4019 ============================================================================
4020*/
4021
4022int
4023cx_crsh()
4024{
4025 if (!wzcrsh)
4026 printf("** Crash switch NOT set **\r\n");
4027
4028 redo = FALSE;
4029 showcr();
4030 return(TRUE);
4031}
4032
4033/*
4034
4035*/
4036
4037/*
4038 ============================================================================
4039 bphit -- clear breakpoints, see if any were hit
4040 ============================================================================
4041*/
4042
4043int
4044bphit()
4045{
4046 int rc;
4047
4048 rc = FALSE;
4049
4050 if ((char *)p_ba0 EQ regptr->reg_pc) {
4051
4052 if (*p_ba0 EQ BPINST) {
4053
4054 *p_ba0 = p_bv0;
4055 p_ba0 = 0L;
4056 p_bv0 = BPINST;
4057 rc = TRUE;
4058
4059 } else {
4060
4061 writeln(cmdunit, "** Breakpoint word at ");
4062 puthn(p_ba0, 8 , cmdunit);
4063 writeln(cmdunit, " was ");
4064 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
4065 writeln(cmdunit, " instead of ");
4066 puthn((long)BPINST, 4, cmdunit);
4067 writeln(cmdunit, " **\r\n\n");
4068 rc = TRUE;
4069 }
4070 }
4071
4072/*
4073
4074*/
4075
4076 if ((char *)p_ba1 EQ regptr->reg_pc) {
4077
4078 if (*p_ba1 EQ BPINST) {
4079
4080 *p_ba1 = p_bv1;
4081 p_ba1 = 0L;
4082 p_bv1 = BPINST;
4083 rc = TRUE;
4084
4085 } else {
4086
4087 writeln(cmdunit, "** Breakpoint word at ");
4088 puthn((long)p_ba0, 8 , cmdunit);
4089 writeln(cmdunit, " was ");
4090 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
4091 writeln(cmdunit, " instead of ");
4092 puthn((long)BPINST, 4, cmdunit);
4093 writeln(cmdunit, " **\r\n\n");
4094 rc = TRUE;
4095 }
4096 }
4097/*
4098
4099*/
4100 if (p_ba0) {
4101
4102 if (*p_ba0 EQ BPINST) {
4103
4104 *p_ba0 = p_bv0;
4105 p_ba0 = 0L;
4106 p_bv0 = BPINST;
4107 rc = TRUE;
4108
4109 } else {
4110
4111 writeln(cmdunit, "** Breakpoint word at ");
4112 puthn(p_ba0, 8 , cmdunit);
4113 writeln(cmdunit, " was ");
4114 puthn(0xFFFFL & (long)(*p_ba0), 4, cmdunit);
4115 writeln(cmdunit, " instead of ");
4116 puthn((long)BPINST, 4, cmdunit);
4117 writeln(cmdunit, " **\r\n\n");
4118 rc = TRUE;
4119 }
4120 }
4121
4122/*
4123
4124*/
4125
4126 if (p_ba1) {
4127
4128 if (*p_ba1 EQ BPINST) {
4129
4130 *p_ba1 = p_bv1;
4131 p_ba1 = 0L;
4132 p_bv1 = BPINST;
4133 rc = TRUE;
4134
4135 } else {
4136
4137 writeln(cmdunit, "** Breakpoint word at ");
4138 puthn((long)p_ba0, 8 , cmdunit);
4139 writeln(cmdunit, " was ");
4140 puthn(0xFFFFL & (long)(*p_ba1), 4, cmdunit);
4141 writeln(cmdunit, " instead of ");
4142 puthn((long)BPINST, 4, cmdunit);
4143 writeln(cmdunit, " **\r\n\n");
4144 rc = TRUE;
4145 }
4146 }
4147
4148 if (rc)
4149 return(rc);
4150
4151 writeln(cmdunit, "\r\n** Program invoked ROMP trap **\r\n");
4152 return(FALSE);
4153}
4154
4155/*
4156
4157*/
4158
4159/*
4160 ============================================================================
4161 cx_regs() -- process the regs command
4162 ============================================================================
4163*/
4164
4165int
4166cx_regs()
4167{
4168 showrs(regptr);
4169 return(TRUE);
4170}
4171
4172/*
4173
4174*/
4175
4176/*
4177 ============================================================================
4178 rompbp() -- process a breakpoint for ROMP
4179 ============================================================================
4180*/
4181
4182rompbp(d0,d1,d2,d3,d4,d5,d6,d7, a0,a1,a2,a3,a4,a5,a6,a7, sr0,sr, pc)
4183long d0,d1,d2,d3,d4,d5,d6,d7;
4184char *a0,*a1,*a2,*a3,*a4,*a5,*a6,*a7, *pc;
4185UWORD16 sr0,sr;
4186{
4187 register int i;
4188
4189 regptr = (struct regs *)&d0; /* make registers accessable */
4190 pc -= 2L; /* adjust pc */
4191
4192 if (-1 EQ setipl(iplev)) /* enable interrupts */
4193 writeln(cmdunit, "\r\n\n***** setipl() failed *****\r\n\n");
4194
4195 if (first1) { /* initial entry from xtrap15() */
4196
4197 for (i = 0; i < 8; i++) /* clear d0..d7 */
4198 regptr->d_reg[i] = 0L;
4199
4200 for (i = 0; i < 7; i++) /* clear a0..a6 */
4201 regptr->a_reg[i] = (char *)0L;
4202
4203 regptr->a_reg[7] = ISTACK; /* setup initial stack */
4204
4205 sr = INITSR; /* setup sr */
4206 pc += 2L; /* adjust pc past TRAP 15 */
4207
4208 } else { /* breakpoint */
4209
4210 writeln(cmdunit, "\r\n\n** ROMP Breakpoint TRAP **\r\n");
4211
4212 showrs(regptr); /* show registers */
4213
4214 if (bphit() EQ FALSE) /* fixup breakpoints */
4215 pc += 2L; /* and maybe the pc */
4216
4217 }
4218
4219 first1 = FALSE; /* not first time any more */
4220 exflag = FALSE; /* clear exit flag */
4221
4222 do {
4223
4224 do_cmd(); /* process commands ... */
4225
4226 } while (!exflag); /* ... until exit flag is set */
4227
4228 return; /* return to xtrap15 */
4229}
4230
4231/*
4232
4233*/
4234
4235/*
4236 ============================================================================
4237 progid() -- identify the program
4238 ============================================================================
4239*/
4240
4241progid()
4242{
4243 register char *pcptr;
4244
4245 writeln(cmdunit, "\r\n\nBuchla 700 Multi-Tasking BIOS / Debug PROM\r\n");
4246 writeln(cmdunit, " Multi-Tasking ROMP Version ");
4247 writeln(cmdunit, ROMPVER);
4248 writeln(cmdunit, "\r\n Multi-Tasking BIOS Version ");
4249 pcptr = (char *)PRM_VERS;
4250 putn((long)*pcptr++, 2, cmdunit);
4251 BIOS(B_PUTC, cmdunit, '.');
4252 putn((long)*pcptr++, 2, cmdunit);
4253 writeln(cmdunit, promdate);
4254}
4255
4256/*
4257
4258*/
4259
4260/*
4261 ============================================================================
4262 pclr() -- clear the panel FIFO
4263 ============================================================================
4264*/
4265
4266short
4267pclr()
4268{
4269 register short i;
4270
4271 DB_ENTR("pclr");
4272 ftimer = FIFOLIM;
4273
4274 while (XBIOS(X_APICHK)) {
4275
4276 afi = XBIOS(X_ANALOG); /* check panel inputs */
4277 asig = 0x007F & (afi >> 8); /* signal number */
4278
4279 if (0 EQ asig) {
4280
4281 /* all keys up */
4282
4283 for (i = 0; i < 128; i++) {
4284
4285 sigtab[i][0] = 0;
4286 sigtab[i][1] = 0;
4287 }
4288
4289 break;
4290 }
4291
4292 if (ftimer-- < 0) {
4293
4294 DB_EXIT("pclr - timed out");
4295 return(FAILURE);
4296 }
4297 }
4298
4299 DB_EXIT("pclr - panel clear");
4300 return(SUCCESS);
4301}
4302
4303/*
4304
4305*/
4306
4307/*
4308 ============================================================================
4309 pscan() -- scan the panel and maybe even load a program from diskette
4310 ============================================================================
4311*/
4312
4313short
4314pscan()
4315{
4316 register short i, c;
4317
4318 DB_ENTR("pscan");
4319
4320 if (0 GE ledcntr--) {
4321
4322 if ((baseled + 3) > 23) /* turn on a LED */
4323 io_leds = baseled - 21;
4324 else
4325 io_leds = baseled + 3;
4326
4327 io_leds = 0x80 + baseled; /* turn off a LED */
4328
4329 if (++baseled > 23) /* update LED number */
4330 baseled = 0;
4331
4332 ledcntr = LED_TIME;
4333 }
4334
4335 DB_CMNT("pscan - checking panel");
4336
4337 aflag = FALSE;
4338
4339 if (XBIOS(X_APICHK)) { /* check panel inputs */
4340
4341 afi = XBIOS(X_ANALOG); /* get the signal */
4342 asig = 0x007F & (afi >> 8); /* signal number */
4343 astat = 0x0001 & (afi >> 7); /* status */
4344 aval = 0x007F & afi; /* value */
4345
4346 if (asig) { /* active signal */
4347
4348 aflag = TRUE;
4349
4350 sigtab[asig][0] = aval;
4351 sigtab[asig][1] = astat;
4352
4353 } else { /* all keys up */
4354
4355 aflag = FALSE;
4356
4357 for (i = 0; i < 128; i++)
4358 sigtab[i][1] = 0;
4359 }
4360 }
4361/*
4362
4363*/
4364 if (aflag) { /* anything changed ? */
4365
4366 if (astat AND (asig EQ BOOTKEY)) { /* BOOT key */
4367
4368 DB_CMNT("pscan - booting");
4369
4370 for (i = 0; i < 24; i++) /* turn off LEDs */
4371 io_leds = 0x80 + i;
4372
4373 /* load and run BOOTFILE */
4374
4375 B_log_s = FALSE;
4376 B_dbg_s = FALSE;
4377
4378 hdvini();
4379 _bpbin = FALSE;
4380
4381 if (booter(BOOTFILE, 0L)) {
4382
4383 DB_EXIT("pscan - boot failed");
4384 return(FALSE);
4385
4386 } else {
4387
4388 DB_CMNT("pscan - initializing MIDAS TCB");
4389
4390 if ((struct _mt_def *)NIL EQ _MT_)
4391 _MT_ = (struct _mt_def *)XBIOS(X_MTDEFS);
4392
4393 MTSetT(&ipltcb, MTID(), BOOT_PRI, 0x2200, -1L,
4394 ISTACK, B_buf_a, _MT_);
4395
4396 DB_CMNT("pscan - swapping to midas");
4397
4398 MTSwap();
4399 SMWait(&SemQuit);
4400
4401 DB_EXIT("pscan - returned from MIDAS");
4402 return(FALSE);
4403 }
4404
4405 } else if (astat AND (asig EQ ROMPKEY)) { /* ROMP key */
4406
4407 for (i = 0; i < 24; i++) /* turn off LEDs */
4408 io_leds = 0x80 + i;
4409
4410 DB_EXIT("pscan - ROMP selected - panel");
4411 return(TRUE);
4412 }
4413 }
4414
4415/*
4416
4417*/
4418
4419 DB_CMNT("pscan - checking SIO");
4420
4421 if (BIOS(B_RDAV, CON_DEV)) {
4422
4423 c = 0x007F & BIOS(B_GETC, CON_DEV);
4424
4425 if ((c EQ 'r') OR (c EQ 'R')) {
4426
4427 for (i = 0; i < 24; i++) /* turn off LEDs */
4428 io_leds = 0x80 + i;
4429
4430 DB_EXIT("pscan - ROMP selected - SIO");
4431 return(TRUE);
4432 }
4433 }
4434
4435 DB_EXIT("pscan - no inputs");
4436 return(FALSE);
4437}
4438
4439/*
4440
4441*/
4442
4443/*
4444 ============================================================================
4445 mtsetup() -- setup for multi-tasking
4446 ============================================================================
4447*/
4448
4449mtsetup()
4450{
4451 DB_ENTR("mtsetup");
4452
4453 _MT_ = (struct _mt_def *)XBIOS(X_MTDEFS); /* intialize _MT_ */
4454
4455 MTInit(); /* initialize Multi-Tasker */
4456 MBInit(&MSG_Vid); /* initialize video mailbox */
4457 SMInit(&SemQuit, 0L); /* initialize termination semaphore */
4458
4459 /* setup interrupt level 5 (serial I/O) handler */
4460
4461 MTSetT(MT_ITT[5], MTID(), 0x8005, 0x2500, -1L,
4462 &stax[4][STKLEN], _MTInt5, 0L);
4463
4464 DB_CMNT("mtsetup - level 5");
4465
4466 /* setup interrupt level 4 (timer) handler */
4467
4468 MTSetT(MT_ITT[4], MTID(), 0x8004, 0x2400, -1L,
4469 &stax[3][STKLEN], _MTInt4, 0L);
4470
4471 DB_CMNT("mtsetup - level 4");
4472
4473 /* setup interrupt level 3 (panel) handler */
4474
4475 MTSetT(MT_ITT[3], MTID(), 0x8003, 0x2300, -1L,
4476 &stax[2][STKLEN], _MTInt3, 0L);
4477
4478 DB_CMNT("mtsetup - level 3");
4479
4480 /* setup interrupt level 2 (FPU) handler */
4481
4482 MTSetT(MT_ITT[2], MTID(), 0x8002, 0x2200, -1L,
4483 &stax[1][STKLEN], _MTInt2, 0L);
4484
4485 DB_CMNT("mtsetup - level 2");
4486
4487 /* setup interrupt level 1 (Video) handler */
4488
4489 MTSetT(MT_ITT[1], MTID(), 0x8001, 0x2100, -1L,
4490 &stax[0][STKLEN], _MTInt1, 0L);
4491
4492 DB_CMNT("mtsetup - level 1");
4493
4494 DB_EXIT("mtsetup");
4495}
4496
4497/*
4498
4499*/
4500
4501/*
4502 ============================================================================
4503 put_ID() -- identify the firmware on the LCD
4504 ============================================================================
4505*/
4506
4507put_ID()
4508{
4509 DB_ENTR("put_ID");
4510 GLCinit(); /* reset LCD display */
4511 GLCcurs(G_ON);
4512
4513 GLCtext(0, 1, "Load GoTo");
4514 GLCtext(1, 1, "Disk ROMP");
4515
4516 GLCtext(3, 10, "Buchla 700 -- System Firmware by D.N. Lynx Crowe");
4517
4518 sprintf(idbuf, "Multi-Tasking BIOS -- Version %02d.%02d%s",
4519 *(char *)PRM_VERS, *(char *)(PRM_VERS+1), promdate);
4520
4521 GLCtext(5, 10, idbuf);
4522
4523 sprintf(idbuf, "Multi-Tasking ROMP -- Version %s", ROMPVER);
4524
4525 GLCtext(6, 10, idbuf);
4526
4527 GLCcrc(0, 0);
4528 GLCcurs(G_OFF);
4529
4530 DB_EXIT("put_ID");
4531}
4532
4533/*
4534
4535*/
4536
4537/*
4538 ============================================================================
4539 ROMP -- main routine
4540 ============================================================================
4541*/
4542
4543main()
4544{
4545 register short i;
4546 register char *pdptr, *pcptr;
4547
4548 DB_ENTR("main");
4549 baseled = 21; /* setup LED scan */
4550 ledcntr = 0; /* ... */
4551 io_leds = 0x9F; /* turn on LCD lamp */
4552
4553 /* unpack PROM date */
4554
4555 pcptr = (char *)PRM_DATE; /* prom date: yyyymmdd */
4556 pdptr = promdate; /* -- yyyy-mm-dd */
4557 *pdptr++ = ' ';
4558 *pdptr++ = '-';
4559 *pdptr++ = '-';
4560 *pdptr++ = ' ';
4561 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
4562 *pdptr++ = (*pcptr++ & 0x0F) + '0';
4563 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
4564 *pdptr++ = (*pcptr++ & 0x0F) + '0';
4565 *pdptr++ = '-';
4566 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
4567 *pdptr++ = (*pcptr++ & 0x0F) + '0';
4568 *pdptr++ = '-';
4569 *pdptr++ = ((*pcptr >> 4) & 0x0F) + '0';
4570 *pdptr++ = (*pcptr++ & 0x0F) + '0';
4571 *pdptr++ = '\0';
4572
4573 /* initialize variables */
4574
4575 sprintf(hs_mtst, "[[start=$%lX],[end=$%lx]] (or $8..$%lX)",
4576 USER_RAM, RAM_TOP, (USER_RAM - 2L));
4577
4578 cmdunit = CON_DEV;
4579
4580 ilast = 0;
4581 inext = 0;
4582 iplev = DEFIPL;
4583
4584 dflag = FALSE;
4585 exflag = FALSE;
4586 redo = FALSE;
4587 goflag = FALSE;
4588 b0flag = FALSE;
4589 b1flag = FALSE;
4590
4591 p_goto = (char *)ROMADDR;
4592 p_len = 0L;
4593 p_width = 16L;
4594 p_value = 0L;
4595
4596 p_ba0 = 0L;
4597 p_bv0 = BPINST;
4598
4599 p_ba1 = 0L;
4600 p_bv1 = BPINST;
4601
4602 tba0 = 0L;
4603 tba1 = 0L;
4604
4605 inext = 0;
4606
4607 put_ID();
4608
4609 BIOS(B_SETV, 47, trap15); /* set ROMP trap vec */
4610
4611 for (i = 0; i < 128; i++) { /* clear analog I/O status */
4612
4613 sigtab[i][0] = 0;
4614 sigtab[i][1] = 0;
4615 }
4616
4617 mtsetup(); /* setup multi-tasking */
4618
4619 DB_CMNT("main - TCBs setup - starting multitasker");
4620 MTSwap();
4621
4622 DB_CMNT("main - clearing panel FIFO");
4623 XBIOS(X_CLRAFI); /* clear the panel FIFO */
4624
4625 DB_CMNT("main - turning on ints");
4626 setipl(KB_EI); /* enable interrupts */
4627
4628 DB_CMNT("main - emptying panel FIFO");
4629 pclr(); /* empty the panel FIFO */
4630
4631 DB_CMNT("main - clearing panel FIFO");
4632 XBIOS(X_CLRAFI); /* clear the panel FIFO */
4633
4634 DB_CMNT("main - scanning panel");
4635 while (FALSE EQ pscan()) ; /* do the panel scan */
4636
4637/*
4638
4639*/
4640 progid(); /* identify the program */
4641
4642 writeln(cmdunit, "\r\n\n");
4643
4644 /* process commands */
4645
4646 first1 = TRUE; /* set break init flag */
4647
4648 while (TRUE) {
4649
4650 xtrap15(); /* trap into ROMP bp processor */
4651 writeln(cmdunit, "\r\n** xtrap15() returned to ROMP **\r\n\n");
4652 }
4653}
Note: See TracBrowser for help on using the repository browser.