SIO Technical Reference Manual

By Ray Gwinn
 * Date: January 1, 1997

Introduction
Documentation of software is often more difficult than writing the program itself (at least it is for this author). I will do my best though.

But who do I document for? The user that is setting up a BBS just wants to get SIO installed and to move on to more important things. The user that is having problems needs information about serial I/O communications in general and the PC specifically. The application developer (programmer) needs detailed information about each individual function and the information generated.

The answer is, more than one manual is needed. This manual is intended as a reference for use by application programmers that desires to use SIO. A separate Users Manual is included in the distribution file(s).

This manual and the software described is provided as is and with no guarantees. Use at your own risk.

What is SIO
SIO is a Serial Input/Output (SIO) communications character device driver. It provides an interface between application programs and the serial communications hardware.

SIO had been designed as a high performance replacement for the OS/2 device driver COM.SYS. This manual documents the known differences between COM.SYS and SIO.SYS.

SIO only works with 8250 (type) serial I/O devices. Such devices include, but is not limited to the 8250A, 16450, 16550, 16550A and the 82510. If you have a PC that is an IBM or near compatible which has a serial communication port, it is likely that it contains one of these devices. SIO will identify the type of serial devices that it finds at load time.

Like other Device Drivers, SIO will do very little standing alone. There must be an application(s) program that makes use of SIO's functions before one will benefit from the use of SIO.

The Poor Man's Line Monitor (PMLM.EXE)
PMLM is basically of interest to developers of comm applications and those providing technical support for those applications. This SIO utility is released largely (in self defense) in the hope that some users can diagnose their own problems. PMLM's feature of saving trace information to disk will only work with registered and beta versions of SIO.

PMLM provides basic line monitoring for OS/2, DOS and Windows comm programs. All characters sent or received by application programs are displayed in the upper portion of the screen. Receive characters are displayed as "white on blue" and transmitted characters are displayed "yellow on violet". Line signals, such as CTS are displayed as "dim white on red" when turned off and "bright white on red" when turned on. In addition, a signals transition to OFF is displayed in lower case and a signals transition to ON is displayed in upper case.

Status information is displayed in the lower part of the screen. A bright white display means the signal is on, a dim white indicates that the signal is off. In addition, when bright, Rxoff and Txoff indicate the SIO has sent (Txoff) or received (Rxoff) an Xoff, and an Xon is pending.

When a DOS or Windows session uses a comm port, an additional line of signal status appears. This status line shows the state of the virtual UART's signals. Only the signals which MAY be different from the real UART's signals are shown.

"Rx Chars" and "Tx Chars" reflects the number of characters in SIO's receive and transmit buffers respectively.

The last line on the screen shows the keys (from the keyboard) that PMLM will recognize. The bright character shows the key to hit for the associated function. The font keys will not work in a windowed OS/2 session.

PMLM's command line requires one parameter, the comm port number, and optionally accepts an additional parameter giving a save trace file name. For example, PMLM 1 COM1INFO.TEC will monitor COM1 and save ALL of the communications traffic in the file COM1INFO.TRC. The trace files created by PMLM contain exactly the same information that is displayed by PMLM, video attributes and all.

VIEWPMLM.EXE
VIEWPMLM.EXE may be used to view trace files created by PMLM. VIEWPMLM.EXE requires one parameter, the trace file name. The user can use the keys UP, DOWN, PAGEUP, PAGEDOWN, HOME, and END to navigate the saved trace file. Registered SIO users may send VIEWPMLM.EXE (along with saved trace files) to anyone for technical support purposes.

VIEWPMLM can be used in native DOS, in DOS sessions under OS/2, and in OS/2 sessions. This means that even those developers and support people need not have OS/2 to view the captured communications data created by PMLM.

SIO's Utility (SU.EXE)
This utility program has several useful commands. You can obtain a list of the available commands by typing SU at any command line prompt without any parameters. One very useful command is SU IRQS. This command will show IRQs that currently free for use. Commands are provided allowing user control (missing from MODE) are available. Status commands provide a wealth of diagnostic information.

File System Requests
SIO processes all file system requests made to it in one way or another. The following file system requests and how SIO processes them may be of use to the application programmer. Each of these file system requests are discussed in more detail in the following.
 * INIT          Driver initialization.
 * Read          Data transfer from driver to program.
 * Input Status  Get input status.
 * Input Flush   Terminate all pending input requests.
 * Write         Data transfer from program to driver.
 * Output Status Get output status.
 * Output Flush  Terminate all pending output requests.
 * Open          Open the device for use.
 * Close         Close the device.
 * IOCTL         Device I/O control commands.

Driver Initialization
During device driver initialization the command line is parsed, memory for data and control buffers is allocated and the system environment is examined.

Buffers are allocated for the maximum number of ports that the installed version of SIO can support (up to 16).

The mouse port is determined and if it is a serial mouse, that port is excluded from use by SIO.

In the absence of any command line parameters, SIO will only support (look for) COM1 and COM2 at the standard addresses. COM3 and up will not be supported (or looked at) unless they are specifically identified in the SIO command line.

