Deleted Added
sdiff udiff text old ( 12658 ) new ( 12675 )
full compact
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:

--- 33 unchanged lines hidden (view full) ---

42#include <sys/proc.h>
43#include <sys/conf.h>
44#include <sys/dkstat.h>
45#include <sys/file.h>
46#include <sys/uio.h>
47#include <sys/kernel.h>
48#include <sys/syslog.h>
49#include <sys/devconf.h>
50#ifdef DEVFS
51#include <sys/devfsext.h>
52#endif /*DEVFS*/
53
54#include <machine/clock.h>
55
56#include <i386/isa/isa.h>
57#include <i386/isa/isa_device.h>
58#include <i386/isa/sioreg.h>
59
60#include <i386/isa/ic/cd180.h>
61#include <i386/isa/rcreg.h>
62
63
64/* Prototypes */
65int rcprobe __P((struct isa_device *));
66int rcattach __P((struct isa_device *));
67
68/*-
69 * This space intentionally left blank to stop __LINE__ from screwing up
70 * regression tests :-(.

--- 24 unchanged lines hidden (view full) ---

95#define GET_UNIT(dev) (minor(dev) & 0x3F)
96#define CALLOUT(dev) (minor(dev) & 0x80)
97
98/* For isa routines */
99struct isa_driver rcdriver = {
100 rcprobe, rcattach, "rc"
101};
102
103static d_open_t rcopen;
104static d_close_t rcclose;
105static d_read_t rcread;
106static d_write_t rcwrite;
107static d_ioctl_t rcioctl;
108static d_stop_t rcstop;
109static d_ttycv_t rcdevtotty;
110
111#define CDEV_MAJOR 63
112struct cdevsw rc_cdevsw =
113 { rcopen, rcclose, rcread, rcwrite, /*63*/
114 rcioctl, rcstop, nxreset, rcdevtotty,/* rc */
115 ttselect, nommap, NULL, "rc", NULL, -1 };
116
117/* Per-board structure */
118static struct rc_softc {
119 u_int rcb_probed; /* 1 - probed, 2 - attached */
120 u_int rcb_addr; /* Base I/O addr */
121 u_int rcb_unit; /* unit # */
122 u_char rcb_dtr; /* DTR status */
123 struct rc_chans *rcb_baserc; /* base rc ptr */
124} rc_softc[NRC];

--- 13 unchanged lines hidden (view full) ---

138 struct tty *rc_tp; /* tty struct */
139 u_char *rc_iptr; /* Chars input buffer */
140 u_char *rc_hiwat; /* hi-water mark */
141 u_char *rc_bufend; /* end of buffer */
142 u_char *rc_optr; /* ptr in output buf */
143 u_char *rc_obufend; /* end of output buf */
144 u_char rc_ibuf[4 * RC_IBUFSIZE]; /* input buffer */
145 u_char rc_obuf[RC_OBUFSIZE]; /* output buffer */
146#ifdef DEVFS
147 void *devfs_token;
148#endif
149} rc_chans[NRC * CD180_NCHAN];
150
151static int rc_scheduled_event = 0;
152
153/* for pstat -t */
154struct tty rc_tty[NRC * CD180_NCHAN];
155int nrc_tty = NRC * CD180_NCHAN;
156

--- 99 unchanged lines hidden (view full) ---

256int rcattach(dvp)
257 struct isa_device *dvp;
258{
259 register int i, chan, nec = dvp->id_iobase;
260 struct rc_softc *rcb = &rc_softc[dvp->id_unit];
261 struct rc_chans *rc = &rc_chans[dvp->id_unit * CD180_NCHAN];
262 static int rc_wakeup_started = 0;
263 struct tty *tp;
264 char name[32];
265
266 /* Thorooughly test the device */
267 if (rcb->rcb_probed != RC_PROBED)
268 return 0;
269 rcb->rcb_addr = nec;
270 rcb->rcb_dtr = 0;
271 rcb->rcb_baserc = rc;
272 /*rcb->rcb_chipid = 0x10 + dvp->id_unit;*/

--- 14 unchanged lines hidden (view full) ---

287 rc->rc_dtrwait = 3 * hz;
288 rc->rc_dcdwaits= 0;
289 rc->rc_hotchar = 0;
290 tp = rc->rc_tp = &rc_tty[chan];
291 ttychars(tp);
292 tp->t_lflag = tp->t_iflag = tp->t_oflag = 0;
293 tp->t_cflag = TTYDEF_CFLAG;
294 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
295#ifdef DEVFS
296/* FIX THIS to reflect real devices */
297 sprintf(name,"rc%d.%d",dvp->id_unit,chan);
298 rc->devfs_token = devfs_add_devsw( "/", name,
299 &rc_cdevsw,(dvp->id_unit * CD180_NCHAN) + chan ,
300 DV_CHR, 0, 0, 0600);
301#endif
302 }
303 rcb->rcb_probed = RC_ATTACHED;
304 if (!rc_wakeup_started) {
305 rc_wakeup((void *)NULL);
306 rc_wakeup_started = 0;
307 }
308 return 1;
309}

