In Linux, I am trying to write a user land app that can inspect some physical memory (for debug purposes)

StackOverflow https://stackoverflow.com/questions/17242463

Question

I am trying to write a user land app that can inspect some physical memory (for debug purposes).

od -j <0xknown_good_physical_address> -N 256 /dev/mem 

(w/ CONFIG_STRICT_DEVMEM=n) crashes the OS.

functions ioremap, phys_to_virt, and phys_to_page don't exist in my /usr/include dir. I researched and tried the make headers_install procedure but the functions still don't get into my usr/include dir. AFAIK that means they're not available for user-land Apps. Does anyone know how to access physical memory from a user space app? One more FYI, the physical address that I'm trying to read is a PCI BAR that I got from doing a lspci -v in the "memory at" line.

Was it helpful?

Solution

You can mmap() those addresses to get a virtual address that you can read and write depending on how you mmap.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top