Deleted Added
full compact
sio.c (51088) sio.c (51654)
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
1/*-
2 * Copyright (c) 1991 The Regents of the University of California.
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

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

25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/sys/dev/sio/sio.c 51088 1999-09-08 13:46:54Z peter $
33 * $FreeBSD: head/sys/dev/sio/sio.c 51654 1999-09-25 16:21:39Z phk $
34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91
35 * from: i386/isa sio.c,v 1.234
36 */
37
38#include "opt_comconsole.h"
39#include "opt_compat.h"
40#include "opt_ddb.h"
41#include "opt_sio.h"

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

302static void siointr __P((void *arg));
303static int commctl __P((struct com_s *com, int bits, int how));
304static int comparam __P((struct tty *tp, struct termios *t));
305static swihand_t siopoll;
306static int sioprobe __P((device_t dev));
307static void siosettimeout __P((void));
308static int siosetwater __P((struct com_s *com, speed_t speed));
309static void comstart __P((struct tty *tp));
34 * from: @(#)com.c 7.5 (Berkeley) 5/16/91
35 * from: i386/isa sio.c,v 1.234
36 */
37
38#include "opt_comconsole.h"
39#include "opt_compat.h"
40#include "opt_ddb.h"
41#include "opt_sio.h"

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

302static void siointr __P((void *arg));
303static int commctl __P((struct com_s *com, int bits, int how));
304static int comparam __P((struct tty *tp, struct termios *t));
305static swihand_t siopoll;
306static int sioprobe __P((device_t dev));
307static void siosettimeout __P((void));
308static int siosetwater __P((struct com_s *com, speed_t speed));
309static void comstart __P((struct tty *tp));
310static void comstop __P((struct tty *tp, int rw));
310static timeout_t comwakeup;
311static void disc_optim __P((struct tty *tp, struct termios *t,
312 struct com_s *com));
313
314
315static char driver_name[] = "sio";
316
317/* table and macro for fast conversion from a unit number to its com struct */

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

333 sizeof(struct com_s),
334};
335
336static d_open_t sioopen;
337static d_close_t sioclose;
338static d_read_t sioread;
339static d_write_t siowrite;
340static d_ioctl_t sioioctl;
311static timeout_t comwakeup;
312static void disc_optim __P((struct tty *tp, struct termios *t,
313 struct com_s *com));
314
315
316static char driver_name[] = "sio";
317
318/* table and macro for fast conversion from a unit number to its com struct */

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

