Subject: Re: LAN Adapter driver
To: Izumi Tsutsui <tsutsui@ceres.dti.ne.jp>
From: Marcus Comstedt <marcus@mc.pp.se>
List: port-dreamcast
Date: 09/24/2002 17:07:10
Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> writes:

> Each device could have independent bus_space(9) functions
> even if they are on the same bus.
> (See sys/arch/mac68k/obio/wdc_obio.c etc.)
> 
> Anyway, Broadband Adapter is connected over gapspci bridge,
> so it should have own bus_space functions, I think.

It doesn't really make sense to duplicate the code to access the G2
bus into each device driver that uses a device on the G2 bus.  That
only leads to poor code maintainability.  If we need to change the way
the G2 bus itself is accessed, we should only have to change one file.


> Lan Adapter has "sparse" address space, so it requires "stride"
> support if you would like to share bus_space among all devices.W

Yes, this is the only reason for a special Lan Adapter bus_space;
otherwise it could use the normal g2 bus space directly, just like
gapspci does.  If the there was a way to specify stride, then the Lan
Adapter bus_space would not be needed either.  Since bus_space_map
takes a "flags" parameter, maybe we could add a flag to
g2bus_bus_space_map which selects stride mode?  The bus_space_handle_t
would have to be changed into something more complicated for this to
work though, I expect.


> BTW, wdc adapter made by Kiyoshi Ikehara also requires different
> bus_space functions.

What does it require which is missing from the current bus_space
implementation?  We should add those things rather than have multiple
implementations, I think.


> > Then
> > these functions will call G2_LOCK/G2_UNLOCK for it.
> 
> Do you mean all devices on g2bus have to call G2_LOCK and G2_UNLOCK?

All accesses through the g2bus (either to devices or to memory) need
the locking.  It is needed because of a hardware bug in the bus itself.
The locking should be provided by the bus driver, not the individual
device drivers.


  // Marcus