sio.c (42262) | sio.c (42265) |
---|---|
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 --- 17 unchanged lines hidden (view full) --- 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 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 | 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 --- 17 unchanged lines hidden (view full) --- 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 * from: @(#)com.c 7.5 (Berkeley) 5/16/91 |
34 * $Id: sio.c,v 1.71 1998/12/30 08:09:11 kato Exp $ | 34 * $Id: sio.c,v 1.72 1999/01/03 05:03:47 kato Exp $ |
35 */ 36 37#include "opt_comconsole.h" 38#include "opt_compat.h" 39#include "opt_ddb.h" 40#include "opt_devfs.h" 41#include "opt_sio.h" 42#include "sio.h" --- 123 unchanged lines hidden (view full) --- 166#include <i386/isa/isa_device.h> 167#include <i386/isa/sioreg.h> 168#include <i386/isa/intr_machdep.h> 169 170#ifdef COM_ESP 171#include <i386/isa/ic/esp.h> 172#endif 173#include <i386/isa/ic/ns16550.h> | 35 */ 36 37#include "opt_comconsole.h" 38#include "opt_compat.h" 39#include "opt_ddb.h" 40#include "opt_devfs.h" 41#include "opt_sio.h" 42#include "sio.h" --- 123 unchanged lines hidden (view full) --- 166#include <i386/isa/isa_device.h> 167#include <i386/isa/sioreg.h> 168#include <i386/isa/intr_machdep.h> 169 170#ifdef COM_ESP 171#include <i386/isa/ic/esp.h> 172#endif 173#include <i386/isa/ic/ns16550.h> |
174#ifdef PC98 175#include <i386/isa/ic/rsa.h> 176#endif |
|
174 175#include "card.h" 176#if NCARD > 0 177#include <pccard/cardinfo.h> 178#include <pccard/slot.h> 179#endif 180 181#if NPNP > 0 --- 42 unchanged lines hidden (view full) --- 224#define COM_NOFIFO(dev) ((dev)->id_flags & 0x02) 225#define COM_ST16650A(dev) ((dev)->id_flags & 0x20000) 226#define COM_C_NOPROBE (0x40000) 227#define COM_NOPROBE(dev) ((dev)->id_flags & COM_C_NOPROBE) 228#define COM_C_IIR_TXRDYBUG (0x80000) 229#define COM_IIR_TXRDYBUG(dev) ((dev)->id_flags & COM_C_IIR_TXRDYBUG) 230#define COM_FIFOSIZE(dev) (((dev)->id_flags & 0xff000000) >> 24) 231 | 177 178#include "card.h" 179#if NCARD > 0 180#include <pccard/cardinfo.h> 181#include <pccard/slot.h> 182#endif 183 184#if NPNP > 0 --- 42 unchanged lines hidden (view full) --- 227#define COM_NOFIFO(dev) ((dev)->id_flags & 0x02) 228#define COM_ST16650A(dev) ((dev)->id_flags & 0x20000) 229#define COM_C_NOPROBE (0x40000) 230#define COM_NOPROBE(dev) ((dev)->id_flags & COM_C_NOPROBE) 231#define COM_C_IIR_TXRDYBUG (0x80000) 232#define COM_IIR_TXRDYBUG(dev) ((dev)->id_flags & COM_C_IIR_TXRDYBUG) 233#define COM_FIFOSIZE(dev) (((dev)->id_flags & 0xff000000) >> 24) 234 |
232#ifndef PC98 | 235#ifdef PC98 236#define com_emr com_msr /* Extension mode register for RSB-2000/3000 */ 237#else |
233#define com_scr 7 /* scratch register for 16450-16550 (R/W) */ | 238#define com_scr 7 /* scratch register for 16450-16550 (R/W) */ |
234#endif /* !PC98 */ | 239#endif |
235 236/* 237 * Input buffer watermarks. 238 * The external device is asked to stop sending when the buffer exactly reaches 239 * high water, or when the high level requests it. 240 * The high level is notified immediately (rather than at a later clock tick) 241 * when this watermark is reached. 242 * The buffer size is chosen so the watermark should almost never be reached. --- 520 unchanged lines hidden (view full) --- 763 /* COM_IF_RSA98III */ 764 { " (RSA-98III)", -1, -1, 0, 16, comspeedtab_rsa }, 765 /* COM_IF_ESP98 */ 766 { " (ESP98)", -1, -1, 1, 1, comspeedtab_mc16550 }, 767}; 768#endif /* PC98 */ 769 770#ifdef COM_ESP | 240 241/* 242 * Input buffer watermarks. 243 * The external device is asked to stop sending when the buffer exactly reaches 244 * high water, or when the high level requests it. 245 * The high level is notified immediately (rather than at a later clock tick) 246 * when this watermark is reached. 247 * The buffer size is chosen so the watermark should almost never be reached. --- 520 unchanged lines hidden (view full) --- 768 /* COM_IF_RSA98III */ 769 { " (RSA-98III)", -1, -1, 0, 16, comspeedtab_rsa }, 770 /* COM_IF_ESP98 */ 771 { " (ESP98)", -1, -1, 1, 1, comspeedtab_mc16550 }, 772}; 773#endif /* PC98 */ 774 775#ifdef COM_ESP |
771/* XXX configure this properly. */ | |
772#ifdef PC98 | 776#ifdef PC98 |
777 778/* XXX configure this properly. */ |
|
773static Port_t likely_com_ports[] = { 0, 0xb0, 0xb1, 0 }; 774static Port_t likely_esp_ports[] = { 0xc0d0, 0 }; | 779static Port_t likely_com_ports[] = { 0, 0xb0, 0xb1, 0 }; 780static Port_t likely_esp_ports[] = { 0xc0d0, 0 }; |
775#else | 781 782#define ESP98_CMD1 (ESP_CMD1 * 0x100) 783#define ESP98_CMD2 (ESP_CMD2 * 0x100) 784#define ESP98_STATUS1 (ESP_STATUS1 * 0x100) 785#define ESP98_STATUS2 (ESP_STATUS2 * 0x100) 786 787#else /* PC98 */ 788 789/* XXX configure this properly. */ |
776static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, }; 777static Port_t likely_esp_ports[] = { 0x140, 0x180, 0x280, 0 }; | 790static Port_t likely_com_ports[] = { 0x3f8, 0x2f8, 0x3e8, 0x2e8, }; 791static Port_t likely_esp_ports[] = { 0x140, 0x180, 0x280, 0 }; |
792 |
|
778#endif /* PC98 */ 779#endif 780 781/* 782 * handle sysctl read/write requests for console speed 783 * 784 * In addition to setting comdefaultrate for I/O through /dev/console, 785 * also set the initial and lock values for the /dev/ttyXX device --- 633 unchanged lines hidden (view full) --- 1419 } 1420 1421 /* 1422 * We've got something that claims to be a Hayes ESP card. 1423 * Let's hope so. 1424 */ 1425 1426 /* Get the dip-switch configuration */ | 793#endif /* PC98 */ 794#endif 795 796/* 797 * handle sysctl read/write requests for console speed 798 * 799 * In addition to setting comdefaultrate for I/O through /dev/console, 800 * also set the initial and lock values for the /dev/ttyXX device --- 633 unchanged lines hidden (view full) --- 1434 } 1435 1436 /* 1437 * We've got something that claims to be a Hayes ESP card. 1438 * Let's hope so. 1439 */ 1440 1441 /* Get the dip-switch configuration */ |
1442#ifdef PC98 1443 outb(esp_port + ESP98_CMD1, ESP_GETDIPS); 1444 dips = inb(esp_port + ESP98_STATUS1); 1445#else |
|
1427 outb(esp_port + ESP_CMD1, ESP_GETDIPS); 1428 dips = inb(esp_port + ESP_STATUS1); | 1446 outb(esp_port + ESP_CMD1, ESP_GETDIPS); 1447 dips = inb(esp_port + ESP_STATUS1); |
1448#endif |
|
1429 1430 /* 1431 * Bits 0,1 of dips say which COM port we are. 1432 */ 1433#ifdef PC98 1434 if ((com->iobase & 0xff) == likely_com_ports[dips & 0x03]) 1435#else 1436 if (com->iobase == likely_com_ports[dips & 0x03]) 1437#endif 1438 printf(" : ESP"); 1439 else { 1440 printf(" esp_port has com %d\n", dips & 0x03); 1441 return (0); 1442 } 1443 1444 /* 1445 * Check for ESP version 2.0 or later: bits 4,5,6 = 010. 1446 */ | 1449 1450 /* 1451 * Bits 0,1 of dips say which COM port we are. 1452 */ 1453#ifdef PC98 1454 if ((com->iobase & 0xff) == likely_com_ports[dips & 0x03]) 1455#else 1456 if (com->iobase == likely_com_ports[dips & 0x03]) 1457#endif 1458 printf(" : ESP"); 1459 else { 1460 printf(" esp_port has com %d\n", dips & 0x03); 1461 return (0); 1462 } 1463 1464 /* 1465 * Check for ESP version 2.0 or later: bits 4,5,6 = 010. 1466 */ |
1467#ifdef PC98 1468 outb(esp_port + ESP98_CMD1, ESP_GETTEST); 1469 val = inb(esp_port + ESP98_STATUS1); /* clear reg 1 */ 1470 val = inb(esp_port + ESP98_STATUS2); 1471#else |
|
1447 outb(esp_port + ESP_CMD1, ESP_GETTEST); 1448 val = inb(esp_port + ESP_STATUS1); /* clear reg 1 */ 1449 val = inb(esp_port + ESP_STATUS2); | 1472 outb(esp_port + ESP_CMD1, ESP_GETTEST); 1473 val = inb(esp_port + ESP_STATUS1); /* clear reg 1 */ 1474 val = inb(esp_port + ESP_STATUS2); |
1475#endif |
|
1450 if ((val & 0x70) < 0x20) { 1451 printf("-old (%o)", val & 0x70); 1452 return (0); 1453 } 1454 1455 /* 1456 * Check for ability to emulate 16550: bit 7 == 1 1457 */ --- 252 unchanged lines hidden (view full) --- 1710 if (com->esp) { 1711 /* 1712 * Set 16550 compatibility mode. 1713 * We don't use the ESP_MODE_SCALE bit to increase the 1714 * fifo trigger levels because we can't handle large 1715 * bursts of input. 1716 * XXX flow control should be set in comparam(), not here. 1717 */ | 1476 if ((val & 0x70) < 0x20) { 1477 printf("-old (%o)", val & 0x70); 1478 return (0); 1479 } 1480 1481 /* 1482 * Check for ability to emulate 16550: bit 7 == 1 1483 */ --- 252 unchanged lines hidden (view full) --- 1736 if (com->esp) { 1737 /* 1738 * Set 16550 compatibility mode. 1739 * We don't use the ESP_MODE_SCALE bit to increase the 1740 * fifo trigger levels because we can't handle large 1741 * bursts of input. 1742 * XXX flow control should be set in comparam(), not here. 1743 */ |
1744#ifdef PC98 1745 outb(com->esp_port + ESP98_CMD1, ESP_SETMODE); 1746 outb(com->esp_port + ESP98_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO); 1747#else |
|
1718 outb(com->esp_port + ESP_CMD1, ESP_SETMODE); 1719 outb(com->esp_port + ESP_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO); | 1748 outb(com->esp_port + ESP_CMD1, ESP_SETMODE); 1749 outb(com->esp_port + ESP_CMD2, ESP_MODE_RTS | ESP_MODE_FIFO); |
1750#endif |
|
1720 1721 /* Set RTS/CTS flow control. */ | 1751 1752 /* Set RTS/CTS flow control. */ |
1753#ifdef PC98 1754 outb(com->esp_port + ESP98_CMD1, ESP_SETFLOWTYPE); 1755 outb(com->esp_port + ESP98_CMD2, ESP_FLOW_RTS); 1756 outb(com->esp_port + ESP98_CMD2, ESP_FLOW_CTS); 1757#else |
|
1722 outb(com->esp_port + ESP_CMD1, ESP_SETFLOWTYPE); 1723 outb(com->esp_port + ESP_CMD2, ESP_FLOW_RTS); 1724 outb(com->esp_port + ESP_CMD2, ESP_FLOW_CTS); | 1758 outb(com->esp_port + ESP_CMD1, ESP_SETFLOWTYPE); 1759 outb(com->esp_port + ESP_CMD2, ESP_FLOW_RTS); 1760 outb(com->esp_port + ESP_CMD2, ESP_FLOW_CTS); |
1761#endif |
|
1725 1726 /* Set flow-control levels. */ | 1762 1763 /* Set flow-control levels. */ |
1764#ifdef PC98 1765 outb(com->esp_port + ESP98_CMD1, ESP_SETRXFLOW); 1766 outb(com->esp_port + ESP98_CMD2, HIBYTE(768)); 1767 outb(com->esp_port + ESP98_CMD2, LOBYTE(768)); 1768 outb(com->esp_port + ESP98_CMD2, HIBYTE(512)); 1769 outb(com->esp_port + ESP98_CMD2, LOBYTE(512)); 1770#else |
|
1727 outb(com->esp_port + ESP_CMD1, ESP_SETRXFLOW); 1728 outb(com->esp_port + ESP_CMD2, HIBYTE(768)); 1729 outb(com->esp_port + ESP_CMD2, LOBYTE(768)); 1730 outb(com->esp_port + ESP_CMD2, HIBYTE(512)); 1731 outb(com->esp_port + ESP_CMD2, LOBYTE(512)); | 1771 outb(com->esp_port + ESP_CMD1, ESP_SETRXFLOW); 1772 outb(com->esp_port + ESP_CMD2, HIBYTE(768)); 1773 outb(com->esp_port + ESP_CMD2, LOBYTE(768)); 1774 outb(com->esp_port + ESP_CMD2, HIBYTE(512)); 1775 outb(com->esp_port + ESP_CMD2, LOBYTE(512)); |
1776#endif 1777 |
|
1732#ifdef PC98 1733 /* Set UART clock prescaler. */ | 1778#ifdef PC98 1779 /* Set UART clock prescaler. */ |
1734 outb(com->esp_port + ESP_CMD1, ESP_SETCLOCK); 1735 outb(com->esp_port + ESP_CMD2, 2); /* 4 times */ | 1780 outb(com->esp_port + ESP98_CMD1, ESP_SETCLOCK); 1781 outb(com->esp_port + ESP98_CMD2, 2); /* 4 times */ |
1736#endif 1737 } 1738#endif /* COM_ESP */ 1739#ifdef PC98 1740 printf("%s", if_16550a_type[com->pc98_if_type & 0x0f].name); 1741 outb(iobase + (com_fifo << port_shift), 0); 1742#else 1743 outb(iobase + com_fifo, 0); --- 2931 unchanged lines hidden --- | 1782#endif 1783 } 1784#endif /* COM_ESP */ 1785#ifdef PC98 1786 printf("%s", if_16550a_type[com->pc98_if_type & 0x0f].name); 1787 outb(iobase + (com_fifo << port_shift), 0); 1788#else 1789 outb(iobase + com_fifo, 0); --- 2931 unchanged lines hidden --- |