source: buchla-68k/orig/MT/MTSNAP.C@ 0170798

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

Imported original source code.

  • Property mode set to 100755
File size: 9.7 KB
Line 
1/*
2 =============================================================================
3 mtsnap.c -- Multi-Tasker -- snap dump the multitasker structures
4 Version 22 -- 1988-04-17 -- D.N. Lynx Crowe
5 (c) Copyright 1988 -- D.N. Lynx Crowe
6 =============================================================================
7*/
8
9#include "stddefs.h"
10#include "mtdefs.h"
11#include "iorec.h"
12#include "debug.h"
13
14extern unsigned MT_IDct;
15extern unsigned *MT_NTpc;
16extern unsigned *MT_STpc;
17extern unsigned *MT_LSpc;
18extern unsigned *MT_LWpc;
19
20extern TCB *MT_LTCB;
21extern TCB *MT_TCBs;
22extern TCB *MT_CurP;
23extern TCB *MT_RdyQ;
24extern TCB *MT_ITT[];
25
26extern SEM MTISem1;
27extern SEM MTISem2;
28extern SEM MTISem3;
29extern SEM MTISem4;
30extern SEM MTISem5;
31extern SEM SemAPI;
32extern SEM SemFCLK;
33extern SEM SemTick;
34
35extern struct iorec sr1_ior;
36extern struct iorec sr2_ior;
37extern struct iorec mc1_ior;
38extern struct iorec mc2_ior;
39
40/*
41
42*/
43
44/*
45 =============================================================================
46 MTPrFlg() -- convert TCB flags to printable form
47 =============================================================================
48*/
49
50char *
51MTPrFlg(flags, flagbuf)
52short flags;
53char *flagbuf;
54{
55
56 sprintf(flagbuf, "$%04.4X {", flags);
57
58 if (flags & MTF_OCC)
59 strcat(flagbuf, " OCC");
60
61 if (flags & MTF_RDY)
62 strcat(flagbuf, " RDY");
63
64 if (flags & MTF_SWT)
65 strcat(flagbuf, " SWT");
66
67 if (flags & MTF_RUN)
68 strcat(flagbuf, " RUN");
69
70 if (flags & MTF_STP)
71 strcat(flagbuf, " STP");
72
73 strcat(flagbuf, " }");
74
75 return(flagbuf);
76}
77
78/*
79
80*/
81
82/*
83 =============================================================================
84 MTPrTCB() -- print the contents of a TCB in readable form
85 =============================================================================
86*/
87
88MTPrTCB(ptcb, msg)
89register TCB *ptcb;
90char *msg;
91{
92 register unsigned sreg;
93 register short i;
94 char flbuf[64];
95
96 if (msg NE (char *)NULL)
97 printf("%s\n", msg);
98
99 printf("TCB Addr: $%08.8lX Next: $%08.8lX FWD: $%08.8lX\n",
100 ptcb, ptcb->next, ptcb->fwd);
101
102 printf("TID: %5u Pri: %5u ($%04.4X) Flags: %s\n",
103 ptcb->tid, ptcb->pri, ptcb->pri, MTPrFlg(ptcb->flags, flbuf));
104
105 printf("Regs ");
106
107 for (i = 0; i < 8; i++)
108 printf(" %d_______", i);
109
110 printf("\nd0..d7 ");
111
112 for (i = 0; i < 8; i++)
113 printf(" %08.8lX", ptcb->reg[i]);
114
115 printf("\na0..a7 ");
116
117 for (i = 8; i < 16; i++)
118 printf(" %08.8lX", ptcb->reg[i]);
119
120 sreg = ptcb->sr;
121 sprintf(flbuf, "(IPL = %d, ", (sreg >> 8) & 7);
122 strcat(flbuf, 0x8000 & sreg ? "T" : "-");
123 strcat(flbuf, 0x2000 & sreg ? "S " : "- ");
124 strcat(flbuf, 0x0010 & sreg ? "X" : "-");
125 strcat(flbuf, 0x0008 & sreg ? "N" : "-");
126 strcat(flbuf, 0x0004 & sreg ? "Z" : "-");
127 strcat(flbuf, 0x0002 & sreg ? "V" : "-");
128 strcat(flbuf, 0x0001 & sreg ? "C )" : "- )");
129
130 printf("\nPC = $%08.8lX SR = $%04.4X %s\n", ptcb->pc, sreg, flbuf);
131
132 printf("SP: $%08.8lX TOS: $%08.8lX Slice: %ld\n\n",
133 ptcb->sp, ptcb->tos, ptcb->slice);
134}
135
136/*
137
138*/
139
140/*
141 =============================================================================
142 MTPrTst() -- print the contents of a TCB in readable (short) form
143 =============================================================================
144*/
145
146MTPrTst(ptcb)
147register TCB *ptcb;
148{
149 char flbuf[64];
150
151 printf("$%08.8lX $%08.8lX $%04.4X",
152 ptcb, ptcb->pc, ptcb->sr);
153
154 printf(" %5u %5u %s\n",
155 ptcb->tid, ptcb->pri, MTPrFlg(ptcb->flags, flbuf));
156}
157
158/*
159 =============================================================================
160 MTPrQ() -- print a TCB queue
161 =============================================================================
162*/
163
164MTPrQ(tcp)
165register TCB *tcp;
166{
167 printf("TCB______ PC_______ SR___ TID__ PRI__ Flags\n");
168
169 while (tcp) {
170
171 MTPrTst(tcp);
172 tcp = tcp->next;
173 }
174
175 printf("\n");
176}
177
178/*
179
180*/
181
182/*
183 =============================================================================
184 MTPrTS() -- print the TCB chain -- short form
185 =============================================================================
186*/
187
188MTPrTS()
189{
190 register TCB *tcp;
191
192 printf("***** TCB Chain *****\n\n");
193
194 printf("TCB______ PC_______ SR___ TID__ PRI__ Flags\n");
195
196 tcp = MT_TCBs;
197
198 while (tcp) {
199
200 MTPrTst(tcp);
201 tcp = tcp->fwd;
202 }
203
204 printf("\n");
205}
206
207/*
208 =============================================================================
209 MTPrTL() -- print the TCB chain -- long form
210 =============================================================================
211*/
212
213MTPrTL()
214{
215 register TCB *tcp;
216
217 printf("***** TCB Chain *****\n\n");
218
219 tcp = MT_TCBs;
220
221 while (tcp) {
222
223 MTPrTCB(tcp, (char *)0L);
224 tcp = tcp->fwd;
225 }
226
227 printf("\n");
228}
229
230/*
231
232*/
233
234/*
235 =============================================================================
236 MTPrRq() -- print the ready queue
237 =============================================================================
238*/
239
240MTPrRq()
241{
242 if (MT_RdyQ) {
243
244 printf("***** Ready Queue *****\n\n");
245
246 MTPrQ(MT_RdyQ); /* print the ready queue */
247
248 } else {
249
250 printf("***** Ready Queue is EMPTY *****\n\n");
251 }
252}
253
254/*
255 =============================================================================
256 MTSnap() -- snap dump the Multi-Tasker's status
257 =============================================================================
258*/
259
260MTSnap()
261{
262 printf("=============== Multi-Tasker Status ===============\n\n");
263
264 printf(" MT_CurP: $%08.8lX MT_RdyQ: $%08.8lX MT_TCBs: $%08.8lX\n",
265 MT_CurP, MT_RdyQ, MT_TCBs);
266
267 printf(" MT_IDct: %8u MT_STpc: $%08.8lX MT_NTpc: $%08.8lX\n",
268 MT_IDct, MT_STpc, MT_NTpc);
269
270 printf(" MT_LWpc: $%08.8lX MT_LSpc: $%08.8lX\n",
271 MT_LWpc, MT_LSpc);
272
273 printf(" MT_LTCB: $%08.8lX\n\n", MT_LTCB);
274
275 MTPrTCB(MT_CurP, "*** Current TCB *** (MT_CurP)\n");
276
277
278 printf("\n========== End of Multi-Tasker Status ==========\n\n");
279}
280
281/*
282
283*/
284
285/*
286 =============================================================================
287 MTSDump() -- snap dump a semaphore
288 =============================================================================
289*/
290
291MTSDump(sem, msg)
292SEM *sem;
293char *msg;
294{
295 register long sv;
296 register TCB *tcp;
297
298 printf("SEMAPHORE at $%08.8lX = $%08.8lX", sem, *sem);
299
300 if ((char *)0L NE msg)
301 printf(" -- %s", msg);
302
303 printf("\n");
304
305 sv = (long)*sem;
306
307 if (sv) {
308
309 if (sv & 1L) {
310
311 printf(" count = %ld\n\n", sv >> 1);
312
313 } else {
314
315 printf(" not-signalled -- TCBs waiting:\n\n");
316 MTPrQ(sv);
317 }
318
319 } else {
320
321 printf(" count = 0 (LSB = 0)\n\n");
322 }
323}
324
325/*
326
327*/
328
329/*
330 =============================================================================
331 DumpIOR() -- snap dump I/O control record (iorec structure)
332 =============================================================================
333*/
334
335DumpIOR(ip, msg)
336struct iorec *ip;
337char *msg;
338{
339 printf("########## IOREC at $%08.8lX", ip);
340
341 if ((char *)0L NE msg)
342 printf(" -- %s", msg);
343
344 printf(" ##########\n");
345
346 printf(" ibuf $%08.8lX", ip->ibuf);
347 printf(" ibsize %5u", ip->ibsize);
348 printf(" obuf $%08.8lX", ip->obuf);
349 printf(" obsize %5u\n", ip->obsize);
350
351 printf(" ibufhd %5u", ip->ibufhd);
352 printf(" ibuftl %5u", ip->ibuftl);
353 printf(" ibuflow %5u", ip->ibuflow);
354 printf(" ibufhi %5u\n", ip->ibufhi);
355
356 printf(" obufhd %5u", ip->obufhd);
357 printf(" obuftl %5u", ip->obuftl);
358 printf(" obuflow %5u", ip->obuflow);
359 printf(" obufhi %5u\n", ip->obufhi);
360
361 printf(" cfr0 $%02.2X", ip->cfr0 & 0x00FF);
362 printf(" cfr1 $%02.2X", ip->cfr1 & 0x00FF);
363 printf(" flagxon $%02.2X", ip->flagxon & 0x00FF);
364 printf(" flagxof $%02.2X\n", ip->flagxof & 0x00FF);
365
366 printf(" linedis $%02.2X", ip->linedis & 0x00FF);
367 printf(" erbyte $%02.2X", ip->erbyte & 0x00FF);
368 printf(" isr $%02.2X", ip->isr & 0x00FF);
369 printf(" csr $%02.2X\n", ip->csr & 0x00FF);
370
371 printf(" errct %5u", ip->errct);
372 printf(" ibfct %5u\n\n", ip->ibfct);
373
374 MTSDump(&ip->inp_nf, "inp_nf");
375 MTSDump(&ip->inp_ne, "inp_ne");
376 MTSDump(&ip->out_nf, "out_nf");
377 MTSDump(&ip->out_ne, "out_ne");
378
379 printf("########## End of IOREC at $%08.8lX ##########\n\n", ip);
380}
381
382/*
383
384*/
385
386/*
387 =============================================================================
388 MTIDump() -- snap dump interrupt TCBs and semaphores
389 =============================================================================
390*/
391
392MTIDump()
393{
394 register TCB *tcp;
395 register short i;
396 char buf[81];
397 printf("========== I/O System Status ==========\n");
398
399 printf("\n----- Interrupt TCBs -----\n\n");
400
401 for (i = 0; i < 8; i++) {
402
403 if (tcp = MT_ITT[i]) {
404
405 sprintf(buf, "** Level %d Interrupt TCB **", i);
406 MTPrTCB(tcp, buf);
407 }
408 }
409
410 printf("\n----- Internal Interrupt Semaphores -----\n\n");
411
412 MTSDump(&MTISem1, "1 - VSDD");
413 MTSDump(&MTISem2, "2 - FPU");
414 MTSDump(&MTISem3, "3 - panel");
415 MTSDump(&MTISem4, "4 - timer");
416 MTSDump(&MTISem5, "5 - SIO");
417
418 printf("\n----- External Interrupt Semaphores -----\n\n");
419
420 MTSDump(&SemTick, "SemTick");
421 MTSDump(&SemFCLK, "SemFCLK");
422 MTSDump(&SemAPI, "SemAPI");
423
424 printf("\n----- I/O Control Records -----\n\n");
425
426 DumpIOR(&sr1_ior, "Serial-1");
427 DumpIOR(&sr2_ior, "Serial-2");
428 DumpIOR(&mc1_ior, "MIDI-1");
429 DumpIOR(&mc2_ior, "MIDI-2");
430
431 printf("\n========== End of I/O System Status ==========\n\n");
432}
433
434/*
435
436*/
437
438/*
439 =============================================================================
440 MTPanic() -- snap dump the Multi-Tasker's status and trap to ROMP
441 =============================================================================
442*/
443
444MTPanic()
445{
446 MTSnap();
447 MTPrRq();
448 MTIDump();
449 MTPrTL();
450 xtrap15();
451}
Note: See TracBrowser for help on using the repository browser.