home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / decpro300 / proitc.mac < prev    next >
Text File  |  2020-01-01  |  6KB  |  269 lines

  1.     .TITLE    KERITC - Inter Task Communciation
  2.     .SBTTL    Robert McQueen        7-March-1984
  3.  
  4. ; Version number
  5.  
  6.     .IDENT    /1.0.01/
  7.  
  8. ; Directives
  9.  
  10.     .LIBRARY /KERMLB/        ; Pro/Kermit macro library
  11.     .MCALL    KERDEF            ; Get the Kermit definitions
  12.     KERDEF                ; Define the symbols
  13.  
  14.     .SBTTL    Revision History
  15.  
  16. ;++
  17. ; 1.0.00    By: Robert C. McQueen        On: 7-March-1984
  18. ;        Create this module from other modules
  19. ;
  20. ; 1.0.01    By: Robert C. McQueen        On: 15-March-1984
  21. ;        Fix any and all bugs (for the last 4 days at least).
  22. ;--
  23.  
  24.     .SBTTL    System calls
  25.  
  26. ;++
  27. ; The following are the .MCALLs for the various system calls that this
  28. ; module uses.
  29. ;--
  30.  
  31.     .MCALL    MRKT$S            ; Mark Time and set EFN
  32.     .MCALL    ASTX$S            ; AST exit
  33.     .MCALL    CLEF$S            ; Clear event flag
  34.     .MCALL    SETF$S            ; Set event flag
  35.     .MCALL    WTSE$S            ; Wait for single event flag
  36.     .MCALL    RCVD$S            ; Receive data
  37. ;    .MCALL    VRCD$S            ; Variable receive data
  38.     .MCALL    SRDA$S            ; Specifiy Receive Data Ast routine
  39.     .MCALL    SDAT$S            ; Send data
  40. ;    .MCALL    VSDA$S            ; Variable send data
  41.  
  42.     .SBTTL    Inter Task function codes
  43.  
  44. ;++
  45. ; The following are the function codes that are passed between the two
  46. ; tasks.
  47. ;--
  48.  
  49.     $TKNAK==0        ; Negative ack
  50.     $TKOK==    1        ; Ok
  51.     $TKSND==2        ; Send a file
  52.     $TKRCV==3        ; Receive a file
  53.     $TKXIT==4        ; Task is to exit
  54.     $TKSRV==5        ; Enter server mode
  55.     $TKGEN==6        ; Generic command
  56.     $TKPAI==7        ; Cause screen to be painted and keys enabled
  57.     $TKABT==10        ; Abort current processing
  58.  
  59.     .SBTTL    Inter Task Communication data
  60.  
  61. ;++
  62. ; The following is the read/write data for the ITC module.
  63. ;--
  64.  
  65.     .PSECT    $OWN$, RW, D
  66.  
  67. TSKME:    .BLKW    1            ; Address of my task name
  68. TSKYOU:    .BLKW    1            ; Address of your task name
  69.  
  70. ASTRTN:    .BLKW    1            ; Routine to call from AST level
  71.  
  72. ITCBFR:    .BLKW    15.            ; Communication buffer
  73.  ITCBLN=<.-ITCBFR>/2            ; Length of the buffer in words
  74.  
  75.  
  76. ;++
  77. ; The following is the read only data
  78. ;--
  79.  
  80.     .PSECT    $PLIT$, RO, D
  81.  
  82. N$KER::    .RAD50    /KERMIT/        ; Kermit task name
  83. N$FIL::    .RAD50    /KERFIL/        ; Transfer task name
  84.  
  85.     .SBTTL    IT$INI - Initialize the intertask communication
  86.  
  87. ;++
  88. ; This routine will initialize the intertask communication between the
  89. ; two tasks.  It will set the name of the task that we are and the task
  90. ; that we are willing to accept data from.
  91. ;
  92. ; Usage:
  93. ;    R0 - Who I am
  94. ;    R1 - Who I can talk to
  95. ;
  96. ;--
  97.  
  98.     .PSECT    $CODE$, RO, I
  99.  
  100.     .GLOBL    IT$INI
  101.  
  102. IT$INI:    MOV    R0,TSKME        ; Store my name
  103.     MOV    R1,TSKYOU        ; Store your name
  104.     SRDA$S    #IT$AST            ; Post the routine
  105.     RTS    PC            ; Return to the caller
  106.  
  107.     .SBTTL    IT$SND - Send data and wait for Ok
  108.  
  109. ;++
  110. ; This routine will send data to the other task and then wait for the
  111. ; other task to reply with an Ok.  If the other task doesn't reply with
  112. ; the ok, then we will return a failure to the upper level
  113. ;
  114. ; Usage:
  115. ;    R1 - Function to send to the remote
  116. ;    JSR    PC,IT$SND
  117. ;    (Return)
  118. ;
  119. ; On return:
  120. ;    Carry set if success
  121. ;    Carry cleared if failure
  122. ;
  123. ;--
  124.  
  125.     .PSECT    $CODE$, RO, D
  126.  
  127.     .GLOBL    IT$SND
  128.  
  129. IT$SND:    CLEF$S    #ITCEFN            ; Clear the event flag
  130. ;    MRKT$S    #ITCEFN,#1,#2        ; Wait for 1 second
  131.     JSR    PC,IT$SDA        ; Attempt to send the data
  132.     BCC    99$            ; Failed, return to the user
  133. ;
  134. ; Here if the data was set to the other task correctly
  135. ;
  136.     WTSE$S    #ITCEFN            ; Wait until this is set
  137.     CLEF$S    #ITCEFN            ; Clear so if we get another interrupt
  138. ;
  139. ; When we get here we have either gotten the packet from the other end or
  140. ; we timed out
  141. ;
  142.     JSR    PC,IT$RDA        ; Attempt to receive the data
  143.     BCC    99$            ; Branch if that failed
  144.     CMP    R0,#$TKOK        ; Get an ok return?
  145.     BEQ    99$            ; Got an ok return, return to caller
  146. ;
  147. ; Here if we got some junk
  148. ;
  149.     CLC                ; Clear the carry
  150. 99$:    RTS    PC            ; Return to the caller
  151.  
  152.     .SBTTL    IT$SDA - Send data
  153.  
  154. ;++
  155. ; This routine will send information to the other task.  It will then
  156. ; wait to determine if the task really got the information or not.  It
  157. ; will note the failure/success to the upper level routine.
  158. ;
  159. ; Usage:
  160. ;    R0 - Function to send
  161. ;    JSR    PC,IT$SDA
  162. ;    (Return)
  163. ;
  164. ; On return:
  165. ;    Carry set if success
  166. ;    Carry clear if failure
  167. ;
  168. ;--
  169.  
  170.     .PSECT    $CODE$, RO, I
  171.  
  172.     .GLOBL    IT$SDA
  173.  
  174. IT$SDA:    MOV    R0,ITCBFR        ; Store the information in the buffer
  175.     SDAT$S    TSKYOU,#ITCBFR        ; Send the data
  176. ;    VSDA$S    TSKYOU,#ITCBFR,#13.    ; Send the data to the other end
  177.     MOV    @#$DSW,R0        ; Get the status
  178.     BMI    90$            ; Branch if an error
  179.     SEC                ; Set the carry
  180.     RTS    PC            ; Return to the caller
  181. ;
  182. ; Here if there was a problem sending the data
  183. ;
  184. 90$:    CLC                ; Clear the carry
  185.     RTS    PC            ; Return to the caller
  186.  
  187.     .SBTTL    IT$PAS - Post an AST routine
  188.  
  189. ;++
  190. ; This routine will post the AST routine for the Inter Task Communications.
  191. ;
  192. ; Usage:
  193. ;    R0 - Address of AST routine or zero to clear it
  194. ;    JSR    PC,IT$PAS
  195. ;    (Return)
  196. ;
  197. ;--
  198.  
  199.     .PSECT    $CODE$, RO, I
  200.  
  201.     .GLOBL    IT$PAS
  202.  
  203. IT$PAS:    MOV    R0,ASTRTN        ; Store the routine address
  204.     RTS    PC            ; Return to the caller
  205.  
  206.     .SBTTL    IT$AST - AST routine to data
  207.  
  208. ;++
  209. ; This routine will be entered when an AST interrupt occurs.  It will
  210. ; just set the local event flag and call any lower level routine that
  211. ; must be called.
  212. ;
  213. ; Usage:
  214. ;    Called by AST level
  215. ;
  216. ;--
  217.  
  218.     .PSECT    $CODE$, RO, I
  219.  
  220. IT$AST:    SETF$S    #ITCEFN            ; Set the event flag
  221.     TST    ASTRTN            ; Is there a routine
  222.     BEQ    90$            ; None, skip the caller
  223.     MOV    R0,-(SP)        ; Save R0
  224.     JSR    PC,@ASTRTN        ; Call the routine
  225.     MOV    (SP)+,R0        ; Restore R0
  226. 90$:    ASTX$S                ; Exit from AST level
  227.  
  228.     .SBTTL    IT$RDA - Receive data
  229.  
  230. ;++
  231. ; This routine will read the function that the other end has sent.
  232. ;
  233. ; Usage:
  234. ;    JSR    PC,IT$RDA
  235. ;    (Return)
  236. ;
  237. ; On return:
  238. ;    Carry clear if no data received.
  239. ;
  240. ;    Carry set if data received.
  241. ;        R0 - Function read
  242. ;
  243. ;--
  244.  
  245.     .PSECT    $CODE$, RO, I
  246.  
  247.     .GLOBL    IT$RDA
  248.  
  249. IT$RDA:    RCVD$S    ,#ITCBFR
  250. ;    VRCD$S    TSKYOU,#ITCBFR,#ITCBLN    ; Get the data if any
  251.     TST    @#$DSW            ; Any data received?
  252.     BMI    90$            ; No, return the error code
  253. ;
  254. ; Here if we got the data from the other end
  255. ;
  256.     MOV    ITCBFR+4,R0        ; Get the function
  257.     SEC                ; Flag we got the data
  258.     RTS    PC            ; Return to the caller
  259. ;
  260. ; Here if the receive failed to get any data, just return with the
  261. ; carry cleared.
  262. ;
  263. 90$:    CLC                ; Clear the carry
  264.     RTS    PC            ; Return to the caller
  265.  
  266.     .SBTTL    End of KERITC
  267.  
  268.     .END                ; End of KERITC
  269.