334 sizeof(struct com_s),
335};
336
337static d_open_t sioopen;
338static d_close_t sioclose;
339static d_read_t sioread;
340static d_write_t siowrite;
341static d_ioctl_t sioioctl;
341static d_stop_t siostop;
342static d_devtotty_t siodevtotty;
343
344#define CDEV_MAJOR 28
345static struct cdevsw sio_cdevsw = {
346 /* open */ sioopen,
347 /* close */ sioclose,
348 /* read */ sioread,
349 /* write */ siowrite,
350 /* ioctl */ sioioctl,
342
343#define CDEV_MAJOR 28
344static struct cdevsw sio_cdevsw = {
345 /* open */ sioopen,
346 /* close */ sioclose,
347 /* read */ sioread,
348 /* write */ siowrite,
349 /* ioctl */ sioioctl,
351 /* stop */ siostop,
350 /* stop */ nostop,
352 /* reset */ noreset,
351 /* reset */ noreset,
353 /* devtotty */ siodevtotty,
354 /* poll */ ttpoll,
352 /* devtotty */ nodevtotty,
353 /* poll */ ttypoll,
355 /* mmap */ nommap,
356 /* strategy */ nostrategy,
357 /* name */ driver_name,
358 /* parms */ noparms,
359 /* maj */ CDEV_MAJOR,
360 /* dump */ nodump,
361 /* psize */ nopsize,
362 /* flags */ D_TTY,

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

1205 /*
1206 * The device isn't open, so there are no conflicts.
1207 * Initialize it. Initialization is done twice in many
1208 * cases: to preempt sleeping callin opens if we are
1209 * callout, and to complete a callin open after DCD rises.
1210 */
1211 tp->t_oproc = comstart;
1212 tp->t_param = comparam;
354 /* mmap */ nommap,
355 /* strategy */ nostrategy,
356 /* name */ driver_name,
357 /* parms */ noparms,
358 /* maj */ CDEV_MAJOR,
359 /* dump */ nodump,
360 /* psize */ nopsize,
361 /* flags */ D_TTY,

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

1204 /*
1205 * The device isn't open, so there are no conflicts.
1206 * Initialize it. Initialization is done twice in many
1207 * cases: to preempt sleeping callin opens if we are
1208 * callout, and to complete a callin open after DCD rises.
1209 */
1210 tp->t_oproc = comstart;
1211 tp->t_param = comparam;
1212 tp->t_stop = comstop;
1213 tp->t_dev = dev;
1214 tp->t_termios = mynor & CALLOUT_MASK
1215 ? com->it_out : com->it_in;
1216 (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
1217 com->poll = com->no_irq;
1218 com->poll_output = com->loses_outints;
1219 ++com->wopeners;
1220 error = comparam(tp, &tp->t_termios);

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

1331 mynor = minor(dev);
1332 if (mynor & CONTROL_MASK)
1333 return (0);
1334 com = com_addr(MINOR_TO_UNIT(mynor));
1335 tp = com->tp;
1336 s = spltty();
1337 (*linesw[tp->t_line].l_close)(tp, flag);
1338 disc_optim(tp, &tp->t_termios, com);
1213 tp->t_dev = dev;
1214 tp->t_termios = mynor & CALLOUT_MASK
1215 ? com->it_out : com->it_in;
1216 (void)commctl(com, TIOCM_DTR | TIOCM_RTS, DMSET);
1217 com->poll = com->no_irq;
1218 com->poll_output = com->loses_outints;
1219 ++com->wopeners;
1220 error = comparam(tp, &tp->t_termios);

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

1331 mynor = minor(dev);
1332 if (mynor & CONTROL_MASK)
1333 return (0);
1334 com = com_addr(MINOR_TO_UNIT(mynor));
1335 tp = com->tp;
1336 s = spltty();
1337 (*linesw[tp->t_line].l_close)(tp, flag);
1338 disc_optim(tp, &tp->t_termios, com);
1339 siostop(tp, FREAD | FWRITE);
1339 comstop(tp, FREAD | FWRITE);
1340 comhardclose(com);
1341 ttyclose(tp);
1342 siosettimeout();
1343 splx(s);
1344 if (com->gone) {
1345 printf("sio%d: gone\n", com->unit);
1346 s = spltty();
1347 if (com->ibuf != NULL)

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

2370 if (com->state >= (CS_BUSY | CS_TTGO))
2371 siointr1(com); /* fake interrupt to start output */
2372 enable_intr();
2373 ttwwakeup(tp);
2374 splx(s);
2375}
2376
2377static void
1340 comhardclose(com);
1341 ttyclose(tp);
1342 siosettimeout();
1343 splx(s);
1344 if (com->gone) {
1345 printf("sio%d: gone\n", com->unit);
1346 s = spltty();
1347 if (com->ibuf != NULL)

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

2370 if (com->state >= (CS_BUSY | CS_TTGO))
2371 siointr1(com); /* fake interrupt to start output */
2372 enable_intr();
2373 ttwwakeup(tp);
2374 splx(s);
2375}
2376
2377static void
2378siostop(tp, rw)
2378comstop(tp, rw)
2379 struct tty *tp;
2380 int rw;
2381{
2382 struct com_s *com;
2383
2384 com = com_addr(DEV_TO_UNIT(tp->t_dev));
2385 if (com->gone)
2386 return;

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

2410 FIFO_RCV_RST | com->fifo_image);
2411 com_events -= (com->iptr - com->ibuf);
2412 com->iptr = com->ibuf;
2413 }
2414 enable_intr();
2415 comstart(tp);
2416}
2417
2379 struct tty *tp;
2380 int rw;
2381{
2382 struct com_s *com;
2383
2384 com = com_addr(DEV_TO_UNIT(tp->t_dev));
2385 if (com->gone)
2386 return;

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

2410 FIFO_RCV_RST | com->fifo_image);
2411 com_events -= (com->iptr - com->ibuf);
2412 com->iptr = com->ibuf;
2413 }
2414 enable_intr();
2415 comstart(tp);
2416}
2417
2418static struct tty *
2419siodevtotty(dev)
2420 dev_t dev;
2421{
2422 int mynor;
2423 int unit;
2424
2425 mynor = minor(dev);
2426 if (mynor & CONTROL_MASK)
2427 return (NULL);
2428 unit = MINOR_TO_UNIT(mynor);
2429 if ((u_int) unit >= NSIOTOT)
2430 return (NULL);
2431 return (dev->si_tty);
2432}
2433
2434static int
2435commctl(com, bits, how)
2436 struct com_s *com;
2437 int bits;
2438 int how;
2439{
2440 int mcr;
2441 int msr;

--- 619 unchanged lines hidden ---
2418static int
2419commctl(com, bits, how)
2420 struct com_s *com;
2421 int bits;
2422 int how;
2423{
2424 int mcr;
2425 int msr;

--- 619 unchanged lines hidden ---