Accessing PCI-E resources on 460EX
Ayman El-Khashab
AymanE at tanisys.com
Tue Nov 4 08:31:56 EST 2008
linuxppc-embedded-bounces+aymane=tanisys.com at 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
>
> mmap() fails with "invalid argument" error, apparently
> because on 460EX PCI addresses are 36-bit.
>
> What is the correct way of accessing PCI-E from userspace on this
> platform.
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 = static_cast<off64_t>(your physical address);
void * const p =
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
to the page boundry even though some devices are not.
More information about the Linuxppc-embedded
mailing list