.Title AlvUpdate Alvin Device Update .PSECT ALVIN,CON,GBL .Ident /LVL51 / .Mcall $Alv51,$RTDef,.Rctrlo .Globl Ldevice $RTDef $ALV51 ;+ ;;**************************************************************************** ;; Last Modified: 6-Oct-83 DVJensen - Backspace override before echo. ;; 17-Nov-83 DVJensen - "Seized" bit determines if "TTNOWAIT" cleared. ;; 14-Dec-83 DVJensen - Asynchronous break added & Subr IBREAK . ;; 7-May-84 DVJensen - Alvin V5.1 multiple modules for library. ;; 11-Oct-85 DJ - Allow CL-controlled device handlers to be entered. ;; 30-Oct-85 DJ - Included UNSTALL here. There is nolonger the need ;; for an output process responsible for draining a buffer ;; to know about the input process which fills the buffer. ;; For flow control to work, though, AlvUpdate must be called ;; regularly; it is not interrupt driven. To avoid this, ;; AlvUpdate needs to be invoked from a clock-driven routine. ;;**************************************************************************** ;; ALVUPDATE ;; Subroutine to interrogate the device table for work which ;; must be done. Currently the only work which is done is to ;; find RT controlled devices which are incomplete (active console ;; input or output) and invoke the associated pseudo device ;; handler which does the actual transfer of characters. This ;; code is re-entrant and must remain so; it can be invoked ;; at various places in the alvin nucleus (ie, ALVIDLE) and may ;; be invoked asynchronously from a mark-time routine. The ;; request flag in the device logical status is used to prevent ;; device interaction conflicts. ;; ;; Expects calls of the form: JSR PC,ALVUPDATE ;- ALVUPDATE:: MOV R4,-(SP) MOV R3,-(SP) ;STACK REGISTERS USED MOV R2,-(SP) MOV R1,-(SP) MOV #LDEVICE,R1 ;GET POINTER TO DEVICE TABLE DESCRIPTOR MOV (R1)+,R3 ;GET BEGINNING ADDRESS OF DEVICE TABLE ; and point to end adr of dev table. ALVULP: MOV (R3)+,R2 ;GET ADR OF A DEVICE DESC FROM DEV TABLE BEQ ALVUND ;IF ZERO, DEVICE DOES NOT EXIST BIT #RTCTL!CLctl,LCTL(R2) ;Is this a pseudo device handler? BEQ AlvUnstall ; No, branch. BIT #DISABLE!REQUEST,(R2) ; OK to process? BNE ALVUND ; No, branch. BIS #REQUEST,(R2) ; Yes, raise request to avoid interaction. Bit #Asynch!Seized,(R2);Is asynchronous entry allowed even though ; the device may be complete, or is this ; a normal entry for a seized (active) device? Beq Alvunr ;Neither, branch around entry to handler. Alvugo: Mov BDADR(R2),R4 ;Get the Buffer Descriptor to REG 4. JSR PC,@HNDLER(R2) ;INVOKE THE PSEUDO-DEVICE HANDLER Alvunr: BIC #REQUEST,(R2) ;CLEAR DEVICE LOCK-OUT AlvUnstal: Bit #Stalld,(R2) ; Is this device in a stalled state? Beq AlvUnd ; No, branch. Bit #Output,Lctl(R2) ; Yes, but is it an input device? Bne AlvUnd ; Branch, it is an output device. Mov BDadr(R2),R4 ; Get the buffer that needs to drain. Jsr Pc,Unstall ; Go reactivate input if drained sufficiently. ALVUND: CMP R3,(R1) ;HAVE ALL DEVICES BEEN PROCESSED? BLOS ALVULP ;NO, LOOP MOV (SP)+,R1 ;RESTORE REGISTERS USED MOV (SP)+,R2 MOV (SP)+,R3 Mov (SP)+,R4 ALVUPX: RTS PC ;RETURN ;+ ;;*********************************************************************** ;; .Sbttl UnStall Routine to reactivate a stalled device ;; ;; Looking at a input device's buffer, test whether the buffer has drained ;; to within BufMARGIN characters remaining and restart the input via the ;; Input's associated device. If so, the FLOWON character is sent via the ;; the output device associated with the input process. ;; ;; Expects calls of the form: Jsr Pc,UnStall ; Called from AlvUpdate. ;; with - R2 containing the buffer's Input process device desc. ;; - R4 containing the buffer descriptor in question. ;; .Globl BufCount UnStall:: Mov R1,-(Sp) ;Save the work registers Mov R0,-(Sp) JSR PC,BufCOUNT ; Count the characters in the buffer CMP R0,BufMARGIN(R2) ; Should input be started? BHI UnStEXIT ; No, still too full, branch MOV AsocDevice(R2),R0 ; Get the device to turn input back on BIT #Request!Disabled,(R0) ; Can Xon be initiated? BNE UnStEXIT ; No, branch to exit (get it next time) Bic #Stalld,(R2) ; Xon is headed out - don't do it again. Movb FlowOn(R0),NextOut(R0) ; Presume next char to send is Xon. BIS #Extra+Request,(R0) ; Flag to send NEXTOUT immediately. BIT #Seized!Disable,(R0) ; Is output unit currently active? BNE UnStout ; Yes, branch; everything is set. MOV #Seized!Ignore,(R0) ; Seize device & ignore next intrpt MOV DevAdr(R0),R1 ; Get device address MOVB FlowOn(R0),2(R1) ; Send the Flow start char Unstout: Bic #Request,(R1) ; Remove request of output device. UnstEXIT: Mov (Sp)+,R0 Mov (Sp)+,R1 RTS PC ; Return from subroutine. ;;************************************************************************ .End