Read
If another read is already in progress, the process issuing the additional read is blocked (suspended) until the previous read command completes. When a read is started, that read is not interrupted by additional reads. If multiple reads are issued, they are not necessarily processed in the order they were issued. Thus, applications may not see the read requests complete in the order in which they were issued.

The conditions that control when the read will complete are controlled by the active (current) DCB when the read is started.

Input Status
This function returns with "device busy" set if there is no data in the receive buffer. That is, busy is returned if the process may be blocked if the application issues a read command.

Input Flush
This function causes the receive buffer to be cleared (made empty). Any threads that are blocked, waiting for a read, will be restarted when this function is issued.

Write
If another write is already in progress, the process issuing the additional write is blocked (suspended) until the previous write command completes. When a write is started, that write is not interrupted by additional writes. If multiple writes are issued, they are not necessarily processed in the order they were issued. Thus, applications may not see the write requests complete in the order in which they were issued.

The conditions that control when the write will complete are controlled by the current DCB when the write is started.

Output Status
This function returns with "device busy" set if the output buffer is more than three quarters full. That is, busy is returned if the process may be blocked if the application issues a write command.

Output Flush
This function causes the transmit buffer to be cleared (made empty). Any threads that are blocked, waiting for a write, will be restarted when this function is issued.

Open
There are basically two kinds of open. They are an Initial Open and Additional (shared) Opens. The IBM documentation calls the initial open a First Level Open. An Initial Open is an open that occurs when no other process has the communications port open. An Additional Open is when an open occurs and another process already has the communications port open. For an Additional Open to occur, the Initial Opener must have issued an open allowing shared access to the port.

Initial Open
The IRQ associated with the comm port is claimed (taken) when the Initial Open occurs. If the associated IRQ is not available a "Port in Use" error is returned. At the time of this writing, the IRQ is claimed allowing sharing. However, the shared IRQ claiming is done to circumvent anomalies in the OS, and in actuality SIO will not concurrently share an IRQ with another device driver. The author found it necessary to claim (reset) all interrupts directed to the interrupt service routine in order to prevent lock ups of a communications port. The IRQ mess may be cleaned up at a future date when the OS problems are corrected.

During Initial Opens, DTR and RTS are set in accordance with the current Device Control Block (DCB) settings. If DTR Control Mode is the "Enabled" option ( bits 1 and 0 of the DCB Flags1 byte equal 01), then DTR is turned on. Otherwise, DTR is unchanged by the Initial Open. Similarly, if RTS Control Mode is the "Enabled" option ( bits 7 and 6 of the DCB Flags1 byte equal 01), then RTS is turned on. Otherwise, RTS is unchanged by the Initial Open.

The following actions also occur during an Initial Open: If the Initial Opener is an OS/2 process (not a DOS process) then the Read time out processing is set to "Normal" in the current DCB.
 * The Xon and Xoff characters are set to 11h and 13h respectively.
 * The transmit and receive buffers and structures are cleared and re-initialized.
 * Status bits are reset.

Additional Open
A count of active opens is incremented. No changes are made to current comm settings.

Close
There are two basic kinds of closes. They are an Intermediate Close and a Last Close.

Intermediate Close
An intermediate close occurs when a process issues a close and other processes still have the communications port opened. This type of close simply decrements an open count and returns. No action or changes take place at the communications port.

Last Close
The last close occurs when a process issues a close and no other process has the communications port open. If there are any writes pending or incomplete, the process is blocked (suspended) until the writes complete or time out. If 60 seconds pass with no activity at the communications port, the port is forced to close and all writes are terminated. If any processes are blocked (suspended) waiting on a read, they are forced to return to the process that issued the read.

If either DTR Control Mode or RTS Control Mode are set to "Enabled" by the current DCB, then the appropriate signal(s) is turned off.

Finally, the IRQ is released back to the OS.

Device I/O Control (IOCtl) Commands
The following Generic IOCtl functions are supported by SIO.
 * 41h - Set Bit Rate
 * 42h - Set Line Characteristics
 * 43h - Extended Set Bit Rate
 * 44h - Transmit Byte Immediate
 * 45h - Set Break Off
 * 46h - Set Modem Control Signals
 * 47h - Hold Transmit
 * 48h - Start Transmit (after hold)
 * 4Bh - Set Break On
 * 53h - Write Device Control Block (DCB)
 * 54h - Write Extended Mode Parameters
 * 61h - Query Current Bit Rate
 * 62h - Query Line Characteristics
 * 63h - Query Extended Bit Rate
 * 64h - Query SIO Status
 * 65h - Query Transmit Data Status
 * 66h - Query Current Modem Output Control Signals
 * 67h - Query Current Modem Input Signals
 * 68h - Query Number of Characters in Receive Buffer
 * 69h - Query Number of Characters in Transmit Buffer
 * 6Dh - Query SIO Error
 * 72h - Query SIO Event Information
 * 73h - Read Device Control Block (DCB)
 * 74h - Read Enhanced Mode Parameters

