.TITLE KERITC - Inter Task Communciation .SBTTL Robert McQueen 7-March-1984 ; Version number .IDENT /1.0.01/ ; Directives .LIBRARY /KERMLB/ ; Pro/Kermit macro library .MCALL KERDEF ; Get the Kermit definitions KERDEF ; Define the symbols .SBTTL Revision History ;++ ; 1.0.00 By: Robert C. McQueen On: 7-March-1984 ; Create this module from other modules ; ; 1.0.01 By: Robert C. McQueen On: 15-March-1984 ; Fix any and all bugs (for the last 4 days at least). ;-- .SBTTL System calls ;++ ; The following are the .MCALLs for the various system calls that this ; module uses. ;-- .MCALL MRKT$S ; Mark Time and set EFN .MCALL ASTX$S ; AST exit .MCALL CLEF$S ; Clear event flag .MCALL SETF$S ; Set event flag .MCALL WTSE$S ; Wait for single event flag .MCALL RCVD$S ; Receive data ; .MCALL VRCD$S ; Variable receive data .MCALL SRDA$S ; Specifiy Receive Data Ast routine .MCALL SDAT$S ; Send data ; .MCALL VSDA$S ; Variable send data .SBTTL Inter Task function codes ;++ ; The following are the function codes that are passed between the two ; tasks. ;-- $TKNAK==0 ; Negative ack $TKOK== 1 ; Ok $TKSND==2 ; Send a file $TKRCV==3 ; Receive a file $TKXIT==4 ; Task is to exit $TKSRV==5 ; Enter server mode $TKGEN==6 ; Generic command $TKPAI==7 ; Cause screen to be painted and keys enabled $TKABT==10 ; Abort current processing .SBTTL Inter Task Communication data ;++ ; The following is the read/write data for the ITC module. ;-- .PSECT $OWN$, RW, D TSKME: .BLKW 1 ; Address of my task name TSKYOU: .BLKW 1 ; Address of your task name ASTRTN: .BLKW 1 ; Routine to call from AST level ITCBFR: .BLKW 15. ; Communication buffer ITCBLN=<.-ITCBFR>/2 ; Length of the buffer in words ;++ ; The following is the read only data ;-- .PSECT $PLIT$, RO, D N$KER:: .RAD50 /KERMIT/ ; Kermit task name N$FIL:: .RAD50 /KERFIL/ ; Transfer task name .SBTTL IT$INI - Initialize the intertask communication ;++ ; This routine will initialize the intertask communication between the ; two tasks. It will set the name of the task that we are and the task ; that we are willing to accept data from. ; ; Usage: ; R0 - Who I am ; R1 - Who I can talk to ; ;-- .PSECT $CODE$, RO, I .GLOBL IT$INI IT$INI: MOV R0,TSKME ; Store my name MOV R1,TSKYOU ; Store your name SRDA$S #IT$AST ; Post the routine RTS PC ; Return to the caller .SBTTL IT$SND - Send data and wait for Ok ;++ ; This routine will send data to the other task and then wait for the ; other task to reply with an Ok. If the other task doesn't reply with ; the ok, then we will return a failure to the upper level ; ; Usage: ; R1 - Function to send to the remote ; JSR PC,IT$SND ; (Return) ; ; On return: ; Carry set if success ; Carry cleared if failure ; ;-- .PSECT $CODE$, RO, D .GLOBL IT$SND IT$SND: CLEF$S #ITCEFN ; Clear the event flag ; MRKT$S #ITCEFN,#1,#2 ; Wait for 1 second JSR PC,IT$SDA ; Attempt to send the data BCC 99$ ; Failed, return to the user ; ; Here if the data was set to the other task correctly ; WTSE$S #ITCEFN ; Wait until this is set CLEF$S #ITCEFN ; Clear so if we get another interrupt ; ; When we get here we have either gotten the packet from the other end or ; we timed out ; JSR PC,IT$RDA ; Attempt to receive the data BCC 99$ ; Branch if that failed CMP R0,#$TKOK ; Get an ok return? BEQ 99$ ; Got an ok return, return to caller ; ; Here if we got some junk ; CLC ; Clear the carry 99$: RTS PC ; Return to the caller .SBTTL IT$SDA - Send data ;++ ; This routine will send information to the other task. It will then ; wait to determine if the task really got the information or not. It ; will note the failure/success to the upper level routine. ; ; Usage: ; R0 - Function to send ; JSR PC,IT$SDA ; (Return) ; ; On return: ; Carry set if success ; Carry clear if failure ; ;-- .PSECT $CODE$, RO, I .GLOBL IT$SDA IT$SDA: MOV R0,ITCBFR ; Store the information in the buffer SDAT$S TSKYOU,#ITCBFR ; Send the data ; VSDA$S TSKYOU,#ITCBFR,#13. ; Send the data to the other end MOV @#$DSW,R0 ; Get the status BMI 90$ ; Branch if an error SEC ; Set the carry RTS PC ; Return to the caller ; ; Here if there was a problem sending the data ; 90$: CLC ; Clear the carry RTS PC ; Return to the caller .SBTTL IT$PAS - Post an AST routine ;++ ; This routine will post the AST routine for the Inter Task Communications. ; ; Usage: ; R0 - Address of AST routine or zero to clear it ; JSR PC,IT$PAS ; (Return) ; ;-- .PSECT $CODE$, RO, I .GLOBL IT$PAS IT$PAS: MOV R0,ASTRTN ; Store the routine address RTS PC ; Return to the caller .SBTTL IT$AST - AST routine to data ;++ ; This routine will be entered when an AST interrupt occurs. It will ; just set the local event flag and call any lower level routine that ; must be called. ; ; Usage: ; Called by AST level ; ;-- .PSECT $CODE$, RO, I IT$AST: SETF$S #ITCEFN ; Set the event flag TST ASTRTN ; Is there a routine BEQ 90$ ; None, skip the caller MOV R0,-(SP) ; Save R0 JSR PC,@ASTRTN ; Call the routine MOV (SP)+,R0 ; Restore R0 90$: ASTX$S ; Exit from AST level .SBTTL IT$RDA - Receive data ;++ ; This routine will read the function that the other end has sent. ; ; Usage: ; JSR PC,IT$RDA ; (Return) ; ; On return: ; Carry clear if no data received. ; ; Carry set if data received. ; R0 - Function read ; ;-- .PSECT $CODE$, RO, I .GLOBL IT$RDA IT$RDA: RCVD$S ,#ITCBFR ; VRCD$S TSKYOU,#ITCBFR,#ITCBLN ; Get the data if any TST @#$DSW ; Any data received? BMI 90$ ; No, return the error code ; ; Here if we got the data from the other end ; MOV ITCBFR+4,R0 ; Get the function SEC ; Flag we got the data RTS PC ; Return to the caller ; ; Here if the receive failed to get any data, just return with the ; carry cleared. ; 90$: CLC ; Clear the carry RTS PC ; Return to the caller .SBTTL End of KERITC .END ; End of KERITC