Mostly computers today are equipped with the parallel ports and they are used to make connections between pc and printers.
Earlier there was a compatibility issue with parallel ports,like one printer of a company cant be connected to a computer of another manufacture. So later all those manufactures came together to resolve this compatibility issue and developed a new IEEE standard for parallel ports.
They follow IEEE standard 1284-1994. And chip number is 74LS244. This chip has 3 registers ,i.e Data register,status register and control register.
The new standard also defined the compatibility mode that parallel port can transfer data in byte mode and nibble mode.
Standard addresses for a parallel port is 378H,3BCH,278H.Mostly computer acquire 378H ,379H and 37AH for parallel port.
But these addresses may change from machine to machine. When computer turns on, BIOS assign LPT1,LPT2,LPT3(LPT=Line printer terminal)to ports.
First BIOS look at 3BCH address, if a parallel port is found there then BIOS put label LPT1 on that address. And same procedure is followed for other addresses too.
A parallel port is a 25 pin port. Pin number 1,14,16,17 are for control registers. Pin 2 to pin 9 is for data registers. Pin 10,11,12,13,15 are for status registers. Pin number 18 to 25 are ground.
Normally when a computer is turned on, its the kernel who acquire the parallel ports and you can see it by going into proc/ioports. But if we want our device to communicate with the I/O port then we need to acquire those ports from the kernel. There are certain commands in linux by which we can get those ports . All these commands are defined in <linux/ioport.h> and <linux/io.h>.
struct resource *request_region(): Registration interface which allows your kernel to claim the ports it need.
void release_region(): When things are done with the I/O ports, use this command to release them.
int check_region(): If you want to check whether the requested address regions are available or not , use this command.
unsigned inb() and void outb(): These commands are used to read/write to and from the parallel port. Used in byte transfer.
unsigned inw() and void outw(): There are used to access 16 bit ports i.e one work transfer and receive.
unsigned inl() and void outl(): these are used to access 32 bit ports or 32 bit longword.