Each of these IOCtl commands are described in detail on the following pages.

All IOCtl functions are called with a uniform set of parameters. This uniform set of parameters is: DWORD Address of a data packet. WORD  Size of the data packet in bytes. DWORD Address of the parameter packet. WORD  Size of the parameter packet in bytes. WORD  Function code. WORD  Category code (01 for SIO). WORD  Handle for the opened device. Each IOCtl function may or may not have a data or parameter packet. If a given IOCtl function specifies a NULL parameter or data packet, the address of the appropriate item must be NULL (zero) in the parameters. Passing an invalid data or parameter packet may result in a General Protection Fault.

IOCtl Functions From a DOS Session
Additionally the following describes how to call an IOCtl function in an OS/2 driver from a DOS session (VDM). The "handle" is obtained simply by issuing a normal DOS open of the device, ie COM1. The Data Packets (DataPkt below) and Parameter Packets (PrmPkt below) are different for each IOCtl function. The structure and contents of these packets are described in the following pages. push   ds              ;save ds mov     bx,handle       ;file handle to bx mov     ch,1            ;category, 1=serial device control mov    cl,41h          ;func code, 41h=extended set bit rate mov    dx,Seg DataPkt  ;get segment of the data packet mov    ds,dx           ;load ds with seg of the data packet lea    dx,DataPkt      ;data packet address to ds:dx mov    si,Seg PrmPkt   ;segment of command packet to si lea     di,PrmPkt       ;offset of command packet to di mov     ax,440ch        ;IOCtl function call, handle based int    21h             ;issue IOCtl to OS/2 driver. pop    ds              ;restore ds jc      error           ;jump if error returned

41h - Set Bit Rate
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Bit/Baud Rate            │ WORD     │ └───────────────────────────┴──────────┘ "Bit Rate" is any number from 1 to 65535. SIO does not attempt to validate a given bit rate. The minimum bit rate accepted by SIO is 50, the maximum for this IOCtl function is 65535.

Note that the hardware may not be able to generate the given bit rate. For example, if a computer has a standard communications card installed and if a bit rate of 65500 is specified, the nearest bit rate that can be generated will be set, 57600 in this case.

To set bit rates in excess of 57600, see IOCtl function 43h, Extended Set Bit Rate.

Some commonly used bit rates that can be set with this function are: 50      2000   75       2400  110       3600  150       4800  300       7200  600       9600 1200      19200 1800      28800 2000      38400 2400      57600 Data Packet - None

42h - Set Line Characteristics
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Data Bits Per Character  │ BYTE     │ ├───────────────────────────┼──────────┤ │ Parity Setting           │ BYTE     │ ├───────────────────────────┼──────────┤ │ Stop Bit Setting         │ BYTE     │ └───────────────────────────┴──────────┘ Data Bits Per Character may be 5, 7, or 8, all other values are invalid.

Parity Setting may have the following values, all other values are invalid: 0 - No parity bit. 1 - Odd parity. 2 - Even parity. 3 - Mark parity (1). 4 - Space parity (0). Stop Bit Setting may have the following values, all other values are invalid: 0 - 1 stop bit. 1 - 1.5 stop bit (valid with 5 data bit characters). 2 - 2 stop bits. Data Packet - None

43h - Extended Set Bit Rate
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Bit/Baud Rate            │ DWORD    │ ├───────────────────────────┼──────────┤ │ Fraction                 │ BYTE     │ └───────────────────────────┴──────────┘ "Bit Rate" is the desired bit/baud rate. The maximum bit rate supported by SIO is determined by the installed hardware. The IOCtl function "63h - Query Extended Bit Rate" can be used to determine the maximum bit rate allowed for the associated hardware.

SIO does not attempt to validate a given bit rate. This means that the hardware may not be able to generate the given bit rate. For example, if a computer has a standard communications card installed and if a bit rate of 65500 is specified, the nearest bit rate that can be generated will be set, 57600 in this case.

"Fraction" is used to set the fractional part of the bit rate when a high degree of accuracy is needed. As of this writing, SIO does not support a "Fraction" other than zero.

Some commonly used bit rates that can be set with this function are: 110      3600      115200  150       4800      230400  300       7200      460800  600       9600      921600 1200      19200 1800      28800 2000      38400 2400      57600 Data Packet - None

44h - Transmit Byte Immediate
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Character to Transmit    │ BYTE     │ └───────────────────────────┴──────────┘ "Character to Transmit" will be the next character loaded into the UART for transmission. If a previous transmit immediate byte is still pending, it is lost. This function does not wait for the character to transmit before returning.

This function may be used by an application program as one of a set of functions to implement its own Xon/Xoff type handshaking.

Data Packet - None

45h - Set Break Off
Parameter Packet - None

Look!! No Parameter Packet!

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Error Word           │ WORD     │ └───────────────────────────┴──────────┘ See function 6Dh "Query SIO Error" for a description of the SIO Error Word. This function does not reset any bits in the SIO Error Word.

