.Title CDC .Ident /V 2.00/ .Enabl LC ;+ ; ; CDC -- Format the CDC 9766 through the EMULEX SC11/B3 controller ; ;- .Page .Sbttl Macros and constants ; ; Print macro definition ; .Macro Print Add,Length .If Nb,Length Mov Add,TTyOut+Q.IoPl Mov Length,TTyOut+Q.Iopl+2 .IFF Mov R0,-(Sp) Mov add,R0 Movb (R0)+,Ttyout+Q.Iopl+2 Mov R0,TtyOut+Q.iopl Mov (Sp)+,R0 .Endc Dir$ #TTYout .Endm ; ; String macro definition ; .MACRO String STR,SEQUEN .IF B,SEQUEN $$T$$$=0 $$l$$$=. .BYTE 0 .IFF .if eq,<''SEQUEN-'B> $$T$$$=0 $$l$$$=. .BYTE 0 .endc .ENDC .IF NB, .ASCII STR .ENDC .IF B,SEQUEN $$E$$$=. .=$$L$$$ $$T$$$=$$E$$$-$$L$$$-1 .BYTE $$T$$$ .=$$E$$$ .IFF .IF EQ,<''SEQUEN-'E> $$E$$$=. .=$$L$$$ $$T$$$=$$E$$$-$$L$$$-1 .BYTE $$T$$$ .=$$E$$$ .ENDC .endc .ENDM .Mcall Dir$,Qiow$,Gmcr$,ExSt$S .MCall Gcml$,GcmlB$,GcmlD$,Finit$,Fsrsz$ .MCall Mrkt$s,Wtse$S .MCall GLun$S .MCall WtLO$s,ClEF$s,Qio$S,Dir$ .MCall Qiow$S,ALun$s ; ; Set up Ascii codes ; Bell=7 Lf=12 Cr=15 Tab = 11 ; ; Lun Table ; GmlLun = 4 ;Lun for get command line TTyLun = 5 ;Lun for TI: ; ; Event Flag Table ; TTyEfn = 5 ;event flag for TI: I/O .Page .Sbttl Buffers and working storage ; ; Get command line macros and buffers ; Fsrsz$ 1 ;ask for buffer GcmlD$ ;define GcmlB$ offsets CmdBuf: GcmlB$ 1,Cdc,LinBuf,4 ;Lun 4 = command line input LinBuf: .BlkW 41. ; ; Get TI: Lun information buffer ; LunBuf: .BlkW 8. ;storage for local LUN info Iosts: .Blkw 2 ;Qio Io Status block TILun: .Word 5 TIUcb: .Word 0 ;returned pointer to TI:'s UCB DrLun: .Word 1 DrCsr: .Word 0 ;storage for DR:'s CsR address DrUcb: .Word 0 ;storage for dr:'s UCB DrKrb: .Word 0 ;storage for DR:'s Krb (Mplus only) DrScb: .Word 0 ;storage for DR:'s Scb (M only) DrUnit: .Word 0 ;storage for DR:'s RSX unit number PhyUnt: .Word 0 ;storage for controller physical unit no. ChkMsk: .word 0 ;check mask for valid pre-conditions ; ; Mask Bit Definitions ; All.Er = 1 ;device not allocated F11.Er = 2 ;device mounted as Files-11 Rm5.Er = 4 ;device not an RM05 ; ; Tpars stuff ; ; ParBug=0 ;remove leading ";" to assemble tpars debugger ; ; Tpars parser return mask bit definitions ; Er.Msk == 100000 ;syntax error ; ; command mask bits ; Hp.Msk == 1 ;just print help message Id.Msk == 2 ;print Cdc's current version Fm.Msk == 4 ;Format pack ; ; Tpars -- returned value storage ; Mask:: .Word 0 ;TPars line component mask word ; ; Print Qio Directive Parameter Block ; TTYout:: Qiow$ Io.Wvb,TTyLun,TTyEfn,,TTysts,, TTYsts:: .BlkW 2 .Page .Sbttl Message strings SynErr:: String <"Cdc -- Syntax Error"> PrvErr:: String <"Cdc -- Sorry, but you must be a Privileged RSX user for this command"> RmErr: String <"Cdc -- Error, This device is not an RM05"> NoErr: String <"Cdc -- Error, no RM05 found in system"> FmtStr: String <"Cdc -- Format operation beginning at ">,B StrTim: .BlkB 17. String <>,E FmtStp: String <"Cdc -- CDC 9766 (RM05) Formating done at ">,B StpTim: .BlkB 17. String <>,E FmtErr: String <"Cdc -- Error in formatting pack"> MouErr: String <"Cdc -- The Rm05 is mounted as an RSX disk"> AllErr: String <"Cdc -- The Rm05 is not allocated to this terminal"> AttErr: String <"Cdc -- Error in attaching RM05 drive"> FmtWrk: String <""> .Even ; ; ID function storage ; IdMsg:: String <"Cdc -- My current version is ">,B ID:: .BlkB 6 ;storage for Ident field String <>,E ; ; Help funtion messages Help1: String <"Available commands to Cdc are:"> Help2: String <"Help - print this message"> help3: String <"ID - Prints Cdc's current version"> help4: String <"Fmt DDuu:"> Help5: String <"Cdc allows command abbreviation to 3 letters"> .Even .Page .Sbttl Main code Cdc: Finit$ Mov #Id,R0 ;save Ident field Mov R3,R1 ;get 1st 3 Rad50 characters Call $C5ta ;convert to ascii Mov R4,R1 ;get 2cd 3 Rad50 characters Call $C5ta ;convert to ascii GLun$S #5,#LunBuf ;get TI: info from Exec Restrt: Mov #CmdBuf,R0 ;point to command buffer Gcml$ #CmdBuf Bcc 20$ ;if no error, jump around CmpB CmdBuf+G.Err,#Ge.Eof ;end of file? Bne Restrt ;if not, error, try again Jmp Exit ;take normal exit 20$: Mov CmdBuf+G.cmld,R3 ;load length of command line Beq Restrt ;if empty, loop back and try again Mov #3*256.,R1 ;skip blanks in command lines ;keywords must match up to 3 chars Mov #LogKtb,R2 ;point to keyword table Mov CmdBuf+G.cmld+2,R4 ;load address of command line Mov #LogSrt,R5 ;point to initial state Clr Mask ;initialize tpars mask .If Df,ParBug ;if Tpars debugger is to be assembled Mov #TDebug,.TpDeb ;point to Tpars debugging trace routine Call .TparD ;parse command line, with Debug .IFF ;if tpars debugger NOT assembled Call .Tpars ;parse command line .EndC ;end of Tpars debugger conditional Bit #Er.Msk,Mask ;any syntax error Beq 30$ ;if not, jump around ; ; Tpars syntax error, print line and error message, try again if we can ; Mov #TTYout,R0 ;point to print-out DPB Mov #40,Q.iopl+4(R0) ;use carriage control MovB SynErr,Q.iopl+2(R0) ;get length of string Mov #Synerr+1,Q.iopl(R0) ;starting address Dir$ R0 ;print it Call PriErr ;print syntax error Br Restrt ;get next command line ; ; Command line parsed successfully ; 30$: Bit #Hp.Msk,Mask ;was help pleaded for ? Beq 35$ ;if not, jump around Call Help ;print help message Br Restrt ;re-dispatch 35$: Bit #Id.Msk,Mask ;Ident asked for? Beq 40$ ;if not, jump around Print #IdMsg ;print I.D. Br Restrt ;get next command 40$: Bit #Fm.Msk,Mask ;Format asked for? Beq 50$ ;if not, search on Call CdcFmt ;format Br Restrt ;redispatch ; ; Add new commands here ; 50$: Br Restrt ;re-dispatch .Page .SbTTl HELP command - Print a help message Help: Print #Help1 ;print help messages Print #help2 Print #Help3 Print #Help4 Print #Help5 Return .Page .Sbttl Privilege Check subroutine ; ; Check to see if user's TI: has the bit U2.Prv set in his ; second characteristics word, obtained via a GLun$s exec directive. ; PriChk: Bit #U2.Prv,LunBuf+6 ;check 4th word of GLun$s buffer Bne 10$ ;if set, user privileged, OK Print #PrvErr ;print error message Jmp Restrt 10$: Return .Page .Sbttl Format Request CdcFmt: Call PriChk ;check for operator privilege Alun$s DrLun,#"DR,DrUnit Bcc 5$ ;if no error, jump Print #NoErr ;no RM05 in system Jmp ExErr ; ; Obtain UCB pointers for Lun 1 (the disk) and Lun 5 (TI:) ; 5$: Clr ChkMsk ;clear the check mask Call $Swstk,30$ ;switch to system state Mov $TkTcb,R5 ;point to our TCB Mov $HeadR,R4 ;point to our task header Mov #TiLun,R3 ;point to TI: Lun number Call $MpLun ;get pointer to TI:'s UCB Mov R0,TiUcb ;save pointer to TI:'s UCB Mov #DrLun,R3 ;point to lun Mov R0,DrUcb ;save dr:'s UCB pointer Call $MpLun ;get pointer to DR's UCB in R0 ; ; obtain the physical unit number for this controller ; Mov U.Unit(R0),PhyUnt ;store physical unit number ; ; Check for Rm05 allocated to this terminal ; Cmp U.Own(R0),TiUCB ;is device allocated to this TI:? Beq 10$ ;if so, jump around Bis #All.Er,ChkMsk ;indicate alocation error ; ; Check for drive mounted as a Files-11 device ; 10$: BitB #Us.Mnt,U.Sts(R0) ;is drive mounted as files-11? Bne 20$ ;if not, jump around Bis #F11.Er,ChkMsk ;indicate mount error ; ; Check to make sure device is an Rm05 ; 20$: Mov U.Scb(R0),R1 ;get DR:'s status control block pointer .IF Df,R$$Mpl ;If mPlus Mov S.Krb(R1),R1 ;get unit's KRB address Mov K.Csr(R1),DrCsr ;get RM05's CSR Mov R1,DrKrb ;save Krb address .IFF Mov S.Csr(R1),DrCsr ;get unit's CSR register Mov R1,DrScb ;save SCB address .Endc ;end of M-Plus conditional Mov DrCsr,R1 ;ditto CmpB 26(R1),#27 ;is this an RM05? Beq 25$ ;if so, jump around Bis #Rm5.Er,ChkMsk ;if not, indicate error 25$: Return ; ; Back in task state, any errors? ; 30$: Tst ChkMsk ;any errors? Beq 70$ ;if not, try to attach to drive ; ; Check to see if Device mounted ; Bit #F11.Er,ChkMsk ;mounted error? Beq 40$ ;if not, jump around Print #MouErr ;print message Jmp ExErr ;exit ; ; Check to see if device allocated to this user ; 40$: Bit #All.Er,ChkMsk ;allocation error? Beq 50$ ;if not, search on Print #AllErr ;print message Jmp ExErr ;exit ; ; Check for RM05 ; 50$: Bit #Rm5.Er,ChkMsk ;RM05 error? Beq 60$ Print #RmErr ;print error message Jmp ExErr ;exit on error ; ; Place additional checks here as required ; 60$: ; ; Exec checks have passed, try to attach to DR ; 70$: Qio$S #Io.Att,#1,#1,,#IOSTS ;attach disk Bcs 80$ ;if error, exit MrkT$s #2,#2,#2 ;wait for 2 seconds WtLO$s 0,#1!2 ;wait for either flag ClEF$s #1 ;see if trigger was Io.Att Cmp #Is.set,$Dsw ;was flag set? Bne 80$ ;if not, time-out error Cmp #Is.Suc,IOsts ;successful attach? Beq 90$ ;if so, jump 80$: Print #AttErr ;attach error Jmp ExErr 90$: Mov #StrTim,R0 ;point to time buffer Call TimDat ;time stamp Print #FmtStr ;print start message .IF Df, R$$Mpl ;if MPlus Mov DrKrb,R1 ;get KRB address 95$: Tst K.Own(R1) ;controller free Bne 95$ ;if not, loop till free Mov DrUcb,K.Own(R1) ;indicate drive busy .IFF Mov DrScb,R1 ;get SCB address 95$: TstB S.sts(R1) ;controller busy? Bne 95$ ;if so, loop till idle IncB S.Sts(R1) ;indicate busy .EndC Mov DrCsr,R1 ;load pointer to RM05 CSR Mov PhyUnt,10(R1) ;store unit number in controller Mov #11,(R1) ;drive clear, drive 0 Mov #23,(R1) ;pack acknowledge Mov #77,(R1) ;issue format command Br 110$ ;jump around first message ; ; Main Format wait loop ; 100$: Dec R0 ;30 seconds up yet? Bne 120$ Print #FmtWrk ;issue working message 110$: Mov #30.,R0 ;set up message interval 120$: MrkT$S #1,#1,#2 ;issue 1 second mark time Wtse$S #1 ;wait for timer TstB @DrCsr ;is format done? Bpl 100$ ;go back and wait ; ; Check for error ; Tst @DrCsr ;any error? Bmi 140$ ;if yes, jump Mov #StpTim,R0 ;point to time buffer Call TimDat ;time stamp Print #FmtStp ;formating complete Br 150$ ;finish below ; ; Error in formatting Pack ; 140$: Print #FmtErr ;error in formatting pack 150$: .IF Df, R$$Mpl ;if MPlus Mov DrKrb,R1 ;get KRB address Clr K.Own(R1) ;indicate drive avaliable again .IFF Mov DrScb,R1 ;get SCB address ClrB S.Sts(R1) ;indicate idle .EndC Return .Page .Sbttl add date/time to message ; ; Inputs: ; R0 - point to place for time/date ; .MCALL GTIM$S DATE:: .BLKW 8. ;NEEDED FOR GTIM$S MACRO TimDat: CALL $SAVAL ;SAVE REGISTERS CLRB 17.(R0) ;CLEAN OUT LAST BYTE IN BUFFER GTIM$S #DATE ;ASK RSX FOR DATE AND TIME MOV #DATE,R1 ;POINT TO BINARY INPUT BUFFER CALL $DAT ;CONVERT BINARY TO ASCII MOVB #40,(R0)+ ;PUT SPACE IN BETWEEN DATE, TIME MOV #3.,R2 ;ASK FOR HH:MM:SS FORMAT CALL $TIM ;CONVERT BINARY TIME TO ASCII Return .Page .Sbttl Exit to RSX-11M Exit: ExSt$s #Ex$Suc ExErr: ExSt$s #Ex$Err ;indicate error .Page .SbTtl Tpars State Tables .MCALL ISTAT$,STATE$,TRAN$ .If DF, ParBug ISTAT$ LogSTB,LogKTB,$DEBUG .IFF ISTAT$ LogStb,LogKtb .EndC ;end of ParBug conditional State$ LogSrt Tran$ "FMT",FmtDev,,Fm.Msk,Mask Tran$ "HELP",$EXIT,,Hp.Msk,Mask Tran$ "ID",$Exit,,Id.Msk,Mask Tran$ $Lamda,$Exit,,Er.Msk,Mask State$ FmtDev Tran$ 'D,RCHK Tran$ $Lamda,$Exit,,Er.Msk,Mask State$ RChk Tran$ 'R,Unit Tran$ $Lamda,$Exit,,Er.Msk,Mask State$ Unit Tran$ $Numbr,ColChk,SavUnt Tran$ ':,$Exit,Savzer Tran$ $Lamda,$Exit,,Er.Msk,Mask State$ ColChk Tran$ ':,$Exit Tran$ $Lamda,$Exit,,Er.Msk,Mask State$ .Page .Sbttl TPars Action Routines SavUnt: Mov .PNumb,DrUnit Return SavZer: Clr DrUnit Return .Page .SbTTl Tpars Debugger ;+ ; ; *** TDebug -- The Tpars Debugger ; ; Inputs: ; R3 = Length of remainder of input string ; R4 = Address of remainder of input string ; R5 = Current address of Transition table ; ; Outputs: ; The following is printed for every Tpars State transition: ; ; Current Transition table Address = (some octal address) ; Cdc TT34: ; .......^..... ; ;- Pointr: .Rept 72. .Byte '. .EndM .IF Df,ParBug ;if Tpars debugger to be asembled TraAdd: String <"Current Transition Table Address = ">,B AddBuf: .BlkB 6 ;storage for octal ASCII address String <>,E .even TDebug: Call $Saval ;save all of the registers Mov #40,TTyout+Q.iopl+4 ;ask for lf and cr Mov R5,R1 ;get transition address Sub #LogStb,R1 ;get rid of Bias Mov #AddBuf,R0 ;point to output buffer Clr R2 ;suppress leading zeros Call $CBOMG ;convert binary to octal ASCII Print #TraAdd ;print transition address .EndC ;end of tpars debugger conditional PriErr: Print CmdBuf+G.cmld+2,CmdBuf+G.cmld ;print entire line to be parsed Sub CmdBuf+G.cmld+2,R4 ;calculate relative address of remainder MovB #'^,Pointr(R4) ;point to remainder of string Inc R4 ;adjust byte count of message Print #Pointr,R4 ;print the pointer Dec R4 ;restore ^ pointer MovB #'.,Pointr(R4) ;restore default character Return .End CDC