What exactly is memory mapped io and port based io

Aryan Kumar

Well I have some confusions about memory mapped io and port based io. Questions are:-

  1. In port based io if I write to a port will it affect the corresponding memory address or not and vise versa.
  2. Does x86 uses port based io or memory mapped io.(I think it is motherboard dependent and x86 can use both, correct me if I am wrong).
  3. In memory mapped io there are some problems related to cache, what are those problems?
  4. Can we use both types of io on a device?
  5. How is DMA used in context with hdd?

Thanks in advance.

Peter Cordes

IO space (in / out) is a separate address-space from physical memory, including in modern PCI / PCIe devices. It depends on the device how you need to talk to it; modern devices usually only (or mostly) have MMIO registers (in physical address space), because MMIO is more efficient than port IO.

Parts of physical address space containing MMIO registers should be set as uncacheable in your MTRR or PAT; apparently CPUs don't support cacheable memory types at all for MMIO, and can lock up if you try. (You can use WC write-combining memory for stuff like VGA RAM, i.e. device memory, allowing write combining to produce 64-byte store transactions. https://sites.utexas.edu/jdm4372/2013/05/29/notes-on-cached-access-to-memory-mapped-io-regions/)

How is DMA used in context with hdd?

See https://wiki.osdev.org/AHCI for how to tell the controller (with MMIO accesses) you want it to DMA data to or from physical RAM.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at


Login to comment