46h - Set Modem Control Signals
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ DTR and RTS on mask      │ BYTE     │ ├───────────────────────────┼──────────┤ │ DTR and RTS off mask     │ BYTE     │ └───────────────────────────┴──────────┘ Attempted changes in the the setting of signals that are used as flow control signals are ignored. The current DCB determines if either or both RTS and DTR are used as a flow control signal.

The setting of bit 0 affects DTR and the setting of bit 1 affects RTS. Ones in the "on mask" specifies which of the two signals are to be turned on, and zeros in the "off mask" specify which of the two signals are to be turned off.

Some examples are: On Mask       Off Mask 01h           0FFh      Turn DTR on 00h            0FEh      Turn DTR off 02h           0FFh      Turn RTS on 00h            0FDh      Turn RTS off 03h           0FFh      Turn RTS and DTR on 00h            0FCh      Turn RTS and DTR off If both on and off are specified for the setting of a signal, the result is undefined.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Error Word           │ WORD     │ └───────────────────────────┴──────────┘ See function 6Dh "Query SIO Error" for a description of the SIO Error Word. This function does not reset any bits in the SIO Error Word.

47h - Hold Transmit
Parameter Packet - None

Data Packet - None

This function will disable the transmitter. The transmitter will not be enabled again unless IOCtl function 48h is issued. If the transmitter is already disabled, this call has no effect.

This function can be used as part of a set that allows an application to implement its own Xon/Xoff type handshaking.

Note that this is different from how COM.SYS implements this function. COM.SYS will re-enable the transmitter if an Xon is received while SIO will not.

48h - Start Transmit
Parameter Packet - None

Data Packet - None

This function will enable the transmitter, usually following an IOCtl function 47h. If the transmitter is already enabled, this call has no effect.

This function can be used as part of a set that allows an application to implement its own Xon/Xoff type handshaking.

4Bh - Set Break on
Parameter Packet - None

Look!! No Parameter Packet!

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Error Word           │ WORD     │ └───────────────────────────┴──────────┘ See function 6Dh "Query SIO Error" for a description of the SIO Error Word. This function does not reset any bits in the SIO Error Word.

53h - Write Device Control Block (DCB)
This is where the action is! See also function 73h (Read DCB).

Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Write Timeout            │ WORD     │ ├───────────────────────────┼──────────┤ │ Read Timeout             │ WORD     │ ├───────────────────────────┼──────────┤ │ Flags1                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Flags2                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Flags3                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Error Replacement Byte   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Break Replacement Byte   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Xon Character            │ BYTE     │ ├───────────────────────────┼──────────┤ │ Xoff Character           │ BYTE     │ └───────────────────────────┴──────────┘ "Write Timeout" The write timeout is given in hundredths of a second, relative to zero. That is, 0 specifies 0.01 seconds and 1 specifies 0.02 seconds.

"Read Timeout" The read timeout is given in hundredths of a second, relative to zero. That is, 0 specifies 0.01 seconds and 1 specifies 0.02 seconds.

"Flags1" is a bit flag. The bits in the flag specify the following:

Bits 1 and 0       DTR Control Mode. 00 - Disable changing DTR during Open and Close. 01 - Enable Changing DTR during Open and Close. 10 - DTR used for input handshaking (not supported by                        SIO). 11 - Invalid

Bit 2,   Must be zero Bit 3,   Off to ignore CTS. Forced on if RTS is handshake. Bit 4,   DSR is handshake. Not supported by SIO. Bit 5,   DCD required to transmit. Not supported by SIO. Bit 6,   DSR required to receive. Bit 7,   Must be zero.

"Flags2" is a bit flag. The bits in the flag specify the following:
 * Bit 0,   SIO is to honor Xon/XOff received from remote.
 * Bit 1,   SIO may send Xon/Xoff to the remote.
 * Bit 2,   Enable error replacement character. Not supported by SIO.
 * Bit 3,   Enable null stripping.  Not supported by SIO.
 * Bit 4,   Enable break replacement character. Not supported by SIO.
 * Bit 5,   Enable Full duplex.  Half duplex is not supported by SIO.
 * Bits 7 and 6 RTS Control Mode
 * 00 - Disable changing RTS during Open and Close.
 * 01 - Enable Changing RTS during Open and Close.
 * 10 - RTS used for input handshaking.
 * 11 - Toggle on transmit (half duplex). Not supported by SIO.

"Flags3" is a bit flag. The bits in the flag specify the following:
 * Bit 0,   Enable infinite write timeout processing. When set, a write timeout will not occur.
 * Bits 2 and 1 Read timeout processing
 * 00 - Invalid.
 * 01 - Normal read time out.
 * 10 - Wait for something. Reads will return before a timeout occurs if something received.
 * 11 - No Wait. Reads will return immediately with any available data.
 * Bits 4 and 3 FIFO Control
 * 00 - No change in FIFO state.
 * 01 - Disable FIFO buffers.
 * 10 - Enable FIFO buffers.
 * 11 - Dynamic enabling and disabling of FIFOS.
 * **Note, SIO forces bits 4 and 3 to "10".
 * Bits 6 and 5 Set receive trigger level
 * 00 - 1 character.
 * 01 - 4 characters.
 * 10 - 8 characters.
 * 11 - 14 characters.
 * **Note, SIO forces bits 6 and 5 to "10".
 * Bit 7 Transmit load count
 * 0 - Load 1 character.
 * 1 - Load 16 characters.
 * **Note, SIO forces bit 7 to "1".

