Subject: Re: bus.h style question
To: Bill Studenmund <wrstuden@loki.stanford.edu>
From: Chris G. Demetriou <cgd@pa.dec.com>
List: tech-kern
Date: 08/15/1997 14:27:19
[ i meant to jump in earlier in this discussion, but have not had the time. ]

> > On Thu, 14 Aug 1997 15:56:41 -0500 (CDT) 
> >  Scott Reynolds <scottr@Plexus.COM> wrote:
> > 
> >  > There is no byte swapping done by bus_space.  As Leo (I think) points out,
> >  > you may or may not need it for some hardware.  A simple example that
> >  > hasn't been mentioned is the DP8390 Ethernet controller; it can be
> >  > configured for either big- or little-endian modes.
> > 
> > For some busses, the only sane way to treat them is their "native" byte
> > order.  I.e. ISA, EISA, and PCI should all be considered "little endian".
> > It's my opinion that the bus_space_* functions _should_ perform the
> > necessary byte swapping, and the components on boards should always
> > be configured for the byte order they'd be configured if the processor
> > were little-endian.
> 
> What about the case (which I think exists for the Atari's) where
> interveening hardware does the byte swapping? Also, what about PCI
> Powermacs? I'm not sure if the hardware there does swapping, but all of
> the docs I've seen for the MacIO stuff (Mac IO ports off the PCI bus)
> haven't spoken about enianisms, and Apple runs the CPU as big-endian.

Jason said "necessary" byte swapping.  In the case where a bus
interface does byte swapping, the code doesn't need to do the byte
swapping itself.

I seem to recall that there are multiple ISA bridges for the Amiga,
some of which do byte swapping and some of which do not.


> > Of course, this makes using the 16-bit or 32-bit methods for octet streams
> > a bit difficult...
> 
> Since having the swapping DOES make sense for a lot (most maybe?) of cases,
> maybe it should be some sort of option? Maybe set when the space is
> mapped?

Thereby adding complexity to ... lots of things, most importantly the
code which implements the basic read-write path.


The 16-bit and 32-bit methods _should not_ be used for streams of
bytes.  They are meant to access multi-byte data items, and accessing
groups of single byte data items with them is _incorrect_.

If you want to access multiple data items "efficiently" (regardless of
their size) {read,write}_multi_* are the interfaces to use, and should
be used with the correct data item size.


cgd