Memory Mapped vs I/O Mapped Input Output

Memory Mapped vs I/O Mapped Input Output

I'm currently reading a computer organization book and i'm so confused about Input/Output mechanism and have lots of questions in my mind.

As i understood there are two concepts for communicating with peripherals, first one is Memory Mapped I/O and the other one is I/O(Port) Mapped I/O.If the architecture is based on Memory Mapped I/O there are no special I/O instructions like "in","out" etc and device registers are mapped to memory address space so we can read or write to peripheral ports by "mov" instruction.On the other hand if architecture is based on I/O Mapped I/O, device registers are mapped to I/O address space which is completely separated from memory address space and cpu uses special instructions("in","out","ins","outs" ) for reading or writing to I/O Mapped device registers.

Re: Memory Mapped vs I/O Mapped Input Output

Memory mapped and Port I/O are not mutually exclusive. It is often the case that devices that need large amounts of data transfer use Memory Mapped I/O.

I/O ports typically have a much smaller address space than the memory address space, and they usually don't have any built in caching. In the 80386, which was the last x86 I used in a HW design, the I/O address space was 64K bytes.

There is also another I/O mode called DMA (Direct Memory Access) used promarily by disk and tape controllers, where the CPU tells the peripheral where to get or put the data in the RAM address space, and the peripheral periodically steals memory cycles to transfer data to/from RAM under it's command.

Memory mapped I/O is not limited to "registers". The biggest part of the graphic card's memory map is for the screen buffer.

Note that there can be very interesting interactions between the on-chip memory cache and memory mapped I/O. There has to be a way to bypass the cache to ensure that all read and write instructions the I/O device's memory range physically occur to the device and don't get short-circuited by the cache.