Subject: Annoying bus_space limitation
To: None <tech-kern@netbsd.org>
From: Charles M. Hannum <abuse@spamalicious.com>
List: tech-kern
Date: 08/09/2004 22:50:12
So, while fixing up the PCMCIA code, I've discovered that there are many hacks 
caused by a limitation in the bus_space interface.  Specifically, due to 
specific semantics of address decoding on some cards (especially ones with 
multiple functions), they may require I/O addresses to be aligned to a 
boundary that is "larger" than the size of the region.

Now, naively this would be fine.  The information is encoded in the "I/O 
mask", and we could just pass this on to bus_space_alloc().

The problem is that the address may need to be offset from the alignment.  
This happens, for example, with some ne and xi cards that use multiple I/O 
regions.  Currently there are klugy hacks in these drivers to deal with it.

Now, I note that extent_alloc_subregion1() has a "skew" parameter, which looks 
like what I need.  However, the bus_space interface does not seem to have any 
way to use this.  Basically, what I need is:

start = cfe->iospace[n].start
length = cfe->iospace[n].length
alignment = cfe->iomask ? (1 << cfe->iomask) : length
skew = start % alignment

I'd be perfectly happy with either a bus_space function that passes through a 
"skew" or a flag that specifically sets skew=start%alignment deeper down.

Anyone have thoughts on this?