"Error Replacement Byte" Not supported by SIO.

"Break Replacement Byte" Not supported by SIO

"Xon Character" Any value, default is 11h.

"Xoff Character" Any value, default is 13h.

Data Packet - None

54h - Write Extended Mode Parameters
Parameter Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Enhanced Flags1          │ BYTE     │ ├───────────────────────────┼──────────┤ │ Reserved                 │ DWORD    │ └───────────────────────────┴──────────┘ This function is not supported (ignored) by SIO. However the bits are defined here for completeness.

Enhanced Flags1
 * Bit 0 -  Enhanced mode hardware available (Query only 74h).
 * Bit 1 -  Enable enhanced mode.
 * Bits 3 and 2       DMA Receive Operation
 * 00 - Disable DMA receive capability.
 * 01 - Enable DMA receive capability.
 * 10 - Dedicate a DMA channel to receive.
 * 11 - Reserved.
 * Bits 5 and 4       DMA Transmit Operation
 * 00 - Disable DMA transmit capability.
 * 01 - Enable DMA transmit capability
 * 10 - Dedicate a DMA channel to transmit.
 * 11 - Reserved.
 * Bit 6 -  Receive in DMA mode (Query only, 74h).
 * Bit 7 -  Transmit in DMA mode (Query only, 74h).

Data Packet - None.

61h - Query Current Bit Rate
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Bit/Baud Rate            │ WORD     │ └───────────────────────────┴──────────┘ See function 41h for more information.

62h - Query Line Characteristics

Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Data Bits Per Character  │ BYTE     │ ├───────────────────────────┼──────────┤ │ Parity Setting           │ BYTE     │ ├───────────────────────────┼──────────┤ │ Stop Bit Setting         │ BYTE     │ ├───────────────────────────┼──────────┤ │ Transmitting Break       │ BYTE     │ └───────────────────────────┴──────────┘ See function 42h for a definition of Data, Parity and Stop Bits.

"Transmitting Break" is set to 1 if a break is being transmitted. Otherwise, it is set to zero.

63h - Query Extended Bit Rate
Parameter Packet - None

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Current Bit/Baud Rate    │ DWORD    │ ├───────────────────────────┼──────────┤ │ Fraction of Current      │ BYTE     │ ├───────────────────────────┼──────────┤ │ Minimum Bit/Baud Rate    │ DWORD    │ ├───────────────────────────┼──────────┤ │ Fraction of Minimum      │ BYTE     │ ├───────────────────────────┼──────────┤ │ Maximum Bit/Baud Rate    │ DWORD    │ ├───────────────────────────┼──────────┤ │ Fraction of Maximum      │ BYTE     │ └───────────────────────────┴──────────┘ "Current Bit/Baud Rate" is a 32 bit integer defining the current bit rate.

"Fraction of Current" is always 0 when returned by SIO.

"Minimum Bit/Baud Rate" is the minimum value that can be passed to SIO as a bit/baud rate.

"Fraction of Minimum" is always 0 when returned by SIO.

"Maximum Bit/Baud Rate" is the maximum value that can be passed to SIO as a bit/baud rate.

"Fraction of Maximum" is always 0 when returned by SIO.

64h - Query SIO Status
Parameter Packet - None

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Status Byte          │ BYTE     │ └───────────────────────────┴──────────┘ "SIO Status Byte" is a bit flag. The bits have the following meanings:
 * Bit 0 -  Set if SIO is waiting for CTS before transmitting.
 * Bit 1 -  Set if SIO is waiting for DSR before transmitting.
 * Bit 2 -  Set if SIO is waiting for DCD before transmitting.
 * Bit 3 -  Set if SIO is waiting because Xoff received or transmitter is disabled (see function 47h).
 * Bit 4 -  Reserved, not used by SIO.
 * Bit 5 -  Set if SIO is waiting because break is being sent.
 * Bit 6 -  Set if a transmit immediate is pending.
 * Bit 7 - Reserved, not used by SIO.

65h - Query Transmit Data Status
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Transmit Status          │ BYTE     │ └───────────────────────────┴──────────┘ "SIO Status Byte" is a bit flag. The bits have the following meanings:
 * Bit 0 -  Set if write in progress or pending.
 * Bit 1 -  Set if any data is in the transmit buffer.
 * Bit 2 -  Set if UART is currently transmitting.
 * Bit 3 -  Set if a transmit immediate is pending.
 * Bit 4 -  Set if an Xon needs to be sent.
 * Bit 5 -  Set if an Xoff needs to be sent.
 * Bit 6 -  Reserved
 * Bit 7 -  Reserved

