;+ ; ; ; PROGRAM ACTIVATION SUBROUTINE (PGMRUN) ; ; ; FUNCTION: ; This subroutine is used to activate programs and ; pass parameters. ; ; ; CALLING SEQUENCE: ; ; CALL PGMRUN ( MODNUM, PRG, OPTION, BUFAD) ; ; WHERE: ; ARGUMENT = DESCRIPTION ACCESS ; MODNUM = Module number of main task pa ; PRG = Program number or name of task ; to activate pa ; OPTION = Activation type pa ; 0 = Activate by number with parameters ; 1 = Activate by number without parameters ; 2 = Activate by name with parameters ; 3 = Activate by name without parameters ; BUFAD = Address of parameter buffer pa ; ; GLOBAL COMMON DATA REFERENCED: ; VARIABLE NAME TABLE NAME COMMON BLOCK READ/WRITE ; NAME1 XPGMAT XSYSTM R ; NAME2 XPGMAT XSYSTM R ; ; ; DISC DATA REFERENCED: ; NONE ; ; ; MODULE NUMBER: ; -18 ; ; ; SUBROUTINES REFERENCED: ; WTQIO SFTERR PIPE ; ; ; ; DESCRIPTION: ; ; This subroutine performs error checks on the variables ; passed to it. If an error exists, subroutine SFTERR ; is called. If no error exists, the name of the task ; is obtained from XPGMAT or is passed by the user. ; If parameters are to be sent, they are passed to RUNNER ; via variable send driver. Otherwise, the task name to ; be scheduled passed. ; ; SPECIAL CONSIDERATIONS: ; ; 1. If parameters are to be passed, only three parameters ; can be passed. ;- .TITLE PGMRUN - PROGRAM ACTIVATION SUBROUTINE .MCALL RUN$S,SETF$S,STSE$S,QIOW$S,SDAT$S,MRKT$S .MCALL XSYSRL,SCALL XSYSRL ; ; Argument offsets. ; MOD=2 PGM=4 OPT=6 BUF=8. ; ; Variables and constants. ; .PSECT RCS$D,RW,D,LCL,REL,CON REBOOT: .RAD50 /REBOOT/ ISB: .BLKW 2 ; I/O Status Block for VP: PSIZE: .WORD 0 ; bytecount NAM1: .RAD50 /RUN/ ; queue name NAM2: .RAD50 /NER/ RUNBUF: .BLKW 5 ; RUNNER's buffer ZERO: .WORD 0 ERROR: .WORD 0 ; SFTERR number SUBNUM: .WORD -18. ; PGMRUN subroutine number. DEVTYP: .WORD 13. ; VS: device type DEVNUM: .WORD 2 ; device number ; ; START CODE ; ; .PSECT RCS$I,RO,I,LCL,REL,CON ; ; *** PGMRUN ENTRY POINT *** ; PGMRUN:: MOV R0,-(SP) ; save register 0 MOV R1,-(SP) ; save register 1 MOV R2,-(SP) ; save register 2 MOV R3,-(SP) ; save register 3 MOV R4,-(SP) ; save register 4 MOV R5,-(SP) ; save register 5 ; ; Validate number of arguments ; must be at least 4. ; MOV #ZERO,R4 ; parameter 2 is zero CMP (R5),#4 ; Are there at least 4 arguments? BGE ARGOK ; no MOV R5,R2 ; address for sfterr p1 MOV #36.,ERROR ; bad # of args JMP ERRX ; generate soft error ARGOK: ; ; Validate program number; ; must not be greater than maximum defined. ; MOV #20.,ERROR ; set error for SFTERR MOV OPT(R5),R4 ; get option address for SFTERR p2 MOV PGM(R5),R2 ; set pgm # or name address for sfterr p1 MOV (R4),R1 ; get the option MOV R1,R3 ; see if option is 2 or 3 DEC R1 DEC R1 BMI 10$ ; no, check program number MOV R2,R0 ; yes, get program name address MOV R1,R3 ; move option -2 for checking BR 20$ 10$: MOV (R2),R0 ; get prog# to schedule CMP R0,#1 ; is prg < 1 BMI ERRX ; yes, take error exit CMP R0,XNMPRG ; is prg > XNMPRG BGT ERRX ; yes, take error exit ; ; Compute pointer to program name in ; XPGMAT table. ; do a sfterr if program not defined. ; DEC R0 ; decrement program number ASH #2,R0 ; multiply by 2 since two words for ADD XPGMAT,R0 ; add offset to table ADD #XSYSTM,R0 ; add in XSYSTM offset 20$: TST (R0) ; is program name defined ? BEQ ERRX ; no, take error exit MOV #RUNBUF,R1 ; get address for storage MOV (R0)+,(R1)+ ; get first part of name MOV (R0),(R1)+ ; get second part of name ; ; Validate option. ; set error = 21; ; check option (in r3). ; MOV #21.,ERROR ; set soft error to 21 TST R3 ; is option < 0 BEQ SENDP BLT ERRX ; yes, take error exit DEC R3 ; is option = 1 ? BEQ DORUN ; yes, just send task name ERRX: JMP SERR ; go generate soft error and return ; ; Initialize rest of buffer. ; SENDP: MOV BUF(R5),R3 ; get buffer address MOV (R3)+,(R1)+ ; move parameter 1 MOV (R3)+,(R1)+ ; move parameter 2 MOV (R3),(R1)+ ; move parameter 3 ; ; Send paramters to RUNNER. ; DORUN: SUB #RUNBUF,R1 ; calculate buffer size MOV R1,PSIZE SCALL GTLUN,MOD(R5),DEVTYP,DEVNUM TST R0 ; check vs lun BMI XIT ; exit if bad MOV #3,R3 ; three try's DOIO: QIOW$S #IO.WLB,R0,#1,,#ISB,,<#RUNBUF,PSIZE,NAM1,NAM2,,> MOV #ISB,R4 ; get status CMP (R4),#IS.SUC ; error ? BEQ XIT ; no, exit MOV #26.,ERROR ; set error # CMP (R4),#-103. ; queue full ? BNE SERR ; no, print sfterr DEC R3 ; decrement # of try's BEQ DOREST ; retries exhausted ? MRKT$S #1,#5,#2 ; wait 5 seconds STSE$S #1 ; stop for event flag BR DOIO DOREST: MOV XRSTRT,R1 ; get restart info ADD #XSYSTM,R1 BIT #100000,(R1) ; debug mode ? BNE SERR ; yes, print sfterr and return BIT #040000,(R1) ; restarting ? BNE SERR ; yes, print sfterr and return MOV #RUNBUF,R4 ; cause a restart MOV #14.,(R4) ; restart reason 14, MOV (R2),4(R4) ; ps is the program we want to schedule SDAT$S #REBOOT,R4 ; send the data to reboot SETF$S #39. BR XIT ; ; This is exit path. ; XIT: MOV (SP)+,R5 ; restore register 5 MOV (SP)+,R4 ; restore register 4 MOV (SP)+,R3 ; restore register 3 MOV (SP)+,R2 ; restore register 2 MOV (SP)+,R1 ; restore register 1 MOV (SP)+,R0 ; restore register 0 RTS PC ; return ; ; This is soft error path. ; SERR: SCALL SFTERR,MOD(R5),SUBNUM,ERROR,R2,R4 BR XIT .END