COM(4) BSD Programmer's Manual COM(4)NAME
com - 8051/16450/16550 serial port driver
SYNOPSIS
com0 at isa? port 0x3f8 [flags val]
DESCRIPTION
The COM driver supports standard PC compatible serial ports and some sim-
ple serial multiport cards. Each serial port uses a block of 8 I/O ports
which must be aligned on an 8 port boundary. The standard serial ports
(com0 through com3, generally known in hardware documentation as COM1
through COM4) are often provided by cards with 2 serial ports and possi-
bly other devices. Multiport cards generally provide 4 or more serial
ports, which can be configured in ways other than the standard COM1
through COM4 configurations. Some multiport cards can be jumpered to
provide standard COM1-4 ports and/or a group of ports that share an in-
terrupt. With such cards, the standard ports should be configured as de-
scribed here, and the remaining ports should be configured as shown for
multiport cards.
Each standard com device (com0 through com3) and each multiport card
should have its own interrupt. The hardware interrupt level is detected
during autoconfiguration, or it may be specified in the configuration
file. The FIFO on 16550 UARTs is enabled automatically.
The standard com ports (com0 through com3, also known as COM1 through
COM4), can be configured as follows:
device com0 at isa? port 0x3f8
device com1 at isa? port 0x3e8
device com2 at isa? port 0x2f8
device com3 at isa? port 0x2e8
Each of these ports must have a separate irq, which is automatically de-
tected in these examples. Note that the conventional irq for com2 is the
same as for com0, similarly for com3 and com1, and thus different values
must be used.
The flags parameter in the configuration entries is used to set up the
shared irq mechanism for ports on a multiport card. The flags value is
normally composed of three fields: the interrupt indicator port (bits
0x3ff), the group number (bits 0xf000), and the sub-unit number (bits
0xf0000). The devices with the same group number and interrupt indicator
share the interrupt determined by sub-unit 0 of the group. The unit with
sub-unit 0 must be listed first in the configuration file. For USENET II
serial cards there is a fourth field which can turn on hardware flow con-
trol as well as control the size of the FIFO (bits 0xf00000). See below
for more details.
For AST-compatible cards, the interrupt indicator bits should be set to
the I/O address of the interrupt indicator register of the serial card.
Some multiplexor cards do not have an interrupt indicator register. For
such cards, set this field to 0.
The group number is used to show which serial ports share an interrupt.
It should be 0 for all ports on the first multiplexor card, 1 for the all
ports on the second, etc.
The sub-unit number is used to identify the different serial ports on a
single multiport card. It should be 0 for the first port, 1 for the sec-
ond, etc.
For example, to configure two AST-compatible 4-port cards, use the fol-
lowing device lines:
device com4 at isa? port 0x2a0 flags 0x002bf
device com5 at isa? port 0x2a8 flags 0x102bf
device com6 at isa? port 0x2b0 flags 0x202bf
device com7 at isa? port 0x2b8 flags 0x302bf
device com8 at isa? port 0x1a0 flags 0x011bf
device com9 at isa? port 0x1a8 flags 0x111bf
device com10 at isa? port 0x1b0 flags 0x211bf
device com11 at isa? port 0x1b8 flags 0x311bf
Also, make sure the two cards are jumpered for different interrupts.
A similar scheme is used with the USENET II serial cards and other cards
that do not use the interrupt indicator port to enable shared interrupts.
For these cards the interrupt indicator port is set to 0, and the group
number must be non-zero. Devices with the same group number share an in-
terrupt. For example, use the following device lines to configure a Boca
Research BB1008, which does not have an interrupt identification regis-
ter. The first 4 lines could also be used for a USENET II 4-port card,
omitting the irq value for automatic interrupt configuration.
device com4 at isa? port 0x100 irq 4 flags 0x01000
device com5 at isa? port 0x108 irq 4 flags 0x11000
device com6 at isa? port 0x110 irq 4 flags 0x21000
device com7 at isa? port 0x118 irq 4 flags 0x31000
device com8 at isa? port 0x120 irq 4 flags 0x41000
device com9 at isa? port 0x128 irq 4 flags 0x51000
device com10 at isa? port 0x130 irq 4 flags 0x61000
device com11 at isa? port 0x138 irq 4 flags 0x71000
Automatic irq discovery does not work for Boca Research cards, and the
irq must be included in the configuration file. Also, shared irq mode
for multiple boards is not supported; i.e. each Boca Research and compat-
ible multiplexor should have a different irq.
FIFO sizes and hardware flow control on USENET II cards can be adjusted
by ORing in one of the following values to the flags field on a port by
port basis:
Flags Receive Output Hardware
Value Trigger FIFO Flow Control
0x000000 default 16
0x100000 1 16
0x200000 4 16
0x300000 8 16
0x400000 14 16
0x500000 1 1
0x600000 4 4
0x700000 8 8
0x800000 14 14
0x900000 FIFO DISABLED
0xb00000 1 1 enabled
0xc00000 4 4 enabled
0xd00000 8 8 enabled
0xe00000 14 14 enabled
0xf00000 14 16 enabled
The default value of the receive trigger is currently 4. Enabling hard-
ware flow control is known to cause performance degradation on some sys-
tems and improve performance on others. If performance is degraded when
hardware flow control is enabled, try disabling it.
For other hardware, the flags should be omitted or set to 0.
Except on multiport cards designed to share an interrupt for multiport
ports on the same card, the use of the same interrupt by different ports
at different times is discouraged. However, the interrupt output from
the port is enabled only when a port is open, potentially allowing dif-
ferent standard ports (com0 through com3) to share an interrupt if only
one port is used at a time. If a port that is not in use still drives
the interrupt line, it is likely that the bus drivers for both cards
sharing an interrupt will be fried.
The speed may be set to any value up to 115200 bits per second that can
be set within a 3% tolerance by dividing a 115200 Hz clock. The
termios(4) interface must be used rather than the old-style ioctl inter-
face to use non-traditional speeds.
An open on the com driver will block until carrier is present, unless
O_NONBLOCK or CLOCAL is set.
Hardware flow control via RTS and CTS may be enabled using the CRTS_IFLOW
and CCTS_OFLOW flags in the c_cflag field in the termios structure.
FILES
/dev/tty00, /dev/tty01, etc.
BUGS
The input fifos on com devices are relatively small. If another device
blocks interrupts for a significant period input characters may be
dropped by the com driver. The higher the data rate on the com device the
shorter the period of blocked interrupts which can be tolerated. The di-
gi(4) driver can cause this if the com driver is running at high baud
rates.
HISTORY
The com driver first appeared in Berkeley Networking-2. Multiport card
support was added by BSDI.
BSDI BSD/OS February 2, 1995 3