.mcall .module .module CI,release=X05,version=4,comment=,audit=YES ;+ ; Copyright (c) 1985 ; C. E. Chew ; ; This software is furnished under a license and may be used and copied ; only in accordance with the terms of such license and with the ; inclusion of the above copyright notice. This software or any other ; copies thereof may not be provided or otherwise made available to any ; other person. No title to and ownership of the software is hereby ; transferred. ; ; The information in this software is subject to change without notice ; and should not be construed as a commitment by the author. ; ; The author assumes no responsibility for the use or reliability of his ; software. ;- .page .sbttl Definitions .dsabl gbl .mcall .drdef .br .assume .mfps .mtps .synch .inten .drdef ci 367 spfun$ 0 0 0 ; swt$fn =: 377 ;switch console context cmd$fn =: 376 ;pass string get$fn =: 375 ;obtain console context ; ttoid =: -6 ;offset to context id ttousr =: -4 ;offset to output context ttiusr =: -2 ;offset to input context ; pr7 =: 340 ; sysptr =: 54 ttiin2 =: 14. tkbvec =: 60 cr =: 15 ;ascii carriage return ; jobmax =: 8. ;number of jobs ; i.state =: 0 ;state bits in impure area abpnd$ =: 1 ;abort has been requested abort$ =: 40 ;job is being aborted i.blok =: 36 ;blocking bits in impure area norun$ =: 1000 ;job is not running ; jobnum =: 322 cntxt =: 320 p1ext =: 432 ; .macro section name .sbttl name .endm section section ;+ ; Only permit non-system handler installation if monitor offsets are ok. ;- .drins ci br o.ins br o.rets ;cannot install as system handler o.ins: mov r2,-(sp) mov r3,-(sp) call o.set ;check out monitor mov (sp)+,r3 mov (sp)+,r2 bcs o.rets cmp o.imp,(pc)+ i.imp: .word 0 bne o.rets cmp o.tcn,(pc)+ i.tcn: .word 0 bne o.rets cmp o.tti,(pc)+ i.tti: .word 0 bne o.rets br o.retc ;go ahead .iif gt .-400 .error section ;+ ; Configures the handler to the current monitor offsets. ;- .drset config 1 o.con .enabl lsb o.con: call o.set ;get monitor offsets bcs o.rets mov o.imp,impure ;fix up handler mov o.imp,i.imp mov o.tcn,tcntxt mov o.tcn,i.tcn mov o.tti,ttiint mov o.tti,i.tti o.retc: tst (pc)+ o.rets: sec return ; o.set: mov @#sysptr,r0 ;point to RMON mov jobnum(r0),r3 ;number of current job add #4,r3 ;offset to beginning of table mov cntxt(r0),r1 ;context of current job add #,r0 ;end of fixed offsets mov r0,r2 ; 10$: cmp (r0)+,r1 ;search for impure pointers beq 40$ 20$: cmp r0,#160000 blo 10$ ;don't enter IO page br o.rets ;no good ; 30$: add r3,r0 ;retrieve br 20$ ; 40$: sub r3,r0 ;see if this is it cmp (r0)+,#-1 ;start of table bne 30$ ;no, keep trying mov r0,(pc)+ ;remember beginning of impure table o.imp: .blkw 1 mov #jobmax,r1 ;number of possible alternatives mov r2,r3 ;remember where we started from ; 50$: cmp (r2)+,(r2) ;search for terminal context area beq 100$ 60$: cmp r2,#<160000-2> blo 50$ mov r3,r2 ;start again br 80$ ; 70$: tst (r0) ;background job always there bne 50$ ;someone there 80$: tst (r0)+ ;next job 90$: sob r1,70$ br o.rets ;no good ; 100$: cmp (r2)+,(r0) ;perhaps this one bne 60$ ;no tst ttoid(r2) bne 60$ ;no ; mov r2,(pc)+ ;this is it o.tcn: .blkw 1 mov @#tkbvec,(pc)+ ;get interrupt location o.tti: .blkw 1 add #ttiin2,o.tti br o.retc ;no errors .iif gt .-1000 .error section ;+ ; RT-11 enters here. Initialise if necessary. ;- .drbeg ci mov cicqe,r4 ;what's required ; clr r5 bisb q$func(r4),r5 .assume swt$fn eq 377 .assume cmd$fn eq 376 .assume get$fn eq 375 sub #get$fn,r5 cmp r5,# bhi cierr ;illegal function inc r5 ;index into jump table asl r5 add pc,r5 add (r5),pc ;and go cidisp: .word ciget-cidisp .word cicmd-cidisp .word ciswt-cidisp impure: .word 0 tcntxt: .word 0 ttiint: .word 0 section ;+ ; Obtain the current context of the console. ; ; q$buff -> pointer to two words to receive the context ; first word input context ; second word output context ;- .enabl lsb ciget: mov tcntxt,r3 ;point to context data .if ne mmg$t mov -(r3),-(sp) call @$ptwrd mov -(r3),-(sp) call @$ptwrd .iff mov q$buff(r4),r2 mov -(r3),(r2)+ mov -(r3),(r2)+ .endc br cifin section ;+ ; Change the context of the console to the appropriate job. ; ; q$buff -> pointer to job context ; q$wnct -> -ve output context switch only ; zero input and output context switch ; +ve input context switch only ;- .enabl lsb ciswt: .if eq mmg$t mov @q$buff(r4),r3 ;context to switch to .iff call @$gtbyt ;context to switch to call @$gtbyt movb (sp)+,1(sp) mov (sp)+,r3 .endc mov impure,r0 ;scan impure table to check validity mov #jobmax,r1 1000$: cmp (r0)+,r3 beq 1010$ ;it does exist sob r1,1000$ br cierr ;someone was pulling my leg ; 1010$: bit #,(r3) .assume i.state eq 0 bne cierr ;abort is in progress or pending bit #norun$,i.blok(r3) bne cierr ;job is dead .assume i.blok ne 0 mov tcntxt,r5 mov q$wcnt(r4),r2 .mfps mov #pr7,-(sp) .mtps clr ttoid(r5) tst r2 blt 20$ ;don't switch input mov r3,ttiusr(r5) 20$: tst r2 bgt 30$ ;don't switch output mov r3,ttousr(r5) 30$: .mtps br cifin section ;+ ; Pass a string to the console interrupt processor. ; ; q$buff -> pointer to string ;- .enabl lsb cicmd: .if ne mmg$t call @$gtbyt movb (sp)+,r5 .iff movb @q$buff(r4),r5 inc q$buff(r4) tst r5 .endc beq 10$ ;end of string cmpb r5,#200 beq 20$ ;end but without return call ttint br cicmd ; 10$: movb #cr,r5 ;carriage return call ttint 20$: br cifin section ;+ ; Return to RT-11. ;- .enabl lsb cierr: bis #hderr$,@q$csw(r4) ;error time cifin: .drfin ci section ;+ ; Simulates an interrupt from the keyboard. Call with r5 holding the character ; to be passed. r5 and r4 will be saved. ;- .enabl lsb ttint: mov (sp),-(sp) .mfps ;set up stack mov (sp)+,2(sp) mov r5,(pc)+ ;character 10$: .blkw 1 mov #pr7,-(sp) .mtps ;interrupt .inten 4 PIC mov 10$,r4 jmp @ttiint section ;+ ; This is primarily to keep the linker happy. ;- ciint: rti .drend ci .end