From: David Hawkins <dwh@ovro.caltech.edu>
To: Bruce_Leonard@selinc.com
Cc: linuxppc-embedded-bounces+brucle=selinc.com@ozlabs.org,
linuxppc-embedded@ozlabs.org
Subject: Re: How do I access nvRAM from user space?
Date: Thu, 25 Sep 2008 11:14:10 -0700 [thread overview]
Message-ID: <48DBD4F2.1060206@ovro.caltech.edu> (raw)
In-Reply-To: <OF871A5E9F.D762FCD5-ON882574CF.005EDA9D-882574CF.005F1AE2@selinc.com>
Hi Bruce,
> Thanks for the reply. So if my nvSRAM device is located at 0xb0000000 in
> physical memory, what would the mmap() call look like? Also, do I need to
> have a device tree entry for the kernel to know about the memory? I can
> access the device in uboot so I know it works, but I can't figure out the
> mmap to get it from linux
Its pretty much:
/* Open /dev/mem and map it */
printf(" * open /dev/mem\n");
fd = open("/dev/mem", O_RDWR | O_SYNC);
if (fd < 0) {
printf("Open /dev/mem failed - %s\n",
strerror(errno));
return -1;
}
printf(" * map %d page(s) (%d-bytes) at address 0x%.8X\n",
mem_pages, mem_size, mem_phys);
mem_addr = (char *)mmap(
0,
mem_size,
PROT_READ|PROT_WRITE,
MAP_SHARED,
fd,
mem_phys);
if (mem_addr == (char *)MAP_FAILED) {
printf("Error: mmap failed\n");
close(fd);
return -1;
}
I'll send you the code I ripped that from, and another
example from the Busybox code.
Cheers,
Dave
prev parent reply other threads:[~2008-09-25 18:14 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-25 3:18 How do I access nvRAM from user space? Bruce_Leonard
2008-09-25 5:45 ` yanjun.luo
2008-09-25 15:53 ` David Hawkins
2008-09-25 17:18 ` Bruce_Leonard
2008-09-25 18:13 ` Bruce_Leonard
2008-09-25 18:14 ` David Hawkins [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=48DBD4F2.1060206@ovro.caltech.edu \
--to=dwh@ovro.caltech.edu \
--cc=Bruce_Leonard@selinc.com \
--cc=linuxppc-embedded-bounces+brucle=selinc.com@ozlabs.org \
--cc=linuxppc-embedded@ozlabs.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).