66h - Query Current Modem Output Control Signals
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Modem Output Signals     │ BYTE     │ └───────────────────────────┴──────────┘ "Modem Output Signals" is a bit flag. The bits have the following meanings:
 * Bit 0 -  Set if DTR is currently on.
 * Bit 1 -  Set if RTS is currently on.
 * Bits 2-7 Reserved, set to zero by SIO.

67h - Query Current Modem Input Signals
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Modem Input Signals      │ BYTE     │ └───────────────────────────┴──────────┘ "Modem Output Signals" is a bit flag. The bits have the following meanings:
 * Bits 0-3 Reserved, set to zero by SIO.
 * Bit 4 -  Clear To Send (CTS) is active.
 * Bit 5 -  Data Set Ready (DSR) is active.
 * Bit 6 -  Ring Indicator (RI), trailing edge detected.
 * Bit 7 -  Data Carrier Detect (DCD) is active.

68h - Query Number of Characters in Receive Buffer
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Number of Bytes Buffered │ WORD     │ ├───────────────────────────┼──────────┤ │ Byte Size of the Buffer  │ WORD     │ └───────────────────────────┴──────────┘ Self explaining.

69h - Query Number of Characters in Transmit Buffer
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Number of Bytes Buffered │ WORD     │ ├───────────────────────────┼──────────┤ │ Byte Size of the Buffer  │ WORD     │ └───────────────────────────┴──────────┘ Self explaining.

6Dh - Query SIO Error
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Error Word           │ WORD     │ └───────────────────────────┴──────────┘ "SIO Error Word" is a bit flag. The bits have the following meaning:
 * Bit 0 -  Set if a buffer overrun has occurred.
 * Bit 1 -  Set if an overrun occurred at the UART.
 * Bit 2 -  Set if the UART detected a parity error.
 * Bit 3 -  Set if the UART detected a framing error.
 * Bits 4-15 Reserved, set to zero by SIO.

All bits of the SIO Error Word are reset prior to returning to the caller.

72h - Query SIO Event Information
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ SIO Event Word           │ WORD     │ └───────────────────────────┴──────────┘ "SIO Event Word" is a bit flag. The bits have the following meaning:
 * Bit 0 - Set when a receive character is transferred from the UART to the receive buffer.
 * Bit 1 - Set when a receive (Read) timeout occurs.
 * Bit 2 - Set if the transmit buffer is empty.
 * Bit 3 - Set if Clear To Send (CTS) has changed state.
 * Bit 4 - Set if Data Set Ready (DSR) has changed state.
 * Bit 5 - Set if Data Carrier Detect (DCD) has changed state.
 * Bit 6 - Set if a break has been detected.
 * Bit 7 - Set if a framing, parity, or overrun error has occurred.
 * Bit 8 - Set if trailing edge of Ring Indicator (RI) has occurred.
 * Bits 9-15 Reserved, set to zero by SIO.

All bits are reset prior to returning to the caller.

73h - Read Device Control Block (DCB)
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Write Timeout            │ WORD     │ ├───────────────────────────┼──────────┤ │ Read Timeout             │ WORD     │ ├───────────────────────────┼──────────┤ │ Flags1                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Flags2                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Flags3                   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Error Replacement Byte   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Break Replacement Byte   │ BYTE     │ ├───────────────────────────┼──────────┤ │ Xon Character            │ BYTE     │ ├───────────────────────────┼──────────┤ │ Xoff Character           │ BYTE     │ └───────────────────────────┴──────────┘ See function 53h for a description of the parameters.

74h - Read Enhanced Mode Parameters
Parameter Packet - None.

Data Packet ┌──────────────────────────────────────┐ │        Item                Type     │ ├───────────────────────────┬──────────┤ │ Enhanced Flags1          │ BYTE     │ ├───────────────────────────┼──────────┤ │ Reserved                 │ DWORD    │ └───────────────────────────┴──────────┘ See function 54h for a description of the Flags1 Byte.

Differences between SIO/VSIO and COM/VCOM
What follows is some of the differences between SIO/VSIO and COM/VCOM that are known to the author.

1 - COM.SYS will automatically seek out and support four comm ports, COM1 through COM4. SIO.SYS will automatically seek out and support only COM1 and COM2. If SIO.SYS is to support more than two comm ports, they must be defined in the command line that loads SIO.SYS. For example, DEVICE=SIO.SYS (COM3) (COM4) will cause SIO.SYS to support four comm ports.

2 - In the absence of overrides in the command line, COM.SYS will seek out four comm ports in the sequence of I/O ports 3F8h, 2F8h, 3E8h and 2E8h. The first port found in this sequence is given the logical name COM1, the second is COM2 etc. This means that the comm port at 2F8h could become COM1. In the opinion of the author, this confuses some users to frustration.

