Deleted Added
full compact
sio.c (85302) sio.c (85365)
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 85302 2001-10-22 02:48:38Z imp $
33 * $FreeBSD: head/sys/dev/sio/sio.c 85365 2001-10-23 15:17:33Z imp $
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"
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"
42#include "card.h"
43#include "pci.h"
44
45/*
46 * Serial driver, based on 386BSD-0.1 com driver.
47 * Mostly rewritten to use pseudo-DMA.
48 * Works for National Semiconductor NS8250-NS16550AF UARTs.
49 * COM driver, based on HP dca driver.
50 *
51 * Changes for PC-Card integration:
52 * - Added PC-Card driver table and handlers
53 */
54#include <sys/param.h>
55#include <sys/systm.h>
56#include <sys/bus.h>
42
43/*
44 * Serial driver, based on 386BSD-0.1 com driver.
45 * Mostly rewritten to use pseudo-DMA.
46 * Works for National Semiconductor NS8250-NS16550AF UARTs.
47 * COM driver, based on HP dca driver.
48 *
49 * Changes for PC-Card integration:
50 * - Added PC-Card driver table and handlers
51 */
52#include <sys/param.h>
53#include <sys/systm.h>
54#include <sys/bus.h>
57#include <sys/bus.h>
58#include <sys/conf.h>
59#include <sys/dkstat.h>
60#include <sys/fcntl.h>
61#include <sys/interrupt.h>
62#include <sys/kernel.h>
63#include <sys/lock.h>
64#include <sys/malloc.h>
65#include <sys/module.h>

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

70#include <sys/syslog.h>
71#include <sys/tty.h>
72#include <machine/bus_pio.h>
73#include <machine/bus.h>
74#include <sys/rman.h>
75#include <sys/timetc.h>
76#include <sys/timepps.h>
77
55#include <sys/conf.h>
56#include <sys/dkstat.h>
57#include <sys/fcntl.h>
58#include <sys/interrupt.h>
59#include <sys/kernel.h>
60#include <sys/lock.h>
61#include <sys/malloc.h>
62#include <sys/module.h>

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

67#include <sys/syslog.h>
68#include <sys/tty.h>
69#include <machine/bus_pio.h>
70#include <machine/bus.h>
71#include <sys/rman.h>
72#include <sys/timetc.h>
73#include <sys/timepps.h>
74
78#include <isa/isareg.h>
79#include <isa/isavar.h>
80#if NPCI > 0
81#include <pci/pcireg.h>
82#include <pci/pcivar.h>
83#endif
84
85#include <machine/clock.h>
86#include <machine/resource.h>
87
88#include <dev/sio/sioreg.h>
75#include <machine/clock.h>
76#include <machine/resource.h>
77
78#include <dev/sio/sioreg.h>
79#include <dev/sio/siovar.h>
89
80
81#include <isa/isavar.h>
82
90#ifdef COM_ESP
91#include <dev/ic/esp.h>
92#endif
93#include <dev/ic/ns16550.h>
94
95#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
96
97#define CALLOUT_MASK 0x80

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

113
114#define COM_CONSOLE(flags) ((flags) & 0x10)
115#define COM_FORCECONSOLE(flags) ((flags) & 0x20)
116#define COM_LLCONSOLE(flags) ((flags) & 0x40)
117#define COM_DEBUGGER(flags) ((flags) & 0x80)
118#define COM_LOSESOUTINTS(flags) ((flags) & 0x08)
119#define COM_NOFIFO(flags) ((flags) & 0x02)
120#define COM_ST16650A(flags) ((flags) & 0x20000)
83#ifdef COM_ESP
84#include <dev/ic/esp.h>
85#endif
86#include <dev/ic/ns16550.h>
87
88#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */
89
90#define CALLOUT_MASK 0x80

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

106
107#define COM_CONSOLE(flags) ((flags) & 0x10)
108#define COM_FORCECONSOLE(flags) ((flags) & 0x20)
109#define COM_LLCONSOLE(flags) ((flags) & 0x40)
110#define COM_DEBUGGER(flags) ((flags) & 0x80)
111#define COM_LOSESOUTINTS(flags) ((flags) & 0x08)
112#define COM_NOFIFO(flags) ((flags) & 0x02)
113#define COM_ST16650A(flags) ((flags) & 0x20000)
121#define COM_C_NOPROBE (0x40000)
122#define COM_NOPROBE(flags) ((flags) & COM_C_NOPROBE)
123#define COM_C_IIR_TXRDYBUG (0x80000)
124#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG)
125#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24)
126
127#define com_scr 7 /* scratch register for 16450-16550 (R/W) */
128
129#define sio_getreg(com, off) \
130 (bus_space_read_1((com)->bst, (com)->bsh, (off)))

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

