LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices

Reply
 
Search this Thread
Old 03-24-2009, 09:30 AM   #1
manaav
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Rep: Reputation: 0
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
 
Old 03-24-2009, 06:08 PM   #2
JaksoDebr
Member
 
Registered: Mar 2009
Distribution: Fedora, Slackware
Posts: 104

Rep: Reputation: 21
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

Last edited by JaksoDebr; 04-02-2009 at 06:06 AM.
 
Old 03-25-2009, 12:43 AM   #3
manaav
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Original Poster
Rep: Reputation: 0
I will read and try out this solution. Thanks a lot.

Regards,
Manav
 
Old 03-25-2009, 04:38 AM   #4
manaav
LQ Newbie
 
Registered: Sep 2008
Posts: 4

Original Poster
Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Question on using mmap to access physical memory Gnu2Linux2 Linux - Embedded & Single-board computer 1 10-05-2009 04:54 AM
How to access Physical memory not mapped in kernel sbc Programming 0 02-09-2009 10:13 AM
How to access physical (as opposed to virtual) memory in C language for a Linux app. ss729 Programming 2 12-23-2008 04:02 PM
mmap a physical address fardad Programming 3 10-30-2008 12:30 PM
How to access physical memory in C? cyu021 Programming 6 03-27-2005 05:16 AM


All times are GMT -5. The time now is 06:57 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration