home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 October / usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso / misc / volume21 / ecu / part31 < prev    next >
Text File  |  1991-08-05  |  55KB  |  1,754 lines

  1. Newsgroups: comp.sources.misc
  2. From: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  3. Subject:  v21i083:  ecu - ECU async comm package rev 3.10, Part31/37
  4. Message-ID: <1991Aug5.211927.8288@sparky.IMD.Sterling.COM>
  5. X-Md4-Signature: bde7e60cbaf1053f2a017290c496cccb
  6. Date: Mon, 5 Aug 1991 21:19:27 GMT
  7. Approved: kent@sparky.imd.sterling.com
  8.  
  9. Submitted-by: Warren Tucker <wht@n4hgf.Mt-Park.GA.US>
  10. Posting-number: Volume 21, Issue 83
  11. Archive-name: ecu/part31
  12. Environment: SCO, XENIX, ISC
  13. Supersedes: ecu3: Volume 16, Issue 25-59
  14.  
  15. ---- Cut Here and feed the following to sh ----
  16. #!/bin/sh
  17. # this is ecu310.31 (part 31 of ecu310)
  18. # do not concatenate these parts, unpack them in order with /bin/sh
  19. # file fasi/fas.c continued
  20. #
  21. if touch 2>&1 | fgrep 'amc' > /dev/null
  22.  then TOUCH=touch
  23.  else TOUCH=true
  24. fi
  25. if test ! -r _shar_seq_.tmp; then
  26.     echo 'Please unpack part 1 first!'
  27.     exit 1
  28. fi
  29. (read Scheck
  30.  if test "$Scheck" != 31; then
  31.     echo Please unpack part "$Scheck" next!
  32.     exit 1
  33.  else
  34.     exit 0
  35.  fi
  36. ) < _shar_seq_.tmp || exit 1
  37. if test ! -f _shar_wnt_.tmp; then
  38.     echo 'x - still skipping fasi/fas.c'
  39. else
  40. echo 'x - continuing file fasi/fas.c'
  41. sed 's/^X//' << 'SHAR_EOF' >> 'fasi/fas.c' &&
  42. X    int    num_save;
  43. X    int    old_level;
  44. X
  45. X    ttyp = fip->tty;
  46. X
  47. X    for (;;)
  48. X    {
  49. X        /* Check if tbuf is empty. If it is empty, reset buffer
  50. X           pointer and counter and get the next chunk of output
  51. X           characters.
  52. X        */
  53. X        if (!ttyp->t_tbuf.c_ptr || !ttyp->t_tbuf.c_count)
  54. X        {
  55. X            if (ttyp->t_tbuf.c_ptr)
  56. X                ttyp->t_tbuf.c_ptr -= ttyp->t_tbuf.c_size;
  57. X            if (!((*linesw [ttyp->t_line].l_output) (ttyp)
  58. X                    & CPRES))
  59. X                break;
  60. X        }
  61. X
  62. X        /* set the maximum character limit */
  63. X        num_to_xfer = fip->xmit_ring_size - fip->xmit_ring_cnt;
  64. X
  65. X        /* Return if transmitter ring buffer is full. */
  66. X        if (num_to_xfer < 1)
  67. X            break;
  68. X
  69. X        /* Determine how many chars to transfer this time. */
  70. X        if (&fip->xmit_buffer [XMIT_BUFF_SIZE] - fip->xmit_ring_put_ptr
  71. X            < num_to_xfer)
  72. X            num_to_xfer = &fip->xmit_buffer [XMIT_BUFF_SIZE]
  73. X                    - fip->xmit_ring_put_ptr;
  74. X        if (ttyp->t_tbuf.c_count < num_to_xfer)
  75. X            num_to_xfer = ttyp->t_tbuf.c_count;
  76. X
  77. X        num_save = num_to_xfer;
  78. X        ttyp->t_tbuf.c_count -= num_to_xfer;
  79. X        ttyp->t_state |= BUSY;
  80. X
  81. X        /* do the transfer */
  82. X        do
  83. X        {
  84. X            *fip->xmit_ring_put_ptr = *ttyp->t_tbuf.c_ptr;
  85. X            ttyp->t_tbuf.c_ptr++;
  86. X            fip->xmit_ring_put_ptr++;
  87. X        } while (--num_to_xfer);
  88. X
  89. X        if (fip->xmit_ring_put_ptr == &fip->xmit_buffer [XMIT_BUFF_SIZE])
  90. X            fip->xmit_ring_put_ptr = &fip->xmit_buffer [0];
  91. X
  92. X        intr_disable ();
  93. X        fip->xmit_ring_cnt += num_save;
  94. X        intr_restore ();
  95. X    }
  96. X}
  97. X
  98. X/* Input buffer high/low water mark check. */
  99. Xstatic void
  100. Xfas_ihlw_check (fip)
  101. Xregister struct fas_info    *fip;
  102. X{
  103. X    REGVAR;
  104. X
  105. X    if (fip->flow_flags.i & FF_HWI_STOPPED)
  106. X    {
  107. X        /* If input buffer level has dropped below
  108. X           the low water mark and input was stopped
  109. X           by hardware handshake, restart input.
  110. X        */
  111. X        if (fip->recv_ring_cnt < HW_LOW_WATER)
  112. X        {
  113. X            fip->mcr |= fip->flow.m.ic;
  114. X            fas_first_outb (fip, MDM_CTL_PORT, fip->mcr);
  115. X            fip->flow_flags.s &= ~FF_HWI_STOPPED;
  116. X        }
  117. X    }
  118. X    else
  119. X    {
  120. X        /* If input buffer level has risen above the
  121. X           high water mark and input is not yet
  122. X           stopped, stop input by hardware handshake.
  123. X        */
  124. X        if ((fip->flow_flags.i & FF_HWI_HANDSHAKE)
  125. X            && (fip->recv_ring_cnt > HW_HIGH_WATER))
  126. X        {
  127. X            fip->mcr &= ~fip->flow.m.ic;
  128. X            fas_first_outb (fip, MDM_CTL_PORT, fip->mcr);
  129. X            fip->flow_flags.s |= FF_HWI_STOPPED;
  130. X#if defined(FASI)
  131. X            fip->rcvr_hw_flow_count++;
  132. X            (void)wakeup((caddr_t)&fip->device_flags.i);
  133. X#endif /* FASI */
  134. X        }
  135. X    }
  136. X
  137. X    if (fip->flow_flags.i & FF_SWI_STOPPED)
  138. X    {
  139. X        /* If input buffer level has dropped below
  140. X           the low water mark and input was stopped
  141. X           by XOFF, send XON to restart input.
  142. X        */
  143. X        if (!(fip->iflag & IXOFF)
  144. X            || (fip->recv_ring_cnt < SW_LOW_WATER))
  145. X        {
  146. X            fip->flow_flags.s &= ~FF_SWI_STOPPED;
  147. X            fip->flow_flags.s ^= FF_SW_FC_REQ;
  148. X            if (fip->flow_flags.i & FF_SW_FC_REQ)
  149. X            {
  150. X                fip->tty->t_state |= TTXON;
  151. X                fas_xproc (fip);
  152. X            }
  153. X            else
  154. X                fip->tty->t_state &= ~TTXOFF;
  155. X        }
  156. X    }
  157. X    else
  158. X    {
  159. X        /* If input buffer level has risen above the
  160. X           high water mark and input is not yet
  161. X           stopped, send XOFF to stop input.
  162. X        */
  163. X        if ((fip->iflag & IXOFF)
  164. X            && (fip->recv_ring_cnt > SW_HIGH_WATER))
  165. X        {
  166. X            fip->flow_flags.s |= FF_SWI_STOPPED;
  167. X            fip->flow_flags.s ^= FF_SW_FC_REQ;
  168. X            if (fip->flow_flags.i & FF_SW_FC_REQ)
  169. X            {
  170. X                fip->tty->t_state |= TTXOFF;
  171. X                fas_xproc (fip);
  172. X#if defined(FASI)
  173. X                fip->rcvr_sw_flow_count++;
  174. X                (void)wakeup((caddr_t)&fip->device_flags.i);
  175. X#endif /* FASI */
  176. X            }
  177. X            else
  178. X                fip->tty->t_state &= ~TTXON;
  179. X        }
  180. X    }
  181. X}
  182. X
  183. X/* Half-duplex hardware flow control check. */
  184. Xstatic void
  185. Xfas_hdx_check (fip)
  186. Xregister struct fas_info    *fip;
  187. X{
  188. X    REGVAR;
  189. X
  190. X    /* don't interfere with hardware input handshake */
  191. X    if (fip->flow_flags.i & FF_HWI_HANDSHAKE)
  192. X        return;
  193. X
  194. X#if defined (HAVE_VPIX)
  195. X    /* don't touch the mcr if we are in dos mode and hdx hardware
  196. X       handshake is disabled (dos handles the handshake line(s)
  197. X       on its own in this mode)
  198. X    */
  199. X    if ((fip->iflag & DOSMODE) && !(fip->flow_flags.i & FF_HDX_HANDSHAKE))
  200. X        return;
  201. X#endif
  202. X    if (fip->flow_flags.i & FF_HDX_STARTED)
  203. X    {
  204. X        /* If output buffer is empty signal the connected
  205. X           device that all output is done.
  206. X        */
  207. X        if ((fip->flow_flags.i & FF_HDX_HANDSHAKE)
  208. X            && !(fip->tty->t_state & BUSY))
  209. X        {
  210. X            fip->mcr &= ~fip->flow.m.hc;
  211. X            fas_first_outb (fip, MDM_CTL_PORT, fip->mcr);
  212. X            fip->flow_flags.s &= ~FF_HDX_STARTED;
  213. X        }
  214. X    }
  215. X    else
  216. X    {
  217. X        /* If the output ring buffer contains characters
  218. X           and was previously empty signal the connected
  219. X           device that output is resumed.
  220. X        */
  221. X        if (!(fip->flow_flags.i & FF_HDX_HANDSHAKE)
  222. X            || (fip->tty->t_state & BUSY))
  223. X        {
  224. X            fip->mcr |= fip->flow.m.hc;
  225. X            fas_first_outb (fip, MDM_CTL_PORT, fip->mcr);
  226. X            fip->flow_flags.s |= FF_HDX_STARTED;
  227. X        }
  228. X    }
  229. X}
  230. X
  231. X/* Handle hangup after last close */
  232. Xstatic void
  233. Xfas_hangup (fip)
  234. Xregister struct fas_info    *fip;
  235. X{
  236. X    int    old_level;
  237. X    REGVAR;
  238. X
  239. X    old_level = SPLINT ();
  240. X
  241. X    if (fip->device_flags.i & DF_DO_HANGUP)
  242. X    {
  243. X        /* do the hangup */
  244. X        fip->mcr &= ~(fip->modem.m.ei
  245. X                | fip->modem.m.eo);
  246. X        fip->mcr |= fip->modem.m.di;
  247. X        fas_first_outb (fip, MDM_CTL_PORT, fip->mcr);
  248. X        fip->device_flags.s &= ~(DF_MODEM_ENABLED | DF_DO_HANGUP);
  249. X        (void) timeout (fas_hangup, fip, (fip->device_flags.i
  250. X                            & DF_DEVICE_CONFIGURED)
  251. X                        ? (HANGUP_TIME) * (HZ) / 1000
  252. X                        : (RECOVER_TIME) * (HZ));
  253. X    }
  254. X    else
  255. X    {
  256. X        /* unlock the device */
  257. X        fip->device_flags.s |= DF_DEVICE_CONFIGURED;
  258. X        /* If there was a waiting getty open on this
  259. X           port, reopen the physical device.
  260. X        */
  261. X        if (fip->o_state & OS_WAIT_OPEN)
  262. X        {
  263. X            fas_open_device (fip);
  264. X            fas_param (fip, HARD_INIT);    /* set up port regs */
  265. X        }
  266. X        release_device_lock (fip);
  267. X    }
  268. X    (void) splx (old_level);
  269. X}
  270. X
  271. X/* main timeout function */
  272. Xstatic void
  273. Xfas_timeout (fip)
  274. Xregister struct fas_info    *fip;
  275. X{
  276. X    int    old_level;
  277. X    REGVAR;
  278. X
  279. X    old_level = SPLINT ();
  280. X
  281. X    /* handle break request */
  282. X    if (fip->device_flags.i & DF_DO_BREAK)
  283. X    {
  284. X        /* set up break request flags */
  285. X        fip->lcr |= LC_SET_BREAK_LEVEL;
  286. X        fas_first_outb (fip, LINE_CTL_PORT, fip->lcr);
  287. X        fip->device_flags.s &= ~(DF_DO_BREAK | DF_GUARD_TIMEOUT);
  288. X        (void) timeout (fas_timeout, fip, (BREAK_TIME) * (HZ) / 1000);
  289. X        (void) splx (old_level);
  290. X        return;
  291. X    }
  292. X
  293. X    /* reset break state */
  294. X    if (fip->device_flags.i & DF_XMIT_BREAK)
  295. X    {
  296. X        if (fip->lcr & LC_SET_BREAK_LEVEL)
  297. X        {
  298. X            fip->lcr &= ~LC_SET_BREAK_LEVEL;
  299. X            fas_first_outb (fip, LINE_CTL_PORT, fip->lcr);
  300. X            fip->device_flags.s |= DF_GUARD_TIMEOUT;
  301. X            fip->timeout_idx = timeout (fas_timeout, fip,
  302. X                    fas_ctimes [fip->cflag & CBAUD]);
  303. X            (void) splx (old_level);
  304. X            return;
  305. X        }
  306. X        fip->device_flags.s &= ~DF_XMIT_BREAK;
  307. X        /* restart output after BREAK */
  308. X        fas_xproc (fip);
  309. X    }
  310. X
  311. X    /* handle character guard timeout */
  312. X    if (fip->device_flags.i & DF_GUARD_TIMEOUT)
  313. X    {
  314. X        fip->device_flags.s &= ~DF_GUARD_TIMEOUT;
  315. X        if (!fip->xmit_ring_cnt)
  316. X        {
  317. X            fip->tty->t_state &= ~BUSY;
  318. X            fas_hdx_check (fip);
  319. X        }
  320. X    }
  321. X
  322. X    fip->tty->t_state &= ~TIMEOUT;
  323. X
  324. X    event_sched (fip, EF_DO_XXFER);
  325. X
  326. X    (void) wakeup ((caddr_t) &(fip)->device_flags.i);
  327. X    (void) splx (old_level);
  328. X}
  329. X
  330. X/* Several functions for flow control, character output and special event
  331. X   requests and handling.
  332. X*/
  333. Xstatic void
  334. Xfas_cmd (fip, ttyp, arg2)
  335. Xregister struct fas_info    *fip;
  336. Xregister struct tty    *ttyp;
  337. Xint    arg2;
  338. X{
  339. X    REGVAR;
  340. X
  341. X    switch (arg2)
  342. X    {
  343. X    case T_TIME:    /* timeout */
  344. X        goto start_output;
  345. X
  346. X    case T_OUTPUT:    /* output characters to the transmitter */
  347. X        if (fip->xmit_ring_size > fip->xmit_ring_cnt)
  348. X        {
  349. Xstart_output:
  350. X            event_sched (fip, EF_DO_XXFER);
  351. X        }
  352. X        break;
  353. X
  354. X    case T_SUSPEND:    /* suspend character output */
  355. X        fip->flow_flags.s |= FF_SWO_STOPPED;
  356. X#if defined(FASI)
  357. X        fip->xmtr_sw_flow_count++;
  358. X        (void)wakeup((caddr_t)&fip->device_flags.i);
  359. X#endif /* FASI */
  360. X        ttyp->t_state |= TTSTOP;
  361. X        break;
  362. X
  363. X    case T_RESUME:    /* restart character output */
  364. X        fip->flow_flags.s &= ~FF_SWO_STOPPED;
  365. X        ttyp->t_state &= ~TTSTOP;
  366. X        fas_xproc (fip);
  367. X        break;
  368. X
  369. X    case T_BLOCK:    /* stop character input, request XOFF */
  370. X        ttyp->t_state |= TBLOCK;
  371. X        break;    /* note: we do our own XON/XOFF */
  372. X
  373. X    case T_UNBLOCK:    /* restart character input, request XON */
  374. X        ttyp->t_state &= ~TBLOCK;
  375. X        break;    /* note: we do our own XON/XOFF */
  376. X
  377. X    case T_RFLUSH:    /* flush input buffers and restart input */
  378. X        if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  379. X            fas_first_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_SETUP_CMD
  380. X                        | NS_FIFO_CLR_RECV);
  381. X        else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  382. X        {
  383. X            fas_first_outb (fip, I_BANK_PORT, I_BANK_1);
  384. X            fas_outb (fip, I_RCM_PORT, I_FIFO_CLR_RECV);
  385. X            fas_outb (fip, I_BANK_PORT, I_BANK_0);
  386. X        }
  387. X
  388. X        fip->recv_ring_take_ptr = fip->recv_ring_put_ptr;
  389. X        fip->recv_ring_cnt = 0;
  390. X        ttyp->t_state &= ~TBLOCK;
  391. X
  392. X        fas_ihlw_check (fip);
  393. X        break;
  394. X
  395. X    case T_WFLUSH:    /* flush output buffer and restart output */
  396. X        if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  397. X            fas_first_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_SETUP_CMD
  398. X                        | NS_FIFO_CLR_XMIT);
  399. X        else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  400. X        {
  401. X            fas_first_outb (fip, I_BANK_PORT, I_BANK_1);
  402. X            fas_outb (fip, I_TCM_PORT, I_FIFO_CLR_XMIT);
  403. X            fas_outb (fip, I_BANK_PORT, I_BANK_0);
  404. X        }
  405. X
  406. X        fip->xmit_ring_take_ptr = fip->xmit_ring_put_ptr;
  407. X        fip->xmit_ring_cnt = 0;
  408. X
  409. X        fip->flow_flags.s &= ~FF_SWO_STOPPED;
  410. X        ttyp->t_state &= ~TTSTOP;
  411. X
  412. X        if (ttyp->t_tbuf.c_ptr)
  413. X            ttyp->t_tbuf.c_ptr += ttyp->t_tbuf.c_count;
  414. X        ttyp->t_tbuf.c_count = 0;
  415. X
  416. X        if (!(fip->device_flags.i & (DF_XMIT_BUSY | DF_GUARD_TIMEOUT)))
  417. X        {
  418. X            ttyp->t_state &= ~BUSY;
  419. X            fas_hdx_check (fip);
  420. X            goto start_output;
  421. X        }
  422. X        break;
  423. X
  424. X    case T_BREAK:    /* do a break on the transmitter line */
  425. X        fip->device_flags.s |= DF_XMIT_BREAK;
  426. X        ttyp->t_state |= TIMEOUT;
  427. X        if (fip->device_flags.i & (DF_XMIT_BUSY | DF_GUARD_TIMEOUT))
  428. X        {
  429. X            fip->device_flags.s |= DF_DO_BREAK;
  430. X        }
  431. X        else
  432. X        {
  433. X            /* set up break request flags */
  434. X            fip->lcr |= LC_SET_BREAK_LEVEL;
  435. X            fas_first_outb (fip, LINE_CTL_PORT, fip->lcr);
  436. X            (void) timeout (fas_timeout, fip, (BREAK_TIME) * (HZ)
  437. X                                / 1000);
  438. X        }
  439. X        break;
  440. X
  441. X    case T_PARM:    /* set up the port according to the termio structure */
  442. X        fas_param (fip, SOFT_INIT);
  443. X        break;
  444. X
  445. X    case T_SWTCH:    /* handle layer switch request */
  446. X        break;
  447. X    }
  448. X}
  449. X
  450. X/* open device physically */
  451. Xstatic void
  452. Xfas_open_device (fip)
  453. Xregister struct fas_info    *fip;
  454. X{
  455. X    REGVAR;
  456. X
  457. X    /* if already open, set up the mcr register only */
  458. X    if (fip->device_flags.i & DF_DEVICE_OPEN)
  459. X        goto setmcr;
  460. X
  461. X    /* init some variables */
  462. X    fip->device_flags.s &= DF_DEVICE_CONFIGURED | DF_DEVICE_IS_NS16550A
  463. X                | DF_DEVICE_IS_I82510 | DF_DEVICE_LOCKED
  464. X                | DF_CTL_FIRST | DF_CTL_EVERY;
  465. X    fip->flow_flags.s = 0;
  466. X    fip->cflag = 0;
  467. X    fip->iflag = 0;
  468. X    fip->recv_ring_take_ptr = fip->recv_ring_put_ptr;
  469. X    fip->recv_ring_cnt = 0;
  470. X    fip->xmit_ring_take_ptr = fip->xmit_ring_put_ptr;
  471. X    fip->xmit_ring_cnt = 0;
  472. X
  473. X    /* hook into the interrupt users chain */
  474. X    fip->next_int_user = fas_first_int_user [fip->vec];
  475. X    if (fip->next_int_user)
  476. X        fip->next_int_user->prev_int_user = fip;
  477. X    fas_first_int_user [fip->vec] = fip;
  478. X    fip->prev_int_user = (struct fas_info *) NULL;
  479. X
  480. X    fip->lcr = 0;
  481. X    fas_first_outb (fip, LINE_CTL_PORT, fip->lcr);
  482. X
  483. X    /* clear and disable FIFOs */
  484. X    if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  485. X        fas_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_CLEAR_CMD);
  486. X    else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  487. X    {
  488. X        fas_outb (fip, I_BANK_PORT, I_BANK_1);
  489. X        fas_outb (fip, I_TCM_PORT, I_FIFO_CLR_XMIT);
  490. X        fas_outb (fip, I_RCM_PORT, I_FIFO_CLR_RECV);
  491. X        fas_outb (fip, I_BANK_PORT, I_BANK_2);
  492. X        fas_outb (fip, I_IDM_PORT, I_FIFO_CLEAR_CMD);
  493. X        fas_outb (fip, I_BANK_PORT, I_BANK_0);
  494. X    }
  495. X
  496. X    /* clear interrupts */
  497. X    (void) fas_inb (fip, MDM_STATUS_PORT);
  498. X    (void) fas_inb (fip, RCV_DATA_PORT);
  499. X    (void) fas_inb (fip, RCV_DATA_PORT);
  500. X    (void) fas_inb (fip, LINE_STATUS_PORT);
  501. X    (void) fas_inb (fip, INT_ID_PORT);
  502. X
  503. X    /* enable FIFOs */
  504. X    if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  505. X        fas_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_SETUP_CMD);
  506. X    else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  507. X    {
  508. X        fas_outb (fip, I_BANK_PORT, I_BANK_2);
  509. X        fas_outb (fip, I_IDM_PORT, I_FIFO_SETUP_CMD);
  510. X        fas_outb (fip, I_BANK_PORT, I_BANK_0);
  511. X    }
  512. X
  513. X    fip->msi_cnt = 0;
  514. X    fip->msr = fip->new_msr = fas_inb (fip, MDM_STATUS_PORT)
  515. X                    & (MS_CTS_PRESENT
  516. X                        | MS_DSR_PRESENT
  517. X                        | MS_DCD_PRESENT);
  518. X
  519. X    fip->ier = IE_INIT_MODE;    /* enable UART interrupts */
  520. X    fas_outb (fip, INT_ENABLE_PORT, fip->ier);
  521. X
  522. Xsetmcr:
  523. X    /* set up modem and flow control lines */
  524. X    fip->mcr &= ~(fip->modem.m.di
  525. X            | fip->modem.m.ei
  526. X            | fip->modem.m.eo
  527. X            | fip->flow.m.ic
  528. X            | fip->flow.m.hc);
  529. X
  530. X    fip->mcr |= (fip->o_state & OS_WAIT_OPEN)
  531. X            ? fip->modem.m.ei
  532. X            : fip->modem.m.eo;
  533. X
  534. X    if (fip->o_state & OS_HWI_HANDSHAKE)
  535. X        fip->mcr |= fip->flow.m.ic;
  536. X    else if (!(fip->o_state & OS_HDX_HANDSHAKE))
  537. X    {
  538. X        fip->flow_flags.s |= FF_HDX_STARTED;
  539. X        fip->mcr |= fip->flow.m.hc;
  540. X    }
  541. X
  542. X    fas_outb (fip, MDM_CTL_PORT, fip->mcr);
  543. X
  544. X    fip->device_flags.s |= DF_DEVICE_OPEN | DF_MODEM_ENABLED;
  545. X}
  546. X
  547. X/* close device physically */
  548. Xstatic void
  549. Xfas_close_device (fip)
  550. Xregister struct fas_info    *fip;
  551. X{
  552. X    REGVAR;
  553. X
  554. X    fip->device_flags.s &= ~DF_DEVICE_OPEN;
  555. X
  556. X    fip->ier = IE_NONE;    /* disable UART interrupts */
  557. X    fas_first_outb (fip, INT_ENABLE_PORT, fip->ier);
  558. X
  559. X    /* drop flow control lines */
  560. X    fip->mcr &= (fip->o_state & OS_HWI_HANDSHAKE)
  561. X        ? ~fip->flow.m.ic
  562. X        : ~fip->flow.m.hc;
  563. X    fas_outb (fip, MDM_CTL_PORT, fip->mcr);
  564. X
  565. X    /* clear and disable FIFOs */
  566. X    if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  567. X        fas_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_CLEAR_CMD);
  568. X    else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  569. X    {
  570. X        fas_outb (fip, I_BANK_PORT, I_BANK_1);
  571. X        fas_outb (fip, I_TCM_PORT, I_FIFO_CLR_XMIT);
  572. X        fas_outb (fip, I_RCM_PORT, I_FIFO_CLR_RECV);
  573. X        fas_outb (fip, I_BANK_PORT, I_BANK_2);
  574. X        fas_outb (fip, I_IDM_PORT, I_FIFO_CLEAR_CMD);
  575. X        fas_outb (fip, I_BANK_PORT, I_BANK_0);
  576. X    }
  577. X
  578. X    /* reset break level */
  579. X    fip->lcr &= ~LC_SET_BREAK_LEVEL;
  580. X    fas_outb (fip, LINE_CTL_PORT, fip->lcr);
  581. X
  582. X    /* unhook from interrupt users chain */
  583. X    if (fip->prev_int_user)
  584. X        fip->prev_int_user->next_int_user = fip->next_int_user;
  585. X    else
  586. X        fas_first_int_user [fip->vec] = fip->next_int_user;
  587. X    if (fip->next_int_user)
  588. X        fip->next_int_user->prev_int_user = fip->prev_int_user;
  589. X
  590. X    if ((fip->cflag & HUPCL)
  591. X        || !(fip->device_flags.i & DF_DEVICE_CONFIGURED))
  592. X    {
  593. X        /* request hangup */
  594. X        fip->device_flags.s |= DF_DO_HANGUP;
  595. X        (void) timeout (fas_hangup, fip, (HANGUP_DELAY) * (HZ) / 1000);
  596. X    }
  597. X}
  598. X
  599. X/* compute the port access control value */
  600. Xstatic uint
  601. Xfas_make_ctl_val (fip, unit, num)
  602. Xregister struct fas_info    *fip;
  603. Xuint    unit;
  604. Xuint    num;
  605. X{
  606. X    register uint    mask, val;
  607. X    uint    i;
  608. X
  609. X    if (fip->device_flags.i & DF_CTL_FIRST)
  610. X        return (fas_ctl_val [unit]);
  611. X
  612. X    if (fip->device_flags.i & DF_CTL_EVERY)
  613. X    {
  614. X        for (i = 0, mask = fas_ctl_val [unit],
  615. X                val = fas_ctl_val [unit] << 8; i < 8; i++)
  616. X        {
  617. X            if (mask & 0x100)
  618. X            {
  619. X                if (num & 0x01)
  620. X                    val ^= 0x100;
  621. X                num >>= 1;
  622. X            }
  623. X            mask >>= 1;
  624. X            val >>= 1;
  625. X        }
  626. X        return (val);
  627. X    }
  628. X    return (0);
  629. X}
  630. X
  631. X/* test device thoroughly */
  632. Xstatic int
  633. Xfas_test_device (fip)
  634. Xregister struct fas_info    *fip;
  635. X{
  636. X    register unchar    *cptr;
  637. X    int    done;
  638. X    uint    delay_count, i;
  639. X    static uint    lcrval [3] =
  640. X    {
  641. X        LC_WORDLEN_8,
  642. X        LC_WORDLEN_8 | LC_ENABLE_PARITY,
  643. X        LC_WORDLEN_8 | LC_ENABLE_PARITY | LC_EVEN_PARITY
  644. X    };
  645. X    REGVAR;
  646. X
  647. X    /* make sure FIFO is off */
  648. X    fas_first_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_CLEAR_CMD);
  649. X    fas_outb (fip, I_BANK_PORT, I_BANK_2);
  650. X    fas_outb (fip, I_IDM_PORT, I_FIFO_CLEAR_CMD);
  651. X    fas_outb (fip, I_BANK_PORT, I_BANK_0);
  652. X
  653. X    /* set counter divisor */
  654. X    fas_outb (fip, LINE_CTL_PORT, LC_ENABLE_DIVISOR);
  655. X    fas_outb (fip, DIVISOR_LSB_PORT, fas_speeds [B38400]);
  656. X    fas_outb (fip, DIVISOR_MSB_PORT, fas_speeds [B38400] >> 8);
  657. X    fas_outb (fip, LINE_CTL_PORT, 0);
  658. X
  659. X    /* switch to local loopback */
  660. X    fas_outb (fip, MDM_CTL_PORT, MC_SET_LOOPBACK);
  661. X
  662. X    done = 0;
  663. X
  664. X    /* wait until the transmitter register is empty */
  665. X    for (delay_count = 20000;
  666. X        delay_count && (~fas_inb (fip, LINE_STATUS_PORT)
  667. X                & (LS_XMIT_AVAIL | LS_XMIT_COMPLETE));
  668. X        delay_count--)
  669. X        ;
  670. X
  671. X    if (!delay_count)
  672. X        done = 1;
  673. X
  674. X    if (!done)
  675. X    {
  676. X        /* clear flags */
  677. X        (void) fas_inb (fip, RCV_DATA_PORT);
  678. X        (void) fas_inb (fip, RCV_DATA_PORT);
  679. X        (void) fas_inb (fip, LINE_STATUS_PORT);
  680. X
  681. X        /* make sure there are no more characters in the
  682. X           receiver register
  683. X        */
  684. X        for (delay_count = 20000;
  685. X            delay_count && !(fas_inb (fip, LINE_STATUS_PORT) & LS_RCV_AVAIL);
  686. X            delay_count--)
  687. X            ;
  688. X
  689. X        if (delay_count)
  690. X            (void) fas_inb (fip, RCV_DATA_PORT);
  691. X
  692. X        /* test pattern */
  693. X        cptr = (unchar *) "\
  694. X\377\125\252\045\244\0\
  695. X\377\125\252\045\244\0\
  696. X\377\125\252\045\244\0\
  697. X\377\125\252\045\244\0\
  698. X\377\125\252\045\244\0\0";
  699. X
  700. X        do
  701. X        {
  702. X            for (i = 0; i < 3; i++)
  703. X            {
  704. X                /* test transmitter and receiver
  705. X                   with different line settings
  706. X                */
  707. X                fas_outb (fip, LINE_CTL_PORT, lcrval [i]);
  708. X
  709. X                /* wait until the transmitter register
  710. X                   is empty
  711. X                */
  712. X                for (delay_count = 20000;
  713. X                    delay_count && (~fas_inb (fip, LINE_STATUS_PORT)
  714. X                            & (LS_XMIT_AVAIL
  715. X                              | LS_XMIT_COMPLETE));
  716. X                    delay_count--)
  717. X                    ;
  718. X
  719. X                if (!delay_count)
  720. X                {
  721. X                    done = 2;
  722. X                    break;
  723. X                }
  724. X
  725. X                /* send test pattern */
  726. X                fas_outb (fip, XMT_DATA_PORT, *cptr);
  727. X
  728. X                /* wait until the test pattern is received */
  729. X                for (delay_count = 20000;
  730. X                    delay_count && ((fas_inb (fip, LINE_STATUS_PORT)
  731. X                                & LS_RCV_INT)
  732. X                            != LS_RCV_AVAIL);
  733. X                    delay_count--)
  734. X                    ;
  735. X
  736. X                if (!delay_count)
  737. X                {
  738. X                    done = 3;
  739. X                    break;
  740. X                }
  741. X
  742. X                /* check test pattern */
  743. X                if (fas_inb (fip, RCV_DATA_PORT) != *cptr)
  744. X                {
  745. X                    done = 4;
  746. X                    break;
  747. X                }
  748. X            }
  749. X
  750. X            if (done)
  751. X                break;
  752. X        } while (*((ushort *) cptr++));
  753. X    }
  754. X
  755. X    if (!done)
  756. X    {
  757. X        /* wait until the transmitter register is empty */
  758. X        for (delay_count = 20000;
  759. X            delay_count && (~fas_inb (fip, LINE_STATUS_PORT)
  760. X                    & (LS_XMIT_AVAIL | LS_XMIT_COMPLETE));
  761. X            delay_count--)
  762. X            ;
  763. X
  764. X        if (!delay_count)
  765. X            done = 5;
  766. X    }
  767. X
  768. X    if (!done)
  769. X    {
  770. X        /* test pattern */
  771. X        cptr = (unchar *) "\
  772. X\005\142\012\237\006\130\011\257\017\361\0\017\
  773. X\005\142\012\237\006\130\011\257\017\361\0\017\
  774. X\005\142\012\237\006\130\011\257\017\361\0\017\
  775. X\005\142\012\237\006\130\011\257\017\361\0\017\
  776. X\005\142\012\237\006\130\011\257\017\361\0\017\0\0";
  777. X
  778. X        /* clear delta bits */
  779. X        (void) fas_inb (fip, MDM_STATUS_PORT);
  780. X
  781. X        do
  782. X        {
  783. X            /* test modem control and status lines */
  784. X            fas_outb (fip, MDM_CTL_PORT, *cptr | MC_SET_LOOPBACK);
  785. X            if (fas_inb (fip, MDM_STATUS_PORT) != *(cptr + 1))
  786. X            {
  787. X                done = 6;
  788. X                break;
  789. X            }
  790. X        } while (*((ushort *) cptr)++);
  791. X    }
  792. X
  793. X    /* switch back to normal operation */
  794. X    fas_outb (fip, MDM_CTL_PORT, 0);
  795. X
  796. X    return (done);
  797. X}
  798. X
  799. X#if defined (NEED_PUT_GETCHAR)
  800. X
  801. Xint
  802. Xasyputchar (arg1)
  803. Xunchar    arg1;
  804. X{
  805. X    register struct    fas_info    *fip;
  806. X    REGVAR;
  807. X
  808. X    if (!fas_is_initted)
  809. X        (void) fasinit ();
  810. X
  811. X    fip = &fas_info [0];
  812. X    if (fip->device_flags.i & DF_DEVICE_CONFIGURED)
  813. X    {
  814. X        fas_ctl (fip, LINE_STATUS_PORT);
  815. X        while (!(inb (LINE_STATUS_PORT.addr) & LS_XMIT_AVAIL))
  816. X            ;
  817. X        fas_outb (fip, XMT_DATA_PORT, arg1);
  818. X        if (arg1 == 10)
  819. X            (void) asyputchar (13);
  820. X    }
  821. X    return (0);
  822. X}
  823. X
  824. Xint
  825. Xasygetchar ()
  826. X{
  827. X    register struct    fas_info    *fip;
  828. X    REGVAR;
  829. X
  830. X    if (!fas_is_initted)
  831. X        (void) fasinit ();
  832. X
  833. X    fip = &fas_info [0];
  834. X    if ((fip->device_flags.i & DF_DEVICE_CONFIGURED)
  835. X        && (fas_first_inb (fip, LINE_STATUS_PORT) & LS_RCV_AVAIL))
  836. X        return (fas_inb (fip, RCV_DATA_PORT));
  837. X    else
  838. X        return (-1);
  839. X}
  840. X#endif
  841. X
  842. X#if defined (NEED_INIT8250)
  843. X
  844. X/* reset the requested port to be used directly by a DOS process */
  845. Xint
  846. Xinit8250 (port, ier)
  847. Xushort    port, ier;    /* ier not used in this stub */
  848. X{
  849. X    register struct fas_info    *fip;
  850. X    register uint    physical_unit;
  851. X    int    old_level;
  852. X    REGVAR;
  853. X
  854. X    /* See if the port address matches a port that is used by
  855. X       the fas driver.
  856. X    */
  857. X    for (physical_unit = 0; physical_unit < fas_physical_units;
  858. X            physical_unit++)
  859. X        if (port == (ushort) (fas_port [physical_unit]))
  860. X            break;
  861. X
  862. X    if (physical_unit >= fas_physical_units)
  863. X        return (-1);    /* port didn't match */
  864. X
  865. X    fip = fas_info_ptr [physical_unit];
  866. X
  867. X    old_level = SPLINT ();
  868. X
  869. X    fip->ier = IE_NONE;
  870. X    fas_first_outb (fip, INT_ENABLE_PORT, fip->ier);
  871. X
  872. X    fip->mcr &= ~(fip->flow.m.ic | fip->flow.m.hc);
  873. X    fas_outb (fip, MDM_CTL_PORT, fip->mcr);
  874. X
  875. X    if (fip->device_flags.i & DF_DEVICE_IS_NS16550A)
  876. X        fas_outb (fip, NS_FIFO_CTL_PORT, NS_FIFO_CLEAR_CMD);
  877. X    else if (fip->device_flags.i & DF_DEVICE_IS_I82510)
  878. X    {
  879. X        fas_outb (fip, I_BANK_PORT, I_BANK_1);
  880. X        fas_outb (fip, I_TCM_PORT, I_FIFO_CLR_XMIT);
  881. X        fas_outb (fip, I_RCM_PORT, I_FIFO_CLR_RECV);
  882. X        fas_outb (fip, I_BANK_PORT, I_BANK_2);
  883. X        fas_outb (fip, I_IDM_PORT, I_FIFO_CLEAR_CMD);
  884. X        fas_outb (fip, I_BANK_PORT, I_BANK_0);
  885. X    }
  886. X
  887. X    (void) fas_inb (fip, MDM_STATUS_PORT);
  888. X    (void) fas_inb (fip, RCV_DATA_PORT);
  889. X    (void) fas_inb (fip, RCV_DATA_PORT);
  890. X    (void) fas_inb (fip, LINE_STATUS_PORT);
  891. X    (void) fas_inb (fip, INT_ID_PORT);
  892. X    (void) splx (old_level);
  893. X    return (0);
  894. X}
  895. X#endif
  896. SHAR_EOF
  897. echo 'File fasi/fas.c is complete' &&
  898. $TOUCH -am 0725125791 'fasi/fas.c' &&
  899. chmod 0644 fasi/fas.c ||
  900. echo 'restore of fasi/fas.c failed'
  901. Wc_c="`wc -c < 'fasi/fas.c'`"
  902. test 81145 -eq "$Wc_c" ||
  903.     echo 'fasi/fas.c: original size 81145, current size' "$Wc_c"
  904. rm -f _shar_wnt_.tmp
  905. fi
  906. # ============= fasi/idfasi ==============
  907. if test -f 'fasi/idfasi' -a X"$1" != X"-c"; then
  908.     echo 'x - skipping fasi/idfasi (File already exists)'
  909.     rm -f _shar_wnt_.tmp
  910. else
  911. > _shar_wnt_.tmp
  912. echo 'x - extracting fasi/idfasi (Text)'
  913. sed 's/^X//' << 'SHAR_EOF' > 'fasi/idfasi' &&
  914. X:
  915. X#+---------------------------------------------------------------
  916. X# idefas - ECU FASI/FAS Installation
  917. X# Alas, SCO idinstall has no -z (Define) option like ISC does
  918. X#----------------------------------------------------------------
  919. X/etc/conf/bin/idcheck -p fas
  920. Xif [ $? -lt 16 ] ; then
  921. X    /etc/conf/bin/idinstall -a -e -k fas
  922. Xelse
  923. X    /etc/conf/bin/idinstall -u -e -k fas
  924. Xfi
  925. SHAR_EOF
  926. $TOUCH -am 0429171591 'fasi/idfasi' &&
  927. chmod 0744 fasi/idfasi ||
  928. echo 'restore of fasi/idfasi failed'
  929. Wc_c="`wc -c < 'fasi/idfasi'`"
  930. test 370 -eq "$Wc_c" ||
  931.     echo 'fasi/idfasi: original size 370, current size' "$Wc_c"
  932. rm -f _shar_wnt_.tmp
  933. fi
  934. # ============= ecufriend/ecufriend.c ==============
  935. if test -f 'ecufriend/ecufriend.c' -a X"$1" != X"-c"; then
  936.     echo 'x - skipping ecufriend/ecufriend.c (File already exists)'
  937.     rm -f _shar_wnt_.tmp
  938. else
  939. > _shar_wnt_.tmp
  940. echo 'x - extracting ecufriend/ecufriend.c (Text)'
  941. sed 's/^X//' << 'SHAR_EOF' > 'ecufriend/ecufriend.c' &&
  942. X#define DUMP_SCREEN
  943. X/*+-------------------------------------------------------------------------
  944. X    ecufriend.c -- example of using ecu shared memory access
  945. X    wht@n4hgf.Mt-Park.GA.US
  946. X
  947. XExecute by ecu procedure command:  system -s 'ecufriend '+%itos(%shmid)
  948. XTo manually execute for perusal, do an ipcs command to find the
  949. Xshared memory id or HOME pc echo 'shmid='+%itos(%shmid)
  950. XThen HOME >ecufriend # where # is replaced by the shmid
  951. X--------------------------------------------------------------------------*/
  952. X/*+:EDITS:*/
  953. X/*:07-25-1991-12:56-wht@n4hgf-ECU release 3.10 */
  954. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  955. X
  956. X#include <stdio.h>
  957. X#include <signal.h>
  958. X#include <termio.h>
  959. X#include <sys/errno.h>
  960. X#include <sys/types.h>
  961. X#include <sys/stat.h>
  962. X#include <time.h>
  963. X#include <sys/ipc.h>
  964. X#include <sys/msg.h>
  965. X#include <sys/shm.h>
  966. X#include "../ecushm.h"
  967. X
  968. XECU_SDS FAR *shm;        /* shared segment pointer */
  969. Xint shmid;                /* sharged segment id */
  970. X
  971. X/*+-------------------------------------------------------------------------
  972. X    main(argc,argv,envp)
  973. X--------------------------------------------------------------------------*/
  974. Xmain(argc,argv,envp)
  975. Xint argc;
  976. Xchar **argv;
  977. Xchar **envp;
  978. X{
  979. Xregister itmp;
  980. X#ifdef DUMP_SCREEN
  981. Xint row,col;
  982. Xunsigned char sch;
  983. X#endif
  984. X
  985. X    if(argc < 2)
  986. X    {
  987. X        printf("usage: ecufriend <ecu-shmid>\n");
  988. X            exit(255);
  989. X    }
  990. X    shmid = atoi(argv[1]);
  991. X
  992. X    if((shm = (ECU_SDS FAR *)shmat(shmid,(char FAR *)0,SHM_RDONLY))
  993. X            == (ECU_SDS FAR *)-1)
  994. X    {
  995. X        perror("shmat");
  996. X        exit(1);
  997. X    }
  998. X
  999. X    printf("ecu shm address = %08lx shmid=%d revision=%08lx\n",
  1000. X        shm,shmid,shm->shm_revision);
  1001. X
  1002. X    if(shm->shm_revision != SHM_REV)
  1003. X    {
  1004. X        printf("incompatible shared memory revision (compiled with %08lx)\n",
  1005. X            SHM_REV);
  1006. X        exit(1);
  1007. X    }
  1008. X
  1009. X    printf("xmit chars=%lu rcvd chars=%lu\n",
  1010. X        shm->xmit_chars,shm->rcvd_chars);
  1011. X    printf("The receive cursor position is at column %d row %d\n",
  1012. X        shm->cursor_y,shm->cursor_x);
  1013. X
  1014. X    printf("If this program was not executed by a shell that closed it,\n");
  1015. X    printf("then fd %d is available to us to write and read from the line.\n",
  1016. X        shm->Liofd);
  1017. X
  1018. X    if(isatty(shm->Liofd))
  1019. X        printf("It is available.\n");
  1020. X    else
  1021. X        printf("It is not available. Even so, we could re-open %s here\n",
  1022. X            shm->Lline);
  1023. X
  1024. X    if(shm->Lmodem_off_hook)
  1025. X        printf("Hmmm.. we seem to be connected to %s at %s\n",
  1026. X            shm->Ldescr,shm->Ltelno);
  1027. X
  1028. X#ifdef DUMP_SCREEN
  1029. X    printf("screen dump\n");
  1030. X    printf("-----------\n");
  1031. X    for(row = 0; row < 43; row++)
  1032. X    {
  1033. X        for(col = 0; col < 79; col++)
  1034. X        {
  1035. X            sch = shm->screen[row][col];
  1036. X            if((sch < 0x20) && (sch > 0x7E))
  1037. X                putc('.',stdout);
  1038. X            else
  1039. X                putc(sch,stdout);
  1040. X        }
  1041. X        putc('\n',stdout);
  1042. X    }
  1043. X#endif
  1044. X
  1045. X    exit(0);
  1046. X}    /* end of main */
  1047. X
  1048. X/* vi: set tabstop=4 shiftwidth=4: */
  1049. X/* end of ecufriend.c */
  1050. SHAR_EOF
  1051. $TOUCH -am 0725125691 'ecufriend/ecufriend.c' &&
  1052. chmod 0644 ecufriend/ecufriend.c ||
  1053. echo 'restore of ecufriend/ecufriend.c failed'
  1054. Wc_c="`wc -c < 'ecufriend/ecufriend.c'`"
  1055. test 2718 -eq "$Wc_c" ||
  1056.     echo 'ecufriend/ecufriend.c: original size 2718, current size' "$Wc_c"
  1057. rm -f _shar_wnt_.tmp
  1058. fi
  1059. # ============= mapkey/README ==============
  1060. if test ! -d 'mapkey'; then
  1061.     echo 'x - creating directory mapkey'
  1062.     mkdir 'mapkey'
  1063. fi
  1064. if test -f 'mapkey/README' -a X"$1" != X"-c"; then
  1065.     echo 'x - skipping mapkey/README (File already exists)'
  1066.     rm -f _shar_wnt_.tmp
  1067. else
  1068. > _shar_wnt_.tmp
  1069. echo 'x - extracting mapkey/README (Text)'
  1070. sed 's/^X//' << 'SHAR_EOF' > 'mapkey/README' &&
  1071. X
  1072. X#+:EDITS:
  1073. X#:05-02-1991-01:57-wht@n4hgf-alt-[a-z] range moved from 0x80-0x99 to 0xe0-0xf9
  1074. X
  1075. XThis file contains information necessary to map ALT-A through ALT-Z
  1076. Xin accordance with ecuxkey.h to produce unique codes so that
  1077. XALT-[a-z] can cause ECU to execute procedures with a single keystroke.
  1078. X
  1079. XBeginning with ECU 3.10, the key code range changed:
  1080. X      128 through 153 (0x80 through 0x99)     to
  1081. X      229 through 249 (0xE0 through 0xF9)
  1082. X
  1083. XModify your /usr/lib/keyboard/keys value for the ALT values for
  1084. Xkey codes matching keys [a-z] as follows.  If you have made no 
  1085. Xother changes to your key file, use the supplied keys.usa.ecu
  1086. X
  1087. XMy apologies to those caught by having already done something
  1088. Xsimilar for EMACS or CRISP.
  1089. X
  1090. XThese are the necessary differences:
  1091. X
  1092. X                                ALT-unshifted
  1093. X                                     |
  1094. X                                     V
  1095. X    16  'q'    'Q'    dc1    dc1    0xf0   'Q'    dc1    dc1     C
  1096. X    17  'w'    'W'    etb    etb    0xf6   'W'    etb    etb     C
  1097. X    18  'e'    'E'    enq    enq    0xe4   'E'    enq    enq     C
  1098. X    19  'r'    'R'    dc2    dc2    0xf1   'R'    dc2    dc2     C
  1099. X    20  't'    'T'    dc4    dc4    0xf3   'T'    dc4    dc4     C
  1100. X    21  'y'    'Y'    em     em     0xf8   'Y'    em     em      C
  1101. X    22  'u'    'U'    nak    nak    0xf4   'U'    nak    nak     C
  1102. X    23  'i'    'I'    ht     ht     0xe8   'I'    ht     ht      C
  1103. X    24  'o'    'O'    si     si     0xee   'O'    si     si      C
  1104. X    25  'p'    'P'    dle    dle    0xef   'P'    dle    dle     C
  1105. X    30  'a'    'A'    soh    soh    0xe0   'A'    soh    soh     C
  1106. X    31  's'    'S'    dc3    dc3    0xf2   'S'    dc3    dc3     C
  1107. X    32  'd'    'D'    eot    eot    0xe3   'D'    eot    eot     C
  1108. X    33  'f'    'F'    ack    ack    0xe5   'F'    ack    ack     C
  1109. X    34  'g'    'G'    bel    bel    0xe6   'G'    bel    bel     C
  1110. X    35  'h'    'H'    bs     bs     0xe7   'H'    bs     bs      C
  1111. X    36  'j'    'J'    nl     nl     0xe9   'J'    nl     nl      C
  1112. X    37  'k'    'K'    vt     vt     0xea   'K'    vt     vt      C
  1113. X    38  'l'    'L'    np     np     0xeb   'L'    np     np      C
  1114. X    44  'z'    'Z'    sub    sub    0xf9   'Z'    sub    sub     C
  1115. X    45  'x'    'X'    can    can    0xf7   'X'    can    can     C
  1116. X    46  'c'    'C'    etx    etx    0xe2   'C'    etx    etx     C
  1117. X    47  'v'    'V'    syn    syn    0xf5   'V'    syn    syn     C
  1118. X    48  'b'    'B'    stx    stx    0xe1   'B'    stx    stx     C
  1119. X    49  'n'    'N'    so     so     0xed   'N'    so     so      C
  1120. X    50  'm'    'M'    cr     cr     0xec   'M'    cr     cr      C
  1121. X
  1122. SHAR_EOF
  1123. $TOUCH -am 0502022691 'mapkey/README' &&
  1124. chmod 0644 mapkey/README ||
  1125. echo 'restore of mapkey/README failed'
  1126. Wc_c="`wc -c < 'mapkey/README'`"
  1127. test 2624 -eq "$Wc_c" ||
  1128.     echo 'mapkey/README: original size 2624, current size' "$Wc_c"
  1129. rm -f _shar_wnt_.tmp
  1130. fi
  1131. # ============= mapkey/keys.usa.ecu ==============
  1132. if test -f 'mapkey/keys.usa.ecu' -a X"$1" != X"-c"; then
  1133.     echo 'x - skipping mapkey/keys.usa.ecu (File already exists)'
  1134.     rm -f _shar_wnt_.tmp
  1135. else
  1136. > _shar_wnt_.tmp
  1137. echo 'x - extracting mapkey/keys.usa.ecu (Text)'
  1138. sed 's/^X//' << 'SHAR_EOF' > 'mapkey/keys.usa.ecu' &&
  1139. X#+----------------------------------------------------------------------------
  1140. X# keys.usa.ecu
  1141. X# SCO keys file for ECU alt-[a-z] support
  1142. X#-----------------------------------------------------------------------------
  1143. X#+:EDITS:
  1144. X#:05-02-1991-01:57-wht@n4hgf-alt-[a-z] range moved from 0x80-0x99 to 0xe0-0xf9
  1145. X
  1146. X# scan                      cntrl          alt    alt   cntrl  lock
  1147. X# code  base  shift  cntrl  shift   alt   shift  cntrl  shift  state
  1148. X     0  nop    nop    nop    nop    nop    nop    nop    nop     O
  1149. X     1  esc    esc    esc    esc    esc    esc    esc    esc     O
  1150. X     2  '1'    '!'    nop    nop    '1'    '!'    nop    nop     O
  1151. X     3  '2'    '@'    nul    nul    '2'    '@'    nul    nul     O
  1152. X     4  '3'    '#'    nop    nop    '3'    '#'    nop    nop     O
  1153. X     5  '4'    '$'    nop    nop    '4'    '$'    nop    nop     O
  1154. X     6  '5'    '%'    nop    nop    '5'    '%'    nop    nop     O
  1155. X     7  '6'    '^'    rs     rs     '6'    '^'    rs     rs      O
  1156. X     8  '7'    '&'    nop    nop    '7'    '&'    nop    nop     O
  1157. X     9  '8'    '*'    nop    nop    '8'    '*'    nop    nop     O
  1158. X    10  '9'    '('    nop    nop    '9'    '('    nop    nop     O
  1159. X    11  '0'    ')'    nop    nop    '0'    ')'    nop    nop     O
  1160. X    12  '-'    '_'    ns     ns     '-'    '_'    ns     ns      O
  1161. X    13  '='    '+'    nop    nop    '='    '+'    nop    nop     O
  1162. X    14  bs     bs     del    del    bs     bs     del    del     O
  1163. X    15  ht     btab   nop    nop    ht     btab   nop    nop     O
  1164. X    16  'q'    'Q'    dc1    dc1    0xf0   'Q'    dc1    dc1     C
  1165. X    17  'w'    'W'    etb    etb    0xf6   'W'    etb    etb     C
  1166. X    18  'e'    'E'    enq    enq    0xe4   'E'    enq    enq     C
  1167. X    19  'r'    'R'    dc2    dc2    0xf1   'R'    dc2    dc2     C
  1168. X    20  't'    'T'    dc4    dc4    0xf3   'T'    dc4    dc4     C
  1169. X    21  'y'    'Y'    em     em     0xf8   'Y'    em     em      C
  1170. X    22  'u'    'U'    nak    nak    0xf4   'U'    nak    nak     C
  1171. X    23  'i'    'I'    ht     ht     0xe8   'I'    ht     ht      C
  1172. X    24  'o'    'O'    si     si     0xee   'O'    si     si      C
  1173. X    25  'p'    'P'    dle    dle    0xef   'P'    dle    dle     C
  1174. X    26  '['    '{'    esc    esc    '['    '{'    esc    esc     O
  1175. X    27  ']'    '}'    gs     gs     ']'    '}'    gs     gs      O
  1176. X    28  cr     cr     nl     nl     cr     cr     nl     nl      O
  1177. X    29  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl  lctrl   O
  1178. X    30  'a'    'A'    soh    soh    0xe0   'A'    soh    soh     C
  1179. X    31  's'    'S'    dc3    dc3    0xf2   'S'    dc3    dc3     C
  1180. X    32  'd'    'D'    eot    eot    0xe3   'D'    eot    eot     C
  1181. X    33  'f'    'F'    ack    ack    0xe5   'F'    ack    ack     C
  1182. X    34  'g'    'G'    bel    bel    0xe6   'G'    bel    bel     C
  1183. X    35  'h'    'H'    bs     bs     0xe7   'H'    bs     bs      C
  1184. X    36  'j'    'J'    nl     nl     0xe9   'J'    nl     nl      C
  1185. X    37  'k'    'K'    vt     vt     0xea   'K'    vt     vt      C
  1186. X    38  'l'    'L'    np     np     0xeb   'L'    np     np      C
  1187. X    39  ';'    ':'    nop    nop    ';'    ':'    nop    nop     O
  1188. X    40  '\''   '"'    nop    nop    '\''   '"'    nop    nop     O
  1189. X    41  '`'    '~'    nop    nop    '`'    '~'    nop    nop     O
  1190. X    42  lshift lshift lshift lshift lshift lshift lshift lshift  O
  1191. X    43  '\\'   '|'    fs     fs     '\\'   '|'    fs     fs      O
  1192. X    44  'z'    'Z'    sub    sub    0xf9   'Z'    sub    sub     C
  1193. X    45  'x'    'X'    can    can    0xf7   'X'    can    can     C
  1194. X    46  'c'    'C'    etx    etx    0xe2   'C'    etx    etx     C
  1195. X    47  'v'    'V'    syn    syn    0xf5   'V'    syn    syn     C
  1196. X    48  'b'    'B'    stx    stx    0xe1   'B'    stx    stx     C
  1197. X    49  'n'    'N'    so     so     0xed   'N'    so     so      C
  1198. X    50  'm'    'M'    cr     cr     0xec   'M'    cr     cr      C
  1199. X    51  ','    '<'    nop    nop    ','    '<'    nop    nop     O
  1200. X    52  '.'    '>'    nop    nop    '.'    '>'    nop    nop     O
  1201. X    53  '/'    '?'    nop    nop    '/'    '?'    nop    nop     O
  1202. X    54  rshift rshift rshift rshift rshift rshift rshift rshift  O
  1203. X    55  '*'    '*'    nscr   nscr   '*'    '*'    nscr   nscr    O
  1204. X    56  lalt   lalt   lalt   lalt   lalt   lalt   lalt   lalt    O
  1205. X    57  ' '    ' '    ' '    ' '    ' '    ' '    ' '    ' '     O
  1206. X    58  clock  clock  clock  clock  clock  clock  clock  clock   O
  1207. X    59  fkey1  fkey13 fkey25 fkey37 scr1   scr11  scr1   scr11   O
  1208. X    60  fkey2  fkey14 fkey26 fkey38 scr2   scr12  scr2   scr12   O
  1209. X    61  fkey3  fkey15 fkey27 fkey39 scr3   scr13  scr3   scr13   O
  1210. X    62  fkey4  fkey16 fkey28 fkey40 scr4   scr14  scr4   scr14   O
  1211. X    63  fkey5  fkey17 fkey29 fkey41 scr5   scr15  scr5   scr15   O
  1212. X    64  fkey6  fkey18 fkey30 fkey42 scr6   scr16  scr6   scr16   O
  1213. X    65  fkey7  fkey19 fkey31 fkey43 scr7   scr7   scr7   scr7    O
  1214. X    66  fkey8  fkey20 fkey32 fkey44 scr8   scr8   scr8   scr8    O
  1215. X    67  fkey9  fkey21 fkey33 fkey45 scr9   scr9   scr9   scr9    O
  1216. X    68  fkey10 fkey22 fkey34 fkey46 scr10  scr10  scr10  scr10   O
  1217. X    69  nlock  nlock  dc3    dc3    nlock  nlock  dc3    dc3     O
  1218. X    70  slock  slock  del    del    slock  slock  del    del     O
  1219. X    71  fkey49 '7'    '7'    '7'    '7'    '7'    '7'    '7'     N
  1220. X    72  fkey50 '8'    '8'    '8'    '8'    '8'    '8'    '8'     N
  1221. X    73  fkey51 '9'    '9'    '9'    '9'    '9'    '9'    '9'     N
  1222. X    74  fkey52 '-'    '-'    '-'    '-'    '-'    '-'    '-'     N
  1223. X    75  fkey53 '4'    '4'    '4'    '4'    '4'    '4'    '4'     N
  1224. X    76  fkey54 '5'    '5'    '5'    '5'    '5'    '5'    '5'     N
  1225. X    77  fkey55 '6'    '6'    '6'    '6'    '6'    '6'    '6'     N
  1226. X    78  fkey56 '+'    '+'    '+'    '+'    '+'    '+'    '+'     N
  1227. X    79  fkey57 '1'    '1'    '1'    '1'    '1'    '1'    '1'     N
  1228. X    80  fkey58 '2'    '2'    '2'    '2'    '2'    '2'    '2'     N
  1229. X    81  fkey59 '3'    '3'    '3'    '3'    '3'    '3'    '3'     N
  1230. X    82  fkey60 '0'    '0'    '0'    '0'    '0'    '0'    '0'     N
  1231. X    83  del    '.'    del    del    del    del    del    del     N
  1232. X    84  0x1f   0x1f   0x1f   0x1f   0x1f   0x1f   0x1f   0x1f    O
  1233. X    85  nop    nop    nop    nop    nop    nop    nop    nop     O
  1234. X    86  nop    nop    nop    nop    nop    nop    nop    nop     O
  1235. X    87  fkey11 fkey23 fkey35 fkey47 scr11  scr11  scr11  scr11   O
  1236. X    88  fkey12 fkey24 fkey36 fkey48 scr12  scr12  scr12  scr12   O
  1237. X    89  nop    nop    nop    nop    nop    nop    nop    nop     O
  1238. X    90  nop    nop    nop    nop    nop    nop    nop    nop     O
  1239. X    91  nop    nop    nop    nop    nop    nop    nop    nop     O
  1240. X    92  nop    nop    nop    nop    nop    nop    nop    nop     O
  1241. X    93  nop    nop    nop    nop    nop    nop    nop    nop     O
  1242. X    94  nop    nop    nop    nop    nop    nop    nop    nop     O
  1243. X    95  nop    nop    nop    nop    nop    nop    nop    nop     O
  1244. X    96  fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50  O
  1245. X    97  fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53  O
  1246. X    98  fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58  O
  1247. X    99  fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55  O
  1248. X   100  fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49  O
  1249. X   102  fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57  O
  1250. X   103  fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59  O
  1251. X   104  fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60  O
  1252. X   105  del    del    del    del    del    del    del    del     N
  1253. X   106  fkey54 fkey54 fkey54 fkey54 fkey54 fkey54 fkey54 fkey54  O
  1254. X   107  nop    nop    nop    nop    nop    nop    nop    nop     O
  1255. X   108  nop    nop    nop    nop    nop    nop    nop    nop     O
  1256. X   109  nop    nop    nop    nop    nop    nop    nop    nop     O
  1257. X   110  nop    nop    nop    nop    nop    nop    nop    nop     O
  1258. X   111  fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51  O
  1259. X   111  nop    nop    nop    nop    nop    nop    nop    nop     O
  1260. X   112  nop    nop    nop    nop    nop    nop    nop    nop     O
  1261. X   113  nop    nop    nop    nop    nop    nop    nop    nop     O
  1262. X   114  nop    nop    nop    nop    nop    nop    nop    nop     O
  1263. X   116  nop    nop    nop    nop    nop    nop    nop    nop     O
  1264. X   117  nop    nop    nop    nop    nop    nop    nop    nop     O
  1265. X   118  nop    nop    nop    nop    nop    nop    nop    nop     O
  1266. X   119  nop    nop    nop    nop    nop    nop    nop    nop     O
  1267. X   120  nop    nop    nop    nop    nop    nop    nop    nop     O
  1268. X   121  nop    nop    nop    nop    nop    nop    nop    nop     O
  1269. X   122  nop    nop    nop    nop    nop    nop    nop    nop     O
  1270. X   123  nop    nop    nop    nop    nop    nop    nop    nop     O
  1271. X   124  nop    nop    nop    nop    nop    nop    nop    nop     O
  1272. X   125  nop    nop    nop    nop    nop    nop    nop    nop     O
  1273. X   126  nop    nop    nop    nop    nop    nop    nop    nop     O
  1274. X   127  nop    nop    nop    nop    nop    nop    nop    nop     O
  1275. X   128  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl  rctrl   O
  1276. X   129  ralt   ralt   ralt   ralt   ralt   ralt   ralt   ralt    O
  1277. X   130  fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60 fkey60  O
  1278. X   131  del    del    del    del    del    del    del    del     N
  1279. X   132  fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49 fkey49  O
  1280. X   133  fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57 fkey57  O
  1281. X   134  fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51 fkey51  O
  1282. X   135  fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59 fkey59  O
  1283. X   136  fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55 fkey55  O
  1284. X   137  fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53 fkey53  O
  1285. X   138  fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50 fkey50  O
  1286. X   139  fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58 fkey58  O
  1287. X   140  '/'    nop    nop    nop    '/'    nop    nop    nop     O
  1288. X   141  cr     cr     nl     nl     cr     cr     nl     nl      O
  1289. SHAR_EOF
  1290. $TOUCH -am 0502021091 'mapkey/keys.usa.ecu' &&
  1291. chmod 0644 mapkey/keys.usa.ecu ||
  1292. echo 'restore of mapkey/keys.usa.ecu failed'
  1293. Wc_c="`wc -c < 'mapkey/keys.usa.ecu'`"
  1294. test 9889 -eq "$Wc_c" ||
  1295.     echo 'mapkey/keys.usa.ecu: original size 9889, current size' "$Wc_c"
  1296. rm -f _shar_wnt_.tmp
  1297. fi
  1298. # ============= xsel386/fixttiocom.c ==============
  1299. if test ! -d 'xsel386'; then
  1300.     echo 'x - creating directory xsel386'
  1301.     mkdir 'xsel386'
  1302. fi
  1303. if test -f 'xsel386/fixttiocom.c' -a X"$1" != X"-c"; then
  1304.     echo 'x - skipping xsel386/fixttiocom.c (File already exists)'
  1305.     rm -f _shar_wnt_.tmp
  1306. else
  1307. > _shar_wnt_.tmp
  1308. echo 'x - extracting xsel386/fixttiocom.c (Text)'
  1309. sed 's/^X//' << 'SHAR_EOF' > 'xsel386/fixttiocom.c' &&
  1310. X/*+-------------------------------------------------------------------------
  1311. X    fixttiocom.c - change ttiocom to Ttiocom calls in /usr/sys/sys/libsys.a
  1312. XThis program patched my Xenix 386 2.3.1 system library (a copy of which
  1313. Xhad been named libfix.a, fixed, verified, then moved to libsys.a)
  1314. X--------------------------------------------------------------------------*/
  1315. X/*+:EDITS:*/
  1316. X/*:07-25-1991-12:59-wht@n4hgf-ECU release 3.10 */
  1317. X/*:08-14-1990-20:40-wht@n4hgf-ecu3.00-flush old edit history */
  1318. X
  1319. X#include <stdio.h>
  1320. X#include <sys/types.h>
  1321. X#include <fcntl.h>
  1322. X
  1323. Xchar *lib = "libfix.a";
  1324. X
  1325. X/* file positions where names needed changing */
  1326. X#define PLACE1 0xdcaL
  1327. X#define PLACE2 0x1b1cbL
  1328. X#define PLACE3 0x1c41bL
  1329. X
  1330. X/*+-------------------------------------------------------------------------
  1331. X    main(argc,argv,envp)
  1332. X--------------------------------------------------------------------------*/
  1333. Xmain(argc,argv,envp)
  1334. Xint argc;
  1335. Xchar **argv;
  1336. Xchar **envp;
  1337. X{
  1338. Xint fd = open(lib,O_RDWR,0);
  1339. Xunsigned char ch1,ch2,ch3;
  1340. Xlong lseek();
  1341. X
  1342. X    if(fd < 0)
  1343. X    {
  1344. X        perror(lib);
  1345. X        exit(9);
  1346. X    }
  1347. X
  1348. X    if(lseek(fd,PLACE1,0) != PLACE1)
  1349. X    {
  1350. X        perror("seek1");
  1351. X        exit(1);
  1352. X    }
  1353. X    if(read(fd,&ch1,1) != 1)
  1354. X    {
  1355. X        perror("read1");
  1356. X        exit(1);
  1357. X    }
  1358. X    printf("char 1 = %02x\n",ch1);
  1359. X
  1360. X    if(lseek(fd,PLACE2,0) != PLACE2)
  1361. X    {
  1362. X        perror("seek2");
  1363. X        exit(2);
  1364. X    }
  1365. X    if(read(fd,&ch2,2) != 2)
  1366. X    {
  1367. X        perror("read2");
  1368. X        exit(2);
  1369. X    }
  1370. X    printf("char 2 = %02x\n",ch2);
  1371. X
  1372. X
  1373. X    if(lseek(fd,PLACE3,0) != PLACE3)
  1374. X    {
  1375. X        perror("seek3");
  1376. X        exit(3);
  1377. X    }
  1378. X    if(read(fd,&ch3,1) != 1)
  1379. X    {
  1380. X        perror("read3");
  1381. X        exit(3);
  1382. X    }
  1383. X    printf("char 3 = %02x\n",ch3);
  1384. X
  1385. X    if((ch1 != 't') || (ch2 != 't') || (ch3 != 't'))
  1386. X        exit(8);
  1387. X    if(lseek(fd,PLACE1,0) != PLACE1)
  1388. X    {
  1389. X        perror("seek1");
  1390. X        exit(1);
  1391. X    }
  1392. X    write(fd,"T",1);
  1393. X    if(lseek(fd,PLACE2,0) != PLACE2)
  1394. X    {
  1395. X        perror("seek1");
  1396. X        exit(1);
  1397. X    }
  1398. X    write(fd,"T",1);
  1399. X    if(lseek(fd,PLACE3,0) != PLACE3)
  1400. X    {
  1401. X        perror("seek1");
  1402. X        exit(1);
  1403. X    }
  1404. X    write(fd,"T",1);
  1405. X    printf("done\n");
  1406. X    close(fd);
  1407. X
  1408. X    exit(0);
  1409. X}    /* end of main */
  1410. X
  1411. X/* vi: set tabstop=4 shiftwidth=4: */
  1412. X/* end of fixttiocom.c */
  1413. SHAR_EOF
  1414. $TOUCH -am 0725125991 'xsel386/fixttiocom.c' &&
  1415. chmod 0644 xsel386/fixttiocom.c ||
  1416. echo 'restore of xsel386/fixttiocom.c failed'
  1417. Wc_c="`wc -c < 'xsel386/fixttiocom.c'`"
  1418. test 1999 -eq "$Wc_c" ||
  1419.     echo 'xsel386/fixttiocom.c: original size 1999, current size' "$Wc_c"
  1420. rm -f _shar_wnt_.tmp
  1421. fi
  1422. # ============= xsel386/select-update ==============
  1423. if test -f 'xsel386/select-update' -a X"$1" != X"-c"; then
  1424.     echo 'x - skipping xsel386/select-update (File already exists)'
  1425.     rm -f _shar_wnt_.tmp
  1426. else
  1427. > _shar_wnt_.tmp
  1428. echo 'x - extracting xsel386/select-update (Text)'
  1429. sed 's/^X//' << 'SHAR_EOF' > 'xsel386/select-update' &&
  1430. XSubject: Re: Select(S) in Xenix 386 2.3.2
  1431. XNewsgroups: comp.unix.xenix
  1432. XKeywords: select, serial, pipes
  1433. XReferences: <117@accsys.acc.uu.no> <172@prmmbx.UUCP>
  1434. X
  1435. XIn article <172@prmmbx.UUCP>, csch@netcs.UUCP (Clemens Schrimpe) writes:
  1436. X> ivar@acc.uu.no (Ivar Hosteng) writes:
  1437. X> <> I have experienced some problems using the select call in Xenix 386 V2.3.2.
  1438. X> <> It does not seems to detect when a pipe gets ready to been read from.
  1439. X> This is, because there is no provision to select on pipes!
  1440. X> Why? The stuff is almost totally ported 1:1 from the Berkeley code and
  1441. X> in BSD pipes should consist of AF_UNIX sockets, on which you can naturally
  1442. X> select.
  1443. X> I was very angry, when I found this out after hours of digging with adb in
  1444. X> the kernel. But I also tried the same on a SUN under SunOS 4.0 and it doesn't
  1445. X> work either ... seems to be a common illness ???
  1446. X> (I wonder, because the code for that is very simple ... ??? ...)
  1447. X> 
  1448. X> <> I also 
  1449. X> <> have trouble using select on a serial port.  When I do that the input
  1450. X> <> turns into garbage.  This does not occur when I use select on the
  1451. X> <> multiscreen ttys (tty01-tty12).
  1452. X> Hehe - we had just the same!
  1453. X> Here is the solution (thanks to my colleague Stefan Koehler, who took one
  1454. X> look at my screen, into which I had starred for hours, to find it ...)
  1455. X> 
  1456. X> Select is implemented by an undocumented ioctl
  1457. X>     (0xFFFF == IOC_SELECT -> [sys/slect.h])
  1458. X> which is handled by ttiocom() for all devices using the standard
  1459. X> SYS-V linediscipline!
  1460. X> 
  1461. X> The ioctl-routine for the serial devices [sioioctl()] just calls 
  1462. X> ttiocom() [after some undefinable VPIX stuff ???] and
  1463. X> if it returns NON-ZERO it calls sioparam(), which adjusts certain
  1464. X> parameters and garbles the output!
  1465. X> OK so far. Now: The Bug lies in the ttiocom-code within the check
  1466. X> for IOC_SELECT. After detecting the IOC_SELECT, the ttiocom calls
  1467. X> the select-code and returns NOTHING, which means that if EAX is
  1468. X> non-zero (randomly) sioparam() is called and garbles the output.
  1469. X> 
  1470. X> The Fix: (quick and dirty)
  1471. X> Write a routine called "ttiocom", which might look like this:
  1472. X> 
  1473. X> ttiocom(ttyp, com, arg, flag)
  1474. X> struct tty *ttyp;
  1475. X> int com, arg, flag;    /* there should be better types for this :-) */
  1476. X> {
  1477. X>     if (com == IOC_SELECT)
  1478. X>     {
  1479. X>         ttselect(ttyp, flag);
  1480. X>         return(0);    /*** THIS IS IMPORTANT ***/
  1481. X>     }
  1482. X>     return(Ttiocom(ttyp, com ,arg, flag));
  1483. X> }
  1484. X> 
  1485. X> Compile something like this, then use whatever you have (GNU-Emacs is
  1486. X> great in patching strings in binaries) to patch /usr/sys/sys/libsys.a
  1487. X> to change the original ttiocom into Ttiocom !
  1488. X> Link in your code and -by some magic reason- experience a full blown
  1489. X> select on your System V / Xenix machine!!!
  1490. X> 
  1491. X> Have fun playing around with it -
  1492. X> 
  1493. X>     Clemens Schrimpe, netCS Informationstechnik GmbH Berlin
  1494. X> --
  1495. X> UUCP:        csch@netcs        BITNET:    csch@db0tui6.BITNET
  1496. X> ARPA/NSF:    csch@garp.mit.edu    PSI: PSI%45300033047::CSCH
  1497. X> PHONE:        +49-30-24 42 37        FAX: +49-30-24 38 00
  1498. X> BTX:        0303325016-0003        TELEX: 186672 net d
  1499. X
  1500. X
  1501. SHAR_EOF
  1502. $TOUCH -am 0429171591 'xsel386/select-update' &&
  1503. chmod 0644 xsel386/select-update ||
  1504. echo 'restore of xsel386/select-update failed'
  1505. Wc_c="`wc -c < 'xsel386/select-update'`"
  1506. test 2981 -eq "$Wc_c" ||
  1507.     echo 'xsel386/select-update: original size 2981, current size' "$Wc_c"
  1508. rm -f _shar_wnt_.tmp
  1509. fi
  1510. # ============= xsel386/select.asm ==============
  1511. if test -f 'xsel386/select.asm' -a X"$1" != X"-c"; then
  1512.     echo 'x - skipping xsel386/select.asm (File already exists)'
  1513.     rm -f _shar_wnt_.tmp
  1514. else
  1515. > _shar_wnt_.tmp
  1516. echo 'x - extracting xsel386/select.asm (Text)'
  1517. sed 's/^X//' << 'SHAR_EOF' > 'xsel386/select.asm' &&
  1518. X;  CHK=0x1E37
  1519. X;+----------------------------------------------------------
  1520. X; select(S)
  1521. X;
  1522. X;#include <stdio.h>
  1523. X;#include <sys/select.h>
  1524. X;#include <fcntl.h>
  1525. X;
  1526. X;main(argc,argv,envp)
  1527. X;int argc;
  1528. X;char **argv;
  1529. X;char **envp;
  1530. X;{
  1531. X;struct timeval t;
  1532. X;int readfds;
  1533. X;int fd = open("/dev/null",O_RDONLY,0);
  1534. X;
  1535. X;    readfds = 1<<fd | 1<<0;
  1536. X;
  1537. X;    t.tv_sec = 5;
  1538. X;    t.tv_usec = 0;
  1539. X;
  1540. X;    printf("%d\n",select(32,&readfds,0,0,&t));
  1541. X;    printf("%08x\n",readfds);
  1542. X;    exit(0);
  1543. X;}    /* end of main */
  1544. X;
  1545. X;-----------------------------------------------------------
  1546. X
  1547. X    title    select
  1548. X
  1549. X    .386
  1550. X
  1551. XSYSNUM    equ     2428h
  1552. X
  1553. Xextrn    _errno:dword
  1554. X
  1555. Xpublic  _select
  1556. X
  1557. X_TEXT    segment  dword use32 public 'CODE'
  1558. X    assume   cs: _TEXT
  1559. X_select    proc near
  1560. X    mov    eax, SYSNUM        ; Get system call number.
  1561. X
  1562. X    ;
  1563. X    ; I don't even pretend to understand masm syntax.  I tried
  1564. X    ; the following line (and variations) without any success.
  1565. X    ;
  1566. X
  1567. X;    call    far 7:0            ; Switch to kernel and call SYSNUM.
  1568. X
  1569. X    ;
  1570. X    ; Don't laugh, it works.
  1571. X    ;
  1572. X
  1573. X    db 9ah
  1574. X    dw 0,0
  1575. X    dw 7
  1576. X
  1577. X    jb    short _cerror        ; below == error.
  1578. X
  1579. X;    xor    eax, eax        ; zero return value (no error).
  1580. X    ret                ; done.
  1581. X
  1582. X_cerror:
  1583. X    mov    _errno, eax        ; Save error code in _errno.
  1584. X    mov    eax, -1            ; Return -1 (as error).
  1585. X    ret                ; done.
  1586. X
  1587. X_select    endp
  1588. X
  1589. X_TEXT    ends
  1590. X
  1591. X    end
  1592. X; vi: set tabstop=8 :
  1593. SHAR_EOF
  1594. $TOUCH -am 0429171591 'xsel386/select.asm' &&
  1595. chmod 0644 xsel386/select.asm ||
  1596. echo 'restore of xsel386/select.asm failed'
  1597. Wc_c="`wc -c < 'xsel386/select.asm'`"
  1598. test 1237 -eq "$Wc_c" ||
  1599.     echo 'xsel386/select.asm: original size 1237, current size' "$Wc_c"
  1600. rm -f _shar_wnt_.tmp
  1601. fi
  1602. # ============= xsel386/select.txt ==============
  1603. if test -f 'xsel386/select.txt' -a X"$1" != X"-c"; then
  1604.     echo 'x - skipping xsel386/select.txt (File already exists)'
  1605.     rm -f _shar_wnt_.tmp
  1606. else
  1607. > _shar_wnt_.tmp
  1608. echo 'x - extracting xsel386/select.txt (Text)'
  1609. sed 's/^X//' << 'SHAR_EOF' > 'xsel386/select.txt' &&
  1610. XNOTE from ...!gatech!emory!tridom!wht:
  1611. Xthe following is the mail message I originally received; with
  1612. Xa little tinkering, i got the select call to behave as advertised
  1613. Xin the BSD manual (my xenix is 386 2.3).  Added it to /lib/386/Slibx.a
  1614. Xand all is well for me.  Good luck.
  1615. X
  1616. X
  1617. XFrom emory!gatech!hubcap!ncrcae!ncr-sd!crash!elgar!ag Thu Feb  2 13:04:07 EST 1989
  1618. XArticle 4851 of comp.unix.xenix:
  1619. XPath: tridom!emory!gatech!hubcap!ncrcae!ncr-sd!crash!elgar!ag
  1620. X>From: ag@elgar.UUCP (Keith Gabryelski)
  1621. XNewsgroups: comp.unix.xenix
  1622. XSubject: select() on SCO XENIX 2.3.
  1623. XMessage-ID: <38@elgar.UUCP>
  1624. XDate: 24 Jan 89 04:54:17 GMT
  1625. XReply-To: ag@elgar.UUCP (Keith Gabryelski)
  1626. XOrganization: Elgar Corporation, San Diego, CA
  1627. XLines: 474
  1628. X
  1629. XA few days ago I was paging through my SCO XENIX 2.3.1 Release Notes
  1630. Xand found, on page 44 (section 16), a section describing 4BSD
  1631. Xenhancements to the current release of SCO XENIX.
  1632. X
  1633. Xselect(S) was mentioned specifically.
  1634. X
  1635. XI checked the rest of the 2.3 manuals to see if there was a clue on
  1636. Xhow to access select(); no dice.  I tried my 2.2 dev sys libraries to
  1637. Xsee if it had been supported in previous releases and just not
  1638. Xmentioned; negative.
  1639. X
  1640. XI decided to see if I could get select() to work on my system.  And
  1641. Xthat is what this article is about.
  1642. X
  1643. XI checked /xenix and found:
  1644. X
  1645. X    % nm xenix | grep select
  1646. X    nm: xenix: too many symbols to sort        # chuckle
  1647. X    0020:00015bec  T _select
  1648. X
  1649. XBingo!  I also found <sys/select.h> (which has a comment about
  1650. Xthe select(2) system call. :-) ).
  1651. X
  1652. XWhen a system call is made in a C program on a Unix system (eg
  1653. Xopen(2)), it actually links in a file from libc.a (/lib/libc.a) (in
  1654. Xthis case `open.o') written in assembly that loads a register with a
  1655. Xsystem call number and causes an exception to occur.  The `trap'
  1656. Xinstruction is used on the 68000, on a vax it's `chmk', and on a 370
  1657. Xit's `svc'.  Control is transfered to the kernel which (in the case of
  1658. Xthis particular exception) will index the register into a table
  1659. X(called the sysent table) to get the address of the actual routine in
  1660. Xkernel memory to call (_open).
  1661. X
  1662. XAt least under SCO XENIX this algorithm is modified somewhat.
  1663. X
  1664. XWhen a system call is made in a C program on a SCO XENIX system (eg
  1665. Xopen(S)), it links in a file from libc.a (/lib/386/Slibc.a) (in this
  1666. Xcase `open.o') written in assembly that loads the register `eax' with
  1667. Xa system call number and jumps to 7:0 which (a guess) is mapped to an
  1668. Xinstruction that switches into supervisory mode and jumps to the
  1669. Xroutine ioint (??) in the kernel address space.  The interrupt routine
  1670. Xhands the system call number (along with the user given arguments) to
  1671. X_trap with figures out what to sysent table to use (there are a few
  1672. Xunder SCO XENIX) and does the right thing.
  1673. X
  1674. XThe _open routine (in libc.a's open.o) would probably look something
  1675. Xlike:
  1676. X
  1677. X;
  1678. X; open - open a file for reading or writing
  1679. X;
  1680. X
  1681. X    title    open
  1682. X
  1683. X    .386
  1684. X
  1685. XSYSNUM    equ     5            ; open's system call number is `5'.
  1686. Xextrn    _errno:dword
  1687. X
  1688. Xpublic  _open
  1689. X
  1690. X_TEXT    segment  dword use32 public 'CODE'
  1691. X    assume   cs: _TEXT
  1692. X_open    proc near
  1693. X    mov    eax, SYSNUM        ; Get system call number.
  1694. X
  1695. X    ;
  1696. X    ; I don't even pretend to understand masm syntax.  I tried
  1697. X    ; the following line (and variations) without any success.
  1698. X    ;
  1699. X
  1700. X;    call    far 7:0            ; Switch to kernel and call SYSNUM.
  1701. X
  1702. X    ;
  1703. X    ; Don't laugh, it works.
  1704. X    ;
  1705. X
  1706. X    db 9ah
  1707. X    dw 0,0
  1708. X    dw 7
  1709. X
  1710. X    jb    short _cerror        ; below == error.
  1711. X
  1712. X    xor    eax, eax        ; zero return value (no error).
  1713. X    ret                ; done.
  1714. X
  1715. X_cerror:
  1716. X    mov    _errno, eax        ; Save error code in _errno.
  1717. X    mov    eax, -1            ; Return -1 (as error).
  1718. X    ret                ; done.
  1719. X
  1720. X_open    endp
  1721. X
  1722. X_TEXT    ends
  1723. X
  1724. X    end
  1725. X
  1726. XUnder SCO XENIX the sysent table (struct sysent in <sys/systm.h>) looks
  1727. Xsomething like:
  1728. X
  1729. Xstruct sysent
  1730. X{
  1731. X    unsigned char  sy_ret;     /* Type of return value (int, void ...) */
  1732. X    unsigned char  sy_arg386;     /* Number of 386 words args on stack */
  1733. X    unsigned char  sy_nlarg286;     /* # of 286 large model word args on stack */
  1734. X    unsigned char  sy_nmarg286;     /* 286 Small Middle: max # of args */
  1735. X    unsigned       sy_argmask;     /* Argument types on stack. */
  1736. X         int   (*sy_call)(); /* System call address in kernel */
  1737. SHAR_EOF
  1738. true || echo 'restore of xsel386/select.txt failed'
  1739. fi
  1740. echo 'End of ecu310 part 31'
  1741. echo 'File xsel386/select.txt is continued in part 32'
  1742. echo 32 > _shar_seq_.tmp
  1743. exit 0
  1744. --------------------------------------------------------------------
  1745. Warren Tucker, TuckerWare emory!n4hgf!wht or wht@n4hgf.Mt-Park.GA.US
  1746. Hacker Extraordinaire  d' async PADs,  pods,  proteins and protocols
  1747.  
  1748. exit 0 # Just in case...
  1749. -- 
  1750. Kent Landfield                   INTERNET: kent@sparky.IMD.Sterling.COM
  1751. Sterling Software, IMD           UUCP:     uunet!sparky!kent
  1752. Phone:    (402) 291-8300         FAX:      (402) 291-4362
  1753. Please send comp.sources.misc-related mail to kent@uunet.uu.net.
  1754.