home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / unix / volume27 / fas-2.11.0 / part04 < prev    next >
Text File  |  1993-10-12  |  61KB  |  1,536 lines

  1. Newsgroups: comp.sources.unix
  2. From: fas@geminix.in-berlin.de (FAS Support Account)
  3. Subject: v27i070: FAS-2.11.0 - asynch serial driver for System V, Part04/08
  4. References: <1.750471074.20539@gw.home.vix.com>
  5. Sender: unix-sources-moderator@gw.home.vix.com
  6. Approved: vixie@gw.home.vix.com
  7.  
  8. Submitted-By: fas@geminix.in-berlin.de (FAS Support Account)
  9. Posting-Number: Volume 27, Issue 70
  10. Archive-Name: fas-2.11.0/part04
  11.  
  12. #!/bin/sh
  13. # this is fas211pl0.04 (part 4 of a multipart archive)
  14. # do not concatenate these parts, unpack them in order with /bin/sh
  15. # file fas.7.cat continued
  16. #
  17. if test ! -r _shar_seq_.tmp; then
  18.     echo 'Please unpack part 1 first!'
  19.     exit 1
  20. fi
  21. (read Scheck
  22.  if test "$Scheck" != 4; then
  23.     echo Please unpack part "$Scheck" next!
  24.     exit 1
  25.  else
  26.     exit 0
  27.  fi
  28. ) < _shar_seq_.tmp || exit 1
  29. if test ! -f _shar_wnt_.tmp; then
  30.     echo 'x - still skipping fas.7.cat'
  31. else
  32. echo 'x - continuing file fas.7.cat'
  33. sed 's/^X//' << 'SHAR_EOF' >> 'fas.7.cat' &&
  34. X           control CCCCTTTTSSSS will    go low and therefore the output    gets
  35. X           blocked.     If at this time there are still characters in the
  36. X           output buffer the last process closing this port    can't ter-
  37. X           minate until the    buffer has drained.  But as DDDDSSSSRRRR    will also
  38. X           go low if you switch off    the device the blocking    of the out-
  39. X           put will    be prevented.
  40. X
  41. X           In short:  Hardware output handshake is only used if the
  42. X           connected device    sets DDDDSSSSRRRR high, that is,    the device is
  43. X           switched    on and is ready.  So make sure that you    keep this
  44. X           in mind when you    make serial cables and when you    configure
  45. X           your serial devices.  DDDDSSSSRRRR must be on if you want    CCCCTTTTSSSS
  46. X           handshake.
  47. X
  48. X           The other advantage of this CCCCTTTTSSSS/DDDDSSSSRRRR mechanismn is that you
  49. X           can still connect "dumb"    serial devices to an _F_A_S hardware
  50. X           handshake port using a minimal 3-wire cable.  As    an uncon-
  51. X           nected DDDDSSSSRRRR line is automatically    low, hardware output
  52. X           handshake is disabled, which is just what you want in this
  53. X           case.  However, it's safer to use a minor device    number of 0000
  54. X           + device    # for 3-wire cables (see section CCCCAAAABBBBLLLLIIIINNNNGGGG).
  55. X
  56. X           The CLOCAL flag doesn't affect this mode.
  57. X
  58. X           Note: If    you use    a minor    device number where hardware
  59. X             handshake is disabled (see    ``First    mode'' below) you
  60. X             can, if you have SCO UNIX 3.2.4, enable full duplex
  61. X             hardware flow control by setting the CRTSFL _t_e_r_m_i_o(M)
  62. X             flag.  This works,    however, only if neither
  63. X             CTSFLOW/RTSFLOW nor CLOCAL    are set.
  64. X
  65. X             In    SCO UNIX 3.2.4.2 the meaning of    CTSFLOW/RTSFLOW    has
  66. X
  67. X
  68. X      Rev. Release 2.11.0                         Page 7
  69. X
  70. X
  71. X
  72. X
  73. X
  74. X
  75. X      FAS(7)            UNIX System    V             FAS(7)
  76. X
  77. X
  78. X
  79. X             changed.  These flags enable full duplex hardware flow
  80. X             control.  For backward compatibility there    is the
  81. X             ORTSFL flag which enables,    when set together with
  82. X             CTSFLOW and/or RTSFLOW, half duplex flow control.
  83. X             These flags only work if CLOCAL is    nnnnooootttt set.
  84. X
  85. X         Half duplex mode
  86. X           There are actually three    half duplex modes selected by the
  87. X           minor device number:
  88. X
  89. X          First    mode
  90. X             If    the RTSFLOW _t_e_r_m_i_o(M) flag is set and the CLOCAL
  91. X             flag is nnnnooootttt set the RRRRTTTTSSSS line is used to signal the
  92. X             connected device that there is data in the    output
  93. X             buffer.  As long as there is output data to come the
  94. X             RRRRTTTTSSSS line stays high.  If the output buffer    has drained
  95. X             RRRRTTTTSSSS drops to low until there is more data to be sent
  96. X             to    the connected device.
  97. X
  98. X             If    the CTSFLOW _t_e_r_m_i_o(M) flag is set and the CLOCAL
  99. X             flag is nnnnooootttt set the CCCCTTTTSSSS line is used to control the
  100. X             output character flow.  This works    as in full duplex
  101. X             mode.
  102. X
  103. X             If    neither    CTSFLOW    nor RTSFLOW are    set hardware flow
  104. X             control is    disabled.  But see the description of the
  105. X             CRTSFL/ORTSFL _t_e_r_m_i_o(M) flags at the end of the sec-
  106. X             tion FFFFuuuullllllll dddduuuupppplllleeeexxxx mmmmooooddddeeee.
  107. X
  108. X             Note: Setting the CTSFLOW and RTSFLOW flags (and
  109. X               CRTSFL/ORTSFL, if available)    only applies to    SCO
  110. X               UNIX    and Xenix.  To my knowledge, other UNIX
  111. X               flavors don't have these flags.  For    them,
  112. X               hardware flow control is always disabled in this
  113. X               mode.
  114. X
  115. X          Second mode
  116. X             This mode overrides the RTSFLOW, CTSFLOW, CRTSFL and
  117. X             ORTSFL flags and works as if the CTSFLOW flag is set
  118. X             permanently (all UNIX flavors).  The CLOCAL flag
  119. X             doesn't affect this mode.
  120. X
  121. X          Third    mode
  122. X             This mode overrides the RTSFLOW, CTSFLOW, CRTSFL and
  123. X             ORTSFL flags and works as if both the RTSFLOW and
  124. X             CTSFLOW flags (in SCO UNIX    prior to 3.2.4.2 and SCO
  125. X             Xenix) are    set permanently    (all UNIX flavors).  The
  126. X             CLOCAL flag doesn't affect    this mode.
  127. X
  128. X           Note: Under SCO UNIX prior to 3.2.4.2 and Xenix the
  129. X             _t_e_r_m_i_o(M) RTSFLOW flag is intended    for half duplex
  130. X             hardware flow control devices.  Setting it    when the
  131. X             connected device does ffffuuuullllllll    duplex hardware    flow
  132. X
  133. X
  134. X      Rev. Release 2.11.0                         Page 8
  135. X
  136. X
  137. X
  138. X
  139. X
  140. X
  141. X      FAS(7)            UNIX System    V             FAS(7)
  142. X
  143. X
  144. X
  145. X             control is    a configuration    error!    The RRRRTTTTSSSS    signalling
  146. X             for half duplex devices has a completely different
  147. X             meaning than for full duplex devices.  So you should
  148. X             either set    only CTSFLOW (or CRTSFL, if available),    or
  149. X             you should    select hardware    flow control via the minor
  150. X             device number.  If    you set    RTSFLOW    for full duplex
  151. X             hardware flow control devices it is likely    that the
  152. X             port won't    work.  This is in line with SCO's _s_i_o
  153. X             driver implementation.
  154. X
  155. X         Direct control
  156. X           On UNIX flavors where the RTS_TOG _i_o_c_t_l(2|S) command is
  157. X           available the hardware handshake    output (RRRRTTTTSSSS by default)    can
  158. X           be set under program control.  An _i_o_c_t_l(2|S) argument of    0000
  159. X           sets the    output to low and an argument of 1111 sets    it to high.
  160. X           However,    this only works    if the hardware    handshake modes    as
  161. X           well as _V_P/_i_x DOS mode are disabled.  If    one of these modes
  162. X           is enabled _F_A_S needs the    hardware handshake output for its
  163. X           own flow    control.
  164. X
  165. X           On the other hand, even if one of these modes is    in use and
  166. X           _F_A_S gets    an RTS_TOG command, the    state of the handware
  167. X           handshake output    that this command tries    to set is stored
  168. X           and the output is set to    the state of the last RTS_TOG com-
  169. X           mand as soon as both hardware handshake mode and    DOS mode
  170. X           are disabled.
  171. X
  172. X           In other    words, _F_A_S doesn't ignore the RTS_TOG command if
  173. X           hardware    handshake modes    or DOS mode are    set but    rather
  174. X           overrides the hardware handshake    output with the    appropriate
  175. X           state computed internally.
  176. X
  177. X      _V_P/_i_x    SUPPORT
  178. X           _F_A_S allows DOS programs running under _V_P/_i_x to access serial
  179. X           ports.  You simply need to modify your personal _V_P/_i_x confi-
  180. X           guration    file (_v_p_i_x._c_n_f)    to tell    the DOS    emulator which _F_A_S
  181. X           devices to use for COM1 (or COM1MOUSE) and COM2.
  182. X
  183. X           Note that _V_P/_i_x opens these devices at startup time, so you
  184. X           better make sure    that the desired devices aren't    used by
  185. X           other processes when you    start _V_P/_i_x as _V_P/_i_x wants to use
  186. X           them exclusively.
  187. X
  188. X           There are some special features with the    handling of the    RRRRTTTTSSSS
  189. X           and DDDDTTTTRRRR lines you should    know about.  If    your DOS program
  190. X           asserts the DDDDTTTTRRRR line this will actually cause action on the
  191. X           modem enable line you configured    in _s_p_a_c_e._c.  Likewise, RRRRTTTTSSSS
  192. X           asserts the half    duplex hardware    handshake line configured
  193. X           in _s_p_a_c_e._c.
  194. X
  195. X           If the used _F_A_S device has full duplex hardware handshake
  196. X           enabled,    asserting RRRRTTTTSSSS from DOS actually    stops the character
  197. X           flow from _F_A_S to    _V_P/_i_x.    This prevents input buffers of
  198. X
  199. X
  200. X      Rev. Release 2.11.0                         Page 9
  201. X
  202. X
  203. X
  204. X
  205. X
  206. X
  207. X      FAS(7)            UNIX System    V             FAS(7)
  208. X
  209. X
  210. X
  211. X           interrupt driven    DOS programs from overflowing.    _F_A_S, on    the
  212. X           other hand, uses    its hardware handshake to prevent an over-
  213. X           flow of its own input buffer.  Therefore, you can use DOS
  214. X           telecommunication programs even at high baud rates without
  215. X           losing characters, provided your    DOS programs are configured
  216. X           to use full duplex RRRRTTTTSSSS/CCCCTTTTSSSS flow control.
  217. X
  218. X           All this    virtual    handling has the advantage that    the DOS
  219. X           program doesn't need to know certain details about your
  220. X           actual port setup.  Reading the modem status register, on
  221. X           the other hand, doesn't cause any translation of    the regis-
  222. X           ter value.
  223. X
  224. X           To enable _V_P/_i_x support,    the HAVE_VPIX define in    _f_a_s._h has
  225. X           to be uncommented.
  226. X
  227. X      MODIFYING A PORT'S DEFAULT BEHAVIOUR
  228. X           There are some flags that you can set in    the _f_a_s__m_o_d_i_f_y[]
  229. X           array (_s_p_a_c_e._c) for each    port independently.  You have to
  230. X           relink the kernel before    these flags have any effect.  Here
  231. X           is a description:
  232. X
  233. X          NNNNOOOO____TTTTEEEESSSSTTTT
  234. X             If    for some reason    a UART doesn't pass the    functional-
  235. X             lity test _F_A_S makes at boot time you can override the
  236. X             test result and use this port, anyway.  However, you
  237. X             do    this on    your own risk.    Don't be surprised if ports
  238. X             get hung or your machine crashes.    I won't    support    _F_A_S
  239. X             installations where this flag is used.  It    is intended
  240. X             as    a last resort.
  241. X
  242. X             There is one exception to this, though.  If the
  243. X             NNNNOOOO____TTTTEEEESSSSTTTT flag is already set in the    sample config files
  244. X             for certain serial    cards and provided that    these sam-
  245. X             ple files are part    of the original    _F_A_S distribution,
  246. X             you won't lose my support because in this case I've
  247. X             tested the    respective product myself and decided that
  248. X             it    is safe    to use the NNNNOOOO____TTTTEEEESSSSTTTT flag    with it.
  249. X
  250. X          NNNNOOOO____HHHHUUUUPPPP____PPPPRRRROOOOTTTTEEEECCCCTTTT
  251. X             Normally, with modem control enabled, after the car-
  252. X             rier is lost the carrier is ignored and assumed to    be
  253. X             missing even if the physical carrier line is asserted
  254. X             again.
  255. X
  256. X             Additionally, as the device can't accept a    call in
  257. X             this state, anyway, the modem enable line is set to
  258. X             low so that the modem won't answer    calls.    This
  259. X             prevents users from getting the shell of a    previous
  260. X             user in case that the shell doesn't react to SIGHUP
  261. X             for some reason.  So the modem port is dead until this
  262. X             situation is dealt    with.
  263. X
  264. X
  265. X
  266. X      Rev. Release 2.11.0                        Page 10
  267. X
  268. X
  269. X
  270. X
  271. X
  272. X
  273. X      FAS(7)            UNIX System    V             FAS(7)
  274. X
  275. X
  276. X
  277. X             This adds some security to    modem ports.  However, if
  278. X             this feature breaks one of    your applications for some
  279. X             reason, just set NNNNOOOO____HHHHUUUUPPPP____PPPPRRRROOOOTTTTEEEECCCCTTTT and the hangup protec-
  280. X             tion is disabled for this port.
  281. X
  282. X          NNNNOOOO____OOOOVVVVEEEERRRRRRRRUUUUNNNN
  283. X             The device    has some sort of receiver overrun protec-
  284. X             tion.  For    instance, it may be used with certain
  285. X             internal modems that use a    _N_S_1_6_x_5_0    UART emulation and
  286. X             have their    own receiver buffer.  This flag    only
  287. X             affects the position of the device    in the interrupt
  288. X             users chain, that is, because the device can't overrun
  289. X             it    is serviced only after all devices that    don't have
  290. X             an    overrun    protection have    been taken care    of.
  291. X
  292. X          NNNNEEEEWWWW____CCCCTTTTSSSSRRRRTTTTSSSS
  293. X             Some "intelligent"    serial cards from third    party ven-
  294. X             dors have the meaning of the RTSFLOW _t_e_r_m_i_o(M) flag
  295. X             redefined.     It is used, together with CTSFLOW, to
  296. X             enable full duplex    hardware flow control, whereas SCO
  297. X             introduced    RTSFLOW    for the    more traditional half
  298. X             duplex hardware flow control that is implemented in
  299. X             their _s_i_o driver.    By default, _F_A_S    emulates the _s_i_o
  300. X             driver for    compatibility reasons.
  301. X
  302. X             However, if you like to use CTSFLOW/RTSFLOW for full
  303. X             duplex hardware flow control in a way that    is compati-
  304. X             ble with the above    mentioned "intelligent"    cards, you
  305. X             can do this by setting NNNNEEEEWWWW____CCCCTTTTSSSSRRRRTTTTSSSS.     Also,
  306. X             CTSFLOW/RTSFLOW are no longer affected by CLOCAL if
  307. X             NNNNEEEEWWWW____CCCCTTTTSSSSRRRRTTTTSSSS    is set.     In this mode CTSFLOW enables the
  308. X             output flow control and RTSFLOW enables the input flow
  309. X             control.  Both flags are independent from each other.
  310. X
  311. X             Note that under SCO UNIX 3.2.4.2 the CTSFLOW/RTSFLOW
  312. X             flags have    changed    their meaning in that they enable
  313. X             full duplex hardware flow control.
  314. X
  315. X           These flags are defined in _f_a_s._h.  For example, if you want
  316. X           to use the meaning of RTSFLOW that is compatible    to some    of
  317. X           the "intelligent" serial    cards you would    write
  318. X
  319. X            NEW_CTSRTS
  320. X
  321. X           at the appropriate position in _f_a_s__m_o_d_i_f_y[].  If    you addi-
  322. X           tionally    want to    skip the test routine for this port you
  323. X           would write
  324. X
  325. X            NO_TEST | NEW_CTSRTS
  326. X
  327. X      UART FIFO CONTROL
  328. X           In order    to control the operating modes of UARTs    that have
  329. X           built-in    FIFOs you can select the desired mode for each port
  330. X
  331. X
  332. X      Rev. Release 2.11.0                        Page 11
  333. X
  334. X
  335. X
  336. X
  337. X
  338. X
  339. X      FAS(7)            UNIX System    V             FAS(7)
  340. X
  341. X
  342. X
  343. X           independently by    modifying the _f_a_s__f_i_f_o__c_t_l[] array
  344. X           (_s_p_a_c_e._c).  You have to relink the kernel before    these
  345. X           changes have any    effect.     There are a number of predefined,
  346. X           mutually    exclusive symbols available:
  347. X
  348. X          FFFFIIIIFFFFOOOO____DDDDEEEEFFFFAAAAUUUULLLLTTTT
  349. X             All UART types with FIFOs.
  350. X             The FIFOs are enabled and in case that an _N_S_1_6_5_5_0_A    was
  351. X             detected, the receiver FIFO trigger level is set to 4
  352. X             or    8 characters (depending    on the UNIX flavour, see
  353. X             the description of    LOW_INT_LAT in section
  354. X             TTTTRRRROOOOUUUUBBBBLLLLEEEE----SSSSHHHHOOOOOOOOTTTTIIIINNNNGGGG, subsection CCCChhhhaaaarrrraaaacccctttteeeerrrr lllloooossssssss).
  355. X
  356. X          FFFFIIIIFFFFOOOO____OOOOFFFFFFFF
  357. X             All UART types with FIFOs.
  358. X             The FIFOs are disabled and    the UART works in the
  359. X             _N_S_1_6_4_5_0 compatible    mode.
  360. X
  361. X          FFFFIIIIFFFFOOOO____EEEEMMMMUUUULLLL____NNNNSSSS11116666444455550000
  362. X             All UART types with FIFOs.
  363. X             The FIFOs are enabled and in case that an _N_S_1_6_5_5_0_A    was
  364. X             detected, the receiver FIFO trigger level is set to 1
  365. X             character.     The transmitter FIFO is filled    with only 1
  366. X             character per transmitter interrupt.  This    emulates
  367. X             the _N_S_1_6_4_5_0 UART and additionally gives you the over-
  368. X             run protection provided by    the receiver FIFO.
  369. X
  370. X          FFFFIIIIFFFFOOOO____PPPPOOOOIIIINNNNTTTTEEEERRRR____DDDDEEEEVVVV
  371. X             _N_S_1_6_5_5_0_A, only.
  372. X             The FIFOs are enabled and the receiver FIFO trigger
  373. X             level is set to 1 character.  This    should be used for
  374. X             pointer devices like mice or trackballs because it
  375. X             prevents the short    receiver FIFO timeout delay that
  376. X             could lead    to jerky pointer movement.
  377. X
  378. X          FFFFIIIIFFFFOOOO____TTTTRRRRIIIIGGGGGGGGEEEERRRR____1111
  379. X             _N_S_1_6_5_5_0_A, only.
  380. X             The FIFOs are enabled and the receiver FIFO trigger
  381. X             level is set to 1 character.
  382. X
  383. X          FFFFIIIIFFFFOOOO____TTTTRRRRIIIIGGGGGGGGEEEERRRR____4444
  384. X             _N_S_1_6_5_5_0_A, only.
  385. X             The FIFOs are enabled and the receiver FIFO trigger
  386. X             level is set to 4 characters.
  387. X
  388. X          FFFFIIIIFFFFOOOO____TTTTRRRRIIIIGGGGGGGGEEEERRRR____8888
  389. X             _N_S_1_6_5_5_0_A, only.
  390. X             The FIFOs are enabled and the receiver FIFO trigger
  391. X             level is set to 8 characters.
  392. X
  393. X          FFFFIIIIFFFFOOOO____TTTTRRRRIIIIGGGGGGGGEEEERRRR____11114444
  394. X             _N_S_1_6_5_5_0_A, only.
  395. X             The FIFOs are enabled and the receiver FIFO trigger
  396. X
  397. X
  398. X      Rev. Release 2.11.0                        Page 12
  399. X
  400. X
  401. X
  402. X
  403. X
  404. X
  405. X      FAS(7)            UNIX System    V             FAS(7)
  406. X
  407. X
  408. X
  409. X             level is set to 14    characters.
  410. X
  411. X           Note that you can set these values even if the respective
  412. X           UART doesn't have FIFOs,    in which case they are ignored.     If
  413. X           you later upgrade to a UART with    FIFOs the FIFO control
  414. X           values automatically become active without having to build a
  415. X           new kernel.
  416. X
  417. X      SELECTING ALTERNATIVE    BAUD RATES
  418. X           The UNIX    _t_e_r_m_i_o(7|M) interface only supports baud rates of
  419. X           up to 38400 bps.     However, with the advent of V32bis and
  420. X           faster modems with compression ratios of    up to 4:1 (V.42bis)
  421. X           this upper baud rate boundary isn't adequate anymore.  Baud
  422. X           rates of    57600 or even 115200 are necessary to make full    use
  423. X           of these    modems.
  424. X
  425. X           _F_A_S provides these high baud rates even though the
  426. X           _t_e_r_m_i_o(7|M) interface doesn't know them.     To make this work,
  427. X           _F_A_S has one or more baud    rate tables in _s_p_a_c_e._c
  428. X           (_f_a_s__b_a_u_d[][]) which contain the    baud rate base and the 15
  429. X           baud rates that correspond to B50 to B38400.  Arbitrary baud
  430. X           rates can be assigned to    these baud rate    symbols.  Baud rate
  431. X           table 0 by default contains the standard    baud rates that
  432. X           coincide    with the standard _t_e_r_m_i_o(7|M) baud rates.  Table 1
  433. X           contains    the same values    for the    first 13 baud rates.  How-
  434. X           ever, B19200 is assigned    to a baudrate of 57600 and B38400
  435. X           is assigned to 115200 bps.  These values    are the    default    in
  436. X           the _F_A_S distribution, and you can change    these tables to
  437. X           whatever    values you need.
  438. X
  439. X           Note, however, that the baud rate base in this table has    to
  440. X           be dividable by all 15 baud rate    values without remainder,
  441. X           or at least with    a very small remainder.     Otherwise there
  442. X           would be    a noticeable deviation between the requested and
  443. X           the actually used baud rate.  It    helps a    little that _F_A_S
  444. X           rounds the result of this division to minimize the devia-
  445. X           tion.
  446. X
  447. X           Note also that it isn't advisable to use    the B50    and B75
  448. X           symbols for 57600 and 115200 bps.  This has two reasons.
  449. X
  450. X           In the worst case (SCO UNIX and Xenix) _F_A_S transfers the
  451. X           characters between its ring buffers and the UNIX    CLIST
  452. X           buffers only every 17 milliseconds.  This optimizes perfor-
  453. X           mance and reduces the CPU load.    Now, there are certain baud
  454. X           rate dependent threshold    values that limit the number of
  455. X           characters the CLIST buffers can    hold.  This is to reduce
  456. X           the drain time of the output buffers.  So, at low baud rates
  457. X           these thresholds    are very low, and because _F_A_S transfers
  458. X           characters only 60 times    a second, the maximum throughput
  459. X           for transmitted characters is threshold * 60.  One can
  460. X           easily calculate    that the threshold has to be at    least 192
  461. X           characters for 115200 bps (11520    cps).  A sufficient
  462. X
  463. X
  464. X      Rev. Release 2.11.0                        Page 13
  465. X
  466. X
  467. X
  468. X
  469. X
  470. X
  471. X      FAS(7)            UNIX System    V             FAS(7)
  472. X
  473. X
  474. X
  475. X           threshold is only provided for baud rates >= B9600.
  476. X
  477. X           Because the threshold table in the UNIX kernel is a global
  478. X           object that is also used    by other drivers, _F_A_S can't simply
  479. X           override    these values.  So max. throughput is only possible
  480. X           with baud rate table positions of B9600 or better.
  481. X
  482. X           The other reason    not to use B50 etc. is that programs like
  483. X           _v_i and _e_m_a_c_s make their behaviour dependent on the baud rate
  484. X           of the tty they run on.    And this behaviour clearly wouldn't
  485. X           fit baud    rates like 57600 and 115200.
  486. X
  487. X           Therefore, even if it looks tempting to use baud    rate sym-
  488. X           bols that aren't    in use anymore today (like B50 and B75),
  489. X           just don't do it.  It won't work    very well.
  490. X
  491. X           So we have two or more baud rate    tables in _s_p_a_c_e._c, one for
  492. X           the standard _t_e_r_m_i_o(7|M)    assignment and the others for
  493. X           non-standard baud rates.     You can select    which table to use
  494. X           for each    port by    simply putting the table number    in the
  495. X           _f_a_s__b_t__s_e_l_e_c_t[] array in    _s_p_a_c_e._c.  Provided you use the
  496. X           default baud rate table values you would    use a table selec-
  497. X           tor value of 0000 for ports    that should have the standard
  498. X           _t_e_r_m_i_o(7|M) baud    rate assignment, and a value of    1111 to have
  499. X           57600 and 115200    bps available instead of 19200 and 38400
  500. X           bps.
  501. X
  502. X           Note: At    speeds of more than 38400 bps it is likely that
  503. X             even an _N_S_1_6_5_5_0_A will lose    incoming characters because
  504. X             in    many UNIX flavors the worst case interrupt latency
  505. X             is    rather high.  It has to    be <= 1    ms or you are in
  506. X             trouble.  This problem is caused by the UNIX kernel
  507. X             design.  _F_A_S can't    do anything about it.  ISC UNIX
  508. X             3.0, for instance,    on a 486/33 works fine at this
  509. X             speed.  On    the other hand,    ISC UNIX 2.x can't handle
  510. X             it.  You may want to look at the description of
  511. X             LOW_INT_LAT in section TTTTRRRROOOOUUUUBBBBLLLLEEEE----SSSSHHHHOOOOOOOOTTTTIIIINNNNGGGG, subsection
  512. X             CCCChhhhaaaarrrraaaacccctttteeeerrrr lllloooossssssss.
  513. X
  514. X           Additionally to having higher baud rates    available, this
  515. X           table based baud    rate selection mechanism can be    used to
  516. X           support serial cards that don't use the standard    1.8432 MHz
  517. X           oscillator frequency.  For instance, if you have    a card that
  518. X           is equiped with a 3.6864    MHz oscillator you would have the
  519. X           additional baud rates of    57600, 76800, 96000 and    115200
  520. X           available (you shouldn't    use more than 115200 because that
  521. X           loads the CPU too much).     Just enter the    baud rate base
  522. X           (3686400    / 16 = 230400) and the 15 baud rates into one of
  523. X           the baud    rate tables in _f_a_s__b_a_u_d[][] and    select the respec-
  524. X           tive table in _f_a_s__b_t__s_e_l_e_c_t[].
  525. X
  526. X           Note that _V_P/_i_x programs    which use serial ports will select
  527. X           wrong baud rates    on ports that are driven by a non-standard
  528. X
  529. X
  530. X      Rev. Release 2.11.0                        Page 14
  531. X
  532. X
  533. X
  534. X
  535. X
  536. X
  537. X      FAS(7)            UNIX System    V             FAS(7)
  538. X
  539. X
  540. X
  541. X           oscillator, unless they know about the different    oscillator
  542. X           frequency.
  543. X
  544. X           Note also that whatever baud rate is actually used, the UNIX
  545. X           application programs still know only the    standard
  546. X           _t_e_r_m_i_o(7|M) baud    rates.    So don't wonder    if _s_t_t_y    shows you
  547. X           38400 bps on a port that    in fact    runs at    115200 bps.  _F_A_S
  548. X           hides the real baud rate    from the rest of the UNIX kernel
  549. X           and the application programs.  That's the only way these
  550. X           additional baud rates can work at all.
  551. X
  552. X      CABLING
  553. X           Cabling depends on the serial card and the device that you
  554. X           want to connect.
  555. X
  556. X         Connecting    a modem
  557. X           The most    common case is connecting a modem to a computer.
  558. X           "Dumb"-port cards in an IBM-AT compatible computer usually
  559. X           act as a    DTE device and have a male connector while modems
  560. X           are DCE devices and have    a female connector.  So    all you
  561. X           need is an extension cable with a male connector    on one side
  562. X           and a female connector on the other side.
  563. X
  564. X           The cable has to    have wires for at least    the signals TTTTDDDD,    RRRRDDDD,
  565. X           RRRRTTTTSSSS, CCCCTTTTSSSS, DDDDSSSSRRRR, DDDDCCCCDDDD, DDDDTTTTRRRR,    RRRRIIII and GGGGNNNNDDDD.  On    a D-Sub    25 RS232C
  566. X           connector these are the pin numbers 2222, 3333, 4444, 5555, 6666, 8888, 22220000, 22222222
  567. X           and 7777, respectively, and    the wireing scheme has to be
  568. X           "straight through", that    is, none of the    wires are crossed.
  569. X           For the cabling of less common devices please look at the
  570. X           manuals for further details.
  571. X
  572. X           In all cases, though, use shielded cables wherever you can,
  573. X           especially with high baud rates!     Shielded cables are better
  574. X           protected against electromagnetic interferences and there-
  575. X           fore help to prevent data corruption during transmission.
  576. X           Also, make the cables as    short as possible.
  577. X
  578. X           However,    don't leave unused input lines (CCCCTTTTSSSS, DDDDCCCCDDDD, DDDDSSSSRRRR, RRRRIIII)
  579. X           open!  Due to crosstalking from other lines these input
  580. X           lines might change their    logic level, resulting in all sorts
  581. X           of problems (bad    throughput, blocked character output etc.).
  582. X           Therefore, you should connect any unused    input line to GGGGNNNNDDDD
  583. X           (pin 7777 on the D-Sub 25 RS232C connector).
  584. X
  585. X           Additionally, you should    use the    proper operating mode (via
  586. X           the minor device    number)    for your application, for instance,
  587. X           if the connected    device doesn't have hardware flow control,
  588. X           you should use a    mode where hardware flow control is dis-
  589. X           abled.  The same    is true    for modem control.
  590. X
  591. X         Connecting    two UNIX systems
  592. X           If you want to connect two UNIX systems (both using _F_A_S)    via
  593. X           a null modem cable, and if you want to run a _g_e_t_t_y on both
  594. X
  595. X
  596. X      Rev. Release 2.11.0                        Page 15
  597. X
  598. X
  599. X
  600. X
  601. X
  602. X
  603. X      FAS(7)            UNIX System    V             FAS(7)
  604. X
  605. X
  606. X
  607. X           ends you    need to    modify the _s_p_a_c_e._c file    to prevent both
  608. X           _g_e_t_t_ys from chatting with each other, wasting valuable CPU
  609. X           time.
  610. X
  611. X           Remove the EEEEIIII____DDDDTTTTRRRR macro for the desired port from the ini-
  612. X           tializer    part of    the _f_a_s__m_o_d_e_m[]    array.    This will cause    DDDDTTTTRRRR
  613. X           to be asserted only on dialout.    Therefore, the _g_e_t_t_y will
  614. X           become alive only if a dialout on the other side    is in pro-
  615. X           gress.
  616. X
  617. X           Also, replace the HHHHOOOO____CCCCTTTTSSSS____OOOONNNN____DDDDSSSSRRRR macro in    the _f_a_s__f_l_o_w[]
  618. X           array with HHHHOOOO____CCCCTTTTSSSS.  This    will cause CCCCTTTTSSSS to be used for
  619. X           hardware    output flow control regardless of the state of DDDDSSSSRRRR.
  620. X
  621. X           The required null modem cable needs to cross TTTTDDDD/RRRRDDDD, RRRRTTTTSSSS/CCCCTTTTSSSS
  622. X           and DDDDTTTTRRRR/DDDDCCCCDDDD.  The following diagram shows the wireing scheme
  623. X           for DTE D-Sub 25    connectors on both sides.
  624. X
  625. X            D-Sub 25   System A               System B
  626. X            ========   ========               ========
  627. X            2     TD  --------\ /-------- TD
  628. X                          X
  629. X            3     RD  --------/ \-------- RD
  630. X
  631. X            4     RTS --------\ /-------- RTS
  632. X                          X
  633. X            5     CTS --------/ \-------- CTS
  634. X
  635. X               20     DTR --------\ /-------- DTR
  636. X                          X
  637. X            8     DCD --------/ \-------- DCD
  638. X
  639. X            6     DSR --\         /-- DSR
  640. X                    >-\      /-<
  641. X               22     RI  --/   \     /   \-- RI
  642. X                        >---<
  643. X            7     GND ------/     \------ GND
  644. X
  645. X           Note that DDDDSSSSRRRR and RRRRIIII are    directly connected to GGGGNNNNDDDD on each
  646. X           side so that they can't catch electromagnetic interferences.
  647. X
  648. X         Connecting    a mouse
  649. X           Another caveat is connecting a mouse or some other pointer
  650. X           device to an _F_A_S    port.  There are many mice on the market
  651. X           that don't handle the modem and hardware    flow control lines
  652. X           in a proper way.     Therefore, they should    be connected to    a
  653. X           port with a minor device    number of 0000 + device #.     This dis-
  654. X           ables any modem or hardware flow    control    and prevents the
  655. X           device from locking up under certain circumstances.
  656. X
  657. X           You may also want to refer to the section UUUUAAAARRRRTTTT FFFFIIIIFFFFOOOO CCCCOOOONNNNTTTTRRRROOOOLLLL
  658. X           if your mouse is    connected to a port driven by a    UART with
  659. X           FIFOs.
  660. X
  661. X
  662. X      Rev. Release 2.11.0                        Page 16
  663. X
  664. X
  665. X
  666. X
  667. X
  668. X
  669. X      FAS(7)            UNIX System    V             FAS(7)
  670. X
  671. X
  672. X
  673. X      MODEM    SETUP
  674. X           _F_A_S has certain requirements for    the modem setup    that must
  675. X           be met in order to avoid    problems during    operation.
  676. X
  677. X           If modem    control    should be used (carrier    sensing    with DDDDCCCCDDDD
  678. X           and hangup control with DDDDTTTTRRRR), you need to program the modem
  679. X           in the following    way:
  680. X
  681. X          DDDDTTTTRRRR high->low    causes the modem to drop the connection
  682. X          (hangup) and resets the modem    to its power-on    default
  683. X          setup.  Additionally,    when the modem is in answer mode
  684. X          (for dialin) it shouldn't answer calls if DDDDTTTTRRRR    is low.
  685. X
  686. X          DDDDCCCCDDDD is set high when there is    a carrier detected or
  687. X          rather, to be    precise, when the connection procedure
  688. X          between the two modems is finished and the modems are
  689. X          ready    to transfer user data.    DDDDCCCCDDDD is dropped to low if
  690. X          the modem senses that    the connection to the other modem
  691. X          is lost (e.g.    no carrier).
  692. X
  693. X           If hardware flow    control    should be used (CCCCTTTTSSSS for    output
  694. X           direction and RRRRTTTTSSSS for input direction), you need    this setup:
  695. X
  696. X          RRRRTTTTSSSS signals to the modem whether the DTE (e.g. the com-
  697. X          puter) can accept data or not.  High means the DTE can
  698. X          accept data while low    means that the modem should stop
  699. X          sending data to the DTE.
  700. X
  701. X          CCCCTTTTSSSS signals to the DTE whether the modem can accept data
  702. X          or not.  High    means the modem    can accept data    while low
  703. X          means    that the DTE should stop sending data.
  704. X
  705. X          DDDDSSSSRRRR is always    on.  This line acts as a gate for the CCCCTTTTSSSS
  706. X          signal.  _F_A_S ignores CCCCTTTTSSSS if DDDDSSSSRRRR is low, so DDDDSSSSRRRR has to    be
  707. X          always high to make sure that    _F_A_S always pays    attention
  708. X          to CCCCTTTTSSSS.
  709. X
  710. X          Note that the    behaviour of RRRRTTTTSSSS and CCCCTTTTSSSS (as described
  711. X          above) is called bidirectional or full duplex    hardware
  712. X          flow control.     Don't select half duplex hardware flow
  713. X          control with modern highspeed    modems!
  714. X
  715. X           By default, _F_A_S uses both modem and hardware flow control so
  716. X           you have    to make    sure that in your modem    DDDDTTTTRRRR, DDDDCCCCDDDD, RRRRTTTTSSSS, CCCCTTTTSSSS
  717. X           and DDDDSSSSRRRR work the    way described above.
  718. X
  719. X           If your modem can't handle modem    and/or hardware    flow con-
  720. X           trol you    have to    use a different    minor device number for
  721. X           this device that    disables the respective    feature.  Otherwise
  722. X           lockups and malfunctions    could occure.  Look at section
  723. X           OOOOPPPPEEEERRRRAAAATTTTIIIINNNNGGGG MMMMOOOODDDDEEEESSSS AAAANNNNDDDD MMMMIIIINNNNOOOORRRR DDDDEEEEVVVVIIIICCCCEEEE    NNNNUUUUMMMMBBBBEEEERRRRSSSS    for a description
  724. X           of possible operating modes (minor device numbers).
  725. X
  726. X
  727. X
  728. X      Rev. Release 2.11.0                        Page 17
  729. X
  730. X
  731. X
  732. X
  733. X
  734. X
  735. X      FAS(7)            UNIX System    V             FAS(7)
  736. X
  737. X
  738. X
  739. X           Here are    a few additional hints for the modem setup:
  740. X
  741. X          If you program the modem to answer calls (dialin mode)
  742. X          you should make sure that the    modem escape code character
  743. X          which    allows online access to    the modem command mode is
  744. X          disabled.  Otherwise,    the escape code    sequence typed in
  745. X          at the remote    side is    echoed by the local computer and
  746. X          causes the local modem to switch to command mode as well.
  747. X          At this stage, only a    hangup will reactivate the modem
  748. X          port.     Modems    with an    AT command set disable the escape
  749. X          code with
  750. X
  751. X               AT S2=128
  752. X
  753. X          If you want to dial in and out on the    same modem port    the
  754. X          modem's power-on default setup should    be tailored for
  755. X          dialin mode (incl. auto answer eeeennnnaaaabbbblllleeee).  When    a dialout
  756. X          takes    place the dialout application provides the neces-
  757. X          sary modem commands to switch    the modem to dialout mode
  758. X          (incl. auto answer ddddiiiissssaaaabbbblllleeee) and then does the    actual
  759. X          dialout.  After the dialout is finished _F_A_S makes sure
  760. X          that DDDDTTTTRRRR is dropped for a second which resets    the modem
  761. X          to its power-on defaults so that the modem is    in dialin
  762. X          mode,    again.
  763. X
  764. X      TROUBLE-SHOOTING
  765. X           There are a number of know problems that    you might encounter
  766. X           when you    are using _F_A_S.    They are usually caused    either by a
  767. X           configuration error or by limitations of    the hard- and
  768. X           software    environment _F_A_S    has to work in.
  769. X
  770. X         Character loss
  771. X           A common    problem    with fast serial data transmission is that
  772. X           the receiving side occasionally drops characters.  The rea-
  773. X           son for this lies in the    ancient    UART devices used in many
  774. X           286/386 systems:     the _8_2_5_0 (not supported by _F_A_S) and the
  775. X           _N_S_1_6_4_5_0.
  776. X
  777. X           They have only one receiver character buffer.  This implies
  778. X           that the    operating system must read a character from this
  779. X           buffer before the next one arrives from the UART's shift
  780. X           register.  For the old IBM PC with DOS this was sufficient.
  781. X           But for UNIX and    with baud rates    as high    as 115200 this is
  782. X           just a bad joke.
  783. X
  784. X           UNIX is not a real-time operating system.  This means that
  785. X           its kernel isn't    optimized for fast interrupt response.
  786. X           With properly designed hardware that buffers data until the
  787. X           OS has time to fetch it this is no problem.  But    since UNIX
  788. X           for PCs has to work with    the standard hardware found in
  789. X           286/386 systems,    serial driver developers have to cope with
  790. X           the _N_S_1_6_4_5_0 UARTs which are in there simply to be compatible
  791. X           with IBM    PCs, XTs and ATs under DOS.
  792. X
  793. X
  794. X      Rev. Release 2.11.0                        Page 18
  795. X
  796. X
  797. X
  798. X
  799. X
  800. X
  801. X      FAS(7)            UNIX System    V             FAS(7)
  802. X
  803. X
  804. X
  805. X           With this hardware it is    impossible to make it work at high
  806. X           baud rates without a major redesign of the USL supplied UNIX
  807. X           kernel.    But then it wouldn't be    UNIX SYSV any more.
  808. X
  809. X           Fortunately, there is a pin-to-pin replacement available
  810. X           from National Semiconductors:  the _N_S_1_6_5_5_0_A.
  811. X
  812. X           This device has separate    16 character FIFOs for the receiver
  813. X           and the transmitter.  With these    FIFOs the interrupt latency
  814. X           of the kernel can be quite high without losing characters.
  815. X           And because with    most interrupts    several    characters are pro-
  816. X           cessed at once the CPU is loaded    much less.
  817. X
  818. X           So, as _F_A_S supports _N_S_1_6_5_5_0_A UARTs, all you have    to do to
  819. X           fix the character loss problem is to either buy a serial
  820. X           card with _N_S_1_6_5_5_0_A chips    on it or replace the UARTs on the
  821. X           card that you already have.
  822. X
  823. X           If for some reason you can't get    the _N_S_1_6_5_5_0_A chips you
  824. X           could use the _i_8_2_5_1_0 chips from Intel.  Although    they are
  825. X           much less efficient they    are still better than the _N_S_1_6_4_5_0.
  826. X
  827. X           There are, however, some    conditions under which even the
  828. X           receiver    FIFO in    the _N_S_1_6_5_5_0_A UART can't    prevent    character
  829. X           loss:
  830. X
  831. X          Other    kernel drivers
  832. X             Some kernel drivers may disable interrupts    for too
  833. X             long.  One    culprit    is the disk cache flush    routine.
  834. X             If    you configure your kernel with too many    cache
  835. X             buffers (_N_B_U_F parameter for USL derived UNIX) you may
  836. X             still lose    characters (at least at    38400 bps and
  837. X             above).
  838. X
  839. X             Another candidate is _V_P/_i_x, or rather the kernel func-
  840. X             tions to support _V_P/_i_x.  This may also lead to lost
  841. X             characters    at very    high input speeds.
  842. X
  843. X          Bus master controllers
  844. X             There are some bus    master disk controllers    (like the
  845. X             Adaptec 1540/1542 SCSI controller)    on the market that
  846. X             slow down the CPU so much during data transfer that it
  847. X             isn't fast    enough to process characters coming in at
  848. X             high baud rates.
  849. X
  850. X             Therefore,    if you can configure your disk controller,
  851. X             don't use values that will    bring the CPU down to its
  852. X             knees.  Otherwise,    _F_A_S will lose incoming characters
  853. X             during disk I/O.
  854. X
  855. X           If your operating system    has a low interrupt latency you    can
  856. X           define LOW_INT_LAT in the _M_a_k_e_f_i_l_e in order to set the
  857. X           receiver    FIFO trigger level from    4 (default) to 8
  858. X
  859. X
  860. X      Rev. Release 2.11.0                        Page 19
  861. X
  862. X
  863. X
  864. X
  865. X
  866. X
  867. X      FAS(7)            UNIX System    V             FAS(7)
  868. X
  869. X
  870. X
  871. X           characters.  This cuts the receiver interrupt frequency in
  872. X           half and    therefore saves    a lot of CPU time.  That pays off
  873. X           especially at very high baud rates.
  874. X
  875. X           If you set this flag you    should do some rigid tests (receiv-
  876. X           ing characters at the highest baud rate while the system    is
  877. X           heavily loaded with disk    and network I/O) to make sure that
  878. X           there are really    no lost    characters due to interrupt
  879. X           latency.     ISC UNIX 3.0 is known to have a low tty interrupt
  880. X           latency,    therefore LOW_INT_LAT is defined in _M_a_k_e_f_i_l_e._I_S_C_3.
  881. X           On the other hand, ISC UNIX 2.x has a rather high interrupt
  882. X           latency and shouldn't have this flag set.  For other UNIX
  883. X           flavors you have    to find    out yourself whether this flag is
  884. X           applicable.
  885. X
  886. X         Device lockups
  887. X           There are certain conditions under which    a device can lock
  888. X           up, that    is, at least one process that uses this    device
  889. X           waits for a tty I/O related event that apparently doesn't
  890. X           occure.
  891. X
  892. X           The most    common case is that there are still characters in
  893. X           the output buffer, but the output is disabled for some rea-
  894. X           son.  Then the last process that    closes the tty device hangs
  895. X           in the _c_l_o_s_e(2|S) function until    the output buffer has
  896. X           drained.
  897. X
  898. X           Tty output may be stopped by the    software (XON/XOFF) or
  899. X           hardware    (RRRRTTTTSSSS/CCCCTTTTSSSS, by default) flow control.  In    this case
  900. X           something seems to be wrong with    the cabling or the con-
  901. X           nected device.  Please check this first out before you blame
  902. X           _F_A_S.  Sometimes it helps    to switch the device off and on    a
  903. X           few times to unblock the    tty output.
  904. X
  905. X           If this doesn't help the    last resort would be to    kill the
  906. X           process that hangs on the _F_A_S device, and if it still hangs,
  907. X           to open the respective device with the O_APPEND flag.  This
  908. X           flushes the output buffers and therefore    releases the hang-
  909. X           ing process.  To    do that, you simply type
  910. X
  911. X            echo '\c' >> /dev/ttyF00
  912. X
  913. X           if, for instance, the process is    hanging    on ttttttttyyyyFFFF00000000.  Don't
  914. X           omit the    backslash before the cccc!
  915. X
  916. X           Another reason for a blocked output could be a lost
  917. X           transmitter interrupt.  If this isn't caused by a configura-
  918. X           tion error this usually indicates a hardware problem in your
  919. X           computer    which should be    fixed as soon as possible.  Other-
  920. X           wise, you can't run this    system unattended because it is    too
  921. X           unreliable.  All    you can    do after a transmitter interrupt is
  922. X           lost is to reboot the machine in    order to use the blocked
  923. X           _F_A_S device, again.
  924. X
  925. X
  926. X      Rev. Release 2.11.0                        Page 20
  927. X
  928. X
  929. X
  930. X
  931. X
  932. X
  933. X      FAS(7)            UNIX System    V             FAS(7)
  934. X
  935. X
  936. X
  937. X           If interrupts are lost on IRQ2 this might have to do with an
  938. X           EGA or VGA video    card using this    IRQ line for the vertical
  939. X           retrace interrupt.  This    interrupt isn't    used at    all these
  940. X           days, neither under DOS nor UNIX.  It's simply there for
  941. X           compatibility.
  942. X
  943. X           On some video cards (the    more expensive ones) there is a
  944. X           jumper or dip switch to disable the vertical retrace inter-
  945. X           rupt.  On the rest you have to cut the trace to the bus con-
  946. X           tact B4 with a sharp knife.  This contact is on the solder
  947. X           side of the video card, the fourth bus contact counted from
  948. X           the side    where the 9 or 15 pin D-SUB connector to the moni-
  949. X           tor is located.    Cutting    this trace has the same    effect as
  950. X           pulling the IRQ2    jumper on other    cards.
  951. X
  952. X           Note that cutting the trace will    void your video    card's war-
  953. X           ranty.
  954. X
  955. X           Now IRQ2    should be available for    use with _F_A_S.  Look at the
  956. X           _I_N_S_T_A_L_L_A_T_I_O_N file for details on    how to configure _F_A_S for
  957. X           IRQ2.  This is operating    system dependent.
  958. X
  959. X           And there is a rare case    which has to do    with the number    of
  960. X           available CLIST buffers in the UNIX kernel.  The    UNIX output
  961. X           and input buffers are 256 bytes each (by    default).  If for
  962. X           some reason the output of a tty device is stopped but a pro-
  963. X           cess continues to send data one character at a time this
  964. X           uses up one CLIST buffer    for every charcacter.  If the
  965. X           number of CLIST buffers in the kernel is    less than 222255556666 all
  966. X           CLIST buffers will be busy eventually.
  967. X
  968. X           The dangerous thing here    is that    the pool of CLIST buffers
  969. X           is used by all tty devices of the system.  Therefore, if    one
  970. X           single tty device manages to eat    up all available CLIST
  971. X           buffers all tty in- and output comes to a halt.    If this
  972. X           happens you can't access    your machine any more, not even
  973. X           from the    operator console.  Although the    system is still
  974. X           alive internally.
  975. X
  976. X           Unfortunately, many UNIX    vendors    have put a negligently low
  977. X           number-of-CLIST-buffers parameter into their kernel tune
  978. X           files.  You should increase it to a value that makes it
  979. X           impossible that one device alone    can occupy all CLIST
  980. X           buffers (it's the _N_C_L_I_S_T    parameter under    USL derived UNIX
  981. X           SVR[34].x).  A value of 444400000000 should be sufficient.
  982. X
  983. X         Background    processes and _g_e_t_t_y problems
  984. X           Due to the design of the    SysV kernel there might    be problems
  985. X           with _g_e_t_t_y when the previous dialup user    on the respective
  986. X           port was    using background processes.  Unfortunaley, _F_A_S
  987. X           can't do    much about it.
  988. X
  989. X           The reason for these problems is    that when a device is held
  990. X
  991. X
  992. X      Rev. Release 2.11.0                        Page 21
  993. X
  994. X
  995. X
  996. X
  997. X
  998. X
  999. X      FAS(7)            UNIX System    V             FAS(7)
  1000. X
  1001. X
  1002. X
  1003. X           open by some process there can be no _g_e_t_t_y waiting for car-
  1004. X           rier on this device.  Notice that we are    talking    about the
  1005. X           ssssaaaammmmeeee logical device for both the    offending process and
  1006. X           _g_e_t_t_y.  This has    nothing    to do with the built-in    modem line
  1007. X           sharing for dialin and dialout.
  1008. X
  1009. X           There are two problematic situations:
  1010. X
  1011. X          1. _g_e_t_t_y has already blocked in the _o_p_e_n(2|S)    function
  1012. X             and is waiting for    the carrier.  Another process now
  1013. X             opens the device with O_NDELAY.  Because the device is
  1014. X             open after    this there is no way for _g_e_t_t_y to remain in
  1015. X             the carrier waiting state.     Therefore _g_e_t_t_y is waked
  1016. X             up    and completes its _o_p_e_n(2|S) call as if the carrier
  1017. X             were present.  Of course, as the carrier isn't really
  1018. X             there, subsequent _r_e_a_d(2|S) and _w_r_i_t_e(2|S)    calls will
  1019. X             return immediately    with an    EOF condition.    _g_e_t_t_y just
  1020. X             exits in this case.
  1021. X
  1022. X          2. A background process holds    the device open    when _g_e_t_t_y
  1023. X             is    respawned by _i_n_i_t.  _g_e_t_t_y's _o_p_e_n(2|S) call suc-
  1024. X             ceedes immediately    because    it can't block and wait    for
  1025. X             the carrier due to    the device already being held open
  1026. X             by    the background process.     Again,    subsequent
  1027. X             _r_e_a_d(2|S) and _w_r_i_t_e(2|S) calls return EOF (provided
  1028. X             that the carrier is missing) and _g_e_t_t_y exits.
  1029. X
  1030. X           In both cases _i_n_i_t will immediately respawn new _g_e_t_t_ys and
  1031. X           eventually gives    up with    a ``respawning too rapidly'' mes-
  1032. X           sage on the console.  This disables dialins on this port    for
  1033. X           at least    a couple of minutes.
  1034. X
  1035. X           In this state you may notice that the DDDDTTTTRRRR line is low
  1036. X           although    it should be high as the port is held open by the
  1037. X           background process.  This is caused by the _F_A_S security
  1038. X           feature that prevents modems from accepting calls when the
  1039. X           port isn't ready    for logins.  This can save frequently cal-
  1040. X           ling UUCP sites a lot of    money.    However, the security
  1041. X           feature only makes the symptoms more visible, but it isn't
  1042. X           the cause of the    _g_e_t_t_y problems.
  1043. X
  1044. X           While the first case above happens rarely (usually due to a
  1045. X           configuration error) the    second case is more common.  The
  1046. X           reason is that dialup users start background processes and
  1047. X           then log    off or drop the    line.  If the background process
  1048. X           was started by a    job control shell it runs in its own pro-
  1049. X           cess group and therefore    doesn't    receive    the SIGHUP signal
  1050. X           sent by _F_A_S on carrier loss.  It    is the responsibility of
  1051. X           the shell to notice either the SIGHUP or    the EOF    condition
  1052. X           and to then kill    its child (background) processes before
  1053. X           exiting.     Unfortunately,    not all    job control shells do this
  1054. X           reliably.
  1055. X
  1056. X
  1057. X
  1058. X      Rev. Release 2.11.0                        Page 22
  1059. X
  1060. X
  1061. X
  1062. X
  1063. X
  1064. X
  1065. X      FAS(7)            UNIX System    V             FAS(7)
  1066. X
  1067. X
  1068. X
  1069. X           Another problem is that under some UNIX flavors the _c_s_h
  1070. X           automatically disables SIGHUP for all background    processes
  1071. X           it starts.  So these processes have no chance to    terminate
  1072. X           when the    carrier    drops.
  1073. X
  1074. X           Whatever    causes the background processes    to survive the log-
  1075. X           off or carrier drop, it causes massive problems with _g_e_t_t_y
  1076. X           as described above.  If you see these effects on    your
  1077. X           machine,    and it can't be    cured by using a better    (in this
  1078. X           respect)    shell, your only option    is to convince your dialup
  1079. X           users to    either not use any background processes    or to
  1080. X           redirect    ssssttttddddiiiinnnn, ssssttttddddoooouuuutttt and ssssttttddddeeeerrrrrrrr to some files so that the
  1081. X           processes don't hold the    device open.  If you or    your users
  1082. X           can't live without background processes on dialup lines you
  1083. X           may want    to install the _s_c_r_e_e_n virtual tty multiplexer which
  1084. X           allows several independent screens to run programs even
  1085. X           while you are logged off.  _s_c_r_e_e_n or _i_s_c_r_e_e_n should be
  1086. X           available on every GNU archive server.
  1087. X
  1088. X         Crashes or    video problems at boot time
  1089. X           Several vendors of video    cards with the S3 chip set (maybe
  1090. X           with other chip sets as well) were stupid enough    to use the
  1091. X           I/O address 0000xxxx2222eeee8888 for their own purpose.     This address, how-
  1092. X           ever, has been used, at least inofficially, for the COM4
  1093. X           port since the days the IBM AT came out.
  1094. X
  1095. X           So what happens if you have such    a video    card in    your com-
  1096. X           puter together with an enabled COM4 port    is that    _F_A_S writes
  1097. X           to the port at boot time    (in order to detect it)    and actu-
  1098. X           ally writes to the video    card as    well, because of the over-
  1099. X           layed I/O addresses.  This confuses the video card so that,
  1100. X           for instance, the screen    gets dark, or it even manages to
  1101. X           crash the system.
  1102. X
  1103. X           The only    thing you can do in this situation is to physically
  1104. X           disable the COM4    port (usually by some DIP switch or jumper)
  1105. X           and to tell _F_A_S (via its    config files) not to use COM4.
  1106. X
  1107. X      FILES
  1108. X           /_d_e_v/_t_t_y_F??
  1109. X          Dialout device with modem and    hardware flow control (by
  1110. X          default).
  1111. X
  1112. X           /_d_e_v/_t_t_y_F_M??
  1113. X          Dialin device    with modem and hardware    flow control (by
  1114. X          default).
  1115. X
  1116. X      SEE ALSO
  1117. X           _t_e_r_m_i_o(7|M), _s_i_g_n_a_l(2|S), _o_p_e_n(2|S), _c_l_o_s_e(2|S),    _r_e_a_d(2|S),
  1118. X           _w_r_i_t_e(2|S), _f_c_n_t_l(2|S), _i_o_c_t_l(2|S), _g_e_t_t_y(1M|M),    _c_u(1C|C),
  1119. X           _u_u_c_i_c_o(1M|C)
  1120. X
  1121. X      BUGS
  1122. X
  1123. X
  1124. X      Rev. Release 2.11.0                        Page 23
  1125. X
  1126. X
  1127. X
  1128. X
  1129. X
  1130. X
  1131. X      FAS(7)            UNIX System    V             FAS(7)
  1132. X
  1133. X
  1134. X
  1135. X           _F_A_S is not yet ported to    SVR4 STREAMS and therefore its
  1136. X           functionality is    limited    under SVR4.
  1137. X
  1138. X           DosMerge's virtual COM ports are    unsupported.
  1139. X
  1140. X      COPYRIGHT
  1141. X           Copyright (C) 1990-1993 Uwe Doering
  1142. X           See the file _C_O_P_Y_I_N_G (distributed with the source code) for
  1143. X           distribution rights and restrictions associated with this
  1144. X           software.
  1145. X
  1146. X
  1147. X
  1148. X
  1149. X
  1150. X
  1151. X
  1152. X
  1153. X
  1154. X
  1155. X
  1156. X
  1157. X
  1158. X
  1159. X
  1160. X
  1161. X
  1162. X
  1163. X
  1164. X
  1165. X
  1166. X
  1167. X
  1168. X
  1169. X
  1170. X
  1171. X
  1172. X
  1173. X
  1174. X
  1175. X
  1176. X
  1177. X
  1178. X
  1179. X
  1180. X
  1181. X
  1182. X
  1183. X
  1184. X
  1185. X
  1186. X
  1187. X
  1188. X
  1189. X
  1190. X      Rev. Release 2.11.0                        Page 24
  1191. X
  1192. X
  1193. X
  1194. SHAR_EOF
  1195. echo 'File fas.7.cat is complete' &&
  1196. true || echo 'restore of fas.7.cat failed'
  1197. rm -f _shar_wnt_.tmp
  1198. fi
  1199. # ============= fas.c ==============
  1200. if test -f 'fas.c' -a X"$1" != X"-c"; then
  1201.     echo 'x - skipping fas.c (File already exists)'
  1202.     rm -f _shar_wnt_.tmp
  1203. else
  1204. > _shar_wnt_.tmp
  1205. echo 'x - extracting fas.c (Text)'
  1206. sed 's/^X//' << 'SHAR_EOF' > 'fas.c' &&
  1207. X/* FAS Final Async Solution driver for 286/386 versions of System V UNIX */
  1208. X
  1209. X/* FAS was developed by
  1210. XUwe Doering <fas@geminix.in-berlin.de>
  1211. XBillstedter Pfad 17 b
  1212. X13591 Berlin
  1213. XGermany
  1214. X*/
  1215. X
  1216. X#if !defined (M_I286)
  1217. X#ident    "@(#)fas.c    2.11"
  1218. X#endif
  1219. X
  1220. X/* Note: This source code has been quite heavily optimized for speed.
  1221. X         You may wonder that register variables aren't used everywhere.
  1222. X         This is because there is an overhead in memory accesses
  1223. X         when using register variables. As you may know data accesses
  1224. X         usually need much more wait states on the memory bus than
  1225. X         code accesses (because of page or cache misses). Therefore,
  1226. X         saving some data accesses has higher priority than saving
  1227. X         code accesses.
  1228. X
  1229. X         You may also note some not very elegant constructions that
  1230. X         may be intentional because they are faster. If you want to
  1231. X         make style improvements you should check the assembler output
  1232. X         whether this wouldn't slow things down.
  1233. X
  1234. X         Decisions for speed optimization were based on assembler
  1235. X         listings produced by the standard UNIX V [34].X/386 C compiler.
  1236. X
  1237. X   IMPORTANT: On systems where FAS is to be compiled with the standard
  1238. X              UNIX C compiler the assembler output file is optimized
  1239. X              by an AWK script. That is, outb(), inb() and fas_mem_copy()
  1240. X              calls are substituted with inline i/o mnemonics. As the
  1241. X              intelligence of this script is limited it is necessary that
  1242. X              the port address argument of outb() and inb() is a simple
  1243. X              expression that allows the compiler to produce code that
  1244. X              fetches the address with a single load operation. Look at
  1245. X              the assembler output if you are in doubt about an expression.
  1246. X
  1247. X              This is a kludge but it is the method that produces the
  1248. X              fastest code with the standard UNIX C compiler.
  1249. X*/
  1250. X
  1251. X#include "fas.h"
  1252. X
  1253. X#if defined (__GNUC__) && !defined (NO_ASM)
  1254. X#if defined (XENIX)
  1255. X#define OUTB(port,val) \
  1256. X({\
  1257. X    __asm__ volatile ("outb %%al,%%dx" : : "d" ((uint) (port)), "a" ((unchar) (val)));\
  1258. X})
  1259. X
  1260. X#define INB(port) \
  1261. X({\
  1262. X    unchar __val;\
  1263. X    __asm__ volatile ("inb %%dx,%%al" : "=a" (__val) : "d" ((uint) (port)));\
  1264. X    __val;\
  1265. X})
  1266. X#else    /* XENIX */
  1267. X#define OUTB(port,val) \
  1268. X({\
  1269. X    __asm__ volatile ("outb (%%dx)" : : "d" ((uint) (port)), "a" ((unchar) (val)));\
  1270. X})
  1271. X
  1272. X#define INB(port) \
  1273. X({\
  1274. X    unchar __val;\
  1275. X    __asm__ volatile ("inb (%%dx)" : "=a" (__val) : "d" ((uint) (port)));\
  1276. X    __val;\
  1277. X})
  1278. X#endif    /* XENIX */
  1279. X
  1280. X#define FAS_MEM_COPY(dst,src,n) \
  1281. X({\
  1282. X    __asm__ volatile ("movl %2,%%ecx\n"\
  1283. X            "\tcld\n"\
  1284. X            "\tshrl $2,%%ecx\n"\
  1285. X            "\trep\n"\
  1286. X            "\tmovsl\n"\
  1287. X            "\tmovl %2,%%ecx\n"\
  1288. X            "\tandl $3,%%ecx\n"\
  1289. X            "\trep\n"\
  1290. X            "\tmovsb" : : "D" ((unchar *) (dst)),\
  1291. X                        "S" ((unchar *) (src)),\
  1292. X                        "r" ((uint) (n))\
  1293. X                    : "D", "S", "c", "cc");\
  1294. X})
  1295. X
  1296. X/* We know better than gcc which variables should be in hard registers.
  1297. X   This seems to be the only method to force gcc to use a hard register
  1298. X   for a variable.
  1299. X*/
  1300. X#define REG_SI __asm__ ("%esi")
  1301. X#define REG_DI __asm__ ("%edi")
  1302. X#define REG_BX __asm__ ("%ebx")
  1303. X#define REG_CX __asm__ ("%ecx")
  1304. X#endif    /* __GNUC__ && !NO_ASM */
  1305. X
  1306. X#if !defined (__GNUC__) && !defined (NO_ASM) && !defined (XENIX)
  1307. X/* fas_mem_copy () is expanded to inline assembler code by the optimizing
  1308. X   AWK script (see above).
  1309. X*/
  1310. X#define FAS_MEM_COPY(dst,src,n) fas_mem_copy (dst, src, n)
  1311. Xextern void    fas_mem_copy ();
  1312. X
  1313. X/* Define `OPTIM' for uPort, ISC doesn't know about `.optim', but has turned
  1314. X   on optimization by default, so we don't need it there anyway.
  1315. X*/
  1316. X#if defined (OPTIM)
  1317. X/* This function inserts the address optimization assembler pseudo-op
  1318. X   wherever called.
  1319. X*/
  1320. X
  1321. Xasm    void optim ()
  1322. X{
  1323. X    .optim
  1324. X}
  1325. X
  1326. X/* This dummy function has nothing to do but to call optim so that
  1327. X   the `.optim' assembler pseudo-op will be included in the assembler
  1328. X   file. This must be the first of all functions.
  1329. X*/
  1330. X
  1331. Xstatic void
  1332. Xdummy ()
  1333. X{
  1334. X    optim ();
  1335. X}
  1336. X#endif    /* OPTIM */
  1337. X#endif    /* !__GNUC__ && !NO_ASM && !XENIX */
  1338. X
  1339. X#if !defined (REG_SI)
  1340. X#define REG_SI
  1341. X#endif
  1342. X#if !defined (REG_DI)
  1343. X#define REG_DI
  1344. X#endif
  1345. X#if !defined (REG_BX)
  1346. X#define REG_BX
  1347. X#endif
  1348. X#if !defined (REG_CX)
  1349. X#define REG_CX
  1350. X#endif
  1351. X
  1352. X#if defined (NEED_PUT_GETCHAR)
  1353. X#if defined (SCO) || defined (XENIX)
  1354. X#define FASPUTCHAR sioputchar
  1355. X#define FASGETCHAR siogetchar
  1356. X#else
  1357. X#define FASPUTCHAR asyputchar
  1358. X#define FASGETCHAR asygetchar
  1359. X#endif
  1360. X#endif
  1361. X
  1362. X#if defined (PROFILE)
  1363. X#define STATIC
  1364. X#else
  1365. X#define STATIC static
  1366. X#endif
  1367. X
  1368. X/* The following defines are used to access multiplexed ports. */
  1369. X#define FAS_FIRST_CTL(fip,port) \
  1370. X    ((void) (((fip)->device_flags & DF_CTL_FIRST)\
  1371. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1372. X            : 0))
  1373. X
  1374. X#define FAS_EVERY_CTL(fip,port) \
  1375. X    ((void) (((fip)->device_flags & DF_CTL_EVERY)\
  1376. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1377. X            : 0))
  1378. X
  1379. X#define FAS_CTL(fip,port) \
  1380. X    ((void) (((fip)->device_flags & (DF_CTL_FIRST | DF_CTL_EVERY))\
  1381. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1382. X            : 0))
  1383. X
  1384. X#define FAS_FIRST_OUTB(fip,port,val) \
  1385. X    ((void) (((fip)->device_flags & (DF_CTL_FIRST | DF_CTL_EVERY))\
  1386. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1387. X            : 0),\
  1388. X        (void) OUTB ((port).addr, (val)))
  1389. X
  1390. X#define FAS_OUTB(fip,port,val) \
  1391. X    ((void) (((fip)->device_flags & DF_CTL_EVERY)\
  1392. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1393. X            : 0),\
  1394. X        (void) OUTB ((port).addr, (val)))
  1395. X
  1396. X#define FAS_SAME_OUTB(fip,port,val) \
  1397. X    ((void) OUTB ((port).addr, (val)))
  1398. X
  1399. X#define FAS_FIRST_INB(fip,port) \
  1400. X    ((void) (((fip)->device_flags & (DF_CTL_FIRST | DF_CTL_EVERY))\
  1401. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1402. X            : 0),\
  1403. X        INB ((port).addr))
  1404. X
  1405. X#define FAS_INB(fip,port) \
  1406. X    ((void) (((fip)->device_flags & DF_CTL_EVERY)\
  1407. X            ? OUTB (CTL_PORT.addr, (port).p.ctl)\
  1408. X            : 0),\
  1409. X        INB ((port).addr))
  1410. X
  1411. X#define FAS_SAME_INB(fip,port) \
  1412. X    (INB ((port).addr))
  1413. X
  1414. X/* The following defines are used to take apart the minor device numbers. */
  1415. X#define GET_UNIT(dev)        ((dev) & 0x0f)
  1416. X#define GET_OPEN_MODE(dev)    (fas_open_modes [((dev) >> 4) & 0x0f])
  1417. X
  1418. X/* Lock device against concurrent use. */
  1419. X#define GET_DEVICE_LOCK(fip,prio) \
  1420. X{\
  1421. X    /* sleep while device is used by an other process */\
  1422. X    while ((fip)->device_flags & DF_DEVICE_LOCKED)\
  1423. X        (void) sleep ((caddr_t) &(fip)->tty, (prio));\
  1424. X    (fip)->device_flags |= DF_DEVICE_LOCKED;\
  1425. X}
  1426. X
  1427. X/* Release device. */
  1428. X#define RELEASE_DEVICE_LOCK(fip) \
  1429. X{\
  1430. X    (fip)->device_flags &= ~DF_DEVICE_LOCKED;\
  1431. X    /* wakeup the process that may wait for this device */\
  1432. X    (void) wakeup ((caddr_t) &(fip)->tty);\
  1433. X}
  1434. X
  1435. X/* Schedule event. */
  1436. X#define EVENT_SCHED(fip,event) \
  1437. X{\
  1438. X    (fip)->event_flags |= (event);\
  1439. X    if (!event_scheduled)\
  1440. X    {\
  1441. X        event_scheduled = TRUE;\
  1442. X        (void) timeout (fas_event, (caddr_t) NULL, 1);\
  1443. X    }\
  1444. X}
  1445. X
  1446. X/* Put character into receiver ring buffer. */
  1447. X#define PUT_RECV_BUFFER(fip,ring_ptr,c) \
  1448. X{\
  1449. X    *(ring_ptr) = (c);\
  1450. X    if (++(ring_ptr) == &(fip)->recv_buffer [RECV_BUFF_SIZE])\
  1451. X        (ring_ptr) = &(fip)->recv_buffer [0];\
  1452. X}
  1453. X
  1454. X#if !defined (FAS_MEM_COPY)
  1455. X/* Define the base 2 logarithm of x in the range of 1 to 16 (for shifting). */
  1456. X#define LOG2(x) \
  1457. X((x) == 1 ? 0 :\
  1458. X (x) == 2 ? 1 :\
  1459. X (x) == 4 ? 2 :\
  1460. X (x) == 8 ? 3 :\
  1461. X (x) == 16 ? 4 : 0)
  1462. X
  1463. X/* This is the generic version. */
  1464. X#define FAS_MEM_COPY(dst,src,n) \
  1465. X{\
  1466. X    register unchar    *srcptr REG_SI;\
  1467. X    register unchar    *destptr REG_DI;\
  1468. X    register uint    num_to_xfer REG_BX;\
  1469. X\
  1470. X    num_to_xfer = num_save;\
  1471. X    srcptr = tmp_srcptr;\
  1472. X    destptr = tmp_destptr;\
  1473. X\
  1474. X    /* do the transfer */\
  1475. X    if (num_to_xfer >= sizeof (uint) * 2)\
  1476. X    {\
  1477. X        /* do multi-byte transfers */\
  1478. X        num_to_xfer >>= LOG2 (sizeof (uint));\
  1479. X        do\
  1480. X        {\
  1481. X            *((uint *) destptr) = *((uint *) srcptr);\
  1482. X            srcptr += sizeof (uint);\
  1483. X            destptr += sizeof (uint);\
  1484. X        } while (--num_to_xfer);\
  1485. X\
  1486. X        num_to_xfer = num_save;\
  1487. X        if (num_to_xfer &= sizeof (uint) - 1)\
  1488. X        {\
  1489. X            /* do the rest with single-byte transfers */\
  1490. X            do\
  1491. X            {\
  1492. X                *destptr = *srcptr;\
  1493. X                ++srcptr;\
  1494. X                ++destptr;\
  1495. X            } while (--num_to_xfer);\
  1496. X        }\
  1497. X    }\
  1498. X    else\
  1499. X    {\
  1500. X        /* do single-byte transfers */\
  1501. X        do\
  1502. X        {\
  1503. X            *destptr = *srcptr;\
  1504. X            ++srcptr;\
  1505. X            ++destptr;\
  1506. X        } while (--num_to_xfer);\
  1507. X    }\
  1508. X}
  1509. X#endif
  1510. X
  1511. X/* Functions provided by this driver. */
  1512. Xvoid        fasinit P((void));
  1513. Xvoid        fasopen P((dev_t dev, int flag, int otyp));
  1514. Xvoid        fasclose P((dev_t dev, int flag, int otyp));
  1515. Xvoid        fasread P((dev_t dev));
  1516. Xvoid        faswrite P((dev_t dev));
  1517. Xvoid        fasproc P((struct tty *ttyp, int cmd));
  1518. Xvoid        fasioctl P((dev_t dev, int cmd, union ioctl_arg arg, int mode));
  1519. Xvoid        fasintr P((int vect));
  1520. XSTATIC n_unchar    fas_rproc P((struct fas_internals *fip, n_unchar line_status));
  1521. XSTATIC void    fas_xproc P((struct fas_internals *fip));
  1522. XSTATIC void    fas_open_device P((struct fas_internals *fip));
  1523. XSTATIC void    fas_close_device P((struct fas_internals *fip));
  1524. XSTATIC void    fas_param P((struct fas_internals *fip, int init_type));
  1525. XSTATIC void    fas_pos_by_speed P((struct fas_internals *fipp));
  1526. XSTATIC void    fas_event P((void *dummy));
  1527. XSTATIC void    fas_mproc P((struct fas_internals *fip));
  1528. XSTATIC bool    fas_rxfer P((struct fas_internals *fipp));
  1529. SHAR_EOF
  1530. true || echo 'restore of fas.c failed'
  1531. fi
  1532. echo 'End of  part 4'
  1533. echo 'File fas.c is continued in part 5'
  1534. echo 5 > _shar_seq_.tmp
  1535. exit 0
  1536.