Subject: Re: bus.h style question
To: Martin Husemann <martin@rumolt.teuto.de>
From: Matt Thomas <matt@3am-software.com>
List: tech-kern
Date: 08/14/1997 12:48:19
At 07:05 AM 8/14/97 +0200, Martin Husemann wrote:
>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);

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));


>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.

>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).
-- 
Matt Thomas               Internet:   matt@3am-software.com
3am Software Foundry      WWW URL:    http://www.3am-software.com/bio/matt.html
Nashua, NH                Disclaimer: I disavow all knowledge of this message