Linux Kernel Architecture

(Jacob Rumans) #1

Chapter 6: Device Drivers


6.6.2 I/O Memory


One of the most important aspects of the resource concept deals with how I/O memory is distributed
because this is the main way on all platforms (with the exception of IA-32, where great importance is
attached to I/O ports) of communicating with peripherals.

I/O memory includes not only the memory regions used directly to communicate with expansion devices
but also the regular RAM and ROM memory available to the system and included in the resource list
(which can be displayed using theiomemfile in theprocfilesystem).

wolfgang@meitner>cat /proc/iomem
00000000-0009e7ff : System RAM
0009e800-0009ffff : reserved
000a0000-000bffff : Video RAM area
000c0000-000c7fff : Video ROM
000f0000-000fffff : System ROM
00100000-07ceffff : System RAM
00100000-002a1eb9 : Kernel code
002a1eba-0030cabf : Kernel data
07cf0000-07cfefff : ACPI Tables
07cf0000-07cfefff : ACPI Tables
07cff000-07cfffff : ACPI Non-volatile Storage
...
f4000000-f407ffff : Intel Corp. 82815 CGC [Chipset Graphics Controller]
f4100000-f41fffff : PCI Bus #01
f4100000-f4100fff : Intel Corp. 82820 (ICH2) Chipset Ethernet Controller
f4100000-f4100fff : eepro100
f4101000-f41017ff : PCI device 104c:8021 (Texas Instruments)
...

All allocated I/O memory addresses are managed in a resource tree that uses the global kernel variable
iomem_resourceas its root. Each text indentation represents a child level. All entries with the same
indentation level are siblings and are linked as such. Figure 6-21 shows the parts of the data structures in
memory from which the information in theprocfilesystem is obtained.

However, reservation of a memory region is not the only action needed when using I/O memory.
Depending on bus system and processor type, it may be necessary to map the address space of an expan-
sion device into kernel address space before it can be accessed (this is known assoftware I/O mapping).
This is achieved by setting up the system page tables appropriately using theioremapkernel function,
which is available at various points in the kernel sources and whose definition is architecture-specific.
The likewise architecture-specificiounmapfunction is provided to unmap mappings.

Implementation requires, in part, long and complex manipulation of the process tables. I won’t there-
fore discuss it in detail, particularly as it varies greatly from system to system and is not important for
an understanding of device drivers. What’s more important is that — in general terms — a physical
address is mapped into the virtual address space of the processor so that it can be used by the kernel.
As applied to device drivers, this means that the address space of an expansion bus is mapped into the
address space of the CPU, where it can then be manipulated using normal memory access functions.
Free download pdf