Subject: bus.h style question
To: None <tech-kern@NetBSD.ORG>
From: Martin Husemann <martin@rumolt.teuto.de>
List: tech-kern
Date: 08/14/1997 07:05:27
I have two question on usage of the bus.h interface:

My card is mapped into ISA memory. At one time it generates a zero terminated
string in this memory area, followed by a u_int32_t value. So what I do is:

	int i;
	u_int32_t value;
	u_int8_t *p, buffer[MAX_BUF_SIZE];
	for (p = buffer, i = 0; *p && i < sizeof buffer; i++, p++)
		*p++ = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+i);
	if (i >= sizeof buffer)
		return EIO;
	value = bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+1+i) |
		(bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+1+i) << 8) |
		(bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+1+i) << 16) |
		(bus_space_read_1(sc->sc_iot, sc->sc_ioh, MYOFF+1+i) << 24);

Could I use bus_space_read_4 savely to get value? Are there alignement 
constraints in the bus.h interface?

The other question is the expected byte order. At another point I do check
a signature with:

	u_int16_t signature;
	signature = bus_space_read_2(sc->sc_iot, sc->sc_ioh, MYOFF);
	if (signature != SIGNATURE_VALUE)
		return EIO;

On the i386 the signature I get is 0x4447 - should I expect 0x4744 on
the atari or amiga? I guess (hope?) not.

But when doing it this way:

	bus_space_read_region_1(sc->sc_iot, sc->sc_ioh, MYOFF, &signature, 2);

I would get 0x4447 or 0x4744 depending on host byte order, right?


Martin