Information Technology Reference
In-Depth Information
Port mapped I/O
Today, memory mapped I/O is the dominant paradigm for accessing I/O device's con-
trol registers. However an older style, port mapped I/O, is still sometimes used. Notably,
the x86 architecture supports both memory mapped I/O and port mapped I/O.
Port mapped I/O is similar to memory mapped I/O in that instructions read from and
write to specified addresses to control I/O devices. There are two differences. First,
where memory mapped I/O uses standard memory-access instructions (e.g., load and
store ) to communicate with devices, port mapped I/O uses distinct I/O instructions. For
example, the x86 architecture uses the in and out instructions for port mapped I/O.
Second, whereas memory mapped I/O uses the same physical address space as is
used for the system's main memory, the address space for port mapped I/O is distinct
from the main memory address space.
For example, in x86 I/O can be done using either memory mapped or port mapped
I/O, and the low-level assembly code is similar for both cases:
Memory mapped I/O
MOVregister,memAddr //Toread
MOVmemAddr,register //Towrite
Port mapped I/O
INregister,portAddr //Toread
OUTportAddr,register //Towrite
Port mapped I/O can be useful in architectures with constrained physical memory
addresses since I/O devices do not need to consume ranges of physical memory ad-
dresses. On the other hand, for systems with sufficiently large physical address spaces,
memory mapped I/O can be simpler since no new instructions or address ranges need
to be defined and since device drivers can use any standard memory access instruc-
tions to access devices. Also, memory mapped I/O provides a more unified model for
supporting DMA—direct transfers between I/O devices and main memory.
without requiring additional processor involvement.
After setting up a DMA transfer, the operating system must not use the
target physical pages for any other purpose until the DMA transfer is done.
The operating system therefore \pins" the target pages in memory so that they
can not be reused until they are unpinned. For example, a pinned physical
page cannot be swapped out to disk and then remapped to some other virtual
address.
Interrupts. The operating system needs to know when I/O devices have com-
pleted handling a request or when new external input arrives. One option is
polling , repeatedly using memory mapped I/O to read a status register on the
Definition: polling
device. Because I/O devices are often much slower than CPUs and because
inputs received by I/O devices may arrive at irregular rates, it us usually better
for I/O devices to use interrupts to notify the operating system of important
 
Search WWH ::




Custom Search