.TITLE BAPINI .IDENT /V3.00/ .ENABL LC .NLIST BEX ;************************************************************************** ; ; BAPINI.MAC ; ; Batch Processor Initialization Module. ; ;-------------------------------------------------------------------------- ; ; Version: V3.00 April 1983 ; ; Modification History ; ==================== ; ; ;-------------------------------------------------------------------------- ; ; Steve Thompson ; School of Chemical Engineering ; Olin Hall ; Cornell University ; Ithaca ; NY 14850 ; (607) 256 4616 (office) ; (607) 256 3895 (computer room) ; ;************************************************************************** .MCALL GTSK$S, ALUN$S, RCVD$S, SRDA$S .MCALL ENAR$S, DSAR$S, WSIG$S .MCALL FINIT$ ; ; Local data allocations. ; TSKBUF: .BLKW 16. ; Get Task Information Buffer ; ; Error messages. The first part of the message is overwritten if it ; is issued with the current task name. ; ERR1: .ASCIZ /BAP0 -- Illegal name format/ ERR2: .ASCIZ /BAP0 -- Illegal batch stream designation/ ERR3: .ASCIZ /BAP0 -- Processor must run from CO:/ ERR4: .ASCIZ /BAP0 -- Out of sequence initialization packet/ .IF DF,B3$ACC ERR5: .ASCIZ /BAP0 -- Accounting logging task not installed or not active/ .ENDC ; DF,B3$ACC ERR6: .ASCIZ /BAP0 -- Illegal Default Directory Specification/ ERR7: .ASCIZ /BAP0 -- Driver not Loaded/ ; ; Other text messages. ; OK: .ASCII /Batch Processor Initialized, name / OKTSK: .ASCII /BAP0 / .ASCII /, Batch Stream / OKDEV: .ASCIZ /VTNN:/ .EVEN ; ; Other local data. ; UCBADR: .BLKW 1 ; TI: UCB address flag .PAGE .SBTTL MAIN INITIALIZATION MODULE ;+ ; **-$INIEP-Batch Processor Initialization Routine. ; ; This routine is called once when the Batch Processor is woken ; up. ; ; Inputs: ; none ; ; Outputs: ; CC Initialized OK ; CS Initialization Failure ; ;- $INIEP::FINIT$ ; Entry point MOVB SP,WAIFLG ; Show waiting for packet ; ; Get task information and verify task name legality. ; GTSK$S #TSKBUF ; Get task parameters CMP #^RBAP,TSKBUF ; Name start BAP? BEQ 10$ ; If EQ yes CALLR EM1 ; If NE no, error 10$: MOV #TSKNAM,R0 ; Get addr. of task name buffer MOV TSKBUF,R1 ; Get first half of name CALL $C5TA ; Convert to ASCII MOV TSKBUF+2,R1 ; Get second half of name CALL $C5TA ; Convert to ASCII. ; ; Obtain batch stream unit number from task name. ; CMPB TSKNAM+5,#SPA ; Last character a space? BEQ 12$ ; If EQ yes 11$: CALLR EM2 ; If NE no, error 12$: MOVB TSKNAM+3,R1 ; Get first char. of unit SUB #'0,R1 ; Subtract character bias BLT 11$ ; If LT it's not numeric CMP R1,#7 ; Numeric (octal)? BGT 11$ ; If GT no, error MOVB TSKNAM+4,R2 ; Get second char. of unit CMPB R2,#SPA ; Space? BEQ 20$ ; If EQ yes, 1 digit in unit SUB #'0,R2 ; Subtract character bias BLT 11$ ; If LT it's not numeric CMP R2,#7 ; Numeric (octal)? BGT 11$ ; If GT no, error ASL R1 ; Multiply first digit by 10(8) ASL R1 ; ASL R1 ; ADD R2,R1 ; Add second digit 20$: ; Ref. label ; ; Assign the unit and get its UCB address. Check also that we are running ; with a TI: of CO:. ; MOV R1,UNIT ; Save unit number ALUN$S #VTLUN,BATDEV,R1 ; Assign the LUN BCC 22$ ; If CC, device there CALLR EM2 ; If CS, illegal unit 22$: CALL $SWSTK,30$ ; Switch stacks MOV $HEADR,R0 ;; Get our header address MOV H.LUN+<4*>(R0),VTUCB ;; Get batch stream UCB address MOV $TKTCB,R0 ;; Get our TCB address MOV T.UCB(R0),UCBADR ;; Get our TI: UCB address CMP UCBADR,$COPT ;; Is it CO:? BEQ 28$ ;; If EQ yes CLR UCBADR ;; Clear if not CO: 28$: RETURN ;; Return to user state 30$: TST UCBADR ; Are we running on CO:? BNE 31$ ; If NE yes, OK CALLR EM3 ; else error 31$: ; Ref. label ; ; Make sure driver is loaded. ; .IF DF,L$$DRV MOV VTUCB,R0 ; Get stream UCB address MOV U.DCB(R0),R0 ; Point to DCB address TST D.PCB(R0) ; Driver loaded? BNE 34$ ; If NE yes CALLR EM7 ; No, error 34$: ; Ref. label .ENDC ; DF,L$$DRV ; ; Set up spawn DPB for later use. ; MOV UNIT,SPWDPB+S.PWVT ; Set up unit number MOV BATDEV,SPWDPB+S.PWDN ; Set up batch stream device name ; ; Initialise FSR and set up default directory word. ; MOV #TIMBUF+2,R2 ; Get address+2 of default directory ; descriptor (temporary) MOV #$DUFD,(R2) ; Fill in ASCII directory string ; address MOV #$DIRSZ,-(R2) ; and its size MOV #BINUFD,R3 ; Get address of location for default ; directory word CALL .ASCPP ; Convert UFD string to binary BCC 36$ ; If CC OK CALLR EM6 ; If CS it was illegally GBLPAT'ed 36$: ; Ref. label ; ; Validate logfile directory by trying to insert the directory ID into ; the logfile FDB. Although this is done each time a logfile is opened, ; doing it here serves to detect any illegal UFD. ; MOV BINUFD,R1 ; Get binary UFD CALL .WDFUI ; Write into FSR as default directory MOV #LOGFDB,R0 ; Get FDB address in R0 MOV R0,R1 ; Point to filename block ADD #F.FNB,R1 ; CALL .GTDID ; Get directory ID information BCC 38$ ; If CC OK CALLR EM6 ; If CS, illegal directory, or ; directory file did not exist 38$: ; Ref. label ; ; Get TCB address of logging task if accounting is supported. ; .IF DF,B3$ACC CALL $SWSTK,50$ ; Switch stacks CLR LOGPTR ;; Assume it's not there MOV #LOGNAM,R3 ;; Point to logging task name CALL $SRSTD ;; Locate the TCB BCS 40$ ;; If CS, not there BIT #TS.EXE,T.STAT(R0) ;; Installed, but active? BNE 40$ ;; If NE no MOV R0,LOGPTR ;; Save logging task TCB 40$: RETURN ;; Go back to user state 50$: TST LOGPTR ; Was logging task there? BNE 52$ ; If NE yes CALLR EM5 ; If EQ no, error 52$: ; Ref. label ; ; Get address of accounting list. Delete our entry from the list to ; save pool. ; CLR PKTADR ; Assume no DSR packet CLR ACLIST ; Don't know accounting list address CALL $SWSTK,60$ ; Switch to system stack MOV #B.NLEN,R1 ;; Get length of buffer to allocate CALL $ALOCB ;; Allocate it BCS 55$ ;; If CS, error MOV R0,PKTADR ;; Save packet address MOV #,B.MASK(R0) ;; Set command in packet MOV $TKTCB,B.NTCB(R0) ;; Send our TCB address MOV R0,R1 ;; Copy block address to R1 MOV LOGPTR,R0 ;; Get LOG...'S TCB address CALL $EXRQF ;; Queue packet and start LOG... CALLR $STPCT ;; Stop us until we get a reply 55$: RETURN ;; Return to user level 60$: MOV PKTADR,R5 ; Was there an allocation error? BEQ 70$ ; If EQ yes, forget it MOV B.NAHD(R5),ACLIST ; Save accounting list listhead address CALL $SWSTK,70$ ; Switch stacks MOV R5,R0 ;; Get address of packet to deallocate MOV #B.NLEN,R1 ;; And its length CALL $DEACB ;; Deallocate block back to pool MOV ACLIST,R2 ;; Get accounting list address BEQ 68$ ;; If EQ, ACNODE had problems 62$: MOV (R2),R1 ;; Get next entry address BEQ 68$ ;; If EQ, we are not in list CMP $TKTCB,B.TCB(R1) ;; Is this entry us? BEQ 64$ ;; If EQ yes MOV R1,R2 ;; No, set up to keep looking BR 62$ ;; and follow the list further 64$: MOV (R1),(R2) ;; Close up list (remove entry) BNE 66$ ;; If NE, not at end of list MOV ACLIST,R3 ;; Get accounting listhead address MOV R2,2(R3) ;; At end of list, so fix listhead 66$: MOV R1,R0 ;; Copy block address to R0 MOV #B.LGTH,R1 ;; Get length of block CALLR $DEACB ;; Deallocate and return to user state 68$: RETURN ;; Return to user state at 70$ 70$: ; Ref. label .ENDC ; DF,B3$ACC ; ; Now get the initialization packet sent by the Queue Manager. ; 100$: RCVD$S ,#RCVBUF ; Receive data BCC 110$ ; If CC, QMG... has sent it WSIG$S ; Wait a while if not BR 100$ ; Try again 110$: CMP RCVBUF,QMGNAM ; Sent by QMG...? BNE 100$ ; If NE no, reject this one CMP RCVBUF+2,QMGNAM+2 ; Maybe BNE 100$ ; If NE no, try for more CMPB RCVBUF+4+Q.MFUN,#QP.STA ; Startup packet? BNE EM4 ; If NE something's up ; ; Perform rest of initialization functions. ; ENAR$S ; Enable AST recognition DIR$ #CLFRCV ; Clear receive data flag SRDA$S #RCVAST ; Specify receive data AST MOV #OKTSK,R0 ; Get place for task name CALL INSTKN ; Insert task name MOV #OKDEV,R0 ; Get place to stick stream name MOV VTUCB,R3 ; Get batch stream UCB address CALL $FMTDV ; Format device name SUB #OK,R0 ; Calculate message length MOV #OK,COWRIT+Q.IOPL ; Set up DPB MOV R0,COWRIT+Q.IOPL+2 ; DIR$ #COWRIT ; Send message to CO: CLC ; Show initialization done OK RETURN ; and return to root ; ; Error returns. ; EM1: MOV #ERR1,R0 ; Illegal task name BR ERCOM ; Go process this error EM2: MOV #ERR2,R0 ; Illegal device or unit BR ERCOM ; Go process this error EM3: MOV #ERR3,R0 ; Must run on CO: BR ERCOM ; Go process this error EM4: MOV #ERR4,R0 ; Incorrect startup packet BR ERCOM ; Go process this error .IF DF,B3$ACC EM5: MOV #ERR5,R0 ; Logging task error BR ERCOM ; Go process this error .ENDC ; DF,B3$ACC EM6: MOV #ERR6,R0 ; Illegal Default Directory BR ERCOM ; Go process this error EM7: MOV #ERR7,R0 ; Driver not loaded ; Fall through to ERCOM ;+ ; **-ERCOM-Initialization Error Handler. ; ;- ERCOM: MOV R0,-(SP) ; Save message address MOV R0,COWRIT+Q.IOPL ; Insert in DPB CALL INSTKN ; Insert task name 10$: TSTB (R0)+ ; End of message? BNE 10$ ; If NE no, loop SUB (SP)+,R0 ; Calculate message length MOV R0,COWRIT+Q.IOPL+2 ; Put in the DPB DIR$ #COWRIT ; Send out message MOV #EX$SEV,EXSTAT ; Set severe error status SEC ; Set error indication RETURN ; Return to caller ;+ ; **-INSTKN-Insert task name in current buffer. ; ; Inputs: ; R0 Buffer pointer ; ; Outputs: ; R0 (Input R0)+6 ; R1,R2 Used ; ;- INSTKN: MOV #TSKNAM,R1 ; Point to task name MOV #6,R2 ; Get length of name 10$: MOVB (R1)+,(R0)+ ; Insert a byte DEC R2 ; Done yet? BGT 10$ ; If GT no, loop RETURN ; Return to caller .END