.TITLE SPAWN .IDENT /V1.0D/ .ENABL LC ; Formerly SPWNMCR 1.4XA : ; ; MODULE TO TAKE OUTPUT FROM CCL.MAC AS ADDR OF FIRST CHAR, ; LENGTH IN CHARACTERS, AND TO OUTPUT AN MCR COMMAND LINE ; USE THE SPAWN DIRECTIVE TO SEND MESSAGES TO MCR ; ; J. DOWNWARD 16-FEB-79 ; ; 18-MAY-79 EXIT WITH CORRECT STATUS ; WAIT FOR SPAWNED COMMAND TO COMPLETE ; UNLESS COMMAND TERMINATED WITH A %$% ; ; 15-JUN-79 CHANGE ...MCR TO MCR... FOR V3.2 ; ; P. Sorenson 01-mar-81 Update for CCL V7.0 ; Mich. State Univ. ; ; Notes on SPAWN vs. SPWNMCR: modified call sequence and entry points ; for version 7.0A of CCL. Call with: R0 = start address of command, ; R1 = length of command, and R2 = 0 if want SPAWN to wait for spawned ; task to exit (R2 >< 0 will return immediately after successful spawn). ; Entry points are: PUTMCR to spawn command to MCR...; PUTCA2 to spawn ; command to ...CA2, 2nd "catchall" task. ; ; An optional enhancement may be included at SYSGEN time to ; allow the SPAWN directive (see [12,10] DRSPW.MAC) to relink the ; OCB (offspring control block) of CCL's offspring to CCL's parent, ; thereby allowing CCL to silently exit without losing a path back to ; the task that invoked CCL. This enhancement is courtesy of D. ; Steinberg, and was published in the Feb. '81 Multi-tasker. This ; special spawn directive is invoked by issuing the SPAWN with event ; flag = -1, and is enabled here by definition of the symbol $DSSPW ; in a conditional assembly file (typically PRECCL.MAC). ; ; J. Downward 27-Aug-81 For RSX11M V4.0 added RPOI support. If the ; JGD80 %$ is seen or if the CCL command line is ; the only command line (ie it starts with a *), ; the code attempts to use RPOI$ first. If ; however, %R is present, RPOI will not be used. ; If RPOI$ is legal, the OCB will be relinked ; and CCL will immediately exit. RPOI$ relinks ; OCB's for V4.0 the same way the above ; discussed patch does for V3.2. ; ; 16-Nov-81 Use also as CLI ; JGD81 If Must use RPOI. Can't wait to ring bell. ; ; .MCALL SPWN$,DIR$,STSE$S,EXST$S .MCALL RPOI$ ; JGD80 EFN1=1 ; EVENT FLAG FOR STOP ESC=33 RP.ONX=2 ;****** temporary definition ;JGD80 .PSECT $VARS,RW,D,CON,LCL MCRNM: .RAD50 /MCR.../ ; Spawned task name for PUTMCR entry point CA2NM: .RAD50 /...CA2/ ; Spawned task name for PUTCA2 entry point LEN: .WORD 0 ; Length of command to MCR EXSTAT: .WORD EX$SUC ; Exit status block (8. words long) .BLKW 7 SPNDPB: SPWN$ MCR...,,,,,EFN1,,,, CHAIN: RPOI$ MCR...,,,,,,,,,,,, ; JGD80 .PSECT $CODE1,RW,I,CON,LCL PUTCA2:: ; External entry point--spawn ...CA2 MOV R1,LEN ; Save command length MOV #CA2NM,R1 ; Fetch pointer to ...CA2 name BR MERGE ; and branch PUTMCR:: ; External entry point MOV R1,LEN ; Save command length MOV #MCRNM,R1 ; Fetch pointer to MCR... name MERGE: CMP #79.,LEN ; NOW WE CAN'T HAVE A BUFFER >79 CHAR. BLT 34$ ; OR ELSE ERROR MOV #EFN1,SPNDPB+S.PWEF ; Set up event flag TST CLIFLG ; Are we a CLI ;JGD81 BNE 3$ ; If NE, yes, Must use RPOI ;JGD81 TST RING ; Should terminal bell ring on exit ;JGD80 BNE 8$ ; If NE, yes, can't use RPOI$ ;JGD81 TST R2 ; Requested exit right after spawn? BNE 3$ ; In NE, Yes, try RPOI$ first ;JGD80 CMPB SAVTYP,#'* ; Is this the last action line? ;JGD80 BEQ 3$ ; If EQ, yes try RPOI$ first ;JGD80 BR 8$ ; If NE no, Must use SPWN/STOP ;JGD81 3$: MOV (R1),CHAIN+R.POTK ; Yes, use chain directive ;JGD80 MOV 2(R1),CHAIN+R.POTK+2 ; so first set taskname ;JGD80 MOV LEN,CHAIN+R.POBL ; Then length of command ;JGD80 MOV R0,CHAIN+R.POBF ; And command buffer address ;JGD80 MOVB #RP.ONX!RP.OEX,CHAIN+R.POSC; Pass one OCB connection ;JGD81 MOV R0,EXSTAT ; Save pointer ;JGD81 ADD LEN,R0 ; Offset ;JGD80 MOVB ESC,(R0) ; Stop MCR ">" prompt ;JGD80 MOV EXSTAT,R0 ; Restore pointer ;JGD80 MOV #EX$SUC,EXSTAT ; Assume CCL exit status OK ;JGD80 TST CLIFLG ; Are we a cli ;JGD81 BEQ 4$ ; If EQ, no, proceed ;JGD81 MOVB #RP.ONX,CHAIN+R.POSC ; Pass 1 OCB, Don't exit yet ;JGD81 4$: DIR$ #CHAIN ; Chain command to MCR ;JGD80 TST CLIFLG ; Are we a CLI ;JGD81 BEQ 5$ ; If no Proceed ;JGD81 RETURN ; If NE, yes, Return for more ;JGD81 5$: ; Ref lable ;JGD81 ; CHAIN failed, try SPAWN .IFDF $DSSPW ; Conditional assembly for special ; spawn to relink OCB's NEG SPNDPB+S.PWEF ; Signal special spawn (set EFN=-1) .ENDC ;$DSSPW 8$: ; Reference label ;JGD81 MOV (R1),SPNDPB+S.PWTN ; Set up task name MOV 2(R1),SPNDPB+S.PWTN+2 ; MOV LEN,SPNDPB+S.PWCL ; Set up command length MOV R0,SPNDPB+S.PWCA ; Set up command start address MOV #EXSTAT,SPNDPB+S.PWES ; Insert exit status block address 10$: DIR$ #SPNDPB ; Spawn command BCS 32$ ; Check error status 20$: MOV #EX$SUC,EXSTAT ; Spawn OK, assume success TST R2 ; Check value in R2 BNE 30$ ; If non-zero, don't wait for spawned task exit STSE$S #EFN1 ; Stop until command done TST EXSTAT ; Check exit status; If 0, have success BNE 30$ ; If non-zero, use status returned by offspring MOV #EX$SUC,EXSTAT ; Show success 30$: MOV EXSTAT,R0 ; Save exit status for anyone who wants it BR 35$ ; and return 32$: .IFDF $DSSPW ; Conditional assembly for special spawns CMP $DSW,#IE.ITS ; Spawn failed; was it a special spawn (EFN=-1) ; to MCR w/ multiple parent's ? BNE 34$ ; Branch if no, regular spawn error NEG SPNDPB+S.PWEF ; If yes, retry a normal spawn and CLR R2 ; wait for offspring to exit BR 10$ ; .ENDC ;$DSSPW 34$: SEC ; Show spawn failure, set carry and 35$: RETURN ; Exit .END