Subject: Re: Appropriate use of bus_space_vaddr()
To: McGranaghan, Sean <SMcGranaghan@vanteon.com>
From: Eduardo Horvath <eeh@NetBSD.org>
List: netbsd-help
Date: 02/25/2004 19:14:29
On Wed, Feb 25, 2004 at 11:56:35AM -0500, McGranaghan, Sean wrote:
> #define rCTRLREG(b) (*(b + REG_OFFSET))
>
> vaddr_t b;
>
> b = (vaddr_t) bus_space_vaddr(sc->sc_iot, sc->ioh);
> rCTRLREG(b) |= BITMSK;
>
> Seems preferable to:
>
> u_int32_t value;
>
> value = bus_space_read_4(sc->sc_iot, sc->ioh, REG_OFFSET);
> value |= BITMSK;
> bus_space_write_4(sc->sc_iot, sc->ioh, offset, REG_OFFSET);
>
> Are these equivalent? Do I need to specify a barrier after my
The bus_space* macros handle such things as endianness,
write buffers, cache flushing, etc. You should use those
routines whenever possible.
bus_space_vaddr() is only appropriate for things like
accessing on-board framebuffers where you are doing
lots of fancy block move operations where performance
is critical and know you need to handle endiannes and
cache issues explicitly.
Eduardo