.TITLE DLTMGR Digital Loopback Command Manager .PSECT DLTmgr,Con .Ident /LVL5 T/ ; .MCALL $ALVIN,$RMT01,$Twait,$List,$SkipList .Mcall .Print, .Exit ;+ ;;********************************************************************** ;; COMMAND MANAGER by DVJensen, Ames Lab Computer Services 50011 USA ;; DATE VERSION DESCRIPTION ;; 21-Dec-83 5.0 - Converted to Alvin level 5. ;; 27-Dec-83 - Message cleanup. ;; 20-Jan-84 - LIST command added. ;; 30-Nov-84 5.1 - Generic Command Manager for Gerstein. ;; 10-Jan-85 - Added ALVIDLE Timed WAIT if not DISPLAYing ;; This is for TSX so Alvin doesn't hog the CPU. ;; 12-Feb-85 - Removed the command table to CMDTxx.Mac . ;; - Generic system Connect. ;; 3-Dec-85 5.1c - Only the console is enabled when the manager comes ;; up. Connect will now enable/disable ports as ;; required. ;; - AlvIdle will now do a wait under all circumstances. ;; - The entire HELP text is no longer output at startup. ;; 4-Dec-85 - The NMRDefaults subroutine is invoked in at startup ;; to select the Substation. ;; 7-Apr-86 - Generic command manager derived for Digital Loopback ;- ;;********************* ;; INTERNAL GLOBALS: .Globl CMDMGR .Globl BEGIN, REMOTE, BUFWORK, CMDSTRING, CMDWORK .Globl ALVIDLE ;; ;; EXTERNAL GLOBALS: .Globl LocTable, CMDTable, Intro, RevMsg .Globl CRLF, CRLF2, CmdNxt, CmdNx0, CmdNor, CmdUn0 .Globl CanLine, BrkOut, Ringer, BufLimit, KeyCharacteristics .Globl AlvMsg, AlvUpdate, GetDDA, DecPrt, IBreak .Globl AlvEnable, AlvDisable .Globl Send, Receive, CmdCopy, CmdMatch, Press .Globl Bufcopy, BufEOL, BufReset, GetByte .Globl Buf3, Buf3End, Buf4, Buf4End, Bufd1, Bufd2 ;; ; .Globl ConStatus $ALVIN $RMT01 ;; KEYB==0 ; Logical unit # of the console KEYBOARD. LIST==1 ; Logical unit # of the console LISTing device. ;;********************************************************************** ;; STACK=1000 ;Normal address of stack (loc 776 is 1st entry on stack) ;;********************************************************************** ;; E X E C U T I O N B E G I N S H E R E ;;********************************************************************** ;; Begin: Alvin: CmdMgr:: ; INITIALIZE Clr R3 ; Set to enable the command input. Jsr Pc,AlvEnable ; Enable terminal input, Unit = 0. Bcc EnaList ; Branch if no error. EnaCancel: .Print EnaFail ; "Enable failed on terminal." .Exit EnaFail: .Asciz \The command terminal failed to enable - Task aborted.\ EnaList: Inc R3 ; Now enable unit 1, the terminal list device. Jsr Pc,AlvEna ; Get the list device up. Bcs EnaCancel ; If the enable failed, must exit. Jsr R5,GetDDA ; Get the Device Descriptor Address of .Word KeyB ; of the CONSOLE keyboard. Mov R0,Console ; Save it. $List ,RevMsg ; Identify the command manager. ; Jsr Pc,ConStatus ; Update which systems are available. ;;********************************************************************** CMDINIT: JSR PC,CMDNXT ;Prompt for a command. ;;******** ;; Check For a LOCAL command at the start of a new line. ;; If no LOCAL command, proceed with processing connected system, ;; either interpret commands and dispatch, or talk with the REMOTE. ;; Which system is the REMOTE is controlled by CONNECT. ;; CmdMaybe: Mov #IGNORE,@Console ; DE-SEIZE the keyboard. Mov #KeyB!Reset,R3 ; The unit number to get commands from. Bit #Disconnect,RmtCon ; Is a remote system connected? Bne CmdRcv ; No, branch. Bit #Echo,RmtCon ; Does the remote want Alvin to ECHO? Bne CmdRcv ; Yes, branch, this is the default. Bis #Silent,R3 ; No, request Receive to force NOECHO. CmdRcv: Jsr R5,Receive ; Receive input from keyboard. .Word -1 ; (unit and function in Register 3) .Word BUFD1 ; Buffer descriptor. Nop ; (Here if keyboard seized.) ;;******** CMD200: Clr ALTCTL ; Initialize LOCAL command control. ;;******** CMDLP1: MOV @Console,R2 ; Read keyboard logical status (save for end). MOV #BUFD1,R4 ; Set buf desc adr of COMMAND BUFFER. ALTUPD: TST ALTCTL ; Has the 1st char been checked for ALTMODE? BNE Cmd300 ; Yes, branch BIT #RESPONSE,R2 ; Has the 1st char of command come in? BEQ Cmd300 ; No, loop CMPB #ALTMODE,@BOUT(R4) ;Is 1ST CHAR = ALTMODE ? BEQ ALTCMD ;Yes, process LOCAL COMMAND. CMPB #RUBOUT,@BOUT(R4) ;Is it alternate altmode char? BEQ ALTCMD ;Yes, process local command. Dec ALTCTL ; Set NOT LOCAL COMMAND indicator (negative). BR Cmd300 ; proceed normally. ;; ALTCMD: INC ALTCTL ; Set POSITIVE for LOCAL command. BIC #NOECHO,@Console ; Force keyboard ECHO ON. Jsr R5,GetByte ; Remove altmode char from the buffer. .Word Bufd1 Nop ;; $SkipList ; Prompt for the command. CMD300: CHKKEY: BIT #DISCONNECT,RmtCon ; Is a remote system connected? BNE CMD900 ; No, branch - normal command loop. Mov RmtRunit,R3 ; Put the unit number into Reg 3 for passing. Bis #UseDB,R3 ; Use the default buffer for this unit. Jsr R5,Receive ; Receive input from the connected remote. .WORD -1,0 NOP ; (** May not want to ignore this error.) Mov R0,R3 ; Save the remote receiver descriptor address. Mov BdAdr(R3),R4 ; Get the Buffer descriptor being used. JSR R5,SEND ; List anything received from the remote .WORD LIST,0 ; using the buffer in register 4. NOP ; (Ignore if list active or nothing to list.) BIT #BUFULL,(R3); Had the remote receiver's buffer filled up? BEQ Rmt100 ; No, branch. JSR PC,BUFLIM ; Inform the user that the buffer was exceeded. Rmt100: TST ALTCTL ; Check if command being entered is local. BGT CMD900 ; If so, echo and accumulate the command. Mov RmtXunit,R3 ; Else, send the console input to this unit. JSR R5,SEND .WORD -1,BUFD1 ; Function in R3 and buffer explicit. NOP ;(** May want to catch this error and recover) BIT #COMPLETE,R2 ; Did the console input reach a completed state? BEQ CMD800 ; No, continue with normal remote loop. Bit #Complete!Disabled,(R0) ; Wait for all output to be sent. Beq Rmt100 ; Re-request output to the remote just in case ; Check here to detect/transmit a BREAK to the REMOTE. Jmp CmdMaybe ; Re-enable the keyboard. CMD800: JSR PC,ALVIDLE ; Do some busy work for a while. JMP CMDLP1 ; Continue with normal COMMAND LOOP. CMD900: Jsr R5,Press ; Process backspaces/deletes in the command. .Word BufD1 ; Console input buffer. BIT #COMPLETE,R2 ; Is command all entered? BEQ CMD800 ; No, loop until complete. ;;******************************************************** ;; KEYBOARD message COMPLETE - Process COMMAND: ;; BIT #CANCEL!BRKREQ,R2 ; Was the COMMAND CANCELED? BNE KILCMD ; Yes, branch to cancel. BIT #BUFULL,R2 ; Check command buffer for overrun? BEQ CMDCHK ; No, branch. JSR PC,BUFLIM ; List BUFFER LIMIT EXCEEDED message. ;; CMDCHK: JSR R5,BUFCOPY ; Copy input command to work buffer. .WORD BUFD1 ; (I believe this is nolonger needed.) .WORD BUFWORK MOV #CMDSTR,R3 ; Put adr of command string desc in REG 3. JSR R5,CMDCOPY ; Copy input to command string - PREPROCESS. .WORD BUFWORK .WORD CMDSTR TST ALTCTL ; Is this a LOCAL COMMAND? BLE CHKRegular ; No, branch. ;;***************************************** ;; LOCAL MODE COMMAND RECOGNITION ;; ALTGO3: JSR R5,CMDMATCH ; Try to MATCH a LOCAL COMMAND. .WORD LOCTABLE ; Includes regular command entries. .WORD 0 ; CmdString desc in reg 3. BR NotRecognized ; "Command not recognized. " LOCGO: JSR PC,CRLF ;GO TO A NEW LINE LOCGO2: TST R0 ;IS ENTRY POINT DEFINED? BNE DISPATCH ;YES, BRANCH CMDUNN: Jsr Pc,CmdUn0 ;List "Command Unavailable. " BR ALTRTN ;;******** DISPATCH: JSR PC,(R0) ;INVOKE COMMAND BR ALTRTN ;;******************************************* ;; Regular COMMAND RECOGNITION ;; CHKregular: JSR R5,CMDMATCH ; See if this is an regular command. .WORD CMDTABLE .WORD CMDSTRING BR NotRecognized ; Not a command. BR LOCGO ; Process COMMAND dispatch. ;;**************************** ;; NotRecognized: Jsr Pc,CMDNor ; Alert user " Command not recognized. " CMDPROMPT: Jmp CmdInit ; Prompt for NEXT COMMAND. ;; KILCMD: Jsr PC,CANLINE ; List '***' if canceled. ALTRTN: Jmp CmdInit ; Go to a new line and prompt. ;;********************************************************************** ;; TRANSFER SECOND LEVEL RECOGNITION ;; ;TRAN2:: TST (SP)+ ; Got here by JSR PC; pop return adr. ; JSR R5,CMDMATCH ; Try to match TRANSFER 2ND LEVEL. ; .WORD TRANTABLE ; .WORD 0 ; Command string selected in reg 3. ; BR NotRecognized ; Failed to match. ; BR LOCGO2 ; MATCH - proceed to DISPATCH. ;;;********************************************************************** ;; STACKP:: .Word STACK ; Base address of the stack. ;; Console: .Word 0 ; Device Descriptor Address of the CONSOLE keyboard. ;; RmtRunit::.Word 0 ; Unit number of receiver of connected remote. RmtXunit::.Word 0 ; Unit number of transmitter of connected remote. RmtCon:: .Word DisCon ; Status word of the connect remote. ;; REMOTE: .WORD Carrier!Disconnect ; Control word for remote system line. ALTCTL: .WORD 0 ; Control word for LOCAL commands. ;;********************************************************************** CMDSTRING: .WORD BUF4END ;COMMAND STRING DESCRIPTOR .WORD BUF4 .WORD BUF4END .WORD BUF4 ;; BUFWORK: .WORD BUF3 ;WORK BUFFER FOR COMMAND PREPROCESSING .WORD BUF3 .WORD BUF3 .WORD BUF3END ;; CMDWORK: .WORD BUF3END ;ALTERNATE COMMAND STRING - SHARES BUF3 .WORD BUF3 .WORD BUF3END .WORD BUF3 ;+ ;;********************************************************************** ;; AlvIdle ;; Subroutine to do busy work asynchronously when there is basically ;; nothing to do. Currently, the DISPLAY to the oscilliscope is ;; invoked here, and the transfer of characters to/from RT/TSX-Plus is ;; invoked via ALVUPDATE. ;; Expects calls of the form: Jsr PC,AlvIdle ;- ALVIDLE:: AlvWait: $Twait 2 ; Wait for two clock ticks. AlvIup: Jsr Pc,AlvUpdate ; After the wait, update char transfer, Rts Pc ; flow control, etc. Then return . ;;********************************************************************** ;; HELP COMMAND - LISTS MESSAGES AND STATUS ;; HELP:: $SkipList <-- Systems and Options --> Jsr Pc,IBreak ; Check if a break has been requested Tst R0 ; If R0 = zero, then no break. Bne Help00 Jsr Pc,HELPgo ; Print standard startup messages. Rts Pc ; Return from HELP COMMAND. ;; HELP00: JSR PC,BRKOUT ; " BREAK REQUESTED. " RTS PC ; and return. ;; ;; Subroutine: Jsr PC,HelpGo HELPGO: $list ,AlvMsg $SkipList ,RevMsg ; Revision message. $SkipList ,Intro ; Commands message. Jsr Pc,Ibreak Tst R0 BNE HELP00 Jsr Pc,KeyCharacteristers ; ""(large message now in an overlay). Jsr Pc,Ibreak ; Check Break Tst R0 BNE HELP00 ; JSR PC,CONSTATUS ; Connect status message. Jsr Pc,Ibreak Tst R0 BNE HELP00 RTS PC ; Return. ;;********************************************************************** .END BEGIN