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
0

Comments

0 comments
Login to comment

Related

Why does Java memory mapped buffer cause massive unexpected disk IO?

Is virtual memory used when using Port-mapped I/O?

What are memory mapped page and anonymous page?

What is the difference between writing to a file and a mapped memory?

What is the difference between DMA and memory-mapped IO?

System.IO.FileSystemWatcher and mapped network drives

Java memory model - what exactly is flushed to memory on crossing memory barrier?

IO from a mapped file vs IO using filestreams

What exactly is the "memory history" command?

What is the performance impact of virtual memory relative to direct mapped memory?

Async IO without completion port?

What exactly is a 'crate' in the Cargo ecosystem and what is the mapping to what is on crates.io?

What is meant by memory-mapped video?

Memory mapped IO - how does IO device know value has changed?

Does it take longer to read memory-mapped IO than regular memory on a microcontroller?

What is the benefit of calling ioread functions when using memory mapped IO

What exactly is io_uring?

SOCKET.io not listening on a port

Building boost without memory-mapped IO

mmap IO port address for serial port

Where exactly does ChronicleMap create the memory mapped file for a persisted map?

pump.io port in URL

IO Completion port Linux equivalent

Port hopping on IO::SOCKET::INET

How to do memory mapped IO on custom data types?

"Unhandled exception: java.io.IOException" compile time error: What exactly is it for?

Why do we need memory mapped IO?

Setting up a dummy memory mapped IO in Embedded Unit-Tests with a template-based API

What are memory mapped files?