.TITLE GATSLP Network SLIP driver .NLIST BEX,CND .ENABL LC ; ; Pdp11/dcn network SLIP driver ; ; This module is an extension of the network processes. it transmits and ; receives packets using the dl11/dlv11 line unit and the SLIP raw internet ; packet protocol as used by various Unix systems. ; ; Option bits: ; 000007 SYN count (0-7, default 0) ; ; Note: frames cannot begin with SYN (synch idle) or S.FND (frame end) ; ; Conditional assembly switches ; .IIF NDF,CS.DEV CS.DEV == 0 ;0: du11/duv11, 1: dup11, 2: dpv11 ; Note: the dlv11 will operate with any of the switch selections ; ; External symbols ; .GLOBL .WAIT,.SKED,.STIM,NETINP,NETOUT ; ; Entry symbols ; .GLOBL SLIPAT ;input process control vector .GLOBL SLOPAT ;output process control vector ; ; System definitions ; .ASECT .MCALL .COM,.CHR,.PSA,.GAT,.PAT ;dcnlib definitions .MCALL .SETV,.CTIM ;dcnlib macros .COM ;define common data .CHR ;define ascii code .PSA ;define process storage areas .GAT ;define gateway/bridge storage areas ; ; Module definitions ; INTENB = 000100 ;interrupt enable (inpcsr/outcsr) ACT = 000020 ;active bit (inpcsr/outcsr) TSOM = 000400 ;transmit som (outcsr) TEOM = 001000 ;transmit eom (outcsr) .IF EQ,CS.DEV-0 ;conditional assembly for duv11 INICSR = 036000 ;initial inpcsr .ENDC .IF EQ,CS.DEV-1 ;conditional assembly for dup11 INICSR = 101000 ;initial inpcsr .ENDC .IF EQ,CS.DEV-2 ;conditional assembly for dpv11 INICSR = 043400 ;initial inpcsr .ENDC ; ; Control codes ; S.FND = 300 ;frame end S.FSC = 333 ;frame escape S.TFE = 334 ;transposed frame end S.TSC = 335 ;transposed frame escape ; ; Process save area extension (asr) ; . = GATENR ASRSTA: .BLKW 1 ;input state ASRADR: .BLKW 1 ;buffer pointer ASRERR: .BLKW 1 ;error bits ASRCNT: .BLKW 1 ;byte count ASRBUF: .BLKW 1 ;preamble buffer .BLKW REGEND/2+NTISTK ;process stack ASREND = . ;end of asr extension ; ; Process save area extension (asx) ; . = GATENX ASXSTA: .BLKW 1 ;output state ASXADR: .BLKW 1 ;buffer pointer ASXERR: .BLKW 1 ;error bits ASXSYN: .BLKW 1 ;syn count .BLKW REGEND/2+NTOSTK ;process stack ASXEND = . ;end of asx extension ; ; Device register block (dev) ; . = 0 INPCSR: .BLKW 1 ;input status register INPBUF: .BLKW 1 ;input buffer/parameter register OUTCSR: .BLKW 1 ;output status register OUTBUF: .BLKW 1 ;output buffer register .PAGE ; ; Procedure segment ; ; Supervisor-state procedure ; Dsects: r2 = dev, r3 = par, r4 = reg, r5 = psa ; ; Note: calling process sets r0 = byte count, r1 = starting address. ; At completion of transfer r0 = byte count. ; .PSECT $KERI,RO,I ; ; Initialize ; SLOINI: ADD #4,R0 ;allocate output vector BR SLI10 ; SLIINI: MOV #INTENB+6,INPCSR(R2) ;raise trm rdy and req snd MOV #INICSR+SYN,INPBUF(R2) ;initialize mode, length, syn code CLR OUTCSR(R2) ;reset output control bits SLI10: MOV #INT+EXTBAS,R1 ;allocate input vector .SETV SLORST: RTS PC ; ; Start block transfer input ; SLISIO: MOV R0,ASRCNT(R5) ;save pointers BIS #ACT,INPCSR(R2) ;enable receiver JMP .WAIT ; ; Device interrupt input ; SLIINT: MOV INPBUF(R2),R0 ;get byte/control bits BPL 1$ ;branch if no error INC ASRERR(R5) ;count input errors 1$: ADD ASRSTA(R5),PC ;belay BR SLIS0 ;0 octet 1 BR SLIS1 ;1 octet 2 BR SLIS2 ;2 octet 3 BR SLIS3 ;3 remaining octets BR SLIS4 ;4 receive control after frame escape ; SLIS0: CMPB R0,#S.FND ;state 0. is this frame end BEQ SLIRTN ;branch if yes CMPB R0,#SYN ;no. is this syn BEQ SLIRTN ;branch if yes TST ASRERR(R5) ;no. check for errors BEQ 1$ ;branch if none CLR ASRERR(R5) INC PARPAM(R3) ;tally preamble error 1$: MOVB R0,ASRBUF(R5) ;save octet 1 (ver,len) BR SLIINC ;exit to state 1 ; SLIS1: MOVB R0,ASRBUF+1(R5) ;state 1. save octet 2 (tos) BR SLIINC ;exit to state 2 ; SLIS2: TSTB PSASTS(R5) ;state 2. is process running BPL 1$ ;branch if no BIS #100000,ASRERR(R5) ;yes. indicate no buffer RTS PC ; 1$: CLR @R4 ;reset pointers MOV REGR1(R4),ASRADR(R5) MOV ASRBUF(R5),@ASRADR(R5) ;stash octets 1,2 ADD #2,ASRADR(R5) ;update pointers ADD #2,@R4 ADD #1*2,ASRSTA(R5) ;continue in state 3 SLIS3: CMPB R0,#S.FND ;state 3. is this frame end BNE 3$ ;branch if no MOV ASRERR(R5),R0 ;yes. check for errors BEQ 2$ ;branch if none CLR ASRERR(R5) BIS #1,REGPS(R4) ;indicate input error ASL R0 BCC 1$ INC PARBZY(R3) ;tally no buffer 1$: TST R0 BEQ 2$ INC PARIOV(R3) ;tally receive error 2$: CLR ASRSTA(R5) ;exit to state 0 BIC #ACT,INPCSR(R2) ;flap search-sync bit BIS #ACT,INPCSR(R2) JMP .SKED ; 3$: CMPB R0,#S.FSC ;is this frame escape BNE SLITXT ;branch if no SLIINC: ADD #1*2,ASRSTA(R5) ;yes. wait for following octet SLIRTN: RTS PC ; SLIS4: SUB #1*2,ASRSTA(R5) ;return to previous state CMPB R0,#S.TFE ;is this transposed frame end BNE 1$ ;branch if no MOVB #S.FND,R0 ;yes. insert frame end BR SLITXT ; 1$: CMPB R0,#S.TSC ;is this transposed frame escape BNE 2$ ;branch if no MOVB #S.FSC,R0 ;yes. insert frame escape BR SLITXT ; 2$: INC PARVIO(R3) ;indicate protocol error SLITXT: CMP @R4,ASRCNT(R5) ;is buffer full BHIS 1$ ;branch if yes MOVB R0,@ASRADR(R5) ;no. store byte in buffer INC ASRADR(R5) ;update pointers INC @R4 1$: RTS PC ; ; Start block transfer output ; SLOSIO: MOV R1,ASXADR(R5) ;Save buffer pointer MOV PAROPT(R3),R0 ;extract syn count BIC #^C7,R0 BEQ 1$ ;branch if none ADD #3,R0 ;(min 4) MOV R0,ASXSYN(R5) MOV #1*2,ASXSTA(R5) ;start in state 1 MOV #TSOM+SYN,OUTBUF(R2) ;send first syn 1$: JSR PC,.WAIT ;enter wait state BIS #ACT+INTENB,OUTCSR(R2) ;start transmitter CLR ASXERR(R5) MOV PARTRY(R3),R0 ;start output timeout ASL R0 ;(2x base) SUB R0,RESTIM(R5) JMP .STIM ; ; Device interrupt output ; SLOINT: BIS OUTBUF(R2),ASXERR(R5) ;save error bits ADD ASXSTA(R5),PC ;bannister BR SLOS0 ;0 send text BR SLOS1 ;1 send syn BR SLOS2 ;2 send transposed frame end BR SLOS3 ;3 send transposed frame escape ; SLOS1: DEC ASXSYN(R5) ;state 1. is syn sequence complete BEQ 1$ ;branch if yes MOV #SYN,OUTBUF(R2) ;no. send syn RTS PC ; 1$: CLR ASXSTA(R5) ;exit to state 0 SLOS0: TST @R4 ;is packet empty BNE SLOTXT ;branch if no MOV #S.FND,OUTBUF(R2) ;yes. send frame end .CTIM ;no. clear output timeout ADD R0,RESTIM(R5) TST ASXERR(R5) ;did errors occur BPL SLOEND ;branch if no INC PAROOV(R3) ;yes. indicate transmit error SLOASY: BIS #1,REGPS(R4) ;indicate output error SLOEND: BIC #ACT+INTENB,OUTCSR(R2) ;stop transmitter CLR ASXSTA(R5) ;reset to state 0 JMP .SKED ; SLOTXT: MOVB @ASXADR(R5),R0 ;fetch byte INC ASXADR(R5) ;update pointers DEC @R4 CMPB R0,#S.FND ;is this frame end BNE 1$ ;branch if no MOV #2*2,ASXSTA(R5) ;yes. exit to state 2 BR 2$ ; 1$: CMPB R0,#S.FSC ;is this frame escape BNE 3$ ;branch if no MOV #3*2,ASXSTA(R5) ;yes. exit to state 3 2$: MOVB #S.FSC,R0 ;set frame escape 3$: MOV R0,OUTBUF(R2) ;send octet RTS PC ; SLOS2: MOV #S.TFE,OUTBUF(R2) ;state 2. send transposed frame end CLR ASXSTA(R5) ;exit to state 0 RTS PC ; SLOS3: MOV #S.TSC,OUTBUF(R2) ;state 3. send transposed frame escape CLR ASXSTA(R5) ;exit to state 0 RTS PC ; ; Data segment ; .PSECT $KERD,RO,D ; ; Process headers ; SLIPAT: .PAT ASREND,NETINP,PRI4,<0,0,SLIINI,SLISIO,SLIINT> SLOPAT: .PAT ASXEND,NETOUT,PRI3,<0,SLOASY,SLOINI,SLOSIO,SLOINT,SLORST> ; .END