From: j.neuschaefer@gmx.net (Jonathan Neuschäfer)
To: kernelnewbies@lists.kernelnewbies.org
Subject: read PCI memory and config spyce through /dev/mem
Date: Tue, 7 May 2013 18:20:53 +0200 [thread overview]
Message-ID: <20130507162053.GA3194@debian.debian> (raw)
In-Reply-To: <6D83E89737156549AEA25EF9ED712C5D012D8D@DEFTHW99EK1MSX.ww902.siemens.net>
On Tue, May 07, 2013 at 06:35:43AM +0000, Warlich, Christof wrote:
[...]
> Furthermore, read / write access through a simple program using /dev/mem
> _does_ work as expected:
>
> #include <unistd.h>
> #include <stdio.h>
> #include <fcntl.h>
> #include <assert.h>
> #include <sys/mman.h>
> int main( int argc, char *argv[]) {
> char *mem;
> int fd;
> fd = open ("/dev/mem", O_RDWR);
> assert(fd >= 0);
> mem = mmap(NULL, getpagesize(), PROT_READ|PROT_WRITE, MAP_SHARED, fd, (off_t) 0x81423000);
> assert(mem != MAP_FAILED);
> printf("Memory pointer: %p\n", mem);
> printf("The PCI memory is : %#x\n", *mem);
> *mem = *argv[1];
> printf("The PCI memory is : %#x\n", *mem);
> munmap(mem, getpagesize());
> close(fd);
> return 0;
> }
>
> Calling it, yields:
>
> $ led 4
> Memory pointer: 0xb7678000
> The PCI memory is : 0x33
> The PCI memory is : 0x34
>
> And the LED matrix display being behind that address switches from 3 to
> 4 as expected.
>
> Thus, I still cannot see why the access through /dev/mem using dd doesn't
> work.
I suspect dd uses read instead of mmap.
Thanks,
Jonathan Neusch?fer
next prev parent reply other threads:[~2013-05-07 16:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-05-06 14:44 read PCI memory and config spyce through /dev/mem Warlich, Christof
2013-05-06 15:19 ` Valdis.Kletnieks at vt.edu
2013-05-07 6:35 ` Warlich, Christof
2013-05-07 16:20 ` Jonathan Neuschäfer [this message]
[not found] ` <1367981063.2020.2.camel@junwork.opensuse.com>
2013-05-08 6:49 ` Warlich, Christof
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=20130507162053.GA3194@debian.debian \
--to=j.neuschaefer@gmx.net \
--cc=kernelnewbies@lists.kernelnewbies.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.