.TITLE SWLUN RT-11 Switch Console Port Address .Psect SWLUN3,Gbl,Con ;;**************************************************************************** ;; Written by Jim Flatten, Ames Lab, Iowa State University, Ames, IA 50011 ; Modified 11-May-84 DVJensen V2.4 for four logical units. ; Some messages were changed to be more explicit. ; 27-Mar-86 DJ Version 3.0 - Converted to be entirely table driven. ; This allows easier modification for different configurations. ; Modifying the TABLE entries is all that is necessary now. ; ;;*************************************************************************** ;; Modify the following table entries to adjust to your DL(v)-11 ports. ;; There are two words per entry: CSR,Vector. ;; The first entry is LUN 0, the next LUN 1, and so on up to a maximum ;; of ten entries (LUN 9). ;; TABLE:: .WORD 177560,60 .Word 176500,300 .Word 176510,310 .WORD 176520,320 .Word 176530,330 .Word 176540,340 .Word 176550,350 .word 176560,360 .word 176570,370 TabEnd: ; Address marking the end of the table. ;;**************************************************************************** .MCALL .PRINT,.GTLIN,.MTPS .MCALL .RCTRLO,.GVAL,.EXIT .ENABL LC .NLIST BEX RMON =54 M.KSTAT =304 M.BITMAP=326 M.OPTION=372 M.STATWD=366 OP.MTS =20000 CR =15 LF =12 SWLUN:: .GVAL #AREA,#M.OPTION ;Get the value of the sysgen options word. BIT R0,#OP.MTS ;Check for multi-terminal support. BEQ 1$ ;Branch if no MT support. .PRINT #MESG10 ;Print error message. JMP EXIT ;Return. 1$: .GVAL #AREA,#M.STATWD ;Check for indirect file. Mov R0,Indirect ; Save the returned result. Bmi Terse ; If indirect, the high order bit is set. Mov #Table,R1 ; Get the starting address of the LUN table. Clr R2 ; Starting Logical unit NUMBER. .Print #Mesg1 ; SWLUN header message. Ploop: Mov (R1)+,CSR ; Get the CSR address of the LUN. Mov (R1)+,Vector ; Get the Vector address of the LUN. Mov R2,R0 ; Get the associated binary LUN. Add #'0,R0 ; Convert to Character. Movb R0,LUNChr ; Save in Message. Jsr R5,CnvOct ; Convert the CSR to octal char string. .Word CSR ; CSR value pointer. .Word CSRstr ; String storage pointer. Jsr R5,CnvOct ; Convert the Vector to octal char string. .Word Vector ; Vector value. .Word VecStr ; String Storage. Mov #VecStr+3,R3 ; Use only the last three digits. Mov #VecMsg,R4 ; Actual message. Movb (R3)+,(R4)+ Movb (R3)+,(R4)+ Movb (R3)+,(R4)+ .PRINT #MESG2 ; Identify the LUN's to the user. Cmp CSR,#160000 ; Check validity of CSR. Bhi ChkVec ; Branch if in the I/O page. .Print #BadCSR ; Alert user to bad entry in table. ChkVec: Cmp Vector,#500 ; Check validity of the Vector. Blo Next ; Branch if vector in low memory. .Print #BadVec ; Alert user to bad vector in table. Next: Inc R2 ; Skip to next LUN. Cmp R2,#10. ; This scheme only works up to 10 LUN's. Bhis Retry ; Branch if maximum reached. Cmp R1,#TabEnd ; Is this all the LUN's in the table? Blo PLoop ; Loop to print the next LUN if not done. Retry: .RCTRLO ;Be sure that the prompt will print. .GTLIN #LINBUF,#MESG6 ;Get the user to enter the LUN. Br Decode Terse: .GTlin #Linbuf,#Tprompt ; Terse prompt for indirect operation. Decode: MOV #LINBUF,R0 ;Decode the user's response. MOVB (R0)+,R1 ;Get the first digit typed by the user. CMPB R1,#'0 ;Check for a numeric. BLO 6$ CMPB R1,#'9 ; Maximum is up to LUN 9. BHIS 6$ TSTB (R0) ; Decimal Unit # - Now check for end-of-line. BNE 6$ ;Branch if not end-of-line. MOVB R1,LUNNMB SUB #'0,R1 ASL R1 ASL R1 ADD #TABLE,R1 ;Index is formed into the table. Cmp R1,TabEnd ; Is the selected LUN within the table? Bhis 6$ ; No, branch. MOV R1,R4 ;Save this pointer for later. MOV RMON,R1 MOV M.KSTAT(R1),R2 ;What is the current lun? MOV #TABLE,R0 1$: CMP R2,(R0) BNE 2$ MOV 2(R0),R1 ;R1 <== Old vector address. MOV R4,R0 ;R0 <== Pointer into the LUN table of new LUN. MOV (R0)+,R2 ;R2 <== new CSR address. MOV (R0)+,R3 ;R3 <== New vector address. MOV RMON,R4 ADD #M.KSTAT,R4 ;R4 <== Address of the storage area in the ; resident monitor which receives ; the addresses of the new CSR. BR 3$ 2$: ADD #4,R0 ;Point to next table entry. Cmp R0,TabEnd ;Is this to the end of the table? Blo 1$ .PRINT #MESG9 ;'Current console isn't in my table!!' BR EXIT ;Return. 3$: Clr R0 ; Generate a delay so characters get out 31$: Inc R0 ; before the console is changed. Bpl 31$ .MTPS #340 ;Interrupts off. ; The Rmon bit map is modified directly MOV R3,R0 ;\ so it works even under SJ. ASR R0 ; \ ASR R0 ; \ ASR R0 ; >Construct a pointer to the byte to be ASR R0 ; / modified. ADD @#RMON,R0 ; / ADD #M.BITMAP,R0 ;/ A new LUN vector is protected, but the old ; one is not unprotected here. BIT #10,R3 ;This bit will tell which nibble of the BNE 4$ ; byte should be set to ones. BISB #^B11110000,@R0 ;Set the high order nibble. BR 5$ 4$: BISB #^B00001111,@R0 ;Set the low order nibble. 5$: MOV (R1)+,(R3)+ ;Move the pointers in the vector addresses. MOV (R1)+,(R3)+ MOV (R1)+,(R3)+ MOV (R1)+,(R3)+ MOV R2,(R4)+ ;Move the CSR addresses into the monitor. MOV #377,@R2 ;Initialize the receiver. TST (R2)+ MOV R2,(R4)+ TST (R2)+ MOV R2,(R4)+ MOV #300,@R2 ;Initialize the transmitter. TST (R2)+ MOV R2,(R4)+ MOV #0,@R2 .MTPS #0 ;Interrupts back on. .PRINT #MESG7 ;'New console device. ' BR EXIT ;Return. 6$: .PRINT #MESG8 ;'Bad LUN #. ' Tst Indirect ; Is this from an indirect control file? Bmi Exit ; Yes, then presume we must exit. Jmp RETRY ;Try again. EXIT: CLR R0 ;R0=0 --> No error message to be printed. .EXIT ;Return to the RT monitor. ;;********************************************************* CSR: .Word 0 ; Temporary storage for CSR. Vector: .Word 0 ; Temporary storage for Vector. Indirect: .Word 0 ; Save STATWD to tell if indirect file. AREA: .BLKW 10 ;EMT scratch area. LINBUF: .BLKB 82. ;Input buffer. MESG1: .ASCII /SWLUN - Switch console logical unit, Version 3.0/<200> MESG2: .ASCII / LUN / LunChr: .Ascii /0 - CSR at / CSRStr: .Ascii /177560, Vector at / VecMsg: .Ascii /060; /<200> VecStr: .Ascii /000060/ BadCSR: .Ascii /- Bad CSR! /<200> BadVec: .Ascii /- Bad Vector! /<200> MESG6: .BYTE CR,LF .ASCII /Enter new console logical unit number? /<200> Tprompt:.Ascii /SWLUN? /<200> MESG7: .ASCII /New console device - LUN / LUNNMB: .ASCIZ /0./ MESG8: .ASCIZ /Bad logical unit number (must be a single decimal digit)/ MESG9: .ASCII /The current console is not in the LUN table./ .ASCIZ /You would not be able to get back to this terminal./ MESG10: .ASCII /Your operating system was generated with mult-terminal/ .ASCII /support. Use the command SHOW TERMINALS, then:/ .ASCII / SET TT CONSOLE=n/ .ASCIZ /where 'n' is the number of the terminal to be the console./ .Even ;;**************************************************************************** .SbTTL OCTAL Convert routine - 16 bits to 6 octal characters. ;;*********************************************************************: ;; SUBROUTINE TO CONVERT A WORD TO SIX OCTAL CHARACTERS. ;; THE CHARACTERS ARE MOVED FROM LEFT TO RIGHT INTO A STRING. ;; EXPECTS CALLS OF THE FORM: ;; JSR R5,CNVOCT ;; .WORD (ADDRESS OF THE DATA WORD) ;; .WORD (STRING ADDRESS OF MOST SIGNIFICANT OCTAL DIGIT) ;; CNVOCT:: MOV R4,-(SP) ;SAVE REGISTERS USED MOV R3,-(SP) MOV R2,-(SP) MOV R1,-(SP) MOV R0,-(SP) MOV @(R5)+,R2 ;GET THE DATA WORD TO REG 2 MOV (R5)+,R0 ;GET THE STRING ADDRESS FO REG 0 MOV #6,R4 ;PUT THE DIGIT COUNTER IN REG 4 MOV #-2,R1 ;MOST SIGNIFICANT DIGIT IS A SPECIAL CASE CNVO10: ADD #3,R1 ;SET BIT PER DIGIT COUNTER CLR R3 ;CLEAR DIGIT BUILD REGISTER CNVO20: ROL R2 ;ROTATE NEXT BIT INTO CARRY ROL R3 ;RATAOE CARRY INTO REG 3 DEC R1 ;IS THERE A CHARACTER'S WORTH YET? BNE CNVO20 ;NO, LOOP ADD #60,R3 ;CONVERT TO ASCII MOVB R3,(R0)+ ;PUT CHAR IN STRING DEC R4 ;COUNT DOWN # DIGITS BNE CNVO10 ;LOOP UNTIL DONE MOV (SP)+,R0 ;RESTORE REGISTERS USED MOV (SP)+,R1 MOV (SP)+,R2 MOV (SP)+,R3 MOV (SP)+,R4 RTS R5 ;RETURN ;;*********************************************************************: .END SWLUN