--- 398 unchanged lines hidden (view full) ---

708 }
709 if (rc_scheduled_event == 0)
710 break;
711 }
712 if (rc_scheduled_event >= LOTS_OF_EVENTS)
713 goto repeat;
714}
715
716static void
717rcstop(tp, rw)
718 register struct tty *tp;
719 int rw;
720{
721 register struct rc_chans *rc = &rc_chans[GET_UNIT(tp->t_dev)];
722 u_char *tptr, *eptr;
723
724#ifdef RCDEBUG
725 printf("rc%d/%d: rcstop %s%s\n", rc->rc_rcb->rcb_unit, rc->rc_chan,

--- 16 unchanged lines hidden (view full) ---

742 }
743 if (tp->t_state & TS_TTSTOP)
744 rc->rc_flags |= RC_OSUSP;
745 else
746 rc->rc_flags &= ~RC_OSUSP;
747 enable_intr();
748}
749
750static int
751rcopen(dev, flag, mode, p)
752 dev_t dev;
753 int flag, mode;
754 struct proc *p;
755{
756 register struct rc_chans *rc;
757 register struct tty *tp;
758 int unit, nec, s, error = 0;
759

--- 74 unchanged lines hidden (view full) ---

834 (void) splx(s);
835
836 if(rc->rc_dcdwaits == 0 && !(tp->t_state & TS_ISOPEN))
837 rc_hardclose(rc);
838
839 return error;
840}
841
842static int
843rcclose(dev, flag, mode, p)
844 dev_t dev;
845 int flag, mode;
846 struct proc *p;
847{
848 register struct rc_chans *rc;
849 register struct tty *tp;
850 int s, unit = GET_UNIT(dev);
851

--- 40 unchanged lines hidden (view full) ---

892 }
893 rc->rc_flags &= ~RC_ACTOUT;
894 wakeup((caddr_t) &rc->rc_rcb); /* wake bi */
895 wakeup(TSA_CARR_ON(tp));
896 (void) splx(s);
897}
898
899/* Read from line */
900static int
901rcread(dev, uio, flag)
902 dev_t dev;
903 struct uio *uio;
904 int flag;
905{
906 struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp;
907
908 return ((*linesw[tp->t_line].l_read)(tp, uio, flag));
909}
910
911/* Write to line */
912static int
913rcwrite(dev, uio, flag)
914 dev_t dev;
915 struct uio *uio;
916 int flag;
917{
918 struct tty *tp = rc_chans[GET_UNIT(dev)].rc_tp;
919
920 return ((*linesw[tp->t_line].l_write)(tp, uio, flag));
921}

--- 189 unchanged lines hidden (view full) ---

1111 nec = rcb->rcb_addr;
1112 rc_hwreset(rcb->rcb_unit, nec, RC_FAKEID);
1113 rc = &rc_chans[rcb->rcb_unit * CD180_NCHAN];
1114 rce = rc + CD180_NCHAN;
1115 for (; rc < rce; rc++)
1116 (void) rc_param(rc->rc_tp, &rc->rc_tp->t_termios);
1117}
1118
1119static int
1120rcioctl(dev, cmd, data, flag, p)
1121dev_t dev;
1122int cmd, flag;
1123caddr_t data;
1124struct proc *p;
1125{
1126 register struct rc_chans *rc = &rc_chans[GET_UNIT(dev)];
1127 register int s, error;
1128 struct tty *tp = rc->rc_tp;

--- 301 unchanged lines hidden (view full) ---

1430 printf("rc%d/%d: msvr %02x ier %02x ccsr %02x\n",
1431 rc->rc_rcb->rcb_unit, rc->rc_chan,
1432 rcin(CD180_MSVR),
1433 rcin(CD180_IER),
1434 rcin(CD180_CCSR));
1435}
1436#endif /* RCDEBUG */
1437
1438static struct tty *
1439rcdevtotty(dev)
1440 dev_t dev;
1441{
1442 int unit;
1443
1444 unit = GET_UNIT(dev);
1445 if (unit >= NRC * CD180_NCHAN)
1446 return NULL;

--- 75 unchanged lines hidden (view full) ---

1522
1523 for (rcnt = 100; rcnt && rcin(CD180_CCR); rcnt--)
1524 DELAY(15);
1525 if (rcnt == 0)
1526 printf("rc%d/%d: channel command timeout, rc.c line: %d\n",
1527 unit, chan, line);
1528}
1529
1530static rc_devsw_installed = 0;
1531
1532static void rc_drvinit(void *unused)
1533{
1534 dev_t dev;
1535
1536 if( ! rc_devsw_installed ) {
1537 dev = makedev(CDEV_MAJOR, 0);
1538 cdevsw_add(&dev,&rc_cdevsw, NULL);
1539 rc_devsw_installed = 1;
1540 }
1541}
1542
1543SYSINIT(rcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR,rc_drvinit,NULL)
1544
1545
1546#endif /* NRC */