161#define CE_OVERRUN 0
162 "silo overflow",
163#define CE_INTERRUPT_BUF_OVERFLOW 1
164 "interrupt-level buffer overflow",
165#define CE_TTY_BUF_OVERFLOW 2
166 "tty-level buffer overflow",
167};
168
114#define COM_C_IIR_TXRDYBUG (0x80000)
115#define COM_IIR_TXRDYBUG(flags) ((flags) & COM_C_IIR_TXRDYBUG)
116#define COM_FIFOSIZE(flags) (((flags) & 0xff000000) >> 24)
117
118#define com_scr 7 /* scratch register for 16450-16550 (R/W) */
119
120#define sio_getreg(com, off) \
121 (bus_space_read_1((com)->bst, (com)->bsh, (off)))

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

152#define CE_OVERRUN 0
153 "silo overflow",
154#define CE_INTERRUPT_BUF_OVERFLOW 1
155 "interrupt-level buffer overflow",
156#define CE_TTY_BUF_OVERFLOW 2
157 "tty-level buffer overflow",
158};
159
169#define CE_NTYPES 3
170#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
171
160#define CE_RECORD(com, errnum) (++(com)->delta_error_counts[errnum])
161
172/* types. XXX - should be elsewhere */
173typedef u_int Port_t; /* hardware port */
174typedef u_char bool_t; /* boolean */
175
176/* queue of linear buffers */
177struct lbq {
178 u_char *l_head; /* next char to process */
179 u_char *l_tail; /* one past the last char to process */
180 struct lbq *l_next; /* next in queue */
181 bool_t l_queued; /* nonzero if queued */
182};
183
184/* com device structure */
185struct com_s {
186 u_int flags; /* Copy isa device flags */
187 u_char state; /* miscellaneous flag bits */
188 bool_t active_out; /* nonzero if the callout device is open */
189 u_char cfcr_image; /* copy of value written to CFCR */
190#ifdef COM_ESP
162#ifdef COM_ESP
191 bool_t esp; /* is this unit a hayes esp board? */
192#endif
193 u_char extra_state; /* more flag bits, separate for order trick */
194 u_char fifo_image; /* copy of value written to FIFO */
195 bool_t hasfifo; /* nonzero for 16550 UARTs */
196 bool_t st16650a; /* Is a Startech 16650A or RTS/CTS compat */
197 bool_t loses_outints; /* nonzero if device loses output interrupts */
198 u_char mcr_image; /* copy of value written to MCR */
199#ifdef COM_MULTIPORT
200 bool_t multiport; /* is this unit part of a multiport device? */
201#endif /* COM_MULTIPORT */
202 bool_t no_irq; /* nonzero if irq is not attached */
203 bool_t gone; /* hardware disappeared */
204 bool_t poll; /* nonzero if polling is required */
205 bool_t poll_output; /* nonzero if polling for output is required */
206 int unit; /* unit number */
207 int dtr_wait; /* time to hold DTR down on close (* 1/hz) */
208 u_int tx_fifo_size;
209 u_int wopeners; /* # processes waiting for DCD in open() */
210
211 /*
212 * The high level of the driver never reads status registers directly
213 * because there would be too many side effects to handle conveniently.
214 * Instead, it reads copies of the registers stored here by the
215 * interrupt handler.
216 */
217 u_char last_modem_status; /* last MSR read by intr handler */
218 u_char prev_modem_status; /* last MSR handled by high level */
219
220 u_char hotchar; /* ldisc-specific char to be handled ASAP */
221 u_char *ibuf; /* start of input buffer */
222 u_char *ibufend; /* end of input buffer */
223 u_char *ibufold; /* old input buffer, to be freed */
224 u_char *ihighwater; /* threshold in input buffer */
225 u_char *iptr; /* next free spot in input buffer */
226 int ibufsize; /* size of ibuf (not include error bytes) */
227 int ierroff; /* offset of error bytes in ibuf */
228
229 struct lbq obufq; /* head of queue of output buffers */
230 struct lbq obufs[2]; /* output buffers */
231
232 bus_space_tag_t bst;
233 bus_space_handle_t bsh;
234
235 Port_t data_port; /* i/o ports */
236#ifdef COM_ESP
237 Port_t esp_port;
238#endif
239 Port_t int_id_port;
240 Port_t modem_ctl_port;
241 Port_t line_status_port;
242 Port_t modem_status_port;
243 Port_t intr_ctl_port; /* Ports of IIR register */
244
245 struct tty *tp; /* cross reference */
246
247 /* Initial state. */
248 struct termios it_in; /* should be in struct tty */
249 struct termios it_out;
250
251 /* Lock state. */
252 struct termios lt_in; /* should be in struct tty */
253 struct termios lt_out;
254
255 bool_t do_timestamp;
256 bool_t do_dcd_timestamp;
257 struct timeval timestamp;
258 struct timeval dcd_timestamp;
259 struct pps_state pps;
260
261 u_long bytes_in; /* statistics */
262 u_long bytes_out;
263 u_int delta_error_counts[CE_NTYPES];
264 u_long error_counts[CE_NTYPES];
265
266 struct resource *irqres;
267 struct resource *ioportres;
268 void *cookie;
269 dev_t devs[6];
270
271 /*
272 * Data area for output buffers. Someday we should build the output
273 * buffer queue without copying data.
274 */
275 u_char obuf1[256];
276 u_char obuf2[256];
277};
278
279#ifdef COM_ESP
280static int espattach __P((struct com_s *com, Port_t esp_port));
281#endif
163static int espattach __P((struct com_s *com, Port_t esp_port));
164#endif
282static int sioattach __P((device_t dev, int rid));
283static int sio_isa_attach __P((device_t dev));
284
285static timeout_t siobusycheck;
286static timeout_t siodtrwakeup;
287static void comhardclose __P((struct com_s *com));
288static void sioinput __P((struct com_s *com));
289static void siointr1 __P((struct com_s *com));
290static void siointr __P((void *arg));
291static int commctl __P((struct com_s *com, int bits, int how));
292static int comparam __P((struct tty *tp, struct termios *t));
293static void siopoll __P((void *));
165
166static timeout_t siobusycheck;
167static timeout_t siodtrwakeup;
168static void comhardclose __P((struct com_s *com));
169static void sioinput __P((struct com_s *com));
170static void siointr1 __P((struct com_s *com));
171static void siointr __P((void *arg));
172static int commctl __P((struct com_s *com, int bits, int how));
173static int comparam __P((struct tty *tp, struct termios *t));
174static void siopoll __P((void *));
294static int sioprobe __P((device_t dev, int xrid));
295static int sio_isa_probe __P((device_t dev));
296static void siosettimeout __P((void));
297static int siosetwater __P((struct com_s *com, speed_t speed));
298static void comstart __P((struct tty *tp));
299static void comstop __P((struct tty *tp, int rw));
300static timeout_t comwakeup;
301static void disc_optim __P((struct tty *tp, struct termios *t,
302 struct com_s *com));
303
175static void siosettimeout __P((void));
176static int siosetwater __P((struct com_s *com, speed_t speed));
177static void comstart __P((struct tty *tp));
178static void comstop __P((struct tty *tp, int rw));
179static timeout_t comwakeup;
180static void disc_optim __P((struct tty *tp, struct termios *t,
181 struct com_s *com));
182
304#if NCARD > 0
305static int sio_pccard_attach __P((device_t dev));
306static int sio_pccard_detach __P((device_t dev));
307static int sio_pccard_probe __P((device_t dev));
308#endif /* NCARD > 0 */
309
310#if NPCI > 0
311static int sio_pci_attach __P((device_t dev));
312static void sio_pci_kludge_unit __P((device_t dev));
313static int sio_pci_probe __P((device_t dev));
314#endif /* NPCI > 0 */
315
316static char driver_name[] = "sio";
183char sio_driver_name[] = "sio";
317static struct mtx sio_lock;
318static int sio_inited;
319
320/* table and macro for fast conversion from a unit number to its com struct */
184static struct mtx sio_lock;
185static int sio_inited;
186
187/* table and macro for fast conversion from a unit number to its com struct */
321static devclass_t sio_devclass;
188devclass_t sio_devclass;
322#define com_addr(unit) ((struct com_s *) \
323 devclass_get_softc(sio_devclass, unit))
324
189#define com_addr(unit) ((struct com_s *) \
190 devclass_get_softc(sio_devclass, unit))
191
325static device_method_t sio_isa_methods[] = {
326 /* Device interface */
327 DEVMETHOD(device_probe, sio_isa_probe),
328 DEVMETHOD(device_attach, sio_isa_attach),
329
330 { 0, 0 }
331};
332
333static driver_t sio_isa_driver = {
334 driver_name,
335 sio_isa_methods,
336 sizeof(struct com_s),
337};
338
339#if NCARD > 0
340static device_method_t sio_pccard_methods[] = {
341 /* Device interface */
342 DEVMETHOD(device_probe, sio_pccard_probe),
343 DEVMETHOD(device_attach, sio_pccard_attach),
344 DEVMETHOD(device_detach, sio_pccard_detach),
345
346 { 0, 0 }
347};
348
349static driver_t sio_pccard_driver = {
350 driver_name,
351 sio_pccard_methods,
352 sizeof(struct com_s),
353};
354#endif /* NCARD > 0 */
355
356#if NPCI > 0
357static device_method_t sio_pci_methods[] = {
358 /* Device interface */
359 DEVMETHOD(device_probe, sio_pci_probe),
360 DEVMETHOD(device_attach, sio_pci_attach),
361
362 { 0, 0 }
363};
364
365static driver_t sio_pci_driver = {
366 driver_name,
367 sio_pci_methods,
368 sizeof(struct com_s),
369};
370#endif /* NPCI > 0 */
371
372static d_open_t sioopen;
373static d_close_t sioclose;
374static d_read_t sioread;
375static d_write_t siowrite;
376static d_ioctl_t sioioctl;
377
378#define CDEV_MAJOR 28
379static struct cdevsw sio_cdevsw = {
380 /* open */ sioopen,
381 /* close */ sioclose,
382 /* read */ sioread,
383 /* write */ siowrite,
384 /* ioctl */ sioioctl,
385 /* poll */ ttypoll,
386 /* mmap */ nommap,
387 /* strategy */ nostrategy,
192static d_open_t sioopen;
193static d_close_t sioclose;
194static d_read_t sioread;
195static d_write_t siowrite;
196static d_ioctl_t sioioctl;
197
198#define CDEV_MAJOR 28
199static struct cdevsw sio_cdevsw = {
200 /* open */ sioopen,
201 /* close */ sioclose,
202 /* read */ sioread,
203 /* write */ siowrite,
204 /* ioctl */ sioioctl,
205 /* poll */ ttypoll,
206 /* mmap */ nommap,
207 /* strategy */ nostrategy,
388 /* name */ driver_name,
208 /* name */ sio_driver_name,
389 /* maj */ CDEV_MAJOR,
390 /* dump */ nodump,
391 /* psize */ nopsize,
392 /* flags */ D_TTY | D_KQFILTER,
393 /* kqfilter */ ttykqfilter,
394};
395
396int comconsole = -1;

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

497 splx(s);
498 }
499 return error;
500}
501
502SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW,
503 0, 0, sysctl_machdep_comdefaultrate, "I", "");
504
209 /* maj */ CDEV_MAJOR,
210 /* dump */ nodump,
211 /* psize */ nopsize,
212 /* flags */ D_TTY | D_KQFILTER,
213 /* kqfilter */ ttykqfilter,
214};
215
216int comconsole = -1;

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

