LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* ppc405ep GPIO register mmap'ing invalid argument
@ 2004-04-27 22:57 Charles Frey
  0 siblings, 0 replies; 4+ messages in thread
From: Charles Frey @ 2004-04-27 22:57 UTC (permalink / raw)
  To: linuxppc-embedded


Hey,
 I'm trying to read and write from the GPIO_OR register on an ibm 405ep
(0xEF600700), and just as I've seen on this list and other places on the
net, I do this:

   if ((m_fp = open("/dev/mem", O_RDWR)) < 0)
   {
      printf("Can't open /dev/mem\n");
      return(-1);
   }

   offset = 0xef600700 / getpagesize();
   data = mmap(0, 4, PROT_READ | PROT_WRITE, MAP_SHARED, m_fp, offset);

And it always fails with "Invalid Argument".  The mmap man page seems to
suggest you have to pass the address as a multiple of the pagesize, so that
why I do that.  But I've also tried passing 0xEF600700 straight in, and
I've tried setting length to a getpagesize() as well (as opposed to 4) to
see if I was asking for too little, but still is fails the same way.  At
first I thought this just wasn't a valid operation, but I've seen so many
examples now that I don't believe that's it.  Can anybody point me in the
right direction?

As a somewhat related question, I can "cat /dev/mem > test.bin" and it
comes out to be something like 67 megs, and this board has 64 megs of RAM.
I'm confused as to why the entire 4 GB memory space doesn't come out?

Thanks!
-Charles


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: ppc405ep GPIO register mmap'ing invalid argument
@ 2004-04-27 23:19 Kerl, John
  0 siblings, 0 replies; 4+ messages in thread
From: Kerl, John @ 2004-04-27 23:19 UTC (permalink / raw)
  To: Charles Frey, linuxppc-embedded


Check the manpage:  length must be a multiple of getpagesize().
Which your 4 evidently is not.

-----Original Message-----
From: owner-linuxppc-embedded@lists.linuxppc.org
[mailto:owner-linuxppc-embedded@lists.linuxppc.org]
Sent: Tuesday, April 27, 2004 3:57 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: ppc405ep GPIO register mmap'ing invalid argument



Hey,
 I'm trying to read and write from the GPIO_OR register on an ibm 405ep
(0xEF600700), and just as I've seen on this list and other places on the
net, I do this:

   if ((m_fp = open("/dev/mem", O_RDWR)) < 0)
   {
      printf("Can't open /dev/mem\n");
      return(-1);
   }

   offset = 0xef600700 / getpagesize();
   data = mmap(0, 4, PROT_READ | PROT_WRITE, MAP_SHARED, m_fp, offset);

And it always fails with "Invalid Argument".  The mmap man page seems to
suggest you have to pass the address as a multiple of the pagesize, so that
why I do that.  But I've also tried passing 0xEF600700 straight in, and
I've tried setting length to a getpagesize() as well (as opposed to 4) to
see if I was asking for too little, but still is fails the same way.  At
first I thought this just wasn't a valid operation, but I've seen so many
examples now that I don't believe that's it.  Can anybody point me in the
right direction?

As a somewhat related question, I can "cat /dev/mem > test.bin" and it
comes out to be something like 67 megs, and this board has 64 megs of RAM.
I'm confused as to why the entire 4 GB memory space doesn't come out?

Thanks!
-Charles


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: ppc405ep GPIO register mmap'ing invalid argument
@ 2004-04-27 23:21 Kerl, John
  0 siblings, 0 replies; 4+ messages in thread
From: Kerl, John @ 2004-04-27 23:21 UTC (permalink / raw)
  To: Kerl, John, Charles Frey, linuxppc-embedded


Also the offset must be a multiple of getpagesize().
So you want to map a page (probably 4K) at 0xef600700,
then read/write the returned offset, + 0x700.

-----Original Message-----
From: Kerl, John
Sent: Tuesday, April 27, 2004 4:20 PM
To: 'Charles Frey'; linuxppc-embedded@lists.linuxppc.org
Subject: RE: ppc405ep GPIO register mmap'ing invalid argument


Check the manpage:  length must be a multiple of getpagesize().
Which your 4 evidently is not.

-----Original Message-----
From: owner-linuxppc-embedded@lists.linuxppc.org
[mailto:owner-linuxppc-embedded@lists.linuxppc.org]
Sent: Tuesday, April 27, 2004 3:57 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: ppc405ep GPIO register mmap'ing invalid argument



