Subject: Re: Using same com.c driver for two devices that access serial port differently?
To: David Brownlee <email@example.com>
From: Ian Zagorskih <firstname.lastname@example.org>
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=
> > 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=
> > depending on exact com device context i.e. value 1 for com_ier used f=
> > ISA bus and 4 for PCI bus.
> > One sollution is to re-define bus_space_read/write specially for/in 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=
> > 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=
i386 arch this looks like:
#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))))
AFAIU i must re-write this macros to define my own bus space, is it right=
#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))))
but this dosn't seems to be good nor elegant for me. Or i missed somethin=
JSC Novosibirsk Geophysical Equipment Development Center.