How does I/O ports work in linux kernel

Manavendra Nath Manav mnm.kernel at gmail.com
Fri Oct 5 02:57:40 EDT 2012


On Mon, Oct 1, 2012 at 6:59 PM, Vineel Reddy <vineel.kovvuri at gmail.com> wrote:
> Hi All,
>
> I have read about I/O ports recently from many recommended books for linux.
> Each of the book effectively taught me only two things
> 1. Reserving the I/O ports using request_region(...) function
> 2. Then access the I/O ports using inb, outb functions
>
> Apart from repeated reading and googling I still have the following queries
>
> Question 1:
> The one thing that the books haven't sufficiently answered is 'how does
> linux know to which device it should write or read from when we use inb and
> outb functions'?
> Say for example we are dealing with parallel port for instance. How does
> linux know that the parallel port is registered at 0x378 ?
>
> Question 2:
> Who registers the parallel port at 0x378 ?
> I have read somewhere that all the mapped ports can be found in
> /proc/ioports.
> Who generates this map. BIOS? or the Kernel?
>
> Question 3:
> How is /proc/ioports different from /proc/iomem(System Memory Map). Is there
> any overlap between them(because 0x378  is also an address, so it must be
> some where in the system map. right?) ?
>
> Question 4:
> Is 0x378 the physical address in the system memory map generated by BIOS as
> stated here
> http://www.pcguide.com/ref/mbsys/res/ioSummary-c.html
> Or a logical address from above table remapped inside the RAM which is in
> turn mapped at 0x00100000 physical
>
>
> I am banging my head with all of these bits and pieces of information
> without having a clue to stitch all of them together.
> Please give me some pointers to understand them.
> Thanks in advance.
>
>
> Regards
> Vineel Kumar Reddy Kovvuri
>
>
>
> _______________________________________________
> Kernelnewbies mailing list
> Kernelnewbies at kernelnewbies.org
> http://lists.kernelnewbies.org/mailman/listinfo/kernelnewbies
>

>From http://en.wikipedia.org/wiki/LPT

Most PC-compatible systems in the 1980s and 1990s had one to three
ports, with communication interfaces defined like this:
LPT1: I/O port 0x3BC, IRQ 7 (usually in monochrome graphics adapters)
LPT2: I/O port 0x378, IRQ 7 (dedicated IO cards or using a controller
built into the mainboard)
LPT3: I/O port 0x278, IRQ 5 (dedicated IO cards or using a controller
built into the mainboard)
If no printer port is present at 0x3BC, the second port in the row
(0x378) becomes LPT1 and 0x278 becomes LPT2. Sometimes, printer ports
are jumpered to share an interrupt despite having their own IO
addresses (i.e. only one can be used interrupt-driven at a time). In
some cases, the BIOS supports a fourth printer port as well, but the
base address for it differs significantly between vendors. Since a
fourth printer port is conflictive with other features on PS/2
machines, it typically requires special drivers in most environments.

See also http://en.wikipedia.org/wiki/Input/Output_Base_Address

-- 
Manavendra Nath Manav



More information about the Kernelnewbies mailing list