With no command line overrides, SIO.SYS uses a fixed I/O port concept. That is, COM1 is always at I/O port 3F8h, COM2 is always at 2F8h, etc. Another way of looking at this is; if no comm port exists at port 3F8h, then you do not have a COM1. SIO.SYS will not move another (found) comm port into the logical COM1 slot.

3 - VSIO opens a comm port for a DOS session with sharing allowed. VCOM uses an "exclusive use" open for DOS sessions.

4 - SIO.SYS always controls the FIFOs of the 16550 UART. SIO.SYS will not allow an application program (OS2 or DOS) to disable the FIFOs of a real 16550. The application may specify the transmit fifo load count.

5 - SIO.SYS will accept any number between 50 and 115200 (921600 if a Hayes ESP) as a valid baud rate. For example, if an application program attempts to set a baud rate of 9990 bps, COM.SYS will reject it and SIO.SYS will accept it.

6 - SIO/VSIO execute faster than COM/VCOM. This means that some applications, that are timing dependent, may not work under SIO/VSIO that do work under COM/VCOM.

7 - SIO/VSIO provides more reliable active flow control for DOS sessions. For example, if RTS/CTS handshaking is in use, VSIO processes the RTS settings by the DOS program while SIO completely controls the real RTS signal. COM/VCOM simply passes the RTS signal directly to the hardware.

8 - COM.SYS will block an application until a write completes. SIO will return to the application program immediately if all of the write data will fit into SIO's internal buffers.

Appendix A, Hardware Port and IRQ Assignments
I have obtained the following information from various sources. Accuracy is not guaranteed. In fact, nothing in this document is guaranteed.

Addresses and IRQs for COM1 and COM2 COM1 uses 03F8h and IRQ4 COM2 uses 02F8h and IRQ3

Defacto standard for COM3 and COM4 for PC, XT and AT COM3 uses 03E8h and IRQ4 COM4 uses 02E8h and IRQ3

Addresses and IRQ for COM3 through COM8 on the PS/2
 * COM3 uses 3220h and IRQ3
 * COM4 uses 3228h and IRQ3
 * COM5 uses 4220h and IRQ3
 * COM6 uses 4228h and IRQ3
 * COM7 uses 5220h and IRQ3
 * COM8 uses 5228h and IRQ3

All PCs (known to the author) prior to the PS/2 and EISA only use 10 bits to address hardware I/0 ports. Systems prior to the PS/2 and EISA can not address the standard PS/2 addresses for COM3 through COM8. If an AT or below attempts to address COM3 through COM8 using the PS/2 addresses, only the low 10 bits of the address are used. That is, the high digit of the hexadecimal address will be ignored. This means that any reference to COM3 through COM8 will actually address ports 220h through 22Fh on older PCs.

One should avoid expansion boards that use ports 220h through 22Fh unless the expansion board is a serial I/O board.

SIO will (attempt to) determine the hardware architecture (ISA/EISA and PS/2) that it is being executed on and use the appropriate hardware port addresses for COM1 thru COM4 as defaults.

Appendix B, SIO Chips
The following is a collection of comments developed from hearsay, random documents, experience, and technical specifications. So, take it with a grain of salt. Order information from the various manufactures if you want accurate information.

Very good reference books are available from National Semiconductor Corporation. They cover most of the SIO devices (also called UARTs) that you will find in many PCs and clones. I am not sure that books can be ordered directly from National semiconductor. They may require that you get it from a distributor. In any case, the address on the back of the one manual is:


 * National Semiconductor Corporation
 * 2900 Semiconductor Drive
 * P.O. Box 58090
 * Santa Clara, CA 95052-8090


 * Tel:(408)721-5000
 * TWX:(910)339-9240

8250
As best that I know, the 8250 was the first SIO chip (integrated circuit) that was used by the IBM PC and many clones. In my opinion, it was a poor choice on the part of IBM. I feel many superior devices, at comparable prices, were readily available. At that time, I feel the 8251A or the 8530 would have been better choices. But, they used the 8250 and therefore we must use it.

From a hardware standpoint the 8250 is a relatively slow device. It is advisable that programmers not perform successive inputs or outputs to this device. It seems that software programs can load the various registers of the 8250 faster than it can process the information. The 8250 had a total of 7 registers. The specifications state that 56kb is the maximum baud rate.

8250A
I believe the 8250A is the 8250 with some bug fixes. I have no idea what the bugs may have been. A quick glance at the specifications shows the speed of the 8250 and 8250A to be much the same. The 8250A added an 8th register. This additional register enables software to detect if an 8250 is installed. The specifications state that 56kb is the maximum baud rate.

16450
The 16450 seems to be a speeded up version of the 8250A. There is no direct way (that I know of) for software to detect the difference between an 8250A and a 16450. I believe the 16450 was developed to eliminate the need for software to insert delays between successive accesses to the device. The specifications indicate the 16450 is a much faster device than its predecessors. The additional speed is only the speed at which the processor can access the device. The maximum baud rate for the 16450 is still stated at 56kb. However, I have been told by some people that they have run the 16450 successfully at much higher speeds. I do not believe there was ever a 16450A.

