LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help needed: mmap and physical memory access (https://www.linuxquestions.org/questions/linux-newbie-8/help-needed-mmap-and-physical-memory-access-714057/)

manaav 03-24-2009 08: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.

Regards,
Manav Swargiary

JaksoDebr 03-24-2009 05: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-24-2009 11:43 PM

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

Regards,
Manav

manaav 03-25-2009 03: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 02:14 PM.