.TITLE SETCCF - SET CONTROL-C FLAG .IDENT -000100- .SBTTL TITLE PAGE ;+ ; ABSTRACT: SETCCF ; ; THIS SUBROUTINE ATTACHES THE TERMINAL ON WHICH THE ; CALLING TASK IS EXECUTING FOR CONTROL-C OR UNSOLISITED ; INPUT RECOGNITION. IT CLEARS THE FLAG ARGUMENT AND ; SETS IT WHENEVER A CONTROL-C HAS BEEN ISSUED. ; THE SUBROUTINE CLRCCF SHOULD BE CALLED BEFORE TASK ; TERMINATION TO CLEAR THE CONTROL-C AST AND PREVENT ; AN ERROR MESSAGE LIKE "VIA EXIT WITH PENDING I/O". ; ; CALLING SEQUENCE: ; ; = SETCCF (FILE, FLAG) /* INTERRUPT FOR CONTROL-C ONLY */ ; = SETUIF (FILE, FLAG) /* ONLY UNSOLICITED INPUT */ ; = SETATT (FILE, CFLAG, UFLAG) /* BOTH CONTROL-C AND INPUT */ ; CALL CLRCCF ; /* CLEAR THE ATTACH. */ ; ; RETURNS: FIXED BINARY (15,0) ; ; +1 SUCCESSFUL COMPLETION ; <0 ERROR - NUMBER WILL BE THE RSX ERROR CODE ; ; ARGUMENTS: ; ; FILE FILE STREAM INPUT ; THE INPUT (OR OUTPUT) FILE TO THE TERMINAL. ; ; FLAG FIXED BINARY (15,0) ; THE FLAG TO BE SET WHENEVER A CONTROL-C AST IS ; SEEN. THIS SHOULD BE A PERMANENTLY RESIDENT VARIABLE, ; EITHER AN EXTERNAL OR STATIC WHICH IS IN THE ROOT OR ; AN AUTOMATIC ALLOCATED BY THE MAIN LINE PROGRAM. ; ; FILES: ; ; AS SUPPLIED BY THE USER. ; ; ERRORS: ; ; RETURNED IN RETURN CODE AS PER ABOVE. ; ; SUBROUTINES: ; ; .OPENF - PL/I RUNTIME ROUTINE TO FIND AND OPEN FDB'S. ; ILNAR$ - RUNTIME ROUTINE TO REPORT ARG MISMATCH ; SAVRG$ - RUNTIME ROUTINE TO SAVE REGISTERS ; ; NONSTANDARD FEATURES: ; ; THE ABILITY TO FIELD A CONTROL-C (OR SOME OTHER ; ATTENTION CHARACTER) IS NOT UNIVERSALLY SUPPORTED ; AMONG ALL COMPUTER SYSTEMS (I. E., RSX-11M AND RT-11). ; ; LIMITATIONS: ; ; SINCE THIS ROUTINE MUST ESTABLISH CERTAIN RESIDENT ; INFORMATION, IT CANNOT BE COMPLETELY PURE AND IT ; MUST BE RESIDENT IN THE ROOT SEGMENT OF ANY CALLING ; PROGRAM. IT ALSO CANNOT SET A LIST OF FLAGS; ONLY ; THE MOST RECENT FLAG PASSED TO IT IS USED AS THE ; FLAG VARIABLE. ; ; WRITTEN: 18-JAN-78, -0.0.0-, BRUCE C. WRIGHT ; MODIFIED: 15-JAN-79, -0.1.0-, BRUCE C. WRIGHT ; CHANGED TO NEW REGISTER SAVING ROUTINE ; VERIFIED: 15-JAN-79, -0.1.0-, BRUCE C. WRIGHT ;- .SBTTL ARGUMENT DEFINITIONS ; ; GET THE NEEDED BIOMAC MACROS ; .MCALL QIOW$S,ASTX$S,WSIG$S ; ; DEFINE OFFSETS TO ARGUMENT DEFINITIONS OFF OF THE STACK POINTER ; NARGS = 16 ;NUMBER OF ARGUMENTS PASSED. FILE = NARGS+2 ;FILE NAME. FLAG = FILE+2 ;FLAG ADDRESS RTN = FLAG+2 ;RETURN CODE. ; CFLAG = FILE+2 ;CONTROL-C FLAG UFLAG = CFLAG+2 ;UNSOLICITED INPUT FLAG RTN1 = UFLAG+2 ;RETURN CODE ; .SBTTL STATIC READ/WRITE AREA ; .PSECT $SETCC,RW,D,CON ; $CFLAG: .WORD 0 ;THE LOCATION TO POST WHEN A ;CONTROL-C OCCURRS. $UFLAG: .WORD 0 ;THE LOCATION TO POST WHEN AN ;UNSOLICITED INPUT OCCURRS. $LUN: .WORD 0 ;THE LUN WHICH WAS ATTACHED. .SBTTL EXECUTABLE CODE .PSECT SETCCF,RO,I ; ERR: JSR R5,ILNAR$ ;THIS WILL STOP US GOOD. CLRCCF::JSR R0,SAVRG$ ;SAVE REGISTERS TST NARGS(SP) ;MAKE SURE NO ARGS PASSED BNE ERR ;YES-THE DUMMY 10$: QIOW$S #IO.DET,$LUN,#1 ;DETACH FROM LUN. CMP @#$DSW,#-1 ;NO NODES? BNE 20$ ;NO WSIG$S ;WAIT FOR THEM BR 10$ ;AND LOOP 20$: RTS PC ;AND RETURN TO CALLER. SETCCF::JSR R0,SAVRG$ ;SAVE REGISTERS CMP NARGS(SP),#3 ;CORRECT NUMBER OF ARGS? BNE ERR ;NO CLR @FLAG(SP) ;CLEAR FLAG. MOV FLAG(SP),$CFLAG ;REMEMBER FLAG. CLR R0 ;CLEAR UI-AST. ;**** MOV #CCAST,R1 ;AND GET CC-AST. ;**** CALL SETAST ;AND SET THE AST. MOV R0,@RTN(SP) ;SAVE RETURN CODE. RTS PC ;AND RETURN. SETUIF::JSR R0,SAVRG$ ;SAVE REGISTERS CMP NARGS(SP),#3 ;CORRECT NUMBER OF ARGS? BNE ERR ;NO CLR @FLAG(SP) ;CLEAR FLAG. MOV FLAG(SP),$UFLAG ;REMEMBER FLAG. CLR R1 ;CLEAR CC-AST. ;**** MOV #UIAST,R0 ;AND GET UI-AST. ;**** CALL SETAST ;AND SET THE AST. MOV R0,@RTN(SP) ;SAVE RETURN CODE. RTS PC ;AND RETURN SETATT::JSR R0,SAVRG$ ;SAVE REGISTERS CMP NARGS(SP),#4 ;CORRECT NUMBER OF ARGS? BNE ERR ;NO CLR @UFLAG(SP) ;CLEAR CC-FLAG. CLR @UFLAG(SP) ;AND UI-FLAG MOV CFLAG(SP),$CFLAG ;REMEMBER CC-FLAG. MOV UFLAG(SP),$UFLAG ;REMEMBER UI-FLAG MOV #UIAST,R0 ;SET UI-AST. ;**** MOV #CCAST,R1 ;AND GET CC-AST. ;**** CALL SETAST ;AND SET THE AST. MOV R0,@RTN1(SP) ;SAVE RETURN CODE. RTS PC ;AND RETURN. SETAST: MOV FILE+2(SP),R2 ;GET THE FILE. MOV R1,-(SP) ;SAVE R0,R1 MOV R0,-(SP) ; CLR R1 CLR R0 ;SET UP FOR CALL TO .OPENF .SBTTL GET FDB AND OPEN FILE IF NECESSARY. JSR R5,.OPENF ;OPEN THE FILE IF NOT YET OPEN. 040000 ;DEFAULTS: INPUT. 000020 ;CONFLICTS: STRING MOV (SP)+,R0 ;RECOVER R0 MOV (SP)+,R1 ;RECOVER R1 SUB #S.FDB,R3 ;GET A(FDB) MOVB F.LUN(R3),R3 ;GET THE LUN. MOV R3,$LUN ;REMEMBER LUN. SUB #4,SP ;ALLOCATE IOST MOV SP,R2 ;POINT TO IT. 10$: QIOW$S #IO.ATA,R3,#1,,R2,, ;**** MOV @#$DSW,R0 ;GET DSW ERROR. CMP R0,#-1 ;NO POOL NODES? BNE 20$ ;NO -- SKIP WSIG$S ;WAIT FOR ONE BR 10$ ;AND TRY AGAIN. 20$: BLT 3$ ;ERROR -- RETURN IT TO HIM MOVB (R2),R0 ;GET IOST ERROR CODE. 3$: ADD #4,SP ;DEALLOCATE IOST RETURN ;AND RETURN TO CALLER. CCAST: MOV #1,@$CFLAG ;TELL PROGRAM THAT USER HIT CONTROL-C CCRET: TST (SP)+ ;POP AST PARAMETER ;**** ASTX$S ;AND RETURN TO THE AST. UIAST: MOV #1,@$UFLAG ;TELL PROGRAM THAT USER TYPED SOMETHING BR CCRET ;AND RETURN FROM AST. .END