Subject: Re: Using same com.c driver for two devices that access serial port differently?
To: David Brownlee <abs@netbsd.org>
From: Ian Zagorskih <ianzag@megasignal.com>
List: tech-kern
Date: 06/25/2003 23:22:27
On Wednesday 25 June 2003 16:07, David Brownlee wrote:
> On Wed, 25 Jun 2003, Ian Zagorskih wrote:
> > AFAIU from dev/ic/com.c source code you cannot do this so simple. All
> > bus_space_read_1()/write_1() calls use absolute register offset value=
s
> > defined at dev/ic/ns16550reg.h like below:
> >
> > ------
> > #define=09com_data=09=090=09/* data register (R/W) */
> > #define=09com_ier=09=091=09/* interrupt enable (W) */
> > #define=09com_iir=09=092=09/* interrupt identification (R) */
> > ------
> >
> > and used for all com-like devices. So you have to re-define this offs=
ets
> > depending on exact com device context i.e. value 1 for com_ier used f=
or
> > ISA bus and 4 for PCI bus.
> >
> > One sollution is to re-define bus_space_read/write specially for/in c=
om.c
> > which would fix register value depending on bus space tag and handle.
> >
> > But 1) doing it just looking at "PCI or ISA" bus space type obviously
> > will break suitability of com.c for other PCI UART cards 2) you shoul=
d to
> > it for all <arch>/bus.h :)
> >
> > For me seems like com.c isn't suitable for your device course of
> > different hardware registers mapping.
>
> =09Would it be reasonable to create a new bus type for the pciio
> =09attachments and have it handle the adjustment?
Maybe, but IMO good question is: how ?
bus_space_xxx operations are defined into machine/bus.h and as an example=
for=20
i386 arch this looks like:
---cut ---
#define=09bus_space_read_1(t, h, o)=09=09=09=09=09\
=09((t) =3D=3D I386_BUS_SPACE_IO ? (inb((h) + (o))) :\
=09 (*(volatile u_int8_t *)((h) + (o))))
---cut ---
AFAIU i must re-write this macros to define my own bus space, is it right=
?=20
Kind of
---cut ---
#define bus_space_read_1(t, h, o) \
=09((t) =3D=3D I386_BUS_SPACE_IO ? (inb((h) + (o))) : \
=09((t) =3D=3D MY_BUS_SPACE) ? (my_bus_read_1((t), (h), (o))) : \
=09((t) =3D=3D YOUR_BUS_SPACE) ? (your_bus_read_1((t), (h), (o))) : \
=09((t) =3D=3D 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 somethin=
g ?
--=20
JSC Novosibirsk Geophysical Equipment Development Center.
WEB=09http://www.megasignal.com