PCI reading without endian conversion

Ira Snyder iws at ovro.caltech.edu
Sat Feb 21 08:07:44 EST 2009


On Fri, Feb 20, 2009 at 02:05:08PM -0600, Matt Sealey wrote:
> On Fri, Feb 20, 2009 at 1:11 PM, Ira Snyder <iws at ovro.caltech.edu> wrote:
> > On Fri, Feb 20, 2009 at 12:57:36PM -0600, Matt Sealey wrote:
> >
> > I'm pretty sure memcpy_fromio() and memcpy_toio() will get you what you
> > want. They don't change byte ordering.
> 
> Are they guaranteed to only do 32-bit, aligned accesses?
> 

I don't think so. I certainly wouldn't count on anything better than a
byte-by-byte memcpy.

> I made some cheats on my CPLD to ignore byte enables and so on,
> because it makes the design cleaner and easier to read (for students)
> plus, saves a ton of logic cells. It's totally within the PCI
> standard, but it means if you do a byte read memcpy() you get.. very
> weird results (i.e. not great).
> 

Right, I understand how that works :)

Some usage of cscope shows that __raw_readl() might be what you want,
as well as __raw_writel() for writing. I'm not sure it is universally
available, but maybe they are.

The comment on PowerPC says "Non ordered and non-swapping "raw"
accessors". Looks about right. ARM's implementation uses them to
implement ioread32() and friends by adding byteswapping.

Hope it helps,
Ira

> -- 
> Matt Sealey <matt at genesi-usa.com>
> Genesi, Manager, Developer Relations
> 



More information about the Linuxppc-dev mailing list