sio.c (51056) | sio.c (51202) |
---|---|
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 51056 1999-09-07 11:17:09Z kato $ | 33 * $FreeBSD: head/sys/pc98/cbus/sio.c 51202 1999-09-12 13:44:54Z nyan $ |
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 "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 "sio.h" |
43/* #include "pnp.h" */ 44#define NPNP 0 | |
45 46/* 47 * Serial driver, based on 386BSD-0.1 com driver. 48 * Mostly rewritten to use pseudo-DMA. 49 * Works for National Semiconductor NS8250-NS16550AF UARTs. 50 * COM driver, based on HP dca driver. 51 * 52 * Changes for PC-Card integration: --- 125 unchanged lines hidden (view full) --- 178#include <i386/isa/ic/esp.h> 179#endif 180#include <i386/isa/ic/ns16550.h> 181#ifdef PC98 182#include <i386/isa/ic/rsa.h> 183#endif 184 185#if 0 | 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 * 50 * Changes for PC-Card integration: --- 125 unchanged lines hidden (view full) --- 176#include <i386/isa/ic/esp.h> 177#endif 178#include <i386/isa/ic/ns16550.h> 179#ifdef PC98 180#include <i386/isa/ic/rsa.h> 181#endif 182 183#if 0 |
186 | |
187#include "card.h" 188#if NCARD > 0 189#include <sys/module.h> 190#include <pccard/cardinfo.h> 191#include <pccard/slot.h> 192#endif | 184#include "card.h" 185#if NCARD > 0 186#include <sys/module.h> 187#include <pccard/cardinfo.h> 188#include <pccard/slot.h> 189#endif |
193 194#if NPNP > 0 195#include <i386/isa/pnp.h> | 190#else 191#define NCARD 0 |
196#endif 197 | 192#endif 193 |
198#endif 199 | |
200#ifndef __i386__ | 194#ifndef __i386__ |
201#define disable_intr() 0 202#define enable_intr() 0 | 195#define disable_intr() 196#define enable_intr() |
203#endif 204 205#ifdef SMP 206#define disable_intr() COM_DISABLE_INTR() 207#define enable_intr() COM_ENABLE_INTR() 208#endif /* SMP */ 209 210#ifndef EXTRA_SIO | 197#endif 198 199#ifdef SMP 200#define disable_intr() COM_DISABLE_INTR() 201#define enable_intr() COM_ENABLE_INTR() 202#endif /* SMP */ 203 204#ifndef EXTRA_SIO |
211#if NPNP > 0 212#define EXTRA_SIO MAX_PNP_CARDS 213#else 214#define EXTRA_SIO 0 | 205#define EXTRA_SIO 4 /* XXX shouldn't need NSIO */ |
215#endif | 206#endif |
216#endif | |
217 218#define NSIOTOT (NSIO + EXTRA_SIO) 219 220#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ 221 222#define CALLOUT_MASK 0x80 223#define CONTROL_MASK 0x60 224#define CONTROL_INIT_STATE 0x20 --- 172 unchanged lines hidden (view full) --- 397 struct timeval dcd_timestamp; 398 struct pps_state pps; 399 400 u_long bytes_in; /* statistics */ 401 u_long bytes_out; 402 u_int delta_error_counts[CE_NTYPES]; 403 u_long error_counts[CE_NTYPES]; 404 | 207 208#define NSIOTOT (NSIO + EXTRA_SIO) 209 210#define LOTS_OF_EVENTS 64 /* helps separate urgent events from input */ 211 212#define CALLOUT_MASK 0x80 213#define CONTROL_MASK 0x60 214#define CONTROL_INIT_STATE 0x20 --- 172 unchanged lines hidden (view full) --- 387 struct timeval dcd_timestamp; 388 struct pps_state pps; 389 390 u_long bytes_in; /* statistics */ 391 u_long bytes_out; 392 u_int delta_error_counts[CE_NTYPES]; 393 u_long error_counts[CE_NTYPES]; 394 |
395 struct resource *irqres; 396 struct resource *ioportres; 397 |
|
405 /* 406 * Data area for output buffers. Someday we should build the output 407 * buffer queue without copying data. 408 */ 409#ifdef PC98 410 int obufsize; 411 u_char *obuf1; 412 u_char *obuf2; --- 88 unchanged lines hidden (view full) --- 501static int siocnunit; 502static Port_t siogdbiobase; 503static int siogdbunit = -1; 504static bool_t sio_registered; 505static int sio_timeout; 506static int sio_timeouts_until_log; 507static struct callout_handle sio_timeout_handle 508 = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle); | 398 /* 399 * Data area for output buffers. Someday we should build the output 400 * buffer queue without copying data. 401 */ 402#ifdef PC98 403 int obufsize; 404 u_char *obuf1; 405 u_char *obuf2; --- 88 unchanged lines hidden (view full) --- 494static int siocnunit; 495static Port_t siogdbiobase; 496static int siogdbunit = -1; 497static bool_t sio_registered; 498static int sio_timeout; 499static int sio_timeouts_until_log; 500static struct callout_handle sio_timeout_handle 501 = CALLOUT_HANDLE_INITIALIZER(&sio_timeout_handle); |
509#if 0 /* XXX */ 510static struct tty *sio_tty[NSIOTOT]; 511#else 512static struct tty sio_tty[NSIOTOT]; 513#endif 514static const int nsio_tty = NSIOTOT; | |
515 516#ifdef PC98 517struct siodev { 518 short if_type; 519 short irq; 520 Port_t cmd, sts, ctrl, mod; 521}; 522static int sysclock; --- 372 unchanged lines hidden (view full) --- 895 /* Make sure it isn't already probed. */ 896 if (com_addr(devi->isahd.id_unit)) 897 return(EBUSY); 898 899 /* It's already probed as serial by Upper */ 900 devi->isahd.id_flags |= COM_C_NOPROBE; 901 902 /* | 502 503#ifdef PC98 504struct siodev { 505 short if_type; 506 short irq; 507 Port_t cmd, sts, ctrl, mod; 508}; 509static int sysclock; --- 372 unchanged lines hidden (view full) --- 882 /* Make sure it isn't already probed. */ 883 if (com_addr(devi->isahd.id_unit)) 884 return(EBUSY); 885 886 /* It's already probed as serial by Upper */ 887 devi->isahd.id_flags |= COM_C_NOPROBE; 888 889 /* |
903 * Probe the device. If a value is returned, the 904 * device was found at the location. | 890 * attach the device. |
905 */ | 891 */ |
906 if (sioprobe(&devi->isahd) == 0) | 892 if (sioattach(devi->isahd.id_device) == 0) |
907 return(ENXIO); | 893 return(ENXIO); |
908 if (sioattach(&devi->isahd) == 0) 909 return(ENXIO); | |
910 911 return(0); 912} 913 914/* 915 * siounload - unload the driver and clear the table. 916 * XXX TODO: 917 * This is usually called when the card is ejected, but --- 48 unchanged lines hidden (view full) --- 966 com = com_addr(devi->isahd.id_unit); 967 if (com && !com->gone) 968 siointr1(com_addr(devi->isahd.id_unit)); 969 COM_UNLOCK(); 970 return(1); 971} 972#endif /* NCARD > 0 */ 973 | 894 895 return(0); 896} 897 898/* 899 * siounload - unload the driver and clear the table. 900 * XXX TODO: 901 * This is usually called when the card is ejected, but --- 48 unchanged lines hidden (view full) --- 950 com = com_addr(devi->isahd.id_unit); 951 if (com && !com->gone) 952 siointr1(com_addr(devi->isahd.id_unit)); 953 COM_UNLOCK(); 954 return(1); 955} 956#endif /* NCARD > 0 */ 957 |
974#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit)) 975#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit)) | 958#define SET_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) | (bit)) 959#define CLR_FLAG(dev, bit) device_set_flags(dev, device_get_flags(dev) & ~(bit)) |
976 | 960 |
961static struct isa_pnp_id sio_ids[] = { 962 {0x0005d041, "Standard PC COM port"}, /* PNP0500 */ 963 {0x0105d041, "16550A-compatible COM port"}, /* PNP0501 */ 964 {0x0205d041, "Multiport serial device (non-intelligent 16550)"}, /* PNP0502 */ 965 {0x1005d041, "Generic IRDA-compatible device"}, /* PNP0510 */ 966 {0x1105d041, "Generic IRDA-compatible device"}, /* PNP0511 */ 967 {0x31307256, "USR3031"}, /* USR3031 */ 968 {0} 969}; 970 |
|
977static int 978sioprobe(dev) 979 device_t dev; 980{ 981 static bool_t already_init; 982 bool_t failures[10]; 983 int fn; 984 device_t idev; 985 Port_t iobase; 986 intrmask_t irqmap[4]; 987 intrmask_t irqs; 988 u_char mcr_image; 989 int result; 990 device_t xdev; 991 u_int flags = device_get_flags(dev); | 971static int 972sioprobe(dev) 973 device_t dev; 974{ 975 static bool_t already_init; 976 bool_t failures[10]; 977 int fn; 978 device_t idev; 979 Port_t iobase; 980 intrmask_t irqmap[4]; 981 intrmask_t irqs; 982 u_char mcr_image; 983 int result; 984 device_t xdev; 985 u_int flags = device_get_flags(dev); |
986 int rid; 987 struct resource *port; |
|
992#ifdef PC98 993 int irqout=0; 994 int tmp; 995 int port_shift = 0; 996 struct siodev iod; 997 Port_t rsabase = NULL; 998#endif 999 | 988#ifdef PC98 989 int irqout=0; 990 int tmp; 991 int port_shift = 0; 992 struct siodev iod; 993 Port_t rsabase = NULL; 994#endif 995 |
996 /* Check isapnp ids */ 997 if (ISA_PNP_PROBE(device_get_parent(dev), dev, sio_ids) == ENXIO) 998 return (ENXIO); 999 1000 rid = 0; 1001#ifdef PC98 1002 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 1003 0, ~0, 1, RF_ACTIVE); /* XXX */ 1004#else 1005 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 1006 0, ~0, IO_COMSIZE, RF_ACTIVE); 1007#endif 1008 if (!port) 1009 return ENXIO; 1010 |
|
1000 if (!already_init) { 1001 /* 1002 * Turn off MCR_IENABLE for all likely serial ports. An unused 1003 * port with its MCR_IENABLE gate open will inhibit interrupts 1004 * from any used port that shares the interrupt vector. 1005 * XXX the gate enable is elsewhere for some multiports. 1006 */ 1007 device_t *devs; 1008 int count, i; 1009 1010 devclass_get_devices(sio_devclass, &devs, &count); 1011#ifdef PC98 1012 for (i = 0; i < count; i++) { 1013 xdev = devs[i]; | 1011 if (!already_init) { 1012 /* 1013 * Turn off MCR_IENABLE for all likely serial ports. An unused 1014 * port with its MCR_IENABLE gate open will inhibit interrupts 1015 * from any used port that shares the interrupt vector. 1016 * XXX the gate enable is elsewhere for some multiports. 1017 */ 1018 device_t *devs; 1019 int count, i; 1020 1021 devclass_get_devices(sio_devclass, &devs, &count); 1022#ifdef PC98 1023 for (i = 0; i < count; i++) { 1024 xdev = devs[i]; |
1014 tmp = (flags >> 24) & 0xff; 1015 if (IS_8251(tmp)) 1016 outb((isa_get_port(xdev) & 0xff00) | PC98SIO_cmd_port(tmp & 0x0f), 0xf2); 1017 else 1018 if (tmp == COM_IF_RSA98III) { 1019 rsabase = isa_get_port(xdev) & 0xfff0; 1020 outb(isa_get_port(xdev) + 8 + (com_mcr << if_16550a_type[tmp & 0x0f].port_shift), 0); 1021 } else 1022 outb(isa_get_port(xdev) + (com_mcr << if_16550a_type[tmp & 0x0f].port_shift), 0); | 1025 if (device_is_enabled(xdev)) { 1026 tmp = (flags >> 24) & 0xff; 1027 if (IS_8251(tmp)) 1028 outb((isa_get_port(xdev) & 0xff00) | PC98SIO_cmd_port(tmp & 0x0f), 0xf2); 1029 else 1030 if (tmp == COM_IF_RSA98III) { 1031 rsabase = isa_get_port(xdev) & 0xfff0; 1032 outb(isa_get_port(xdev) + 8 + (com_mcr << if_16550a_type[tmp & 0x0f].port_shift), 0); 1033 } else 1034 outb(isa_get_port(xdev) + (com_mcr << if_16550a_type[tmp & 0x0f].port_shift), 0); 1035 } |
1023 } 1024#else 1025 for (i = 0; i < count; i++) { 1026 xdev = devs[i]; | 1036 } 1037#else 1038 for (i = 0; i < count; i++) { 1039 xdev = devs[i]; |
1027 outb(isa_get_port(xdev) + com_mcr, 0); | 1040 if (device_is_enabled(xdev)) 1041 outb(isa_get_port(xdev) + com_mcr, 0); |
1028 } 1029#endif 1030 free(devs, M_TEMP); 1031 already_init = TRUE; 1032 } 1033 1034 if (COM_LLCONSOLE(flags)) { 1035 printf("sio%d: reserved for low-level i/o\n", --- 40 unchanged lines hidden (view full) --- 1076 * B98_01 doesn't activate TxEMP interrupt line 1077 * when being reset, so we can't check irq pending. 1078 */ 1079 result = 0; 1080 } 1081 if (epson_machine_id==0x20) { /* XXX */ 1082 result = 0; 1083 } | 1042 } 1043#endif 1044 free(devs, M_TEMP); 1045 already_init = TRUE; 1046 } 1047 1048 if (COM_LLCONSOLE(flags)) { 1049 printf("sio%d: reserved for low-level i/o\n", --- 40 unchanged lines hidden (view full) --- 1090 * B98_01 doesn't activate TxEMP interrupt line 1091 * when being reset, so we can't check irq pending. 1092 */ 1093 result = 0; 1094 } 1095 if (epson_machine_id==0x20) { /* XXX */ 1096 result = 0; 1097 } |
1084 isa_set_portsize(dev, 4); | 1098 bus_release_resource(dev, SYS_RES_IOPORT, rid, port); |
1085 return result; 1086 } 1087#endif /* PC98 */ 1088 /* 1089 * If the device is on a multiport card and has an AST/4 1090 * compatible interrupt control register, initialize this 1091 * register and prepare to leave MCR_IENABLE clear in the mcr. 1092 * Otherwise, prepare to set MCR_IENABLE in the mcr. --- 19 unchanged lines hidden (view full) --- 1112 } 1113#endif /* PC98 */ 1114#ifdef COM_MULTIPORT 1115 if (COM_ISMULTIPORT(flags)) { 1116 idev = devclass_get_device(sio_devclass, COM_MPMASTER(flags)); 1117 if (idev == NULL) { 1118 printf("sio%d: master device %d not configured\n", 1119 device_get_unit(dev), COM_MPMASTER(flags)); | 1099 return result; 1100 } 1101#endif /* PC98 */ 1102 /* 1103 * If the device is on a multiport card and has an AST/4 1104 * compatible interrupt control register, initialize this 1105 * register and prepare to leave MCR_IENABLE clear in the mcr. 1106 * Otherwise, prepare to set MCR_IENABLE in the mcr. --- 19 unchanged lines hidden (view full) --- 1126 } 1127#endif /* PC98 */ 1128#ifdef COM_MULTIPORT 1129 if (COM_ISMULTIPORT(flags)) { 1130 idev = devclass_get_device(sio_devclass, COM_MPMASTER(flags)); 1131 if (idev == NULL) { 1132 printf("sio%d: master device %d not configured\n", 1133 device_get_unit(dev), COM_MPMASTER(flags)); |
1120 isa_set_irq(dev, 0); | |
1121 idev = dev; 1122 } 1123#ifndef PC98 1124 if (!COM_NOTAST4(flags)) { 1125 outb(isa_get_port(idev) + com_scr, 1126 isa_get_irq(idev) >= 0 ? 0x80 : 0); 1127 mcr_image = 0; 1128 } --- 17 unchanged lines hidden (view full) --- 1146 device_get_unit(dev)); 1147 return (0); 1148 } 1149 outb((isa_get_port(dev) & 0x00ff) | tmp, irqout); 1150 } 1151 port_shift = if_16550a_type[iod.if_type & 0x0f].port_shift; 1152#endif 1153 bzero(failures, sizeof failures); | 1134 idev = dev; 1135 } 1136#ifndef PC98 1137 if (!COM_NOTAST4(flags)) { 1138 outb(isa_get_port(idev) + com_scr, 1139 isa_get_irq(idev) >= 0 ? 0x80 : 0); 1140 mcr_image = 0; 1141 } --- 17 unchanged lines hidden (view full) --- 1159 device_get_unit(dev)); 1160 return (0); 1161 } 1162 outb((isa_get_port(dev) & 0x00ff) | tmp, irqout); 1163 } 1164 port_shift = if_16550a_type[iod.if_type & 0x0f].port_shift; 1165#endif 1166 bzero(failures, sizeof failures); |
1154 iobase = isa_get_port(dev); | 1167 iobase = rman_get_start(port); |
1155#ifdef PC98 1156 if (iod.if_type == COM_IF_RSA98III) 1157 iobase += 8; 1158#endif 1159 1160 /* 1161 * We don't want to get actual interrupts, just masked ones. 1162 * Interrupts from this line should already be masked in the ICU, --- 97 unchanged lines hidden (view full) --- 1260 */ 1261/* EXTRA DELAY? */ 1262#ifdef PC98 1263 outb(iobase + (com_mcr << port_shift), mcr_image); 1264#else 1265 outb(iobase + com_mcr, mcr_image); 1266#endif /* PC98 */ 1267 | 1168#ifdef PC98 1169 if (iod.if_type == COM_IF_RSA98III) 1170 iobase += 8; 1171#endif 1172 1173 /* 1174 * We don't want to get actual interrupts, just masked ones. 1175 * Interrupts from this line should already be masked in the ICU, --- 97 unchanged lines hidden (view full) --- 1273 */ 1274/* EXTRA DELAY? */ 1275#ifdef PC98 1276 outb(iobase + (com_mcr << port_shift), mcr_image); 1277#else 1278 outb(iobase + com_mcr, mcr_image); 1279#endif /* PC98 */ 1280 |
1268 /* | 1281 /* |
1269 * It's a definitly Serial PCMCIA(16550A), but still be required 1270 * for IIR_TXRDY implementation ( Palido 321s, DC-1S... ) 1271 */ 1272 if ( COM_NOPROBE(flags) ) { 1273 /* Reading IIR register twice */ 1274 for ( fn = 0; fn < 2; fn ++ ) { 1275 DELAY(10000); 1276#ifdef PC98 1277 failures[6] = inb(iobase + (com_iir << port_shift)); 1278#else 1279 failures[6] = inb(iobase + com_iir); 1280#endif 1281 } 1282 /* Check IIR_TXRDY clear ? */ | 1282 * It's a definitly Serial PCMCIA(16550A), but still be required 1283 * for IIR_TXRDY implementation ( Palido 321s, DC-1S... ) 1284 */ 1285 if ( COM_NOPROBE(flags) ) { 1286 /* Reading IIR register twice */ 1287 for ( fn = 0; fn < 2; fn ++ ) { 1288 DELAY(10000); 1289#ifdef PC98 1290 failures[6] = inb(iobase + (com_iir << port_shift)); 1291#else 1292 failures[6] = inb(iobase + com_iir); 1293#endif 1294 } 1295 /* Check IIR_TXRDY clear ? */ |
1283#ifdef PC98 1284 isa_set_portsize(dev, 1285 if_16550a_type[iod.if_type & 0x0f].io_size); 1286#else 1287 isa_set_portsize(dev, IO_COMSIZE); 1288#endif | |
1289 result = 0; 1290 if ( failures[6] & IIR_TXRDY ) { 1291 /* Nop, Double check with clearing IER */ 1292#ifdef PC98 1293 outb(iobase + (com_ier << port_shift), 0); 1294 if (inb(iobase + 1295 (com_iir << port_shift)) & IIR_NOPEND) { 1296#else 1297 outb(iobase + com_ier, 0); 1298 if ( inb(iobase + com_iir) & IIR_NOPEND ) { 1299#endif 1300 /* Ok. we're familia this gang */ 1301 SET_FLAG(dev, COM_C_IIR_TXRDYBUG); /* Set IIR_TXRDYBUG */ 1302 } else { | 1296 result = 0; 1297 if ( failures[6] & IIR_TXRDY ) { 1298 /* Nop, Double check with clearing IER */ 1299#ifdef PC98 1300 outb(iobase + (com_ier << port_shift), 0); 1301 if (inb(iobase + 1302 (com_iir << port_shift)) & IIR_NOPEND) { 1303#else 1304 outb(iobase + com_ier, 0); 1305 if ( inb(iobase + com_iir) & IIR_NOPEND ) { 1306#endif 1307 /* Ok. we're familia this gang */ 1308 SET_FLAG(dev, COM_C_IIR_TXRDYBUG); /* Set IIR_TXRDYBUG */ 1309 } else { |
1303 /* Unknow, Just omit this chip.. XXX*/ | 1310 /* Unknown, Just omit this chip.. XXX */ |
1304 result = ENXIO; 1305 } 1306 } else { 1307 /* OK. this is well-known guys */ 1308 CLR_FLAG(dev, COM_C_IIR_TXRDYBUG); /*Clear IIR_TXRDYBUG*/ 1309 } 1310#ifdef PC98 1311 outb(iobase + (com_cfcr << port_shift), CFCR_8BITS); 1312#else 1313 outb(iobase + com_cfcr, CFCR_8BITS); 1314#endif 1315 enable_intr(); | 1311 result = ENXIO; 1312 } 1313 } else { 1314 /* OK. this is well-known guys */ 1315 CLR_FLAG(dev, COM_C_IIR_TXRDYBUG); /*Clear IIR_TXRDYBUG*/ 1316 } 1317#ifdef PC98 1318 outb(iobase + (com_cfcr << port_shift), CFCR_8BITS); 1319#else 1320 outb(iobase + com_cfcr, CFCR_8BITS); 1321#endif 1322 enable_intr(); |
1323 bus_release_resource(dev, SYS_RES_IOPORT, rid, port); |
|
1316 return (iobase == siocniobase ? 0 : result); 1317 } 1318 1319 /* 1320 * Check that 1321 * o the CFCR, IER and MCR in UART hold the values written to them 1322 * (the values happen to be all distinct - this is good for 1323 * avoiding false positive tests from bus echoes). --- 71 unchanged lines hidden (view full) --- 1395 printf( 1396 "sio%d: configured irq %d not in bitmap of probed irqs %#x\n", 1397 device_get_unit(dev), isa_get_irq(idev), irqs); 1398 if (bootverbose) 1399 printf("sio%d: irq maps: %#x %#x %#x %#x\n", 1400 device_get_unit(dev), 1401 irqmap[0], irqmap[1], irqmap[2], irqmap[3]); 1402 | 1324 return (iobase == siocniobase ? 0 : result); 1325 } 1326 1327 /* 1328 * Check that 1329 * o the CFCR, IER and MCR in UART hold the values written to them 1330 * (the values happen to be all distinct - this is good for 1331 * avoiding false positive tests from bus echoes). --- 71 unchanged lines hidden (view full) --- 1403 printf( 1404 "sio%d: configured irq %d not in bitmap of probed irqs %#x\n", 1405 device_get_unit(dev), isa_get_irq(idev), irqs); 1406 if (bootverbose) 1407 printf("sio%d: irq maps: %#x %#x %#x %#x\n", 1408 device_get_unit(dev), 1409 irqmap[0], irqmap[1], irqmap[2], irqmap[3]); 1410 |
1403#ifdef PC98 1404 isa_set_portsize(dev, if_16550a_type[iod.if_type & 0x0f].io_size); 1405#else 1406 isa_set_portsize(dev, IO_COMSIZE); 1407#endif | |
1408 result = 0; 1409 for (fn = 0; fn < sizeof failures; ++fn) 1410 if (failures[fn]) { 1411#ifdef PC98 1412 outb(iobase + (com_mcr << port_shift), 0); 1413#else 1414 outb(iobase + com_mcr, 0); 1415#endif 1416 result = ENXIO; 1417 if (bootverbose) { 1418 printf("sio%d: probe failed test(s):", 1419 device_get_unit(dev)); 1420 for (fn = 0; fn < sizeof failures; ++fn) 1421 if (failures[fn]) 1422 printf(" %d", fn); 1423 printf("\n"); 1424 } 1425 break; 1426 } | 1411 result = 0; 1412 for (fn = 0; fn < sizeof failures; ++fn) 1413 if (failures[fn]) { 1414#ifdef PC98 1415 outb(iobase + (com_mcr << port_shift), 0); 1416#else 1417 outb(iobase + com_mcr, 0); 1418#endif 1419 result = ENXIO; 1420 if (bootverbose) { 1421 printf("sio%d: probe failed test(s):", 1422 device_get_unit(dev)); 1423 for (fn = 0; fn < sizeof failures; ++fn) 1424 if (failures[fn]) 1425 printf(" %d", fn); 1426 printf("\n"); 1427 } 1428 break; 1429 } |
1430 bus_release_resource(dev, SYS_RES_IOPORT, rid, port); |
|
1427 return (iobase == siocniobase ? 0 : result); 1428} 1429 1430#ifdef COM_ESP 1431static int 1432espattach(com, esp_port) 1433 struct com_s *com; 1434 Port_t esp_port; --- 78 unchanged lines hidden (view full) --- 1513{ 1514 struct com_s *com; 1515#ifdef COM_ESP 1516 Port_t *espp; 1517#endif 1518 Port_t iobase; 1519 int unit; 1520 void *ih; | 1431 return (iobase == siocniobase ? 0 : result); 1432} 1433 1434#ifdef COM_ESP 1435static int 1436espattach(com, esp_port) 1437 struct com_s *com; 1438 Port_t esp_port; --- 78 unchanged lines hidden (view full) --- 1517{ 1518 struct com_s *com; 1519#ifdef COM_ESP 1520 Port_t *espp; 1521#endif 1522 Port_t iobase; 1523 int unit; 1524 void *ih; |
1521 struct resource *res; 1522 int zero = 0; | |
1523 u_int flags = device_get_flags(dev); | 1525 u_int flags = device_get_flags(dev); |
1526 int rid; 1527 struct resource *port; |
|
1524#ifdef PC98 1525 int port_shift = 0; 1526 u_char *obuf; 1527 u_long obufsize; 1528#endif 1529 | 1528#ifdef PC98 1529 int port_shift = 0; 1530 u_char *obuf; 1531 u_long obufsize; 1532#endif 1533 |
1530 iobase = isa_get_port(dev); | 1534 rid = 0; |
1531#ifdef PC98 | 1535#ifdef PC98 |
1536 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 1537 0, ~0, 1, RF_ACTIVE); /* XXX */ 1538#else 1539 port = bus_alloc_resource(dev, SYS_RES_IOPORT, &rid, 1540 0, ~0, IO_COMSIZE, RF_ACTIVE); 1541#endif 1542 if (!port) 1543 return ENXIO; 1544 1545 iobase = rman_get_start(port); 1546#ifdef PC98 |
|
1532 if (((flags >> 24) & 0xff) == COM_IF_RSA98III) 1533 iobase += 8; 1534#endif 1535 unit = device_get_unit(dev); 1536 com = device_get_softc(dev); 1537#ifdef PC98 1538 obufsize = 256; 1539 if (((flags >> 24) & 0xff) == COM_IF_RSA98III) --- 17 unchanged lines hidden (view full) --- 1557 */ 1558 bzero(com, sizeof *com); 1559#ifdef PC98 1560 com->obufsize = obufsize; 1561 com->obuf1 = obuf; 1562 com->obuf2 = obuf + obufsize; 1563#endif 1564 com->unit = unit; | 1547 if (((flags >> 24) & 0xff) == COM_IF_RSA98III) 1548 iobase += 8; 1549#endif 1550 unit = device_get_unit(dev); 1551 com = device_get_softc(dev); 1552#ifdef PC98 1553 obufsize = 256; 1554 if (((flags >> 24) & 0xff) == COM_IF_RSA98III) --- 17 unchanged lines hidden (view full) --- 1572 */ 1573 bzero(com, sizeof *com); 1574#ifdef PC98 1575 com->obufsize = obufsize; 1576 com->obuf1 = obuf; 1577 com->obuf2 = obuf + obufsize; 1578#endif 1579 com->unit = unit; |
1580 com->ioportres = port; |
|
1565 com->cfcr_image = CFCR_8BITS; 1566 com->dtr_wait = 3 * hz; 1567 com->loses_outints = COM_LOSESOUTINTS(flags) != 0; 1568 com->no_irq = isa_get_irq(dev) < 0; 1569 com->tx_fifo_size = 1; 1570 com->obufs[0].l_head = com->obuf1; 1571 com->obufs[1].l_head = com->obuf2; 1572 --- 243 unchanged lines hidden (view full) --- 1816 if ( COM_IIR_TXRDYBUG(flags) ) 1817 printf(" with a bogus IIR_TXRDY register"); 1818 printf("\n"); 1819 1820 if (!sio_registered) { 1821 register_swi(SWI_TTY, siopoll); 1822 sio_registered = TRUE; 1823 } | 1581 com->cfcr_image = CFCR_8BITS; 1582 com->dtr_wait = 3 * hz; 1583 com->loses_outints = COM_LOSESOUTINTS(flags) != 0; 1584 com->no_irq = isa_get_irq(dev) < 0; 1585 com->tx_fifo_size = 1; 1586 com->obufs[0].l_head = com->obuf1; 1587 com->obufs[1].l_head = com->obuf2; 1588 --- 243 unchanged lines hidden (view full) --- 1832 if ( COM_IIR_TXRDYBUG(flags) ) 1833 printf(" with a bogus IIR_TXRDY register"); 1834 printf("\n"); 1835 1836 if (!sio_registered) { 1837 register_swi(SWI_TTY, siopoll); 1838 sio_registered = TRUE; 1839 } |
1824 make_dev(&sio_cdevsw, unit, 1825 UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit); 1826 make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE, 1827 UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit); 1828 make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE, 1829 UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit); 1830 make_dev(&sio_cdevsw, unit | CALLOUT_MASK, 1831 UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit); 1832 make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE, 1833 UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit); 1834 make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE, 1835 UID_UUCP, GID_DIALER, 0660, "cuala%r", unit); 1836 com->flags = device_get_flags(dev); /* Heritate id_flags for later */ | 1840 make_dev(&sio_cdevsw, unit, 1841 UID_ROOT, GID_WHEEL, 0600, "ttyd%r", unit); 1842 make_dev(&sio_cdevsw, unit | CONTROL_INIT_STATE, 1843 UID_ROOT, GID_WHEEL, 0600, "ttyid%r", unit); 1844 make_dev(&sio_cdevsw, unit | CONTROL_LOCK_STATE, 1845 UID_ROOT, GID_WHEEL, 0600, "ttyld%r", unit); 1846 make_dev(&sio_cdevsw, unit | CALLOUT_MASK, 1847 UID_UUCP, GID_DIALER, 0660, "cuaa%r", unit); 1848 make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_INIT_STATE, 1849 UID_UUCP, GID_DIALER, 0660, "cuaia%r", unit); 1850 make_dev(&sio_cdevsw, unit | CALLOUT_MASK | CONTROL_LOCK_STATE, 1851 UID_UUCP, GID_DIALER, 0660, "cuala%r", unit); 1852 com->flags = flags; |
1837 com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR; 1838 pps_init(&com->pps); 1839 | 1853 com->pps.ppscap = PPS_CAPTUREASSERT | PPS_CAPTURECLEAR; 1854 pps_init(&com->pps); 1855 |
1840 res = bus_alloc_resource(dev, SYS_RES_IRQ, &zero, 0ul, ~0ul, 1, 1841 RF_SHAREABLE | RF_ACTIVE); 1842 BUS_SETUP_INTR(device_get_parent(dev), dev, res, | 1856 rid = 0; 1857 com->irqres = bus_alloc_resource(dev, SYS_RES_IRQ, &rid, 0ul, ~0ul, 1, 1858 RF_SHAREABLE | RF_ACTIVE); 1859 BUS_SETUP_INTR(device_get_parent(dev), dev, com->irqres, |
1843 INTR_TYPE_TTY | INTR_TYPE_FAST, 1844 siointr, com, &ih); 1845 1846 return (0); 1847} 1848 1849static int 1850sioopen(dev, flag, mode, p) --- 16 unchanged lines hidden (view full) --- 1867 mynor = minor(dev); 1868 unit = MINOR_TO_UNIT(mynor); 1869 if ((u_int) unit >= NSIOTOT || (com = com_addr(unit)) == NULL) 1870 return (ENXIO); 1871 if (com->gone) 1872 return (ENXIO); 1873 if (mynor & CONTROL_MASK) 1874 return (0); | 1860 INTR_TYPE_TTY | INTR_TYPE_FAST, 1861 siointr, com, &ih); 1862 1863 return (0); 1864} 1865 1866static int 1867sioopen(dev, flag, mode, p) --- 16 unchanged lines hidden (view full) --- 1884 mynor = minor(dev); 1885 unit = MINOR_TO_UNIT(mynor); 1886 if ((u_int) unit >= NSIOTOT || (com = com_addr(unit)) == NULL) 1887 return (ENXIO); 1888 if (com->gone) 1889 return (ENXIO); 1890 if (mynor & CONTROL_MASK) 1891 return (0); |
1875#if 0 /* XXX */ 1876 tp = com->tp = sio_tty[unit] = ttymalloc(sio_tty[unit]); 1877#else 1878 tp = com->tp = &sio_tty[unit]; 1879#endif | 1892 tp = dev->si_tty = com->tp = ttymalloc(com->tp); |
1880 s = spltty(); 1881 1882#ifdef PC98 1883 if (!IS_8251(com->pc98_if_type)) 1884 port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift; 1885#endif 1886 /* 1887 * We jump to this label after all non-interrupted sleeps to pick --- 648 unchanged lines hidden (view full) --- 2536#endif /* PC98 */ 2537 if (com->pps.ppsparam.mode & PPS_CAPTUREBOTH) { 2538 modem_status = inb(com->modem_status_port); 2539 if ((modem_status ^ com->last_modem_status) & MSR_DCD) { 2540 tc = timecounter; 2541 count = tc->tc_get_timecount(tc); 2542 pps_event(&com->pps, tc, count, 2543 (modem_status & MSR_DCD) ? | 1893 s = spltty(); 1894 1895#ifdef PC98 1896 if (!IS_8251(com->pc98_if_type)) 1897 port_shift = if_16550a_type[com->pc98_if_type & 0x0f].port_shift; 1898#endif 1899 /* 1900 * We jump to this label after all non-interrupted sleeps to pick --- 648 unchanged lines hidden (view full) --- 2549#endif /* PC98 */ 2550 if (com->pps.ppsparam.mode & PPS_CAPTUREBOTH) { 2551 modem_status = inb(com->modem_status_port); 2552 if ((modem_status ^ com->last_modem_status) & MSR_DCD) { 2553 tc = timecounter; 2554 count = tc->tc_get_timecount(tc); 2555 pps_event(&com->pps, tc, count, 2556 (modem_status & MSR_DCD) ? |
2544 PPS_CAPTURECLEAR : PPS_CAPTUREASSERT); | 2557 PPS_CAPTUREASSERT : PPS_CAPTURECLEAR); |
2545 } 2546 } 2547 line_status = inb(com->line_status_port); 2548#ifdef PC98 2549 } 2550 if (com->pc98_if_type == COM_IF_RSA98III) 2551 rsa_buf_status = inb(com->rsabase + rsa_srr); 2552#endif /* PC98 */ --- 602 unchanged lines hidden (view full) --- 3155#else 3156 /* do historical conversions */ 3157 if (t->c_ispeed == 0) 3158 t->c_ispeed = t->c_ospeed; 3159 3160 /* check requested parameters */ 3161 divisor = ttspeedtab(t->c_ospeed, comspeedtab); 3162#endif | 2558 } 2559 } 2560 line_status = inb(com->line_status_port); 2561#ifdef PC98 2562 } 2563 if (com->pc98_if_type == COM_IF_RSA98III) 2564 rsa_buf_status = inb(com->rsabase + rsa_srr); 2565#endif /* PC98 */ --- 602 unchanged lines hidden (view full) --- 3168#else 3169 /* do historical conversions */ 3170 if (t->c_ispeed == 0) 3171 t->c_ispeed = t->c_ospeed; 3172 3173 /* check requested parameters */ 3174 divisor = ttspeedtab(t->c_ospeed, comspeedtab); 3175#endif |
3163 if (divisor < 0 || divisor > 0 && t->c_ispeed != t->c_ospeed) | 3176 if (divisor < 0 || (divisor > 0 && t->c_ispeed != t->c_ospeed)) |
3164 return (EINVAL); 3165 3166 /* parameters are OK, convert them to the com struct and the device */ 3167#ifndef PC98 3168 unit = DEV_TO_UNIT(tp->t_dev); 3169 com = com_addr(unit); 3170 iobase = com->iobase; 3171#endif --- 501 unchanged lines hidden (view full) --- 3673 int unit; 3674 3675 mynor = minor(dev); 3676 if (mynor & CONTROL_MASK) 3677 return (NULL); 3678 unit = MINOR_TO_UNIT(mynor); 3679 if ((u_int) unit >= NSIOTOT) 3680 return (NULL); | 3177 return (EINVAL); 3178 3179 /* parameters are OK, convert them to the com struct and the device */ 3180#ifndef PC98 3181 unit = DEV_TO_UNIT(tp->t_dev); 3182 com = com_addr(unit); 3183 iobase = com->iobase; 3184#endif --- 501 unchanged lines hidden (view full) --- 3686 int unit; 3687 3688 mynor = minor(dev); 3689 if (mynor & CONTROL_MASK) 3690 return (NULL); 3691 unit = MINOR_TO_UNIT(mynor); 3692 if ((u_int) unit >= NSIOTOT) 3693 return (NULL); |
3681 return (&sio_tty[unit]); | 3694 return (dev->si_tty); |
3682} 3683 3684static int 3685commctl(com, bits, how) 3686 struct com_s *com; 3687 int bits; 3688 int how; 3689{ --- 209 unchanged lines hidden (view full) --- 3899 u_char mcr; 3900}; 3901 3902static speed_t siocngetspeed __P((Port_t, struct speedtab *)); 3903static void siocnclose __P((struct siocnstate *sp, Port_t iobase)); 3904static void siocnopen __P((struct siocnstate *sp, Port_t iobase, int speed)); 3905static void siocntxwait __P((Port_t iobase)); 3906 | 3695} 3696 3697static int 3698commctl(com, bits, how) 3699 struct com_s *com; 3700 int bits; 3701 int how; 3702{ --- 209 unchanged lines hidden (view full) --- 3912 u_char mcr; 3913}; 3914 3915static speed_t siocngetspeed __P((Port_t, struct speedtab *)); 3916static void siocnclose __P((struct siocnstate *sp, Port_t iobase)); 3917static void siocnopen __P((struct siocnstate *sp, Port_t iobase, int speed)); 3918static void siocntxwait __P((Port_t iobase)); 3919 |
3907#ifdef __i386__ | |
3908static cn_probe_t siocnprobe; 3909static cn_init_t siocninit; 3910static cn_checkc_t siocncheckc; 3911static cn_getc_t siocngetc; 3912static cn_putc_t siocnputc; 3913 | 3920static cn_probe_t siocnprobe; 3921static cn_init_t siocninit; 3922static cn_checkc_t siocncheckc; 3923static cn_getc_t siocngetc; 3924static cn_putc_t siocnputc; 3925 |
3926#ifdef __i386__ |
|
3914CONS_DRIVER(sio, siocnprobe, siocninit, NULL, siocngetc, siocncheckc, siocnputc); 3915 | 3927CONS_DRIVER(sio, siocnprobe, siocninit, NULL, siocngetc, siocncheckc, siocnputc); 3928 |
3929#endif 3930 |
|
3916/* To get the GDB related variables */ 3917#if DDB > 0 3918#include <ddb/ddb.h> 3919#endif | 3931/* To get the GDB related variables */ 3932#if DDB > 0 3933#include <ddb/ddb.h> 3934#endif |
3920#endif | |
3921 3922static void 3923siocntxwait(iobase) 3924 Port_t iobase; 3925{ 3926 int timo; 3927 3928 /* --- 105 unchanged lines hidden (view full) --- 4034 outb(iobase + com_cfcr, sp->cfcr); 4035 /* 4036 * XXX damp oscillations of MCR_DTR and MCR_RTS by not restoring them. 4037 */ 4038 outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS); 4039 outb(iobase + com_ier, sp->ier); 4040} 4041 | 3935 3936static void 3937siocntxwait(iobase) 3938 Port_t iobase; 3939{ 3940 int timo; 3941 3942 /* --- 105 unchanged lines hidden (view full) --- 4048 outb(iobase + com_cfcr, sp->cfcr); 4049 /* 4050 * XXX damp oscillations of MCR_DTR and MCR_RTS by not restoring them. 4051 */ 4052 outb(iobase + com_mcr, sp->mcr | MCR_DTR | MCR_RTS); 4053 outb(iobase + com_ier, sp->ier); 4054} 4055 |
4042#ifdef __i386__ 4043static 4044#endif 4045void | 4056static void |
4046siocnprobe(cp) 4047 struct consdev *cp; 4048{ 4049 speed_t boot_speed; 4050 u_char cfcr; 4051 int s, unit; 4052 struct siocnstate sp; 4053 --- 10 unchanged lines hidden (view full) --- 4064 * yet because our low-level routines don't take a device arg. 4065 * We trust the user to set the console flags properly so that we 4066 * don't need to probe. 4067 */ 4068 cp->cn_pri = CN_DEAD; 4069 4070 for (unit = 0; unit < 16; unit++) { /* XXX need to know how many */ 4071 int flags; | 4057siocnprobe(cp) 4058 struct consdev *cp; 4059{ 4060 speed_t boot_speed; 4061 u_char cfcr; 4062 int s, unit; 4063 struct siocnstate sp; 4064 --- 10 unchanged lines hidden (view full) --- 4075 * yet because our low-level routines don't take a device arg. 4076 * We trust the user to set the console flags properly so that we 4077 * don't need to probe. 4078 */ 4079 cp->cn_pri = CN_DEAD; 4080 4081 for (unit = 0; unit < 16; unit++) { /* XXX need to know how many */ 4082 int flags; |
4083 int disabled; 4084 if (resource_int_value("sio", unit, "disabled", &disabled) == 0) { 4085 if (disabled) 4086 continue; 4087 } |
|
4072 if (resource_int_value("sio", unit, "flags", &flags)) 4073 continue; 4074 if (COM_CONSOLE(flags) || COM_DEBUGGER(flags)) { 4075 int port; 4076 Port_t iobase; 4077 4078 if (resource_int_value("sio", unit, "port", &port)) 4079 continue; --- 25 unchanged lines hidden (view full) --- 4105 siocnopen(&sp, iobase, comdefaultrate); 4106 4107 splx(s); 4108 if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) { 4109 cp->cn_dev = makedev(CDEV_MAJOR, unit); 4110 cp->cn_pri = COM_FORCECONSOLE(flags) 4111 || boothowto & RB_SERIAL 4112 ? CN_REMOTE : CN_NORMAL; | 4088 if (resource_int_value("sio", unit, "flags", &flags)) 4089 continue; 4090 if (COM_CONSOLE(flags) || COM_DEBUGGER(flags)) { 4091 int port; 4092 Port_t iobase; 4093 4094 if (resource_int_value("sio", unit, "port", &port)) 4095 continue; --- 25 unchanged lines hidden (view full) --- 4121 siocnopen(&sp, iobase, comdefaultrate); 4122 4123 splx(s); 4124 if (COM_CONSOLE(flags) && !COM_LLCONSOLE(flags)) { 4125 cp->cn_dev = makedev(CDEV_MAJOR, unit); 4126 cp->cn_pri = COM_FORCECONSOLE(flags) 4127 || boothowto & RB_SERIAL 4128 ? CN_REMOTE : CN_NORMAL; |
4113 printf("sio%d: system console\n", unit); | |
4114 siocniobase = iobase; 4115 siocnunit = unit; 4116 } | 4129 siocniobase = iobase; 4130 siocnunit = unit; 4131 } |
4117 if (COM_DEBUGGER(flags) && !COM_LLCONSOLE(flags)) { | 4132 if (COM_DEBUGGER(flags)) { |
4118 printf("sio%d: gdb debugging port\n", unit); 4119 siogdbiobase = iobase; 4120 siogdbunit = unit; | 4133 printf("sio%d: gdb debugging port\n", unit); 4134 siogdbiobase = iobase; 4135 siogdbunit = unit; |
4121#ifdef __i386__ | |
4122#if DDB > 0 4123 gdbdev = makedev(CDEV_MAJOR, unit); 4124 gdb_getc = siocngetc; 4125 gdb_putc = siocnputc; 4126#endif | 4136#if DDB > 0 4137 gdbdev = makedev(CDEV_MAJOR, unit); 4138 gdb_getc = siocngetc; 4139 gdb_putc = siocnputc; 4140#endif |
4127#endif | |
4128 } 4129 } 4130 } 4131#ifdef __i386__ 4132#if DDB > 0 4133 /* 4134 * XXX Ugly Compatability. 4135 * If no gdb port has been specified, set it to be the console --- 11 unchanged lines hidden (view full) --- 4147 gdb_putc = siocnputc; 4148 } 4149#endif 4150#endif 4151} 4152 4153#ifdef __alpha__ 4154 | 4141 } 4142 } 4143 } 4144#ifdef __i386__ 4145#if DDB > 0 4146 /* 4147 * XXX Ugly Compatability. 4148 * If no gdb port has been specified, set it to be the console --- 11 unchanged lines hidden (view full) --- 4160 gdb_putc = siocnputc; 4161 } 4162#endif 4163#endif 4164} 4165 4166#ifdef __alpha__ 4167 |
4155struct consdev siocons = { 4156 NULL, NULL, siocngetc, siocncheckc, siocnputc, 4157 NULL, 0, CN_NORMAL, 4158}; | 4168CONS_DRIVER(sio, NULL, NULL, NULL, siocngetc, siocncheckc, siocnputc); |
4159 | 4169 |
4160extern struct consdev *cn_tab; 4161 | |
4162int 4163siocnattach(port, speed) 4164 int port; 4165 int speed; 4166{ 4167 int s; 4168 u_char cfcr; 4169 struct siocnstate sp; 4170 4171 siocniobase = port; 4172 comdefaultrate = speed; | 4170int 4171siocnattach(port, speed) 4172 int port; 4173 int speed; 4174{ 4175 int s; 4176 u_char cfcr; 4177 struct siocnstate sp; 4178 4179 siocniobase = port; 4180 comdefaultrate = speed; |
4181 sio_consdev.cn_pri = CN_NORMAL; 4182 sio_consdev.cn_dev = makedev(CDEV_MAJOR, 0); |
|
4173 4174 s = spltty(); 4175 4176 /* 4177 * Initialize the divisor latch. We can't rely on 4178 * siocnopen() to do this the first time, since it 4179 * avoids writing to the latch if the latch appears 4180 * to have the correct value. Also, if we didn't --- 7 unchanged lines hidden (view full) --- 4188 COMBRD(comdefaultrate) & 0xff); 4189 outb(siocniobase + com_dlbh, 4190 (u_int) COMBRD(comdefaultrate) >> 8); 4191 outb(siocniobase + com_cfcr, cfcr); 4192 4193 siocnopen(&sp, siocniobase, comdefaultrate); 4194 splx(s); 4195 | 4183 4184 s = spltty(); 4185 4186 /* 4187 * Initialize the divisor latch. We can't rely on 4188 * siocnopen() to do this the first time, since it 4189 * avoids writing to the latch if the latch appears 4190 * to have the correct value. Also, if we didn't --- 7 unchanged lines hidden (view full) --- 4198 COMBRD(comdefaultrate) & 0xff); 4199 outb(siocniobase + com_dlbh, 4200 (u_int) COMBRD(comdefaultrate) >> 8); 4201 outb(siocniobase + com_cfcr, cfcr); 4202 4203 siocnopen(&sp, siocniobase, comdefaultrate); 4204 splx(s); 4205 |
4196 siocons.cn_dev = makedev(CDEV_MAJOR, 0); 4197 cn_tab = &siocons; | 4206 cn_tab = &sio_consdev; |
4198 return 0; 4199} 4200 4201int 4202siogdbattach(port, speed) 4203 int port; 4204 int speed; 4205{ --- 26 unchanged lines hidden (view full) --- 4232 siocnopen(&sp, siogdbiobase, gdbdefaultrate); 4233 splx(s); 4234 4235 return 0; 4236} 4237 4238#endif 4239 | 4207 return 0; 4208} 4209 4210int 4211siogdbattach(port, speed) 4212 int port; 4213 int speed; 4214{ --- 26 unchanged lines hidden (view full) --- 4241 siocnopen(&sp, siogdbiobase, gdbdefaultrate); 4242 splx(s); 4243 4244 return 0; 4245} 4246 4247#endif 4248 |
4240#ifdef __i386__ 4241static 4242#endif 4243void | 4249static void |
4244siocninit(cp) 4245 struct consdev *cp; 4246{ 4247 comconsole = DEV_TO_UNIT(cp->cn_dev); 4248} 4249 | 4250siocninit(cp) 4251 struct consdev *cp; 4252{ 4253 comconsole = DEV_TO_UNIT(cp->cn_dev); 4254} 4255 |
4250#ifdef __i386__ 4251static 4252#endif 4253int | 4256static int |
4254siocncheckc(dev) 4255 dev_t dev; 4256{ 4257 int c; 4258 Port_t iobase; 4259 int s; 4260 struct siocnstate sp; 4261 --- 88 unchanged lines hidden (view full) --- 4350 siocnopen(&sp, siogdbiobase, gdbdefaultrate); 4351 siocntxwait(siogdbiobase); 4352 outb(siogdbiobase + com_data, c); 4353 siocnclose(&sp, siogdbiobase); 4354 splx(s); 4355} 4356#endif 4357 | 4257siocncheckc(dev) 4258 dev_t dev; 4259{ 4260 int c; 4261 Port_t iobase; 4262 int s; 4263 struct siocnstate sp; 4264 --- 88 unchanged lines hidden (view full) --- 4353 siocnopen(&sp, siogdbiobase, gdbdefaultrate); 4354 siocntxwait(siogdbiobase); 4355 outb(siogdbiobase + com_data, c); 4356 siocnclose(&sp, siogdbiobase); 4357 splx(s); 4358} 4359#endif 4360 |
4358 4359/* 4360 * support PnP cards if we are using 'em 4361 */ 4362 4363#if NPNP > 0 4364 4365static pnpid_t siopnp_ids[] = { 4366 { 0x5015f435, "MOT1550"}, 4367 { 0x8113b04e, "Supra1381"}, 4368 { 0x9012b04e, "Supra1290"}, 4369 { 0x7121b04e, "SupraExpress 56i Sp"}, 4370 { 0x11007256, "USR0011"}, 4371 { 0x30207256, "USR2030"}, 4372 { 0x31307256, "USR3031"}, 4373 { 0x90307256, "USR3090"}, 4374 { 0x0100440e, "Cardinal MVP288IV"}, 4375 { 0 } 4376}; 4377 4378static char *siopnp_probe(u_long csn, u_long vend_id); 4379static void siopnp_attach(u_long csn, u_long vend_id, char *name, 4380 struct isa_device *dev); 4381static u_long nsiopnp = NSIO; 4382 4383static struct pnp_device siopnp = { 4384 "siopnp", 4385 siopnp_probe, 4386 siopnp_attach, 4387 &nsiopnp, 4388 &tty_imask 4389}; 4390DATA_SET (pnpdevice_set, siopnp); 4391 4392static char * 4393siopnp_probe(u_long csn, u_long vend_id) 4394{ 4395 pnpid_t *id; 4396 char *s = NULL; 4397 4398 for(id = siopnp_ids; id->vend_id != 0; id++) { 4399 if (vend_id == id->vend_id) { 4400 s = id->id_str; 4401 break; 4402 } 4403 } 4404 4405 if (s) { 4406 struct pnp_cinfo d; 4407 read_pnp_parms(&d, 0); 4408 if (d.enable == 0 || d.flags & 1) { 4409 printf("CSN %lu is disabled.\n", csn); 4410 return (NULL); 4411 } 4412 4413 } 4414 4415 return (s); 4416} 4417 4418static void 4419siopnp_attach(u_long csn, u_long vend_id, char *name, struct isa_device *dev) 4420{ 4421 struct pnp_cinfo d; 4422 4423 if (dev->id_unit >= NSIOTOT) 4424 return; 4425 4426 if (read_pnp_parms(&d, 0) == 0) { 4427 printf("failed to read pnp parms\n"); 4428 return; 4429 } 4430 4431 write_pnp_parms(&d, 0); 4432 4433 enable_pnp_card(); 4434 4435 dev->id_iobase = d.port[0]; 4436 dev->id_irq = (1 << d.irq[0]); 4437 dev->id_ointr = siointr; 4438 dev->id_ri_flags = RI_FAST; 4439 dev->id_drq = -1; 4440 4441 if (dev->id_driver == NULL) { 4442 dev->id_driver = &siodriver; 4443 dev->id_id = isa_compat_nextid(); 4444 } 4445 4446 if ((dev->id_alive = sioprobe(dev)) != 0) 4447 sioattach(dev); 4448 else 4449 printf("sio%d: probe failed\n", dev->id_unit); 4450} 4451#endif 4452 | |
4453DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass, sio_cdevsw, 0, 0); 4454 4455#ifdef PC98 4456/* 4457 * pc98 local function 4458 */ 4459 4460static void --- 545 unchanged lines hidden --- | 4361DEV_DRIVER_MODULE(sio, isa, sio_driver, sio_devclass, sio_cdevsw, 0, 0); 4362 4363#ifdef PC98 4364/* 4365 * pc98 local function 4366 */ 4367 4368static void --- 545 unchanged lines hidden --- |