Subject: Re: structural bus_space_handles
To: Martin Husemann <martin@duskware.de>
From: Garrett D'Amore <garrett_damore@tadpole.com>
List: tech-kern
Date: 06/04/2006 19:08:59
Martin Husemann wrote:
> On Sun, Jun 04, 2006 at 09:39:18AM -0700, Garrett D'Amore wrote:
>   
>> It would be cleaner to have a macro in bus.h, ala
>> __BUS_SPACE_HANDLE_IS_STRUCT, so that I could test for that flag instead
>> of having a test for a specific port.  What do folks think?
>>     
>
> The ath HAL code is bogus in this regard - it has no right to assume anything
> about the opaque type. I don't think a more general solution is needed,
> as the HAL already needs per-arch configuration, and that's where this check
> goes too.
>   

I disagree.

Even opaque types have to be stored.  This structure lives inside a
binary bit, that can't depend on NetBSD source code, as the binary bit
is shared across a bajillion different OS' and even releases of the same OS.

The "general" solution is to make if_ath_pci.c and if_ath_cardbus.c
store the bus_handle_t in an OS-specific handle, but then that means
that all architectures get penalized by another level of pointer
indirection.  (Making Atheros' "tag" really be a pointer to bus_handle_t
instead of a bus_handle_t itself.)  Architecturally this is clean, but
it seems a poor choice for performance.

As far as arch-specific bits, the only arch-specific configuration we
have is to pick a binary HAL object (and that is now cleaned up quite a
lot in a common configuration file now), and to include a header that
declares how that binary HAL was compiled.  These bits happen in an
OS-agnostic way, and have no knowledge of our peculiarities in NetBSD.

Frankly, I still find the idea of having a structure instead of some
opaque pointer type (which could be a physical address or a pointer to a
more complex structure as in sparc64) distasteful.  But I am not asking
NetBSD to change this, only to make it easier to tell when a
bus_handle_t can be safely cast to a void * or not.

> What problem are you trying to solve?
>   

Bus handles (or opaque access handles for the Atheros HAL) are currently
stored in void *.  I cannot change that bit.    I'm trying to make it
possible to address the problem of making this work well for NetBSD in
the normal case (where the types are pointers anyway), while also
allowing sparc bogosity to work as well.  See above for more explanation.

    -- Garrett
> Martin
>   


-- 
Garrett D'Amore, Principal Software Engineer
Tadpole Computer / Computing Technologies Division,
General Dynamics C4 Systems
http://www.tadpolecomputer.com/
Phone: 951 325-2134  Fax: 951 325-2191