MMAP and MUNMAP
Mmap() is a system call to map a file content in application address space. This are needed if we want to read or write file content directly from memory instead of file read/write.
Source Code
Mapping file content using mmap and reading content by dereferencing pointer is very common example. We are doing something different here. We are mapping MMIO memory using /dev/mem device. Linux has memory device to map system and MMIO memory address space. Once address range is mapped to user space then we can alter MMIO register with simple pointer operations. This mechanism is very common for accessing in embedded system for accessing GPIO and MMIO registers directly from user mode. We have used a ARM9 board and figured out GPIO pin which can be set to high or low. We connected a LED with 1K resistor to ground. We are toggling MMIO register bit and LED will blink as we are altering the bits.
About our authors: Team EQA
You have viewed 1 page out of 252. Your C learning is 0.00% complete. Login to check your learning progress.