16C451
The 16C451 is a CMOS version of the 16450. CMOS is a term for the material and manufacturing process used to make the part. CMOS typically uses less power than other technologies. If you are not designing hardware, you should view the 16C451 as a 16450.

16550 (Non A)
It is hard to find a 16550 (Non A). I was told by National Semiconductor that they did everything they could to get all 16550s back. SIO will detect a 16550 and tell you if you have one. I am told that the 16550 was installed in early PS/2 systems.

The 16550 was the first shot at a FIFOed version of the 8250 family from National semiconductor. However, I was told by National Semiconductor that the FIFOs of the 16550 are not reliable and they should not be enabled. SIO will treat a 16550 like a 16450. In this mode, they are reliable. National Semiconductor would not provide me with a specification for the 16550. However, I suspect its maximum baud rate is the same as the 16550A which is 256kb.

16550A, 16550AF and 16550AFN
In the manuals that I have, National Semiconductor does not explain the differences between the 16550A and the 16550AF. I suspect the AF part may have a few bug fixes. I believe the N in AFN describes packaging, ceramic versus plastic, DIP versus surface mount etc.

In the opinion of the author, there is no substitute for the 16550A (and its successors) in the 8250 type series. The 16550A is compatible with most software written for the entire family of 8250 type devices. Programs that are 16550A aware can provide much improved performance over previous devices.

The maximum baud rate for the 16550A is specified at 256kb. However, due to the hardware design of the PC et al, 115kb is the maximum baud rate that can be programmed by software.

The 16550A can be plugged into the same socket that contains an 8250, 8250A or 16450. If your SIO expansion board has the SIO chips in sockets, you can upgrade to the 16550A by simply removing the old chips and replacing them with 16550As.

The key to the performance increase of the 16550A is its FIFOs. It has 16 byte FIFOs for both transmit and receive data.

16550s Made by Western Digital
I have been told, but I have not verified for myself, that 16550s made by Western Digital have a problem with their FIFOs when working at 2400 baud or below.

16C551
The 16C551 is a CMOS version of the 16550AF. See the above description of the 16C451 for a discussion of CMOS. Do not feel you need to upgrade from a 16550A or AF to a 16C551. There is no gain from an existing users point of view.

16C552
The 16C552 is two 16C551s on a single chip.

16C554
The 16C554 is four 16C551s on a single chip.

82510
I believe Intel is the only company that manufactures the 82510. The 82510 is feature rich with several modes of operation. Its default mode is to operate as a 16450. The 82510 has a 4 byte FIFO for both transmit and receive data. A 4 byte FIFO is sufficient to provide significant performance over a basic 16450.

The 82510 is small in size. Therefore, it is found in many lap tops.

The 82510 is somewhat of a sleeper. I believe it would be much more widely used if Intel had promoted it more. However, given a choice between the 82510 and the 16550A, I would select the 16550A.

16650
The 16650 by Startech seems a good logical step in the evolution of the 8250 type UARTs. One of the many flavors of the 16650 is a package that is pin compatible with the 40 pin (DIP) 16550s. This means that the 16650 can be placed into the same socket as any 16550, 8250, etc.

The 16650 has enhanced the FIFOs to 32 bytes, added on chip flow control ability, and increases the maximum bit rate to 460800. The on chip flow control is a really nice feature. On chip flow control practically eliminates the possibility of missed receive characters. On chip flow control also means that some devices that require immediate attention when it sends Xoff, like the Seiko Label Printer, will work much better in environments like OS/2 and Windows.

The 32 byte FIFOs of the 16650 is an improvement over the 16550, but is still a disappointment. I feel that 1k, or larger, FIFOs would have been a much better choice. When I quizzed Startech about this, they replied that the 32 byte FIFOs were chosen to keep the cost down. They added that if the 16650 is successful, they plan a 16750 with larger FIFOs.

The 16650 powers up in a 16550 compatible mode, meaning most software written for the 16550 should work.

16750 from Texas Instruments
The 16750 from TI is an improvement over the 16550, but the omission of software flow control (Xon/Xoff) makes it inferior to the 16650, in the opinion of the author. The 16750 has a 64 byte fifo and hardware flow control. It is a good choice for a uart.

ComBic
The ComBic is a very impressive UART used on the Hayes ESP card and some others. The ComBic is basically a 16550 UART with on chip flow control and 1k FIFOs and a maximum bit rate of 921600. Like the 16650, on chip flow control practically eliminates the possibility of missed receive characters. On chip flow control also means that some devices that require immediate attention when it sends Xoff, like the Seiko Label Printer, will work much better in environments like OS/2 and Windows.

The ComBic has two modes of operation, compatibility mode and enhanced mode. In compatibility mode, the UART acts as a 16550. However, when in compatibility mode, the 1k FIFOs and on chip flow control can still be used. In enhanced mode, software gains the ability to look into the FIFOs and determine the exact number of bytes loaded. This feature enables software the use block input and output to the ComBic which greatly reduces processor overhead.