317 splx(s);
318 }
319 return error;
320}
321
322SYSCTL_PROC(_machdep, OID_AUTO, conspeed, CTLTYPE_INT | CTLFLAG_RW,
323 0, 0, sysctl_machdep_comdefaultrate, "I", "");
324
505#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit))
506#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit))
507
508#if NCARD > 0
509static int
510sio_pccard_probe(dev)
325int
326siodetach(dev)
511 device_t dev;
512{
327 device_t dev;
328{
513 /* Do not probe IRQ - pccard doesn't turn on the interrupt line */
514 /* until bus_setup_intr */
515 SET_FLAG(dev, COM_C_NOPROBE);
516
517 return (sioprobe(dev, 0));
518}
519
520static int
521sio_pccard_attach(dev)
522 device_t dev;
523{
524 return (sioattach(dev, 0));
525}
526
527/*
528 * sio_detach - unload the driver and clear the table.
529 * XXX TODO:
530 * This is usually called when the card is ejected, but
531 * can be caused by a modunload of a controller driver.
532 * The idea is to reset the driver's view of the device
533 * and ensure that any driver entry points such as
534 * read and write do not hang.
535 */
536static int
537sio_pccard_detach(dev)
538 device_t dev;
539{
540 struct com_s *com;
541 int i;
542
543 com = (struct com_s *) device_get_softc(dev);
544 if (com == NULL) {
545 device_printf(dev, "NULL com in siounload\n");
546 return (0);
547 }

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

560 com->tp->t_gen++;
561 ttyclose(com->tp);
562 ttwakeup(com->tp);
563 ttwwakeup(com->tp);
564 } else {
565 if (com->ibuf != NULL)
566 free(com->ibuf, M_DEVBUF);
567 }
329 struct com_s *com;
330 int i;
331
332 com = (struct com_s *) device_get_softc(dev);
333 if (com == NULL) {
334 device_printf(dev, "NULL com in siounload\n");
335 return (0);
336 }

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

349 com->tp->t_gen++;
350 ttyclose(com->tp);
351 ttwakeup(com->tp);
352 ttwwakeup(com->tp);
353 } else {
354 if (com->ibuf != NULL)
355 free(com->ibuf, M_DEVBUF);
356 }
568 device_printf(dev, "unloaded\n");
569 return (0);
570}
357 return (0);
358}
571#endif /* NCARD > 0 */
572
359
573#if NPCI > 0
574struct pci_ids {
575 u_int32_t type;
576 const char *desc;
577 int rid;
578};
579
580static struct pci_ids pci_ids[] = {
581 { 0x100812b9, "3COM PCI FaxModem", 0x10 },
582 { 0x2000131f, "CyberSerial (1-port) 16550", 0x10 },
583 { 0x01101407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
584 { 0x01111407, "Koutech IOFLEX-2S PCI Dual Port Serial", 0x10 },
585 { 0x048011c1, "Lucent kermit based PCI Modem", 0x14 },
586 { 0x95211415, "Oxford Semiconductor PCI Dual Port Serial", 0x10 },
587 { 0x0000151f, "SmartLink 5634PCV SurfRider", 0x10 },
588 /* { 0xXXXXXXXX, "Xircom Cardbus modem", 0x10 }, */
589 { 0x00000000, NULL, 0 }
590};
591
592static int
593sio_pci_attach(dev)
360int
361sioprobe(dev, xrid, noprobe)
594 device_t dev;
362 device_t dev;
595{
596 u_int32_t type;
597 struct pci_ids *id;
598
599 type = pci_get_devid(dev);
600 id = pci_ids;
601 while (id->type && id->type != type)
602 id++;
603 if (id->desc == NULL)
604 return (ENXIO);
605 sio_pci_kludge_unit(dev);
606 return (sioattach(dev, id->rid));
607}
608
609/*
610 * Don't cut and paste this to other drivers. It is a horrible kludge
611 * which will fail to work and also be unnecessary in future versions.
612 */
613static void
614sio_pci_kludge_unit(dev)
615 device_t dev;
616{
617 devclass_t dc;
618 int err;
619 int start;
620 int unit;
621
622 unit = 0;
623 start = 0;
624 while (resource_int_value("sio", unit, "port", &start) == 0 &&
625 start > 0)
626 unit++;
627 if (device_get_unit(dev) < unit) {
628 dc = device_get_devclass(dev);
629 while (devclass_get_device(dc, unit))
630 unit++;
631 device_printf(dev, "moving to sio%d\n", unit);
632 err = device_set_unit(dev, unit); /* EVIL DO NOT COPY */
633 if (err)
634 device_printf(dev, "error moving device %d\n", err);
635 }
636}
637
638static int
639sio_pci_probe(dev)
640 device_t dev;
641{
642 u_int32_t type;
643 struct pci_ids *id;
644
645 type = pci_get_devid(dev);
646 id = pci_ids;
647 while (id->type && id->type != type)
648 id++;
649 if (id->desc == NULL)
650 return (ENXIO);
651 device_set_desc(dev, id->desc);
652 return (sioprobe(dev, id->rid));
653}
654#endif /* NPCI > 0 */
655
656static struct isa_pnp_id sio_ids[] = {
657 {0x0005d041, "Standard PC COM port"}, /* PNP0500 */
658 {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */
659 {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */
660 {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */
661 {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */
662 /* Devices that do not have a compatid */
663 {0x12206804, NULL}, /* ACH2012 - 5634BTS 56K Video Ready Modem */
664 {0x7602a904, NULL}, /* AEI0276 - 56K v.90 Fax Modem (LKT) */
665 {0x00007905, NULL}, /* AKY0000 - 56K Plug&Play Modem */
666 {0x01405407, NULL}, /* AZT4001 - AZT3000 PnP SOUND DEVICE, MODEM */
667 {0x56039008, NULL}, /* BDP0356 - Best Data 56x2 */
668 {0x56159008, NULL}, /* BDP1556 - B.D. Smart One 56SPS,Voice Modem*/
669 {0x36339008, NULL}, /* BDP3336 - Best Data Prods. 336F */
670 {0x0014490a, NULL}, /* BRI1400 - Boca 33.6 PnP */
671 {0x0015490a, NULL}, /* BRI1500 - Internal Fax Data */
672 {0x0034490a, NULL}, /* BRI3400 - Internal ACF Modem */
673 {0x0094490a, NULL}, /* BRI9400 - Boca K56Flex PnP */
674 {0x00b4490a, NULL}, /* BRIB400 - Boca 56k PnP */
675 {0x0030320d, NULL}, /* CIR3000 - Cirrus Logic V43 */
676 {0x0100440e, NULL}, /* CRD0001 - Cardinal MVP288IV ? */
677 {0x36033610, NULL}, /* DAV0336 - DAVICOM 336PNP MODEM */
678 {0x0000aa1a, NULL}, /* FUJ0000 - FUJITSU Modem 33600 PNP/I2 */
679 {0x1200c31e, NULL}, /* GVC0012 - VF1128HV-R9 (win modem?) */
680 {0x0303c31e, NULL}, /* GVC0303 - MaxTech 33.6 PnP D/F/V */
681 {0x0505c31e, NULL}, /* GVC0505 - GVC 56k Faxmodem */
682 {0x0116c31e, NULL}, /* GVC1601 - Rockwell V.34 Plug & Play Modem */
683 {0x0050c31e, NULL}, /* GVC5000 - some GVC modem */
684 {0x3800f91e, NULL}, /* GWY0038 - Telepath with v.90 */
685 {0x9062f91e, NULL}, /* GWY6290 - Telepath with x2 Technology */
686 {0x8100e425, NULL}, /* IOD0081 - I-O DATA DEVICE,INC. IFML-560 */
687 {0x21002534, NULL}, /* MAE0021 - Jetstream Int V.90 56k Voice Series 2*/
688 {0x0000f435, NULL}, /* MOT0000 - Motorola ModemSURFR 33.6 Intern */
689 {0x5015f435, NULL}, /* MOT1550 - Motorola ModemSURFR 56K Modem */
690 {0xf015f435, NULL}, /* MOT15F0 - Motorola VoiceSURFR 56K Modem */
691 {0x6045f435, NULL}, /* MOT4560 - Motorola ? */
692 {0x61e7a338, NULL}, /* NECE761 - 33.6Modem */
693 {0x08804f3f, NULL}, /* OZO8008 - Zoom (33.6k Modem) */
694 {0x0f804f3f, NULL}, /* OZO800f - Zoom 2812 (56k Modem) */
695 {0x39804f3f, NULL}, /* OZO8039 - Zoom 56k flex */
696 {0x00914f3f, NULL}, /* OZO9100 - Zoom 2919 (K56 Faxmodem) */
697 {0x3024a341, NULL}, /* PMC2430 - Pace 56 Voice Internal Modem */
698 {0x1000eb49, NULL}, /* ROK0010 - Rockwell ? */
699 {0x1200b23d, NULL}, /* RSS0012 - OMRON ME5614ISA */
700 {0x5002734a, NULL}, /* RSS0250 - 5614Jx3(G) Internal Modem */
701 {0x6202734a, NULL}, /* RSS0262 - 5614Jx3[G] V90+K56Flex Modem */
702 {0xc100ad4d, NULL}, /* SMM00C1 - Leopard 56k PnP */
703 {0x9012b04e, NULL}, /* SUP1290 - Supra ? */
704 {0x1013b04e, NULL}, /* SUP1310 - SupraExpress 336i PnP */
705 {0x8013b04e, NULL}, /* SUP1380 - SupraExpress 288i PnP Voice */
706 {0x8113b04e, NULL}, /* SUP1381 - SupraExpress 336i PnP Voice */
707 {0x5016b04e, NULL}, /* SUP1650 - Supra 336i Sp Intl */
708 {0x7016b04e, NULL}, /* SUP1670 - Supra 336i V+ Intl */
709 {0x7420b04e, NULL}, /* SUP2070 - Supra ? */
710 {0x8020b04e, NULL}, /* SUP2080 - Supra ? */
711 {0x8420b04e, NULL}, /* SUP2084 - SupraExpress 56i PnP */
712 {0x7121b04e, NULL}, /* SUP2171 - SupraExpress 56i Sp? */
713 {0x8024b04e, NULL}, /* SUP2480 - Supra ? */
714 {0x01007256, NULL}, /* USR0001 - U.S. Robotics Inc., Sportster W */
715 {0x02007256, NULL}, /* USR0002 - U.S. Robotics Inc. Sportster 33. */
716 {0x04007256, NULL}, /* USR0004 - USR Sportster 14.4k */
717 {0x06007256, NULL}, /* USR0006 - USR Sportster 33.6k */
718 {0x11007256, NULL}, /* USR0011 - USR ? */
719 {0x01017256, NULL}, /* USR0101 - USR ? */
720 {0x30207256, NULL}, /* USR2030 - U.S.Robotics Inc. Sportster 560 */
721 {0x50207256, NULL}, /* USR2050 - U.S.Robotics Inc. Sportster 33. */
722 {0x70207256, NULL}, /* USR2070 - U.S.Robotics Inc. Sportster 560 */
723 {0x30307256, NULL}, /* USR3030 - U.S. Robotics 56K FAX INT */
724 {0x31307256, NULL}, /* USR3031 - U.S. Robotics 56K FAX INT */
725 {0x50307256, NULL}, /* USR3050 - U.S. Robotics 56K FAX INT */
726 {0x70307256, NULL}, /* USR3070 - U.S. Robotics 56K Voice INT */
727 {0x90307256, NULL}, /* USR3090 - USR ? */
728 {0x70917256, NULL}, /* USR9170 - U.S. Robotics 56K FAX INT */
729 {0x90917256, NULL}, /* USR9190 - USR 56k Voice INT */
730 {0x0300695c, NULL}, /* WCI0003 - Fax/Voice/Modem/Speakphone/Asvd */
731 {0x01a0896a, NULL}, /* ZTIA001 - Zoom Internal V90 Faxmodem */
732 {0x61f7896a, NULL}, /* ZTIF761 - Zoom ComStar 33.6 */
733 {0}
734};
735
736
737
738static int
739sio_isa_probe(dev)
740 device_t dev;
741{
742 /* Check isapnp ids */
743 if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO)
744 return (ENXIO);
745 return (sioprobe(dev, 0));
746}
747
748static int
749sioprobe(dev, xrid)
750 device_t dev;
751 int xrid;
363 int xrid;
364 int noprobe;
752{
753#if 0
754 static bool_t already_init;
755 device_t xdev;
756#endif
757 struct com_s *com;
758 bool_t failures[10];
759 int fn;

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

775 return (ENXIO);
776
777 com = device_get_softc(dev);
778 com->bst = rman_get_bustag(port);
779 com->bsh = rman_get_bushandle(port);
780
781 while (sio_inited != 2)
782 if (atomic_cmpset_int(&sio_inited, 0, 1)) {
365{
366#if 0
367 static bool_t already_init;
368 device_t xdev;
369#endif
370 struct com_s *com;
371 bool_t failures[10];
372 int fn;

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

388 return (ENXIO);
389
390 com = device_get_softc(dev);
391 com->bst = rman_get_bustag(port);
392 com->bsh = rman_get_bushandle(port);
393
394 while (sio_inited != 2)
395 if (atomic_cmpset_int(&sio_inited, 0, 1)) {
783 mtx_init(&sio_lock, driver_name, (comconsole != -1) ?
396 mtx_init(&sio_lock, sio_driver_name, (comconsole != -1) ?
784 MTX_SPIN | MTX_QUIET : MTX_SPIN);
785 atomic_store_rel_int(&sio_inited, 2);
786 }
787
788#if 0
789 /*
790 * XXX this is broken - when we are first called, there are no
791 * previously configured IO ports. We could hard code

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

939 */
940/* EXTRA DELAY? */
941 sio_setreg(com, com_mcr, mcr_image);
942
943 /*
944 * Some pcmcia cards have the "TXRDY bug", so we check everyone
945 * for IIR_TXRDY implementation ( Palido 321s, DC-1S... )
946 */
397 MTX_SPIN | MTX_QUIET : MTX_SPIN);
398 atomic_store_rel_int(&sio_inited, 2);
399 }
400
401#if 0
402 /*
403 * XXX this is broken - when we are first called, there are no
404 * previously configured IO ports. We could hard code

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

552 */
553/* EXTRA DELAY? */
554 sio_setreg(com, com_mcr, mcr_image);
555
556 /*
557 * Some pcmcia cards have the "TXRDY bug", so we check everyone
558 * for IIR_TXRDY implementation ( Palido 321s, DC-1S... )
559 */
947 if (COM_NOPROBE(flags)) {
560 if (noprobe) {
948 /* Reading IIR register twice */
949 for (fn = 0; fn < 2; fn ++) {
950 DELAY(10000);
951 failures[6] = sio_getreg(com, com_iir);
952 }
953 /* Check IIR_TXRDY clear ? */
954 result = 0;
955 if (failures[6] & IIR_TXRDY) {

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

1101 * Okay, we seem to be a Hayes ESP card. Whee.
1102 */
1103 com->esp = TRUE;
1104 com->esp_port = esp_port;
1105 return (1);
1106}
1107#endif /* COM_ESP */
1108
561 /* Reading IIR register twice */
562 for (fn = 0; fn < 2; fn ++) {
563 DELAY(10000);
564 failures[6] = sio_getreg(com, com_iir);
565 }
566 /* Check IIR_TXRDY clear ? */
567 result = 0;
568 if (failures[6] & IIR_TXRDY) {

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

714 * Okay, we seem to be a Hayes ESP card. Whee.
715 */
716 com->esp = TRUE;
717 com->esp_port = esp_port;
718 return (1);
719}
720#endif /* COM_ESP */
721
1109static int
1110sio_isa_attach(dev)
1111 device_t dev;
1112{
1113 return (sioattach(dev, 0));
1114}
1115
1116static int
722int
1117sioattach(dev, xrid)
1118 device_t dev;
1119 int xrid;
1120{
1121 struct com_s *com;
1122#ifdef COM_ESP
1123 Port_t *espp;
1124#endif

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

3381 s = spltty();
3382 siocnopen(&sp, siogdbiobase, gdbdefaultrate);
3383 siocntxwait(siogdbiobase);
3384 outb(siogdbiobase + com_data, c);
3385 siocnclose(&sp, siogdbiobase);
3386 splx(s);
3387}
3388#endif
723sioattach(dev, xrid)
724 device_t dev;
725 int xrid;
726{
727 struct com_s *com;
728#ifdef COM_ESP
729 Port_t *espp;
730#endif

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

2987 s = spltty();
2988 siocnopen(&sp, siogdbiobase, gdbdefaultrate);
2989 siocntxwait(siogdbiobase);
2990 outb(siogdbiobase + com_data, c);
2991 siocnclose(&sp, siogdbiobase);
2992 splx(s);
2993}
2994#endif
3389
3390DRIVER_MODULE(sio, isa, sio_isa_driver, sio_devclass, 0, 0);
3391DRIVER_MODULE(sio, acpi, sio_isa_driver, sio_devclass, 0, 0);
3392#if NCARD > 0
3393DRIVER_MODULE(sio, pccard, sio_pccard_driver, sio_devclass, 0, 0);
3394#endif
3395#if NPCI > 0
3396DRIVER_MODULE(sio, pci, sio_pci_driver, sio_devclass, 0, 0);
3397DRIVER_MODULE(sio, cardbus, sio_pci_driver, sio_devclass, 0, 0);
3398#endif