Hey,
 I'm trying to read and write from the GPIO_OR register on an ibm 405ep
(0xEF600700), and just as I've seen on this list and other places on the
net, I do this:

   if ((m_fp = open("/dev/mem", O_RDWR)) < 0)
   {
      printf("Can't open /dev/mem\n");
      return(-1);
   }

   offset = 0xef600700 / getpagesize();
   data = mmap(0, 4, PROT_READ | PROT_WRITE, MAP_SHARED, m_fp, offset);

And it always fails with "Invalid Argument".  The mmap man page seems to
suggest you have to pass the address as a multiple of the pagesize, so that
why I do that.  But I've also tried passing 0xEF600700 straight in, and
I've tried setting length to a getpagesize() as well (as opposed to 4) to
see if I was asking for too little, but still is fails the same way.  At
first I thought this just wasn't a valid operation, but I've seen so many
examples now that I don't believe that's it.  Can anybody point me in the
right direction?

As a somewhat related question, I can "cat /dev/mem > test.bin" and it
comes out to be something like 67 megs, and this board has 64 megs of RAM.
I'm confused as to why the entire 4 GB memory space doesn't come out?

Thanks!
-Charles


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: ppc405ep GPIO register mmap'ing invalid argument
@ 2004-04-27 23:23 Kerl, John
  0 siblings, 0 replies; 4+ messages in thread
From: Kerl, John @ 2004-04-27 23:23 UTC (permalink / raw)
  To: Kerl, John, Charles Frey, linuxppc-embedded


Oop, I meant:

So you want to map a page (probably 4K) at 0xef600000,
then read/write the returned offset, + 0x700.

-----Original Message-----
From: Kerl, John
Sent: Tuesday, April 27, 2004 4:22 PM
To: Kerl, John; 'Charles Frey'; 'linuxppc-embedded@lists.linuxppc.org'
Subject: RE: ppc405ep GPIO register mmap'ing invalid argument


Also the offset must be a multiple of getpagesize().
So you want to map a page (probably 4K) at 0xef600700,
then read/write the returned offset, + 0x700.

-----Original Message-----
From: Kerl, John
Sent: Tuesday, April 27, 2004 4:20 PM
To: 'Charles Frey'; linuxppc-embedded@lists.linuxppc.org
Subject: RE: ppc405ep GPIO register mmap'ing invalid argument


Check the manpage:  length must be a multiple of getpagesize().
Which your 4 evidently is not.

-----Original Message-----
From: owner-linuxppc-embedded@lists.linuxppc.org
[mailto:owner-linuxppc-embedded@lists.linuxppc.org]
Sent: Tuesday, April 27, 2004 3:57 PM
To: linuxppc-embedded@lists.linuxppc.org
Subject: ppc405ep GPIO register mmap'ing invalid argument



Hey,
 I'm trying to read and write from the GPIO_OR register on an ibm 405ep
(0xEF600700), and just as I've seen on this list and other places on the
net, I do this:

   if ((m_fp = open("/dev/mem", O_RDWR)) < 0)
   {
      printf("Can't open /dev/mem\n");
      return(-1);
   }

   offset = 0xef600700 / getpagesize();
   data = mmap(0, 4, PROT_READ | PROT_WRITE, MAP_SHARED, m_fp, offset);

And it always fails with "Invalid Argument".  The mmap man page seems to
suggest you have to pass the address as a multiple of the pagesize, so that
why I do that.  But I've also tried passing 0xEF600700 straight in, and
I've tried setting length to a getpagesize() as well (as opposed to 4) to
see if I was asking for too little, but still is fails the same way.  At
first I thought this just wasn't a valid operation, but I've seen so many
examples now that I don't believe that's it.  Can anybody point me in the
right direction?

As a somewhat related question, I can "cat /dev/mem > test.bin" and it
comes out to be something like 67 megs, and this board has 64 megs of RAM.
I'm confused as to why the entire 4 GB memory space doesn't come out?

Thanks!
-Charles


** Sent via the linuxppc-embedded mail list. See http://lists.linuxppc.org/

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-04-27 23:23 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-27 22:57 ppc405ep GPIO register mmap'ing invalid argument Charles Frey
  -- strict thread matches above, loose matches on Subject: below --
2004-04-27 23:19 Kerl, John
2004-04-27 23:21 Kerl, John
2004-04-27 23:23 Kerl, John

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox