Here's a piece of simple example code for I/O port access:
/*
* example.c: very simple example of port I/O
*
* This code does nothing useful, just a port write, a pause,
* and a port read. Compile with `gcc -O2 -o example example.c',
* and ru.htm. Remember
that since you cannot use IRQs or DMA in a user-mode program, you will
probably have to write a kernel driver to use ECP/EPP; I think someone
is writing such a driver, but I don't know the details.
The port BASE+0 (Data port) controls the data signals of the port (D0
to D7 for bits 0 to 7, respectively; states: 0 = low (0 V), 1 = high
(5 V)). A write to this port latches the data on the pins. A read
returns the data last written in standard or extended write mode, or
the data in the pins from another device in extended read mode.
The port BASE+1 (Status port) is read-only, and returns the state
of the following input signals:
- Bits 0 and 1 are reserved.
- Bit 2 IRQ status (not a pin, I don't know how this works)
- Bit 3 ERROR (1=high)
- Bit 4 SLCT (1=high)
- Bit 5 PE (1=high)
- Bit 6 ACK (1=high)
- Bit 7 -BUSY (0=high)
(I'm not sure about