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 18:28:02
Izumi Tsutsui <tsutsui@ceres.dti.ne.jp> writes:

> Well, I'm not sure what do you mean "to duplicate the code,"
> but do you check implementation of mac68k bus_space?
> On mac68k, bus_space_handle_t is structure which has
> pointers of each access method. In this method, you can
> specify independ functions for each device but you don't
> have to change each device driver.

Sorry, it was a misunderstanding on my part.

What I meant was duplicating the actual functions pointed to
by the structure, so that there would be a bba_bus_mem_read_1, a
lana_bus_mem_read_1, a aica_bus_mem_read_1 etc, all with the same
implementation.

The thing was that I read your message as
"Each device should have independent bus_space(9) functions"
             ^^^^^^
which was not what you actually wrote.  Hence the odd excursion.  I
think we basically agree here already.


> > 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?
> 
> Some ports handle "stride" in this way. arc has members in
> bus_space_tag_t and each read/write functions/macros handle it
> by thierselves. amiga switches methods for each stride by bus.
> mac68k switches them by device.

So there is a precedent here.  That's good.


> > The bus_space_handle_t
> > would have to be changed into something more complicated for this to
> > work though, I expect.
> 
> Yes, and it might cause some overhead, but portability
> is more inportant, I guess :-)

Yeah.  Changing the function pointer like on Amiga would be more
efficient, but I'm not sure how to let the device driver select stride
in this case, since the tag is already created in the attach_args when
the driver is called.  Of course, we could pre-create tags for all the
necessary strides and pass them all in the attach_args, and then the
driver can chose any tag it likes.  Maybe this is the nicest solution;
it would be as efficient as before, and we don't have to change the
bus_space_handle_t since only the tag would be different.  What do you
think?


> > > 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?
> 
> He said he had to use bus_space_{read,write}_2() even on 8 bit access.
> I'm not sure it's hardware problem or driver problem, though.

Ok.  If this is really needed, we could add a flag / tag for this as
well.  Shouldn't be a problem.


> > We should add those things rather than have multiple
> > implementations, I think.
> 
> Again, I won't suggest "multiple implementation."
> I'd just like to have a way to switch access functions
> for each devices.

Fine.  Then I think we want the same thing.  Sorry for misinterpreting.


  // Marcus