Dr.Knowitall
Dr.Knowitall

Reputation: 10468

How does device mmap work in contrast to I/O address ports?

I was wondering if Linux sees a difference between mmap to a peripheral devices memory in comparision to reading/writing to the device via I/O Ports. From what I've learned in my Assembly class, we pretty much looked at I/O port addressing in the same light as memory addressing. So I suppose I was wondering if I were to rw to the I/O my port my device is connected to, is that the same thing mmaping to that devices memory?

Thanks

Upvotes: 1

Views: 1420

Answers (3)

Ilya Matveychikov
Ilya Matveychikov

Reputation: 4024

The vm_area_struct contains vm_flags field. In case of the special mapping it contains VM_PFNMAP or VM_IO flags. See struct vm_area_struct, VM_PFNMAP and VM_IO definitions at LXR.

Upvotes: 0

wildplasser
wildplasser

Reputation: 44230

I think the OP is confusing three things:

  • mmap() is a way for application programs to perform some operations on page registers and/or the MMU.

  • Memory mapped I/O is a hardware architecture concept: instead of having separate buses and operations for I/O, some area of the address space is dedicated to I/O operations. (the 68K processor family uses memory mapped I/O, and IBM's AIX too, IIRC).

  • DMA means that not only the CPU(s), but also the I/O devices can read and write to and from (parts of) physical memory.

Upvotes: 1

I/O ports are not memory. Some hardware (e.g. graphical cards) are interfaced thru the memory bus, not only thru the I/O port bus.

For hardware having a memory interface (that is, viewed as a range of memory to the CPU), you might use mmap.

The X11 server Xorg is very often mmap-ing the graphical cards.

Upvotes: 2

Related Questions