forked from hperaza/RSX280
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtskhdr.mac
617 lines (532 loc) · 10.1 KB
/
tskhdr.mac
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
;***********************************************************************
;
; This file is part of RMD, a Resource Monitoring Display utility
; for the RSX280 OS. Copyright (C) 1985-2023, Hector Peraza.
;
; This program is free software; you can redistribute it and/or
; modify it under the terms of the GNU General Public License as
; published by the Free Software Foundation; either version 2 of
; the License, or (at your option) any later version.
;
; This program is distributed in the hope that it will be useful,
; but WITHOUT ANY WARRANTY; without even the implied warranty of
; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
; GNU General Public License for more details.
;
; You should have received a copy of the GNU General Public License
; along with this program; if not, write to the Free Software
; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
;
;***********************************************************************
; Task Header Display
.Z280
include RMD.INC
include SYSTEM.INC
include TCB.INC
include PCB.INC
include FCB.INC
include DCB.INC
public THDRPG
extrn VPUTC,VPUTS,VPUTN,VXY,VGETXY,VAHEX,VHLHEX
extrn VADEC,VHLDEC,VCLEOL,VCLEOS,VRPAD,HEADER
extrn SKIPBL,STRCMP,UCASE
extrn TSKNAM ; persistent data in root section
cseg
;-----------------------------------------------------------------------
THDRPG: ld hl,$+4
ret
dw dproc ; address of display procedure
dw setup ; address of setup procedure
dw hlptxt ; address of help text
; This is the task header display procedure. It is called with a code
; in register A:
; 0 means redraw everything
; 1 means draw only what has changed from the previous call
dproc: push af
call HEADER
pop af
or a ; check redraw flag
jr nz,m0
call thdr
m0: call updtsk ; update task display
ret
;-----------------------------------------------------------------------
; Process setup command @DE
setup: call SKIPBL
ld hl,hlptxt
ld b,4
call STRCMP ; is it TASK?
scf
ret nz ; return if not
call SKIPBL
cp '=' ; '=' must follow
scf
ret nz
inc de
ld hl,TSKNAM
ld b,6
s0: ld a,(de)
call UCASE
cp ' '
jr c,s1
ld (hl),a
inc hl
inc de
djnz s0
ret
s1: ld (hl),' '
inc hl
djnz s1
xor a
ret
;-----------------------------------------------------------------------
; Help text to add to the setup command page
hlptxt: db "TASK=t display task header for task 't'",CR,LF
db 0
;-----------------------------------------------------------------------
; Display heading
thdr: ld hl,hdr
;jp hloop
th1: ld d,(hl) ; X
inc hl
ld e,(hl) ; Y
inc hl
inc de
ld a,d
or e
ret z
dec de
ex de,hl
call VXY
ex de,hl
call VPUTS
inc hl
jr th1
hdr: db 0,3,'Task:',0
db 14,3,'Partition:',0
db 33,3,'Status:',0
db 1,4,'Own:',0
db 14,4,'I/O:',0
db 25,4,'Dpri:',0
db 36,4,'Pri:',0
db 46,4,'Spri:',0
db 57,4,'Eflg:',0
db 0,6,'AF = ',0
db 11,6,'BC = ',0
db 22,6,'DE = ',0
db 33,6,'HL = ',0
db 44,6,'IX = ',0
db 55,6,'IY = ',0
db 0,7,'AF''= ',0
db 11,7,'BC''= ',0
db 22,7,'DE''= ',0
db 33,7,'HL''= ',0
db 44,7,'PC = ',0
db 55,7,'SP = ',0
db 0,9,'LUN',0
db 0,10,'---',0
db 4,9,'File',0
db 4,10,'----',0
db 33,9,'LUN',0
db 33,10,'---',0
db 37,9,'File',0
db 37,10,'----',0
dw 0FFFFh
stxy: db 25,3,6
db 6,4,6
db 19,4,5
db 31,4,4
db 41,4,4
db 52,4,4
db 63,4,8
regxy: db 5,6
db 16,6
db 27,6
db 38,6
db 49,6
db 60,6
db 5,7
db 16,7
db 27,7
db 38,7
db 49,7
db 60,7
lunxy: db 0,11
db 0,12
db 0,13
db 0,14
db 0,15
db 0,16
db 0,17
db 0,18
db 33,11 ; 40,...
db 33,12
db 33,13
db 33,14
db 33,15
db 33,16
db 33,17
db 33,18
;-----------------------------------------------------------------------
; Update task display
updtsk: ld a,(TSKNAM)
cp ' '
ld hl,ntsmsg
jr z,upd2
VGTOXY 6,3
ld hl,TSKNAM
ld b,6
call VPUTN ; show task name
ld hl,($TLIST)
upd1: ld a,h
or l
jr z,upd21 ; end of list, task not found
push hl
call cmpnam ; compare task name with user-given name
pop ix
jr z,found
ldw hl,(ix+T.TCBL) ; next task in list
jr upd1 ; loop
found: ; Task found
bit TS.ACT,(ix+T.ST) ; task active?
ld hl,timsg
jr z,upd2 ; skip it if not
bit T2.OUT,(ix+T.ST+1) ; task in memory?
ld hl,timsg
jr nz,upd2 ; skip it if not
; Task active and in memory
call shwtsk ; else show task details
ld hl,nulmsg
jr upd6
upd21: ; Task not found
ld hl,tnfmsg
upd2: push hl
ld hl,regxy
ld b,12
upd3: ld d,(hl) ; X
inc hl
ld e,(hl) ; Y
inc hl
ex de,hl
call VXY
ex de,hl
ld c,' ' ; clear register fields
call VPUTC
call VPUTC
call VPUTC
call VPUTC
djnz upd3
ld hl,stxy
ld b,6
upd31: ld d,(hl) ; X
inc hl
ld e,(hl) ; Y
inc hl
ex de,hl
call VXY
ex de,hl
push bc
ld c,' ' ; clear fields
ld b,(hl)
inc hl
upd32: call VPUTC
djnz upd32
pop bc
djnz upd31
VGTOXY 41,3
call VCLEOL ; clear status field
VGTOXY 0,11
call VCLEOS
pop hl
upd6: push hl
VGTOXY 0,1
pop hl
call VPUTS
call VCLEOL
ret
ntsmsg: db 'No task specified',0
tnfmsg: db 'Task not in system',0
timsg: db 'Task inactive or out of memory'
nulmsg: db 0
; Compare task names
cmpnam: ld de,T.NAME
add hl,de
ld de,TSKNAM
ld b,6
tcmp: ld a,(de)
cp (hl)
ret nz
inc hl
inc de
djnz tcmp
ret
; Show task info
shwtsk: VGTOXY 25,3
ldw hl,(ix+T.PCB)
ldw hl,(hl+P.MAIN)
ld de,P.NAME
add hl,de
ld b,6
call VPUTN ; display partition name
VGTOXY 41,3
ld d,(ix+T.ST)
ld hl,stat
bit TS.ACT,d
push af
call nz,tbits ; display status bits
ld d,(ix+T.ST+1)
ld hl,stat2
pop af
call nz,tbits
ld d,(ix+T.ATTR)
ld hl,attr
call tbits ; display attrib bits
call VCLEOL
VGTOXY 6,4
ldw de,(ix+T.TI)
KCALL $UCBDN
ld b,c
ld c,e
call VPUTC
ld c,d
call VPUTC
ld d,8 ; starting X coord in D
ld a,b
call VADEC
ld c,':'
call VPUTC
ld e,6 ; field size
call VRPAD ; pad with spaces
VGTOXY 19,4
ld d,19 ; starting X coord in D
ld a,(ix+T.IOC)
call VADEC
ld e,5 ; field size
call VRPAD ; pad with spaces
VGTOXY 41,4
ld d,41 ; starting X coord in D
ld a,(ix+T.PRI)
call VADEC
ld e,5 ; field size
call VRPAD ; pad with spaces
VGTOXY 31,4
ld d,31 ; starting X coord in D
ld a,(ix+T.DPRI)
call VADEC
ld e,5 ; field size
call VRPAD ; pad with spaces
VGTOXY 52,4
ld a,(ix+T.SPRI)
exts a ; sign extend to HL
ld e,(ix+T.PRI)
ld d,0
or a
adc hl,de
jp p,p1
ld hl,0
p1: ld d,52 ; starting X coord in D
xor a
call VHLDEC
ld e,5 ; field size
call VRPAD ; pad with spaces
VGTOXY 63,4
ld a,(ix+T.FLGS)
call VAHEX
ld a,(ix+T.FLGS+1)
call VAHEX
ld a,(ix+T.FLGS+2)
call VAHEX
ld a,(ix+T.FLGS+3)
call VAHEX
call regs
call luns
xor a
ret
tbits: ld b,8 ; bit counter
ld e,01h ; bit mask
t1: ld a,d
and e ; bit set?
jr z,t2 ; skip if not
ld a,(hl)
inc hl
or a ; got a name for it?
jr z,t3 ; skip if not
dec hl
push bc
ld b,3
call VPUTN ; else display name
pop bc
ld c,' '
call VPUTC ; followed by separator
call VPUTC
jr t3
t2: ld a,(hl)
inc hl
or a
jr z,t3
inc hl
inc hl
t3: rl e
djnz t1
ret
luns: ld b,0
lun1: ldw hl,(ix+T.CTX) ; get address of context block
ld de,TX.LUT
add hl,de ; HL = start of LUN table
ld e,b
ld d,0
add hl,de ; index into LUN table
add hl,de
add hl,de
add hl,de
ldw de,(hl) ; get UCB into DE
inc hl
inc hl
ldw hl,(hl) ; get FCB into HL
call lunfil ; display LUN info
inc b
ld a,b
cp 16
jr nz,lun1
ret
lunfil: ld a,d ; LUN assigned?
or e
jp z,lf2 ; return if not
push hl
push de
ld hl,lunxy
ld e,b
ld d,0
add hl,de
add hl,de
ld d,(hl) ; X
inc hl
ld e,(hl) ; Y
ex de,hl
call VXY ; position cursor
ex de,hl
ld a,b
inc a
call VADEC ; display LUN number
ld e,4 ; field size, old X still in D
call VRPAD ; pad with spaces
pop de
pop hl
ld a,h
or l ; file open on LUN?
jr z,lf1 ; jump if not
push hl
pop iy
ldw de,(iy+F.DEV)
ld c,(iy+F.UNIT)
call dname ; display device name and unit
ld c,'['
call VPUTC
ex de,hl
ld hl,F.DIR
add hl,de
push bc
ld b,9
call fname ; display directory name
ld c,']'
call VPUTC
ld hl,F.NAME
add hl,de
ld b,9
call fname ; display file name
ld c,'.'
call VPUTC
ld hl,F.EXT
add hl,de
ld b,3
call fname ; display file version
pop bc
ld c,';'
call VPUTC
ldw hl,(iy+F.VER)
xor a
call VHLDEC ; display file version number
jr lf2
lf1: KCALL $UCBDN
call dname ; display device name and unit
lf2: ld hl,lunxy
ld e,b
ld d,0
add hl,de
add hl,de
ld a,(hl) ; X
add a,33
ld e,a
ld d,0
call VRPAD
ret
dname: ld a,c
push af
ld c,e ; display device name
call VPUTC
ld c,d
call VPUTC
pop af
call VADEC ; display unit number
ld c,':'
call VPUTC
ret
fname: ld a,(hl)
cp ' '
ret z
ld c,a
call VPUTC
inc hl
djnz fname
ret
regs: xor a
ld (SYSLVL),a ; critical section
ld hl,regbuf
ldw de,(ix+T.SP)
ldw (hl),de ; store SP first
inc hl
inc hl
ex de,hl ; DE = dst
ldw hl,(ix+T.CTX)
ld bc,TX.REGS
add hl,bc ; HL = pointer to saved register frame
ld bc,10*2 ; copy the 10 general-purpose registers
ldir
inc hl ; skip reason code
inc hl
inc hl ; skip MSR
inc hl
ld bc,2
ldir ; copy PC value
inc a
ld (SYSLVL),a
push ix
ld ix,regofs
ld hl,regxy
ld b,12
r1: ld e,(ix) ; get offset to value in buffer
ld d,0
ld iy,regbuf
add iy,de
ld d,(hl) ; X
inc hl
ld e,(hl)
inc hl
ex de,hl
call VXY
ldw hl,(iy) ; get reg pair value
call VHLHEX
ex de,hl
inc ix
djnz r1
pop ix
ret
stat: db 0,'AST','SUP','CKR','ABX','XDT',0,'BPT'
stat2 db 'STP','SEF','EFW','WTD','OUT','CKP','LDR','ABO'
attr: db 'PRV','REM',0,'FIX','MCR','CLI','ACP','CKD'
;-----------------------------------------------------------------------
dseg
regbuf: ds 24
regofs: db 20,18,16,14,4,2
db 12,10,8,6,22,0
end