home *** CD-ROM | disk | FTP | other *** search
/ Columbia Kermit / kermit.zip / pdp11 / k11rxx.mac < prev    next >
Text File  |  2020-01-01  |  12KB  |  425 lines

  1.     .title    k11rxx    alter rsx connect terminal emu
  2.  
  3. ;    16-Jul-85  15:13:03 BDN 
  4. ;
  5. ;    SET RSX CON BIN
  6. ;
  7. ;    Alternate internal flow control and multibuffering for RSX11M/M=
  8. ;    If it turns out that this option work ok, then we will replace
  9. ;    Bob's code with this. RSX is a P A I N  with it's ttdrv.
  10.  
  11.     .ident    /8.0.02/
  12.     .psect
  13.  
  14.  
  15.  
  16.  
  17.     .include    /IN:K11MAC.MAC/
  18.     .iif ndf    ,k11inc    ,.error    ; missing INCLUDE for K11MAC.MAC
  19.  
  20.  
  21.  
  22.  
  23.  
  24.     .sbttl    RSX Connect code - Rev. Notes
  25.  
  26. ;
  27. ; This is the terminal emulator for Kermit-11 on native RSX.  It was
  28. ; rewritten because the original version developed on the RSTS emulator
  29. ; was unsuitable for native RSX.  It wouldn't work reliably at baud
  30. ; rates over 1200 on a moderately busy system.
  31. ;
  32. ;
  33. ; Bob Denny    10-Mar-84
  34. ;
  35. ;    NOTE:    vt125's are a problem as they don't send xon when you type one
  36. ;
  37. ; John Pieper    840607        fix for connecting to an autocall modem
  38. ;    Note:  Autocall modems are a pain under RSX.
  39. ;    If the  TTnn:  is set  /remote ,
  40. ;      the Terminal Handler will NOT let you talk to it until it senses
  41. ;      DSR .  This logic is based on the assumption that a remote line
  42. ;      will be used only for incoming calls.
  43. ;    If the  TTnn:  is set  /noremote ,
  44. ;      then you can talk to it, but the Terminal Handler will drop  DTR .
  45. ;      Thus, unless your modem has a local  DTR  override, it thinks
  46. ;      that you are not connected to it.
  47. ;    Solution:  RSX-11m V4.1  allows  TC.DLU = 2
  48. ;      which holds  DTR  but allows you to talk without having  DSR .
  49. ;    Note -- this mechanism is NOT available from  MCR  level.
  50. ;      Further,  TC.DLU  must be reset to 1 when KERMIT is done or else
  51. ;      the system will not recognize the  TT  as really being remote --
  52. ;      things such as  .IFF <LOCAL>  in an indirect command file will fail.
  53. ;
  54. ;  John Pieper    840614    Slave Terminal Fix!
  55. ;    Due to a change in the Terminal Handler, a slaved terminal must also
  56. ;      be attached or else unsolicited input will NOT be kept in the
  57. ;      typeahead buffer.  (See Software Dispatch Dec. 1983).
  58. ;      Terminal Emulation sure works better with this fix !!
  59. ;
  60. ;  Rich Seibel  850605  Double buffered I/O
  61. ;       It still didn't work at 4800 baud.  Added double buffering
  62. ;         of the remote to local data.  Flow control was not reliable,
  63. ;      so added internal flow control (XON/XOFF).
  64. ;
  65. ;  Brian Nelson 16-Jul-85  15:14:37  Insure XON sent iff XOFF sent
  66. ;                     Split from mainline code into overlay
  67. ;                     via SET RSX CON BIN
  68. ;                     The other mod re SET RSX TC.DLU is NOT
  69. ;                     in this module as of yet. wait........
  70. ;                     if this module works better, then ....
  71.  
  72.  
  73.     .sbttl    RSX Connect code - Definitions
  74.  
  75.  
  76.     ef.lot    = 13.            ; Local output event flag
  77.     em.lot    = 010000        ; Local output event flag mask
  78.     ef.rem    = 14.            ; Remote event flag
  79.     em.rem    = 020000        ; Remote event flag mask
  80.     ef.loc    = 15.            ; Local event flag
  81.     em.loc    = 040000        ; Local event flag mask
  82.  
  83. ;
  84. ; LOCAL IMPURE DATA
  85. ;
  86.     .psect    $idata    rw,d,lcl,rel,con
  87. ;
  88. ; Characteristics buffers
  89.  
  90. ;    Note: TC.SLV must be second in the list   BDN 18-Apr-84  10:47:18
  91.  
  92.  
  93. sentxof:.word    0                ; did we ever send XOFF ?
  94.  
  95. savti:    .byte    TC.FDX,0,TC.SLV,0,TC.BIN,0    ; Original setting for remote
  96. sizti = .-savti                    ; for the next time 
  97.  
  98. savco:    .byte    TC.FDX,0            ; Original setting for local
  99.  
  100. fdxchr:    .byte    TC.FDX,1,TC.SLV,1,TC.BIN,1    ; Change to FDX if required
  101. sizchr = .-fdxchr
  102.  
  103.  
  104. ;  Buffers for Autocall modem fix
  105.  
  106. savti2:    .byte    TC.DLU,0,TC.ABD,0    ; TC.ABD maybe not needed - can't hurt
  107.     sizti2    =  .-savti2        ;  in case we ever add more functions
  108. fixti2:    .byte    TC.DLU,2,TC.ABD,0    ; values we need for a modem
  109.  
  110. rtab:    .byte    TC.TBF,0        ; #chars in remote typeahead
  111. ltab:    .byte    TC.TBF,0        ; #chars in local typeahead
  112.  
  113.  
  114.  
  115.  
  116.     .mcall    qio$    qiow$
  117. ;
  118. ; Oft' used QIO DPB's
  119. ;
  120. remread:
  121.     qio$    <io.rne!tf.ral>,lun.ti,ef.rem,,remios,,<rembf,1>
  122. locread:
  123.     qio$    <io.rne!tf.ral>,lun.co,ef.loc,,locios,,<locbf,1>
  124. remwrite:
  125.     qiow$    io.wal,lun.ti,ef.loc,,,,<locbf,1>
  126. locwrite:
  127.     qio$    io.wal,lun.co,ef.lot,,,,<bufptr>
  128. locech:
  129.     qiow$    io.wal,lun.co,ef.rem,,,,<locbf,1>
  130. remtest:
  131.     qiow$    sf.gmc,lun.ti,ef.rem,,remios,,<rtab,2>
  132. remtab:
  133.     qiow$    <io.rne!tf.ral>,lun.ti,ef.rem,,remios,,<bufptr+1>
  134. remxoff:
  135.     qiow$    io.wal,lun.ti,ef.rem,,,,<xoff,1>
  136. remxon:
  137.     qiow$    io.wal,lun.ti,ef.lot,,,,<xon,1>
  138.  
  139. ;
  140. ; Other stuff
  141. ;
  142. efbuf:    .blkw    4                ; Event flags buffer
  143. rembf:    .blkb    2                ; Remote data buffer
  144. rembf1:    .blkb    256.                ; Local output data buffer
  145. rembf2:    .blkb    256.                ; Local output data buffer
  146. bufptr: .word    0                ; Local output buffer pointer
  147. locbf:    .blkb    2                ; Local data buffer
  148. eseen:    .word    0                ; 1 = escape seen
  149. locios:    .word    0,0
  150. remios:    .word    0,0
  151.  
  152.     .psect    $code
  153.  
  154.  
  155.  
  156. ;    .sbttl    RSX Connect Code -- Setup
  157.  
  158.  
  159.     .mcall    qio$    qiow$    qiow$s    dir$    wtlo$s    setf$s
  160.     .mcall    alun$s    dscp$s    encp$s    exit$s    rdaf$s    srex$s
  161.  
  162.     .sbttl    Connect code for RSX kermit 
  163. ;
  164. ;     D O C O N N  -  Connect for native RSX
  165. ;
  166. ; Assumes that the remote device has been attached via the
  167. ; SET LINE command and its "asslun()" routine.
  168.  
  169.     .enabl    lsb
  170.  
  171.  
  172. xdorsx::message    <Alternate RSX connect code called>,cr
  173.     clr    eseen            ; must do this for next connect cmd
  174.     calls    ttpars    ,<#ttname>    ; Get remote unit number
  175.     srex$s    #rsxabo            ; abort perhaps
  176.     alun$s    #lun.ti,r1,r0        ; Assign it
  177.     alun$s    #lun.co,#"TI,#0        ; Assign our local terminal
  178.     tst    proflg
  179.     bne    5$            ; yes, don't try to attach xk0:
  180.     qiow$s    #io.att,#lun.ti,#ef.rem    ; and now Attach it. (jfp 840614)
  181. 5$:
  182.     ;
  183.     ; Save local and remote's /{NO}FULLDUPLEX settings, and
  184.     ; set them to /FULLDUPLEX.  Then DISABLE CHECKPOINTING
  185.     ; so asynchronous buffered I/O is disabled and true full
  186.     ; duplex communication can take place.
  187.     ; BDN 18-Apr-84  10:41:51  Also force slave mode
  188.     ;
  189.     qiow$s    #sf.gmc,#lun.ti,#ef.rem,,,,<#savti,#sizti>    ; Crude
  190.     qiow$s    #sf.gmc,#lun.co,#ef.loc,,,,<#savco,#2>
  191.     qiow$s    #sf.smc,#lun.ti,#ef.rem,,#remios,,<#fdxchr,#sizchr>
  192.     qiow$s    #sf.smc,#lun.co,#ef.loc,,#remios,,<#fdxchr,#2>
  193.  
  194.     ; If  lun.ti  is currently /noremote (hard wire connection), leave it.
  195.     ; Notify user to make sure correct  TT number.
  196.     ; If it is /remote , fix it for autocall.
  197.  
  198.     tst    proflg
  199.     bne    10$
  200.     qiow$s    #sf.gmc,#lun.ti,#ef.rem,,,,<#savti2,#sizti2>
  201.     tstb    savti2+1            ; currently /remote ?
  202.     bne    6$                ;  Yes
  203.     message    <Note:  This is NOT a Remote line.>,cr
  204.     br    10$                ; that's all we do if local.
  205. 6$:
  206. ;-    qiow$s    #sf.smc,#lun.ti,#ef.rem,,,,<#fixti2,#sizti2>    ; fix it.
  207. 10$:    dscp$s                    ; **DISABLE CHECKPOINTING**
  208.  
  209.  
  210.  
  211.     .sbttl    RSX Connect code - Remote Input
  212.     ;
  213.     ; Prime incoming and outgoing streams
  214.     ;
  215.     dir$    #remread
  216.     dir$    #locread
  217.     setf$s    #ef.lot                ; Signal local output available
  218.     clr    sentxof                ; no xoff's have been sent
  219.     clr    r3                ; Count of rem buffer (empty)
  220.     mov    #rembf1,bufptr            ; Pick a buffer
  221.  
  222.     ;
  223.     ; Main loop - Handle incoming and outgoing streams
  224.     ; until escape character is detected on outgoing (local KB)
  225.     ;
  226. 20$:    wtlo$s    0,#<em.loc!em.rem!em.lot>    ; Wait for a character on either
  227.     rdaf$s    #efbuf                ; Read the event flags
  228.  
  229.     ;
  230.     ; Handle character(s) on incoming stream
  231.     ;
  232.     bit    #em.rem,efbuf+0            ; Anything coming in?
  233.     beq    30$                ; (no)
  234.     movb    remios    ,r5            ; get the status of the read
  235.     call    iocheck                ; and check for allowable errors
  236.     bcs    23$                ; fatal (likely was IE.DNR)
  237.  
  238.     mov    bufptr    ,r1            ; Get buffer
  239.     add    r3    ,r1            ; and position in buffer
  240.     movb    rembf    ,(r1)+            ; put in character
  241.     inc    r3                ; running count of buffer
  242.  
  243.     dir$    #remtest            ; More in typeahead?
  244.     movb    remios    ,r5            ; get the status of the read
  245.     call    iocheck                ; and check for allowable errors
  246. 23$:    bcs    100$                ; fatal (likely was IE.DNR)
  247.  
  248.     clr    r0                ; m+ may have a lot ready to get
  249.     bisb    rtab+1,r0            ; r0 = # in typeahead
  250.     beq    25$                ; (no)
  251.     add    r0    ,r3            ; keep count of buffer
  252.     mov    r1,remtab+q.iopl        ; Set address to drain into
  253.     mov    r0,remtab+q.iopl+2        ; Set # to read to drain
  254.     dir$    #remtab                ; Read 'em in
  255. ;-    movb    remios    ,r5            ; get the status of the read
  256. ;-    call    iocheck                ; and check for allowable errors
  257. ;-    bcs    100$                ; fatal (likely was IE.DNR)
  258.  
  259. 25$:    cmp    r3    ,#20            ; Check for buffer fill limit 
  260.     ble    28$                ; not yet
  261.     dir$    #remxoff            ; Stop input please
  262.     mov    sp    ,sentxof        ; flag that we sent an XOFF
  263.  
  264. 28$:    dir$    #remread            ; Re-issue input
  265.  
  266.  
  267.     .sbttl    RSX Connect code - Local Output
  268.     ;
  269.     ; Handle completion of output to local terminal
  270.     ; and check for more output available
  271.     ;
  272. 30$:    bit    #em.lot,efbuf+0            ; Check output flag
  273.     beq    40$                ; (no, still busy)
  274.  
  275.     tst    r3                ; Anything to output
  276.     beq    40$                ; no
  277.  
  278.     mov    bufptr,locwrite+q.iopl        ; Buffer to write
  279.     mov    r3,locwrite+q.iopl+2        ; amount to write
  280.     dir$    #locwrite            ; Start the output
  281.  
  282.     bit    #log$co,trace            ; Is logging enabled
  283.     beq    34$                ; no
  284.     mov    bufptr,r1            ; start of data
  285. 32$:    calls    putc,<(r1)+,#lun.lo>        ; put character
  286.     sob    r3,32$                ; til count exhausted
  287.  
  288. 34$:    cmp    bufptr,#rembf1            ; switch buffers
  289.     beq    36$
  290.     mov    #rembf1,bufptr
  291.     br    38$
  292. 36$:    mov    #rembf2,bufptr
  293. 38$:    clr    r3                ; New buffer is empty
  294.  
  295.     tst    sentxof                ; skip if we never sent an
  296.     beq    39$                ; xoff please
  297.     dir$    #remxon                ; Start input if stopped
  298.     clr    sentxof                ; no xoff's are active now
  299. 39$:
  300.  
  301.  
  302.  
  303.     .sbttl    RSX Connect code - Local Input
  304.     ;
  305.     ; Handle characters on outgoing (Local input) stream
  306.     ;  do this without fast-drain (yet)
  307.     ;
  308. 40$:    bit    #em.loc,efbuf+0            ; Anything typed locally?
  309.     beq    20$                ; (no, loop back)
  310.  
  311.     movb    locbf,r1            ; r1 = just typed character
  312.     bic    #^C177,r1            ; drop bit 7 if mark set (BDN)
  313.     cmpb    r1,conesc            ; Console escape?
  314.     bne    50$                ; (no)
  315.     tst    eseen                ; Already seen one escape?
  316.     bne    60$                ; (yes, send this one)
  317.     inc    eseen                ; Yes, note it for now
  318.     br    70$                ; And go read again
  319.  
  320. 50$:    tst    eseen                ; Character following conesc?
  321.     beq    60$                ; (no, send it)
  322.     call    concmd                ; Yup, process it
  323.     clr    eseen                ; clear the flag
  324.     tst    r0                ; Exit CONNECT mode?
  325.     bgt    100$                ; (yes, clean up etc.)
  326.     blt    70$                ; no, but it was a command
  327.  
  328. 60$:    clr    eseen                ; clear the flag
  329.     setpar    locbf    ,locbf            ; set correctr outgoing parity
  330.     dir$    #remwrite            ; Transmit character to remote
  331.     tst    duplex                ; ibm type things today?
  332.     beq    70$                ; no
  333.     dir$    #locech                ; need half duplex duplex ?
  334. 70$:    dir$    #locread            ; Re-issue local read
  335.     jmp    20$                ; Loop back
  336.  
  337.     .sbttl    RSX Connect code - Clean Up and Exit
  338.  
  339. ;
  340. ; Exit CONNECT mode
  341. ;
  342. 100$:    call    rsxrst            ; restore terminal settings
  343.     encp$s                ;**ENABLE CHECKP**
  344.     return
  345.  
  346.     
  347.  
  348. rsxabo:    call    rsxrst            ; called via requested exit
  349.     srex$s                ; disable further exits
  350.     exit$s                ; bye
  351.  
  352.  
  353. rsxrst:    qiow$s    #io.kil,#lun.ti,#ef.rem        ; Kill incoming I/O
  354.     qiow$s    #io.kil,#lun.co,#ef.loc        ; Kill incoming I/O
  355.     qiow$s    #sf.smc,#lun.ti,#ef.rem,,,,<#savti,#sizti>    ; Restore lines
  356.     qiow$s    #sf.smc,#lun.co,#ef.loc,,,,<#savco,#2>
  357.     qiow$s    #sf.smc,#lun.ti,#ef.rem,,,,<#savti2,#sizti2>    ;jfp
  358.     qiow$s    #io.det,#lun.ti,#ef.rem        ; De-Attach remote line
  359.     return
  360.  
  361.  
  362. iocheck:mov    r0    ,-(sp)        ; insure this is saved
  363.     tstb    r5            ; sucessesful read qio ?
  364.     bpl    180$            ; yes
  365.     scan    r5    ,#200$        ; allowable error code ?
  366.     tst    r0            ; well
  367.     bne    180$            ; yes, let it through
  368.     neg    r5            ; make > 0 for direrr macro
  369.     direrr    r5            ; simple
  370.     sec                ; failure, exit to command level
  371.     br    190$            ; bye
  372. 180$:    clc                ; success, stay in connect code
  373. 190$:
  374.     mov    (sp)+    ,r0        ; restore old r0 please
  375.     return
  376.  
  377. 200$:    .byte    IE.BCC    ,IE.DAO    ,IE.IES    ,IE.NOD    ,IE.PES    ,IE.VER    ,0
  378.     .even
  379.  
  380.  
  381.     global    <conesc    ,ttcons    ,ttname    ,lun.co    ,lun.ti>
  382.  
  383.     .dsabl    lsb
  384.  
  385.  
  386.  
  387.  
  388.     .sbttl    dump i/o to a log file ?
  389.  
  390.  
  391. dumplo:    bit    #log$co    ,trace        ; is this enabled ?
  392.     beq    100$            ; no
  393.     save    <r0>            ; yes, save temps please
  394.     calls    putc,<r1,#lun.lo>    ; thats it folks
  395.     unsave    <r0>
  396. 100$:    return
  397.  
  398.  
  399.  
  400. sxon:    tst    conflow
  401.     beq    100$
  402.     calls    binwri    ,<#xon,#1,#lun.ti>
  403. 100$:    return
  404.  
  405. sxoff:    tst    conflow
  406.     beq    100$
  407.     calls    binwri    ,<#xoff,#1,#lun.ti>
  408. 100$:    return
  409.  
  410.  
  411.     .save
  412.     .psect    $pdata
  413. xon:    .byte    'Q&37
  414. xoff:    .byte    'S&37
  415.     .even
  416.     .restore
  417.  
  418.  
  419.  
  420.     global    <lun.lo    ,putcr0    ,trace    ,conflow>
  421.  
  422.  
  423.  
  424.     .end
  425.