Subject: Re: bus.h style question
To: Matt Thomas <matt@3am-software.com>
From: Scott Reynolds <scottr@Plexus.COM>
List: tech-kern
Date: 08/14/1997 15:56:41
On Thu, 14 Aug 1997, Matt Thomas wrote:

> That can't be right.  buffer is not initialized yet.
> 
> 	u_int8_t *p, buffer[MAX_BUF_SIZE];
> 	*p = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF);
> 	for (p = buffer, i = 0; *p && i < sizeof buffer - 1; i++)
> 		*++p = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF + (i+1));

Of course, this still suffers from the same problem. :-)  (The original
code further had the problem that it incremented `p' twice!)

	for (p = buffer, i = 0; i < sizeof buffer; i++, p++) {
		*p = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+i);
		if (*p == '\0')
			break;
	}

> >Could I use bus_space_read_4 savely to get value? Are there alignement 
> >constraints in the bus.h interface?
> 
> I've wondered that as well.  My guess would have to be yes.

There are no alignment constraints specified, that I'm aware of.  It is
certainly something that needs to be kept in mind when writing an MI
driver.

> >The other question is the expected byte order. At another point I do check
> >a signature with:
> >
> >On the i386 the signature I get is 0x4447 - should I expect 0x4744 on
> >the atari or amiga? I guess (hope?) not.
> 
> I would hope the bus_space_ calls would byteswap >1 byte units as 
> appropriate for the bus.  (especially since they're are no 
> big endian byteswap routines).

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.

--scott