Subject: Re: Using same com.c driver for two devices that access serial port differently?
To: Ian Zagorskih <ianzag@megasignal.com>
From: Ignatios Souvatzis <is@netbsd.org>
List: tech-kern
Date: 06/25/2003 20:53:35
Hi,

On Wed, Jun 25, 2003 at 11:22:27PM +0000, Ian Zagorskih wrote:

> ---cut ---
> #define bus_space_read_1(t, h, o) \
> 	((t) == I386_BUS_SPACE_IO ? (inb((h) + (o))) : \
> 	((t) == MY_BUS_SPACE) ? (my_bus_read_1((t), (h), (o))) : \
> 	((t) == YOUR_BUS_SPACE) ? (your_bus_read_1((t), (h), (o))) : \
> 	((t) == HIS_BUS_SPACE) ? (his_bus_read_1((t), (h), (o))) : \
>         (*(volatile u_int8_t *)((h) + (o))))
> ---cut ---
> 
> but this dosn't seems to be good nor elegant for me. Or i missed something ?

Use an array of function pointers for the access types, maybe, pointed to
by the bus space tag. I don't know how bad this would be for i386
performance; I had to do it this way for Amiga.

The other solution - would be to rewrite com.c to take an array of offsets;
this way only com.c would be penalized.

Regards,
	-is
-- 
seal your e-mail: http://www.gnupg.org/