Subject: Re: MI bus ops(Re: 16bit aligned NS16550 variant)
To: None <thorpej@wasabisystems.com>
From: TAKEMURA Shin <takemura@netbsd.org>
List: tech-kern
Date: 11/11/2001 00:09:30
----- Original Message -----
From: "Jason R Thorpe" <thorpej@wasabisystems.com>
To: "TAKEMURA Shin" <takemura@netbsd.org>
Cc: <eeh@netbsd.org>; <mouse@rodents.montreal.qc.ca>;
<simonb@wasabisystems.com>; <tech-kern@netbsd.org>
Sent: Saturday, November 10, 2001 1:01 AM
Subject: Re: MI bus ops(Re: 16bit aligned NS16550 variant)
> On Sun, Nov 04, 2001 at 11:24:41AM +0900, TAKEMURA Shin wrote:
>
> > In the last discussion, I found that function vector definition of
> > bus_space method should be michine independent.
> So, the bus_space_ops, while independent, don't actually contain enough
> info for MI code to construct its own bus_space_tag_t's. This is because
> bus_space_tag_t's still have a machine-dependent definition.
>
> I think what I'd really like to see here is for <machine/bus.h> to be
> replaced by:
Okay... I've wrote rough draft of sys/bus.h (attached).
The file describes abstract class of bus object. To implement a conclete
bus space with the sys/bus.h, you should define a new bus_space_tag
derived from the bus_space_tag. This is similar to what you do with the
device structure in sys/device.h.
For example,
machine/bus_mainbus.h --------
#include <sys/bus.h>
struct mainbus_bus_space_tag {
struct bus_space_tag bs_bs;
u_int32_t baseaddr;
};
mainbus.c --------
#include <machine/bus_mainbus.h>
bus_space_protos(mainbus);
u_int8_t
mainbus_bs_r_1(bus_space_tag_t t, bus_space_handle_t bsh, bus_size_t
offset)
{
struct mainbus_bus_space_tag *ht = (struct hpcmips_bus_space_tag*)t;
return (*(volatile u_int8_t *)(ht->baseaddr + bsh + offset));
}
other points:
- I use BUS_SPACE_MD_CALLS instead of
__BUS_SPACE_MC_CALLS because the macro might be referd
somewhere MI code. You can't override a bus method nor create
new MI bus space if the macro was defined.
- A machine/bus_types.h below will provide compatibility. I think
it's too hard to rewrite all bus_space stuff of all ports at once.
machine/bus_types.h:
#define BUS_SPACE_MD_CALLS
#deinfe BUS_SPACE_MD_TYPES
#define BUS_DMA_MD_CALLS
#define BUS_DMA_MD_TYPES
With this bus_types.h, sys/bus.h will do nothing but including
machine/bus.h.
How do you think abous this ? I'm going to write concrete (compilable)
version of new bus.h and hpcmips' main bus.If you object, please let
me know ASAP. I don't like to write more code only to throw it away.
Takemura