Well I have some confusions about memory mapped io and port based io. Questions are:-
Thanks in advance.
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.