Subject: Correct use of bus_space functions
To: None <tech-kern@netbsd.org>
From: Martin J. Laubach <mjl@netbsd.org>
List: tech-kern
Date: 01/07/2003 23:56:02
  Looking at our and OpenBSD's version of the bktr driver, I
see that we do (wrapped for legibility):

#define INB(bktr,offset)
	bus_space_read_1((bktr)->memt,(bktr)->memh,(offset))


  while OpenBSD does:

#define INB(sc,o)	(({					\
	u_int8_t __v;						\
	__v = bus_space_read_1((sc)->memt, (sc)->memh, (o));	\
	bus_space_barrier((sc)->memt, (sc)->memh, (o), 1,	\
			BUS_SPACE_BARRIER_READ);		\
	(__v);							\
	}))

  Similar with INW, INL, OUTB, OUTW, OUTL.


  A part from that gcc-ismic thing of misusing a macro as a function, 
is the bus_space_barrier() correct or not?

	mjl