sio.c (54255) | sio.c (54407) |
---|---|
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/pc98/cbus/sio.c 54255 1999-12-07 09:29:15Z kato $ | 33 * $FreeBSD: head/sys/pc98/cbus/sio.c 54407 1999-12-10 14:03:47Z kato $ |
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" |
|
42#include "sio.h" 43 44/* 45 * Serial driver, based on 386BSD-0.1 com driver. 46 * Mostly rewritten to use pseudo-DMA. 47 * Works for National Semiconductor NS8250-NS16550AF UARTs. 48 * COM driver, based on HP dca driver. 49 * --- 328 unchanged lines hidden (view full) --- 378 379 u_long bytes_in; /* statistics */ 380 u_long bytes_out; 381 u_int delta_error_counts[CE_NTYPES]; 382 u_long error_counts[CE_NTYPES]; 383 384 struct resource *irqres; 385 struct resource *ioportres; | 43#include "sio.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 * --- 328 unchanged lines hidden (view full) --- 379 380 u_long bytes_in; /* statistics */ 381 u_long bytes_out; 382 u_int delta_error_counts[CE_NTYPES]; 383 u_long error_counts[CE_NTYPES]; 384 385 struct resource *irqres; 386 struct resource *ioportres; |
387 void *cookie; |
|
386 387 /* 388 * Data area for output buffers. Someday we should build the output 389 * buffer queue without copying data. 390 */ 391#ifdef PC98 392 int obufsize; 393 u_char *obuf1; --- 26 unchanged lines hidden (view full) --- 420static void comstart __P((struct tty *tp)); 421static void comstop __P((struct tty *tp, int rw)); 422static timeout_t comwakeup; 423static void disc_optim __P((struct tty *tp, struct termios *t, 424 struct com_s *com)); 425 426#if NCARD > 0 427static int sio_pccard_attach __P((device_t dev)); | 388 389 /* 390 * Data area for output buffers. Someday we should build the output 391 * buffer queue without copying data. 392 */ 393#ifdef PC98 394 int obufsize; 395 u_char *obuf1; --- 26 unchanged lines hidden (view full) --- 422static void comstart __P((struct tty *tp)); 423static void comstop __P((struct tty *tp, int rw)); 424static timeout_t comwakeup; 425static void disc_optim __P((struct tty *tp, struct termios *t, 426 struct com_s *com)); 427 428#if NCARD > 0 429static int sio_pccard_attach __P((device_t dev)); |
428static void sio_pccard_detach __P((device_t dev)); | 430static int sio_pccard_detach __P((device_t dev)); |
429static int sio_pccard_probe __P((device_t dev)); 430#endif /* NCARD > 0 */ 431 432static char driver_name[] = "sio"; 433 434/* table and macro for fast conversion from a unit number to its com struct */ 435static devclass_t sio_devclass; 436#define com_addr(unit) ((struct com_s *) \ --- 444 unchanged lines hidden (view full) --- 881#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit)) 882#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit)) 883 884#if NCARD > 0 885static int 886sio_pccard_probe(dev) 887 device_t dev; 888{ | 431static int sio_pccard_probe __P((device_t dev)); 432#endif /* NCARD > 0 */ 433 434static char driver_name[] = "sio"; 435 436/* table and macro for fast conversion from a unit number to its com struct */ 437static devclass_t sio_devclass; 438#define com_addr(unit) ((struct com_s *) \ --- 444 unchanged lines hidden (view full) --- 883#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit)) 884#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit)) 885 886#if NCARD > 0 887static int 888sio_pccard_probe(dev) 889 device_t dev; 890{ |
889 /* Do not probe IRQ - pccardd has not arranged for it yet */ 890 /* XXX Actually it has been asigned to you, but isn't activated */ 891 /* XXX until you specifically activate the resource for your use. */ | 891 /* Do not probe IRQ - pccard doesn't turn on the interrupt line */ 892 /* until bus_setup_intr */ |
892 SET_FLAG(dev, COM_C_NOPROBE); 893 894 return (sioprobe(dev)); 895} 896 897static int 898sio_pccard_attach(dev) 899 device_t dev; --- 14 unchanged lines hidden (view full) --- 914sio_pccard_detach(dev) 915 device_t dev; 916{ 917 struct com_s *com; 918 919 com = (struct com_s *) device_get_softc(dev); 920 if (!com) { 921 device_printf(dev, "NULL com in siounload\n"); | 893 SET_FLAG(dev, COM_C_NOPROBE); 894 895 return (sioprobe(dev)); 896} 897 898static int 899sio_pccard_attach(dev) 900 device_t dev; --- 14 unchanged lines hidden (view full) --- 915sio_pccard_detach(dev) 916 device_t dev; 917{ 918 struct com_s *com; 919 920 com = (struct com_s *) device_get_softc(dev); 921 if (!com) { 922 device_printf(dev, "NULL com in siounload\n"); |
922 return; | 923 return (0); |
923 } 924 if (!com->iobase) { 925 device_printf(dev, "already unloaded!\n"); | 924 } 925 if (!com->iobase) { 926 device_printf(dev, "already unloaded!\n"); |
926 return; | 927 return (0); |
927 } | 928 } |
929 com->gone = 1; 930 if (com->irqres) { 931 bus_teardown_intr(dev, com->irqres, com->cookie); 932 bus_release_resource(dev, SYS_RES_IRQ, 0, com->irqres); 933 } 934 if (com->ioportres) 935 bus_release_resource(dev, SYS_RES_IOPORT, 0, com->ioportres); |
|
928 if (com->tp && (com->tp->t_state & TS_ISOPEN)) { | 936 if (com->tp && (com->tp->t_state & TS_ISOPEN)) { |
929 com->gone = 1; | |
930 device_printf(dev, "unload\n"); 931 com->tp->t_gen++; 932 ttyclose(com->tp); 933 ttwakeup(com->tp); 934 ttwwakeup(com->tp); | 937 device_printf(dev, "unload\n"); 938 com->tp->t_gen++; 939 ttyclose(com->tp); 940 ttwakeup(com->tp); 941 ttwwakeup(com->tp); |
942 device_printf(dev, "Was busy, so crash likely\n"); |
|
935 } else { 936 if (com->ibuf != NULL) 937 free(com->ibuf, M_DEVBUF); | 943 } else { 944 if (com->ibuf != NULL) 945 free(com->ibuf, M_DEVBUF); |
938 free(com, M_DEVBUF); 939 device_printf(dev, "unload,gone\n"); | 946 device_printf(dev, "unload, gone\n"); |
940 } 941 return (0); 942} 943#endif /* NCARD > 0 */ 944 945 946static struct isa_pnp_id sio_ids[] = { 947 {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ --- 604 unchanged lines hidden (view full) --- 1552 device_t dev; 1553{ 1554 struct com_s *com; 1555#ifdef COM_ESP 1556 Port_t *espp; 1557#endif 1558 Port_t iobase; 1559 int unit; | 947 } 948 return (0); 949} 950#endif /* NCARD > 0 */ 951 952 953static struct isa_pnp_id sio_ids[] = { 954 {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ --- 604 unchanged lines hidden (view full) --- 1559 device_t dev; 1560{ 1561 struct com_s *com; 1562#ifdef COM_ESP 1563 Port_t *espp; 1564#endif 1565 Port_t iobase; 1566 int unit; |
1560 void *ih; | |
1561 u_int flags; 1562 int rid; 1563 struct resource *port; 1564 int ret; 1565#ifdef PC98 1566 int port_shift = 0; 1567 u_char *obuf; 1568 u_long obufsize; --- 344 unchanged lines hidden (view full) --- 1913 pps_init(&com->pps); 1914 1915 rid = 0; 1916 com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, 1917 RF_ACTIVE); 1918 if (com->irqres) { 1919 ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres, 1920 INTR_TYPE_TTY | INTR_TYPE_FAST, | 1567 u_int flags; 1568 int rid; 1569 struct resource *port; 1570 int ret; 1571#ifdef PC98 1572 int port_shift = 0; 1573 u_char *obuf; 1574 u_long obufsize; --- 344 unchanged lines hidden (view full) --- 1919 pps_init(&com->pps); 1920 1921 rid = 0; 1922 com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, 1923 RF_ACTIVE); 1924 if (com->irqres) { 1925 ret = BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres, 1926 INTR_TYPE_TTY | INTR_TYPE_FAST, |
1921 siointr, com, &ih); | 1927 siointr, com, &com->cookie); |
1922 if (ret) { 1923 ret = BUS_SETUP_INTR(device_get_parent(dev), dev, 1924 com->irqres, INTR_TYPE_TTY, | 1928 if (ret) { 1929 ret = BUS_SETUP_INTR(device_get_parent(dev), dev, 1930 com->irqres, INTR_TYPE_TTY, |
1925 siointr, com, &ih); | 1931 siointr, com, &com->cookie); |
1926 if (ret == 0) 1927 device_printf(dev, "unable to activate interrupt in fast mode - using normal mode"); 1928 } 1929 if (ret) 1930 device_printf(dev, "could not activate interrupt\n"); 1931 } 1932 1933 return (0); --- 3158 unchanged lines hidden --- | 1932 if (ret == 0) 1933 device_printf(dev, "unable to activate interrupt in fast mode - using normal mode"); 1934 } 1935 if (ret) 1936 device_printf(dev, "could not activate interrupt\n"); 1937 } 1938 1939 return (0); --- 3158 unchanged lines hidden --- |