Memory mapping PCI memory region to user space

Kumar Gala galak at kernel.crashing.org
Fri Mar 24 04:19:58 EST 2006


On Mar 23, 2006, at 11:12 AM, David Hawkins wrote:

>
>
>> Why don't use the mmap file exposed by sysfs so you dont have to   
>> write your own code?
>> See Documentation/filesystems/sysfs-pci.txt.  But effectively  
>> down  under /sys/bus/pci/devices/[domain:bus:dev:func]/ you will  
>> get  resource[0..N-1] that corresponds to each BAR on the device.   
>> This is  a mmap file to access that region.
>
> Hi Kumar,
>
> Most likely he didn't know about it, I didn't :)
>
> When I was testing the Yosemite board as the host, I found
> that I could set the endian flag on the mmapped page, which
> then made the PCI device registers read as 32-bit quantities
> read back with the same layout under both x86 and PPC
> hosts.

Hmm, I guess I would handle this like how the reset of the kernel  
handle is with the io routines handling the swapping.  Not sure if  
there is any advantage to using the endian flag.  I guess if you have  
something you are treating as just memory there would be.

> So, if someone planned on using that 'feature', that would
> be a reason for writing your own mmap() implementation.
> I didn't see any option in the sysfs file for setting that
> page flag (but, I didn't look around in other sysfs files).

There isn't a sysfs flag for the endianness page attribute since  
thats a PPC book-e specific feature.  We could possible expand things  
to support it but, I've been trying to actively avoid using the 'E' bit.

> Thanks for the pointer to the sysfs node!

No problem, its what we're here for :)

- kumar



More information about the Linuxppc-embedded mailing list