-   Linux - Newbie (
-   -   Help needed: mmap and physical memory access (

manaav 03-24-2009 09:30 AM

Help needed: mmap and physical memory access
Hi All,

For some testing purpose I need to use mmap having file descriptor received out of /dev/mem. But, I have no idea about what offset I should use. It would certainly be very helpful if someone could suggest as what offset should I use. The required (desired) length is 1MB.
And, system I am using is FC9.

Manav Swargiary

JaksoDebr 03-24-2009 06:08 PM

Based on the mmap man page: "offset must be a multiple of the page size as returned by sysconf(_SC_PAGE_SIZE)."

For sysconf itself see 'man sysconf'. The suggested solution is:

#include <unistd.h>
offset = sysconf(_SC_PAGE_SIZE);

Linux Archive

manaav 03-25-2009 12:43 AM

I will read and try out this solution. Thanks a lot.


manaav 03-25-2009 04:38 AM

offset = sysconf(_SC_PAGE_SIZE);

This does not return the offset, instead it returns the size of a page.
I need a portion of a physical memory (preferably 1 MB) which is unused and can be accessed from user space using mmap. Offset (relative to base address) should point to an unused physical memory segment.

All times are GMT -5. The time now is 05:53 PM.