Information on a 16550 is based on information from
HELPPC.EXE 2.1 and results from National Semiconductor's
COMTEST.EXE diagnostics program. This code aims to emulate
a 16550A as accurately as possible, using just reasonably
POSIX.2 compliant code. In some cases, this code does a
better job than OS/2 serial emulation (in non-direct mode)
done by its COM.SYS driver! There may be about 100 kilobytes
of source code, but nearly 50% of this size are comments!

This 16550A emulator never even touches the real serial ports,
it merely traps port writes, and does the I/O via file functions
on a device in /dev. Interrupts are also simulated as necessary.

One of the most important things to know before programming
this serial code, is to understand how the com[] array works.

Most of the serial variables are stored in the com[] array.
The com[] array is a structure in itself. Take a look at the
'serial_t' struct declaration in the ../include/serial.h module
for more info about this. Only the most commonly referenced
global variables are listed here:

config.num_ser

Number of serial ports active.

com[x].base_port

The base port address of emulated serial port.

com[x].real_comport

The COM port number.

com[x].interrupt

The PIC interrupt level (based on IRQ number)

com[x].mouse

Flag mouse (to enable extended features)

com[x].fd

File descriptor for port device

com[x].dev[]

Filename of port port device

com[x].dev_locked

Flag whether device has been locked

The arbritary example variable 'x' in com[x] can have a minimum
value of 0 and a maximum value of (config.numser - 1). There
can be no gaps for the value 'x', even though gaps between actual
COM ports are permitted. It is strongly noted that the 'x' does
not equal the COM port number. This example code illustrates
the fact, and how the com[x] array works:

for (i = 0; i < config.numser; i++)
s_printf("COM port number %d has a base address of %x",
com[i].real_comport, com[i].base_port);

The FOSSIL emulation requires a memory-resident DOS module,
FOSSIL.COM. If you don't load it, the code in fossil.c does nothing,
permitting you to use another FOSSIL driver such as X00 or BNU.

The emulation isn't as complete as it could be. Some calls aren't
implemented at all. However, the programs I've tried don't seem to
use these calls. Check fossil.c if you're interested in details.

I've done only minimal testing on this code, but at least the
performance seems to be quite good. Depending on system load, I got
Zmodem speeds ranging from 1500 to nearly 3800 cps over a 38400 bps
null-modem cable when sending data to another PC. Zmodem receive,
however, was only about 2200 cps, since Linux tried to slow down the
sender with flow control (I'm not sure why).

All of this serial code is free software; you can redistribute it
and/or modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2 of
the License, or (at your option) any later version.