Subject: Re: ncr53cxxx driver design issues
To: None <tech-kern@netbsd.org>
From: Jason R Thorpe <thorpej@zembu.com>
List: tech-kern
Date: 04/18/2000 07:22:36
On Tue, Apr 18, 2000 at 09:07:42AM +0200, Lennart Augustsson wrote:

 > > #if BYTE_ORDER == BIG_ENDIAN
 > >         ... put the device into "data structures are big-endian" mode ...
 > > #else
 > >         ... put the device into "data structures are little-endian" mode ...
 > > #endif
 > 
 > But that doesn't necessarily work.  That assumes that host byte order is
 > the same as the bus byte order.

Yes it does.  When you're talking about DMA'd data structures, the
bus logically treates them like octet streams (unless it is *explicitly*
programmed to do so on e.g. UltraSPARC and some PowerPC systems).

It's basically "very convenient" to assume that the device is little-endian
internally if it lives on PCI, as the PCI can be considered to be "natively"
little-endian.

But if you can switch the internal byte order of the device, then you can
avoid swapping those data structures, either explicitly or through some
bus controller magic.

Note that these modes that devices offer almost always affect only DMA'd
data structures; I have never encountered one where putting it in big-endian
mode also affected register writes... those remained little-endian.

 > Yes, if you have a driver that lives in dev/pci you can assume you're on
 > a pci bus.  But all driver in dev/ic can make no such assumption, they should
 > properly handle being on either kind of bus.  I'm not sure there are any
 > drivers that do?

Well, drivers in dev/ic have support for chips which are only PCI chips,
they just sometimes happen to have CardBus glue for some of them.

...and some of these chips *are* little-endian inside.  Some are big-endian
inside.  If you know that about the chip, well...

-- 
        -- Jason R. Thorpe <thorpej@zembu.com>