rc.c (50254) | rc.c (51654) |
---|---|
1/* 2 * Copyright (C) 1995 by Pavel Antonov, Moscow, Russia. 3 * Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 9 unchanged lines hidden (view full) --- 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. | 1/* 2 * Copyright (C) 1995 by Pavel Antonov, Moscow, Russia. 3 * Copyright (C) 1995 by Andrey A. Chernov, Moscow, Russia. 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: --- 9 unchanged lines hidden (view full) --- 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. |
26 * 27 * $FreeBSD: head/sys/dev/rc/rc.c 51654 1999-09-25 16:21:39Z phk $ 28 * |
|
26 */ 27 28/* 29 * SDL Communications Riscom/8 (based on Cirrus Logic CL-CD180) driver 30 * 31 */ 32 33#include "rc.h" --- 48 unchanged lines hidden (view full) --- 82 rcprobe, rcattach, "rc" 83}; 84 85static d_open_t rcopen; 86static d_close_t rcclose; 87static d_read_t rcread; 88static d_write_t rcwrite; 89static d_ioctl_t rcioctl; | 29 */ 30 31/* 32 * SDL Communications Riscom/8 (based on Cirrus Logic CL-CD180) driver 33 * 34 */ 35 36#include "rc.h" --- 48 unchanged lines hidden (view full) --- 85 rcprobe, rcattach, "rc" 86}; 87 88static d_open_t rcopen; 89static d_close_t rcclose; 90static d_read_t rcread; 91static d_write_t rcwrite; 92static d_ioctl_t rcioctl; |
90static d_stop_t rcstop; 91static d_devtotty_t rcdevtotty; | |
92 93#define CDEV_MAJOR 63 94static struct cdevsw rc_cdevsw = { 95 /* open */ rcopen, 96 /* close */ rcclose, 97 /* read */ rcread, 98 /* write */ rcwrite, 99 /* ioctl */ rcioctl, | 93 94#define CDEV_MAJOR 63 95static struct cdevsw rc_cdevsw = { 96 /* open */ rcopen, 97 /* close */ rcclose, 98 /* read */ rcread, 99 /* write */ rcwrite, 100 /* ioctl */ rcioctl, |
100 /* stop */ rcstop, | 101 /* stop */ nostop, |
101 /* reset */ noreset, | 102 /* reset */ noreset, |
102 /* devtotty */ rcdevtotty, 103 /* poll */ ttpoll, | 103 /* devtotty */ nodevtotty, 104 /* poll */ ttypoll, |
104 /* mmap */ nommap, 105 /* strategy */ nostrategy, 106 /* name */ "rc", 107 /* parms */ noparms, 108 /* maj */ CDEV_MAJOR, 109 /* dump */ nodump, 110 /* psize */ nopsize, 111 /* flags */ D_TTY, --- 65 unchanged lines hidden (view full) --- 177/* Static prototypes */ 178static ointhand2_t rcintr; 179static void rc_hwreset __P((int, int, unsigned int)); 180static int rc_test __P((int, int)); 181static void rc_discard_output __P((struct rc_chans *)); 182static void rc_hardclose __P((struct rc_chans *)); 183static int rc_modctl __P((struct rc_chans *, int, int)); 184static void rc_start __P((struct tty *)); | 105 /* mmap */ nommap, 106 /* strategy */ nostrategy, 107 /* name */ "rc", 108 /* parms */ noparms, 109 /* maj */ CDEV_MAJOR, 110 /* dump */ nodump, 111 /* psize */ nopsize, 112 /* flags */ D_TTY, --- 65 unchanged lines hidden (view full) --- 178/* Static prototypes */ 179static ointhand2_t rcintr; 180static void rc_hwreset __P((int, int, unsigned int)); 181static int rc_test __P((int, int)); 182static void rc_discard_output __P((struct rc_chans *)); 183static void rc_hardclose __P((struct rc_chans *)); 184static int rc_modctl __P((struct rc_chans *, int, int)); 185static void rc_start __P((struct tty *)); |
186static void rc_stop __P((struct tty *, int rw)); |
|
185static int rc_param __P((struct tty *, struct termios *)); 186static swihand_t rcpoll; 187static void rc_reinit __P((struct rc_softc *)); 188#ifdef RCDEBUG 189static void printrcflags(); 190#endif 191static timeout_t rc_dtrwakeup; 192static timeout_t rc_wakeup; --- 484 unchanged lines hidden (view full) --- 677 if (rc_scheduled_event == 0) 678 break; 679 } 680 if (rc_scheduled_event >= LOTS_OF_EVENTS) 681 goto repeat; 682} 683 684static void | 187static int rc_param __P((struct tty *, struct termios *)); 188static swihand_t rcpoll; 189static void rc_reinit __P((struct rc_softc *)); 190#ifdef RCDEBUG 191static void printrcflags(); 192#endif 193static timeout_t rc_dtrwakeup; 194static timeout_t rc_wakeup; --- 484 unchanged lines hidden (view full) --- 679 if (rc_scheduled_event == 0) 680 break; 681 } 682 if (rc_scheduled_event >= LOTS_OF_EVENTS) 683 goto repeat; 684} 685 686static void |
685rcstop(tp, rw) | 687rc_stop(tp, rw) |
686 register struct tty *tp; 687 int rw; 688{ 689 register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)]; 690 u_char *tptr, *eptr; 691 692#ifdef RCDEBUG | 688 register struct tty *tp; 689 int rw; 690{ 691 register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)]; 692 u_char *tptr, *eptr; 693 694#ifdef RCDEBUG |
693 printf("rc%d/%d: rcstop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, | 695 printf("rc%d/%d: rc_stop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan, |
694 (rw & FWRITE)?"FWRITE ":"", (rw & FREAD)?"FREAD":""); 695#endif 696 if (rw & FWRITE) 697 rc_discard_output(rc); 698 disable_intr(); 699 if (rw & FREAD) { 700 rc->rc_flags &= ~RC_DORXFER; 701 eptr = rc->rc_iptr; --- 25 unchanged lines hidden (view full) --- 727 728 unit = GET_UNIT(dev); 729 if (unit >= NRC * CD180_NCHAN) 730 return ENXIO; 731 if (rc_softc[unit / CD180_NCHAN].rcb_probed != RC_ATTACHED) 732 return ENXIO; 733 rc = &rc_chans[unit]; 734 tp = rc->rc_tp; | 696 (rw & FWRITE)?"FWRITE ":"", (rw & FREAD)?"FREAD":""); 697#endif 698 if (rw & FWRITE) 699 rc_discard_output(rc); 700 disable_intr(); 701 if (rw & FREAD) { 702 rc->rc_flags &= ~RC_DORXFER; 703 eptr = rc->rc_iptr; --- 25 unchanged lines hidden (view full) --- 729 730 unit = GET_UNIT(dev); 731 if (unit >= NRC * CD180_NCHAN) 732 return ENXIO; 733 if (rc_softc[unit / CD180_NCHAN].rcb_probed != RC_ATTACHED) 734 return ENXIO; 735 rc = &rc_chans[unit]; 736 tp = rc->rc_tp; |
737 dev->si_tty = tp; |
|
735 nec = rc->rc_rcb->rcb_addr; 736#ifdef RCDEBUG 737 printf("rc%d/%d: rcopen: dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); 738#endif 739 s = spltty(); 740 741again: 742 while (rc->rc_flags & RC_DTR_OFF) { --- 23 unchanged lines hidden (view full) --- 766 if (tp->t_state & TS_XCLUDE && 767 suser(p)) { 768 error = EBUSY; 769 goto out; 770 } 771 } else { 772 tp->t_oproc = rc_start; 773 tp->t_param = rc_param; | 738 nec = rc->rc_rcb->rcb_addr; 739#ifdef RCDEBUG 740 printf("rc%d/%d: rcopen: dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); 741#endif 742 s = spltty(); 743 744again: 745 while (rc->rc_flags & RC_DTR_OFF) { --- 23 unchanged lines hidden (view full) --- 769 if (tp->t_state & TS_XCLUDE && 770 suser(p)) { 771 error = EBUSY; 772 goto out; 773 } 774 } else { 775 tp->t_oproc = rc_start; 776 tp->t_param = rc_param; |
777 tp->t_stop = rc_stop; |
|
774 tp->t_dev = dev; 775 776 if (CALLOUT(dev)) 777 tp->t_cflag |= CLOCAL; 778 else 779 tp->t_cflag &= ~CLOCAL; 780 781 error = rc_param(tp, &tp->t_termios); --- 41 unchanged lines hidden (view full) --- 823 rc = &rc_chans[unit]; 824 tp = rc->rc_tp; 825#ifdef RCDEBUG 826 printf("rc%d/%d: rcclose dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); 827#endif 828 s = spltty(); 829 (*linesw[tp->t_line].l_close)(tp, flag); 830 disc_optim(tp, &tp->t_termios, rc); | 778 tp->t_dev = dev; 779 780 if (CALLOUT(dev)) 781 tp->t_cflag |= CLOCAL; 782 else 783 tp->t_cflag &= ~CLOCAL; 784 785 error = rc_param(tp, &tp->t_termios); --- 41 unchanged lines hidden (view full) --- 827 rc = &rc_chans[unit]; 828 tp = rc->rc_tp; 829#ifdef RCDEBUG 830 printf("rc%d/%d: rcclose dev %x\n", rc->rc_rcb->rcb_unit, unit, dev); 831#endif 832 s = spltty(); 833 (*linesw[tp->t_line].l_close)(tp, flag); 834 disc_optim(tp, &tp->t_termios, rc); |
831 rcstop(tp, FREAD | FWRITE); | 835 rc_stop(tp, FREAD | FWRITE); |
832 rc_hardclose(rc); 833 ttyclose(tp); 834 splx(s); 835 return 0; 836} 837 838static void rc_hardclose(rc) 839register struct rc_chans *rc; --- 562 unchanged lines hidden (view full) --- 1402 printf("rc%d/%d: msvr %02x ier %02x ccsr %02x\n", 1403 rc->rc_rcb->rcb_unit, rc->rc_chan, 1404 rcin(CD180_MSVR), 1405 rcin(CD180_IER), 1406 rcin(CD180_CCSR)); 1407} 1408#endif /* RCDEBUG */ 1409 | 836 rc_hardclose(rc); 837 ttyclose(tp); 838 splx(s); 839 return 0; 840} 841 842static void rc_hardclose(rc) 843register struct rc_chans *rc; --- 562 unchanged lines hidden (view full) --- 1406 printf("rc%d/%d: msvr %02x ier %02x ccsr %02x\n", 1407 rc->rc_rcb->rcb_unit, rc->rc_chan, 1408 rcin(CD180_MSVR), 1409 rcin(CD180_IER), 1410 rcin(CD180_CCSR)); 1411} 1412#endif /* RCDEBUG */ 1413 |
1410static struct tty * 1411rcdevtotty(dev) 1412 dev_t dev; 1413{ 1414 int unit; 1415 1416 unit = GET_UNIT(dev); 1417 if (unit >= NRC * CD180_NCHAN) 1418 return NULL; 1419 return (&rc_tty[unit]); 1420} 1421 | |
1422static void 1423rc_dtrwakeup(chan) 1424 void *chan; 1425{ 1426 struct rc_chans *rc; 1427 1428 rc = (struct rc_chans *)chan; 1429 rc->rc_flags &= ~RC_DTR_OFF; --- 66 unchanged lines hidden --- | 1414static void 1415rc_dtrwakeup(chan) 1416 void *chan; 1417{ 1418 struct rc_chans *rc; 1419 1420 rc = (struct rc_chans *)chan; 1421 rc->rc_flags &= ~RC_DTR_OFF; --- 66 unchanged lines hidden --- |