Thread (9 messages) 9 messages, 4 authors, 2008-12-04

RE: Accessing PCI-E resources on 460EX

flat view

From: Ayman El-Khashab <hidden>
Date: 2008-11-03 21:31:58

linuxppc-embedded-bounces+aymane=3Dtanisys.com@ozlabs.org <> said on :
I'm currently struggling with some application that tries to
access PCI-E memory by mmaping address found in
/sys/bus/pci/devices/<device>/resource
=20
mmap() fails with "invalid argument" error, apparently
because on 460EX PCI addresses are 36-bit.
=20
What is the correct way of accessing PCI-E from userspace on this
platform.=20
What works for me is using the mmap64 as in the following example to
map the physical address, fd is the file descriptor for /dev/mem

off64_t offset =3D static_cast<off64_t>(your physical address);
void * const p =3D
mmap64(0,256,PROT_WRITE|PROT_READ,MAP_SHARED,fd,offset);

The only thing to note is that the address you pass should be aligned=20
to the page boundry even though some devices are not.
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help