Subject: 16bit aligned NS16550 variant
To: None <tech-kern@netbsd.org>
From: TAKEMURA Shin <takemura@netbsd.org>
List: tech-kern
Date: 10/20/2001 17:16:27
This is a multi-part message in MIME format.
------=_NextPart_000_0189_01C1598A.F3FD57B0
Content-Type: text/plain;
charset="iso-2022-jp"
Content-Transfer-Encoding: 7bit
I'd like to change NS16550 serial driver, 'com' to add 16bit register
access support. And I've made the patch(attached).
Some embedded companion chip and ASIC have UART compatible
function but you must make 16bit access for thier registers.
With this change, the driver will access it's registers with specified
access wrappers instead of bus_space_read/write.
There will be added new entries for compatibility and no ather files
will be affected. (I found over 50 files calling comprobe1 or
comcnattach and I gave up to chage them all.)
Please review the patch. If no one against me, I will commit this
change next weekend.
Takemura
Index: comvar.h
===================================================================
RCS file: /cvsroot/syssrc/sys/dev/ic/comvar.h,v
retrieving revision 1.42
diff -r1.42 comvar.h
69a70,78
> struct com_accessops {
> void (*caop_write_reg)(bus_space_tag_t, bus_space_handle_t,
> bus_size_t, u_int8_t);
> void (*caop_write_reg_multi)(bus_space_tag_t, bus_space_handle_t,
> bus_size_t, u_int8_t *, bus_size_t);
> u_int8_t (*caop_read_reg)(bus_space_tag_t, bus_space_handle_t,
> bus_size_t);
> };
>
82a92
> struct com_accessops *sc_aops;
149a160,167
> int comcnattachx __P((bus_space_tag_t, struct com_accessops *, bus_addr_t,
> int, int, tcflag_t));
>
> #ifdef KGDB
> int com_kgdb_attachx __P((bus_space_tag_t, struct com_accessops *,
> bus_addr_t, int, int, tcflag_t));
> #endif
>
150a169,170
> int comprobe1x __P((bus_space_tag_t, bus_space_handle_t,
> struct com_accessops *));
163a184,186
>
> extern struct com_accessops com_accessops_1;
> extern struct com_accessops com_accessops_2;
EOF
------=_NextPart_000_0189_01C1598A.F3FD57B0
Content-Type: application/octet-stream;
name="com.patch"
Content-Transfer-Encoding: quoted-printable
Content-Disposition: attachment;
filename="com.patch"
Index: comvar.h=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvsroot/syssrc/sys/dev/ic/comvar.h,v=0A=
retrieving revision 1.42=0A=
diff -c -r1.42 comvar.h=0A=
*** comvar.h 2001/08/27 14:27:01 1.42=0A=
--- comvar.h 2001/10/20 07:42:12=0A=
***************=0A=
*** 67,72 ****=0A=
--- 67,81 ----=0A=
/* Buffer size for character buffer */=0A=
#define COM_RING_SIZE 2048=0A=
=0A=
+ struct com_accessops {=0A=
+ void (*caop_write_reg)(bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t, u_int8_t);=0A=
+ void (*caop_write_reg_multi)(bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t, u_int8_t *, bus_size_t);=0A=
+ u_int8_t (*caop_read_reg)(bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t);=0A=
+ };=0A=
+ =0A=
struct com_softc {=0A=
struct device sc_dev;=0A=
void *sc_si;=0A=
***************=0A=
*** 80,85 ****=0A=
--- 89,95 ----=0A=
bus_space_tag_t sc_iot;=0A=
bus_space_handle_t sc_ioh;=0A=
bus_space_handle_t sc_hayespioh;=0A=
+ struct com_accessops *sc_aops;=0A=
=0A=
u_int sc_overflows,=0A=
sc_floods,=0A=
***************=0A=
*** 147,153 ****=0A=
--- 157,173 ----=0A=
#define CLR(t, f) (t) &=3D ~(f)=0A=
#define ISSET(t, f) ((t) & (f))=0A=
=0A=
+ int comcnattachx __P((bus_space_tag_t, struct com_accessops *, =
bus_addr_t,=0A=
+ int, int, tcflag_t));=0A=
+ =0A=
+ #ifdef KGDB=0A=
+ int com_kgdb_attachx __P((bus_space_tag_t, struct com_accessops *,=0A=
+ bus_addr_t, int, int, tcflag_t));=0A=
+ #endif=0A=
+ =0A=
int comprobe1 __P((bus_space_tag_t, bus_space_handle_t));=0A=
+ int comprobe1x __P((bus_space_tag_t, bus_space_handle_t,=0A=
+ struct com_accessops *));=0A=
int comintr __P((void *));=0A=
void com_attach_subr __P((struct com_softc *));=0A=
int com_detach __P((struct device *, int));=0A=
***************=0A=
*** 161,163 ****=0A=
--- 181,186 ----=0A=
#define splsoftserial() spltty()=0A=
#endif=0A=
#endif=0A=
+ =0A=
+ extern struct com_accessops com_accessops_1;=0A=
+ extern struct com_accessops com_accessops_2;=0A=
Index: com.c=0A=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=0A=
RCS file: /cvsroot/syssrc/sys/dev/ic/com.c,v=0A=
retrieving revision 1.189=0A=
diff -c -r1.189 com.c=0A=
*** com.c 2001/09/17 02:47:13 1.189=0A=
--- com.c 2001/10/20 07:42:21=0A=
***************=0A=
*** 151,161 ****=0A=
int com_to_tiocm __P((struct com_softc *));=0A=
void com_iflush __P((struct com_softc *));=0A=
=0A=
! int com_common_getc __P((dev_t, bus_space_tag_t, bus_space_handle_t));=0A=
! void com_common_putc __P((dev_t, bus_space_tag_t, bus_space_handle_t, =
int));=0A=
=0A=
int cominit __P((bus_space_tag_t, bus_addr_t, int, int, tcflag_t,=0A=
! bus_space_handle_t *));=0A=
=0A=
/* XXX: This belongs elsewhere */=0A=
cdev_decl(com);=0A=
--- 151,163 ----=0A=
int com_to_tiocm __P((struct com_softc *));=0A=
void com_iflush __P((struct com_softc *));=0A=
=0A=
! int com_common_getc __P((dev_t, bus_space_tag_t, bus_space_handle_t,=0A=
! struct com_accessops *));=0A=
! void com_common_putc __P((dev_t, bus_space_tag_t, bus_space_handle_t,=0A=
! struct com_accessops *, int));=0A=
=0A=
int cominit __P((bus_space_tag_t, bus_addr_t, int, int, tcflag_t,=0A=
! bus_space_handle_t *, struct com_accessops *));=0A=
=0A=
/* XXX: This belongs elsewhere */=0A=
cdev_decl(com);=0A=
***************=0A=
*** 181,186 ****=0A=
--- 183,202 ----=0A=
integrate void com_schedrx __P((struct com_softc *));=0A=
void comdiag __P((void *));=0A=
=0A=
+ /* register access op functions */=0A=
+ static void __write_1 __P((bus_space_tag_t, bus_space_handle_t, =
bus_size_t,=0A=
+ u_int8_t));=0A=
+ static void __write_multi_1 __P((bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t, u_int8_t *, bus_size_t));=0A=
+ static u_int8_t __read_1 __P((bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t));=0A=
+ static void __write_2 __P((bus_space_tag_t, bus_space_handle_t, =
bus_size_t,=0A=
+ u_int8_t));=0A=
+ static void __write_multi_2 __P((bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t, u_int8_t *, bus_size_t));=0A=
+ static u_int8_t __read_2 __P((bus_space_tag_t, bus_space_handle_t,=0A=
+ bus_size_t));=0A=
+ =0A=
extern struct cfdriver com_cd;=0A=
=0A=
/*=0A=
***************=0A=
*** 196,201 ****=0A=
--- 212,218 ----=0A=
static bus_addr_t comconsaddr;=0A=
static bus_space_tag_t comconstag;=0A=
static bus_space_handle_t comconsioh;=0A=
+ static struct com_accessops *comconsaops;=0A=
static int comconsattached;=0A=
static int comconsrate;=0A=
static tcflag_t comconscflag;=0A=
***************=0A=
*** 216,227 ****=0A=
--- 233,266 ----=0A=
#endif=0A=
#endif=0A=
=0A=
+ struct com_accessops com_accessops_1 =3D {=0A=
+ __write_1,=0A=
+ __write_multi_1,=0A=
+ __read_1,=0A=
+ };=0A=
+ struct com_accessops com_accessops_2 =3D {=0A=
+ __write_2,=0A=
+ __write_multi_2,=0A=
+ __read_2,=0A=
+ };=0A=
+ struct com_accessops *com_defaops =3D &com_accessops_1;=0A=
+ =0A=
+ #define COM_ACCESS_OP(ops, name) \=0A=
+ ((ops)->name ? (ops)->name : com_defaops->name)=0A=
+ #define com_write_reg(ops, t, h, o, v) \=0A=
+ (*COM_ACCESS_OP(ops, caop_write_reg))((t), (h), (o), (v))=0A=
+ #define com_write_multi(ops, t, h, o, v, n) \=0A=
+ (*COM_ACCESS_OP(ops, caop_write_reg_multi))((t), (h), (o), =
(v),(n))=0A=
+ #define com_read_reg(ops, t, h, o) \=0A=
+ (*COM_ACCESS_OP(ops, caop_read_reg))((t), (h), (o))=0A=
+ =0A=
#ifdef KGDB=0A=
#include <sys/kgdb.h>=0A=
=0A=
static bus_addr_t com_kgdb_addr;=0A=
static bus_space_tag_t com_kgdb_iot;=0A=
static bus_space_handle_t com_kgdb_ioh;=0A=
+ static struct com_accessops *com_kgdb_aops;=0A=
static int com_kgdb_attached;=0A=
=0A=
int com_kgdb_getc __P((void *));=0A=
***************=0A=
*** 253,258 ****=0A=
--- 292,353 ----=0A=
=0A=
#endif=0A=
=0A=
+ /*=0A=
+ * register access ops 1 (8 bit)=0A=
+ */=0A=
+ static void=0A=
+ __write_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, =
u_int8_t v)=0A=
+ {=0A=
+ bus_space_write_1(t, h, o, v);=0A=
+ }=0A=
+ =0A=
+ static void=0A=
+ __write_multi_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,=0A=
+ u_int8_t *v, bus_size_t n)=0A=
+ {=0A=
+ bus_space_write_multi_1(t, h, o, v, n);=0A=
+ }=0A=
+ =0A=
+ static u_int8_t=0A=
+ __read_1(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)=0A=
+ {=0A=
+ return bus_space_read_1(t, h, o);=0A=
+ }=0A=
+ =0A=
+ /*=0A=
+ * register access ops 2 (16 bit)=0A=
+ */=0A=
+ static void=0A=
+ __write_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o, =
u_int8_t v)=0A=
+ {=0A=
+ bus_space_write_2(t, h, o * 2, v);=0A=
+ }=0A=
+ =0A=
+ static void=0A=
+ __write_multi_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o,=0A=
+ u_int8_t *v, bus_size_t n)=0A=
+ {=0A=
+ int i, m;=0A=
+ u_int16_t buf[32];=0A=
+ =0A=
+ while (0 < n) {=0A=
+ m =3D sizeof(buf)/sizeof(*buf);=0A=
+ if (n < m)=0A=
+ m =3D n;=0A=
+ for (i =3D 0; i < m; i++)=0A=
+ buf[i] =3D v[i];=0A=
+ bus_space_write_multi_2(t, h, o * 2, buf, m);=0A=
+ v +=3D m;=0A=
+ n -=3D m;=0A=
+ }=0A=
+ }=0A=
+ =0A=
+ static u_int8_t=0A=
+ __read_2(bus_space_tag_t t, bus_space_handle_t h, bus_size_t o)=0A=
+ {=0A=
+ return (u_int8_t)bus_space_read_2(t, h, o * 2);=0A=
+ }=0A=
+ =0A=
int=0A=
comspeed(speed, frequency)=0A=
long speed, frequency;=0A=
***************=0A=
*** 314,325 ****=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
{=0A=
=0A=
/* force access to id reg */=0A=
! bus_space_write_1(iot, ioh, com_lcr, LCR_8BITS);=0A=
! bus_space_write_1(iot, ioh, com_iir, 0);=0A=
! if ((bus_space_read_1(iot, ioh, com_lcr) !=3D LCR_8BITS) ||=0A=
! (bus_space_read_1(iot, ioh, com_iir) & 0x38))=0A=
return (0);=0A=
=0A=
return (1);=0A=
--- 409,429 ----=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
{=0A=
+ return comprobe1x(iot, ioh, com_defaops);=0A=
+ }=0A=
+ =0A=
+ int=0A=
+ comprobe1x(iot, ioh, aops)=0A=
+ bus_space_tag_t iot;=0A=
+ bus_space_handle_t ioh;=0A=
+ struct com_accessops *aops;=0A=
+ {=0A=
=0A=
/* force access to id reg */=0A=
! com_write_reg(aops, iot, ioh, com_lcr, LCR_8BITS);=0A=
! com_write_reg(aops, iot, ioh, com_iir, 0);=0A=
! if ((com_read_reg(aops, iot, ioh, com_lcr) !=3D LCR_8BITS) ||=0A=
! (com_read_reg(aops, iot, ioh, com_iir) & 0x38))=0A=
return (0);=0A=
=0A=
return (1);=0A=
***************=0A=
*** 335,340 ****=0A=
--- 439,448 ----=0A=
int combaselist[] =3D { 0x3f8, 0x2f8, 0x3e8, 0x2e8 };=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
=0A=
+ /* set default register access ops if it aren't provided */=0A=
+ if (sc->sc_aops =3D=3D NULL)=0A=
+ sc->sc_aops =3D &com_accessops_1;=0A=
+ =0A=
/*=0A=
* Hayes ESP cards have two iobases. One is for compatibility with=0A=
* 16550 serial chips, and at the same ISA PC base addresses. The=0A=
***************=0A=
*** 343,349 ****=0A=
*/=0A=
=0A=
/* Test for ESP signature */=0A=
! if ((bus_space_read_1(iot, hayespioh, 0) & 0xf3) =3D=3D 0)=0A=
return (0);=0A=
=0A=
/*=0A=
--- 451,457 ----=0A=
*/=0A=
=0A=
/* Test for ESP signature */=0A=
! if ((com_read_reg(sc->sc_aops, iot, hayespioh, 0) & 0xf3) =3D=3D 0)=0A=
return (0);=0A=
=0A=
/*=0A=
***************=0A=
*** 351,358 ****=0A=
*/=0A=
=0A=
/* Get the dip-switch configurations */=0A=
! bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETDIPS);=0A=
! dips =3D bus_space_read_1(iot, hayespioh, HAYESP_STATUS1);=0A=
=0A=
/* Determine which com port this ESP card services: bits 0,1 of */=0A=
/* dips is the port # (0-3); combaselist[val] is the com_iobase */=0A=
--- 459,466 ----=0A=
*/=0A=
=0A=
/* Get the dip-switch configurations */=0A=
! com_write_reg(sc->sc_aops, iot, hayespioh, =
HAYESP_CMD1,HAYESP_GETDIPS);=0A=
! dips =3D com_read_reg(sc->sc_aops, iot, hayespioh, HAYESP_STATUS1);=0A=
=0A=
/* Determine which com port this ESP card services: bits 0,1 of */=0A=
/* dips is the port # (0-3); combaselist[val] is the com_iobase */=0A=
***************=0A=
*** 363,371 ****=0A=
=0A=
/* Check ESP Self Test bits. */=0A=
/* Check for ESP version 2.0: bits 4,5,6 =3D=3D 010 */=0A=
! bus_space_write_1(iot, hayespioh, HAYESP_CMD1, HAYESP_GETTEST);=0A=
! val =3D bus_space_read_1(iot, hayespioh, HAYESP_STATUS1); /* Clear =
reg1 */=0A=
! val =3D bus_space_read_1(iot, hayespioh, HAYESP_STATUS2);=0A=
if ((val & 0x70) < 0x20) {=0A=
printf("-old (%o)", val & 0x70);=0A=
/* we do not support the necessary features */=0A=
--- 471,480 ----=0A=
=0A=
/* Check ESP Self Test bits. */=0A=
/* Check for ESP version 2.0: bits 4,5,6 =3D=3D 010 */=0A=
! com_write_reg(sc->sc_aops, iot, hayespioh, =
HAYESP_CMD1,HAYESP_GETTEST);=0A=
! /* Clear reg1 */=0A=
! val =3D com_read_reg(sc->sc_aops, iot, hayespioh, HAYESP_STATUS1);=0A=
! val =3D com_read_reg(sc->sc_aops, iot, hayespioh, HAYESP_STATUS2);=0A=
if ((val & 0x70) < 0x20) {=0A=
printf("-old (%o)", val & 0x70);=0A=
/* we do not support the necessary features */=0A=
***************=0A=
*** 400,408 ****=0A=
s =3D splserial();=0A=
COM_LOCK(sc);=0A=
sc->sc_ier =3D IER_ERXRDY;=0A=
! bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier);=0A=
SET(sc->sc_mcr, MCR_DTR | MCR_RTS);=0A=
! bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_mcr, sc->sc_mcr);=0A=
COM_UNLOCK(sc);=0A=
splx(s);=0A=
}=0A=
--- 509,517 ----=0A=
s =3D splserial();=0A=
COM_LOCK(sc);=0A=
sc->sc_ier =3D IER_ERXRDY;=0A=
! com_write_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh, =
com_ier,sc->sc_ier);=0A=
SET(sc->sc_mcr, MCR_DTR | MCR_RTS);=0A=
! com_write_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh, =
com_mcr,sc->sc_mcr);=0A=
COM_UNLOCK(sc);=0A=
splx(s);=0A=
}=0A=
***************=0A=
*** 428,436 ****=0A=
simple_lock_init(&sc->sc_lock);=0A=
#endif=0A=
=0A=
/* Disable interrupts before configuring the device. */=0A=
sc->sc_ier =3D 0;=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
=0A=
if (iot =3D=3D comconstag && iobase =3D=3D comconsaddr) {=0A=
comconsattached =3D 1;=0A=
--- 537,549 ----=0A=
simple_lock_init(&sc->sc_lock);=0A=
#endif=0A=
=0A=
+ /* set default register access ops if it aren't provided */=0A=
+ if (sc->sc_aops =3D=3D NULL)=0A=
+ sc->sc_aops =3D &com_accessops_1;=0A=
+ =0A=
/* Disable interrupts before configuring the device. */=0A=
sc->sc_ier =3D 0;=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_ier, sc->sc_ier);=0A=
=0A=
if (iot =3D=3D comconstag && iobase =3D=3D comconsaddr) {=0A=
comconsattached =3D 1;=0A=
***************=0A=
*** 464,476 ****=0A=
#endif=0A=
sc->sc_fifolen =3D 1;=0A=
/* look for a NS 16550AF UART with FIFOs */=0A=
! bus_space_write_1(iot, ioh, com_fifo,=0A=
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);=0A=
delay(100);=0A=
! if (ISSET(bus_space_read_1(iot, ioh, com_iir), IIR_FIFO_MASK)=0A=
=3D=3D IIR_FIFO_MASK)=0A=
! if (ISSET(bus_space_read_1(iot, ioh, com_fifo), FIFO_TRIGGER_14)=0A=
! =3D=3D FIFO_TRIGGER_14) {=0A=
SET(sc->sc_hwflags, COM_HW_FIFO);=0A=
=0A=
#ifdef COM16650=0A=
--- 577,589 ----=0A=
#endif=0A=
sc->sc_fifolen =3D 1;=0A=
/* look for a NS 16550AF UART with FIFOs */=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_fifo,=0A=
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_14);=0A=
delay(100);=0A=
! if (ISSET(com_read_reg(sc->sc_aops, iot, ioh, com_iir), IIR_FIFO_MASK)=0A=
=3D=3D IIR_FIFO_MASK)=0A=
! if (ISSET(com_read_reg(sc->sc_aops, iot, ioh, com_fifo),=0A=
! FIFO_TRIGGER_14) =3D=3D FIFO_TRIGGER_14) {=0A=
SET(sc->sc_hwflags, COM_HW_FIFO);=0A=
=0A=
#ifdef COM16650=0A=
***************=0A=
*** 485,497 ****=0A=
* setting DLAB enable gives access to the EFR on=0A=
* these chips.=0A=
*/=0A=
! lcr =3D bus_space_read_1(iot, ioh, com_lcr);=0A=
! bus_space_write_1(iot, ioh, com_lcr, LCR_EERS);=0A=
! bus_space_write_1(iot, ioh, com_efr, 0);=0A=
! if (bus_space_read_1(iot, ioh, com_efr) =3D=3D 0) {=0A=
! bus_space_write_1(iot, ioh, com_lcr,=0A=
lcr | LCR_DLAB);=0A=
! if (bus_space_read_1(iot, ioh, com_efr) =3D=3D 0) {=0A=
CLR(sc->sc_hwflags, COM_HW_FIFO);=0A=
sc->sc_fifolen =3D 0;=0A=
} else {=0A=
--- 598,611 ----=0A=
* setting DLAB enable gives access to the EFR on=0A=
* these chips.=0A=
*/=0A=
! lcr =3D com_read_reg(sc->sc_aops, iot, ioh, com_lcr);=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_lcr,LCR_EERS);=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_efr, 0);=0A=
! if (com_read_reg(sc->sc_aops, iot, ioh, com_efr) =3D=3D 0){=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_lcr,=0A=
lcr | LCR_DLAB);=0A=
! if (com_read_reg(sc->sc_aops, iot, ioh,=0A=
! com_efr) =3D=3D 0) {=0A=
CLR(sc->sc_hwflags, COM_HW_FIFO);=0A=
sc->sc_fifolen =3D 0;=0A=
} else {=0A=
***************=0A=
*** 503,509 ****=0A=
sc->sc_fifolen =3D 16;=0A=
=0A=
#ifdef COM16650=0A=
! bus_space_write_1(iot, ioh, com_lcr, lcr);=0A=
if (sc->sc_fifolen =3D=3D 0)=0A=
printf(": st16650, broken fifo\n");=0A=
else if (sc->sc_fifolen =3D=3D 32)=0A=
--- 617,623 ----=0A=
sc->sc_fifolen =3D 16;=0A=
=0A=
#ifdef COM16650=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_lcr, lcr);=0A=
if (sc->sc_fifolen =3D=3D 0)=0A=
printf(": st16650, broken fifo\n");=0A=
else if (sc->sc_fifolen =3D=3D 32)=0A=
***************=0A=
*** 515,521 ****=0A=
printf(": ns16550, broken fifo\n");=0A=
else=0A=
printf(": ns8250 or ns16450, no fifo\n");=0A=
! bus_space_write_1(iot, ioh, com_fifo, 0);=0A=
if (ISSET(sc->sc_hwflags, COM_HW_TXFIFO_DISABLE)) {=0A=
sc->sc_fifolen =3D 1;=0A=
printf("%s: txfifo disabled\n", sc->sc_dev.dv_xname);=0A=
--- 629,635 ----=0A=
printf(": ns16550, broken fifo\n");=0A=
else=0A=
printf(": ns8250 or ns16450, no fifo\n");=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_fifo, 0);=0A=
if (ISSET(sc->sc_hwflags, COM_HW_TXFIFO_DISABLE)) {=0A=
sc->sc_fifolen =3D 1;=0A=
printf("%s: txfifo disabled\n", sc->sc_dev.dv_xname);=0A=
***************=0A=
*** 599,605 ****=0A=
=0A=
/* Disable interrupts before configuring the device. */=0A=
sc->sc_ier =3D 0;=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
=0A=
#ifdef COM_HAYESP=0A=
/* Look for a Hayes ESP board. */=0A=
--- 713,719 ----=0A=
=0A=
/* Disable interrupts before configuring the device. */=0A=
sc->sc_ier =3D 0;=0A=
! com_write_reg(sc->sc_aops, iot, ioh, com_ier, sc->sc_ier);=0A=
=0A=
#ifdef COM_HAYESP=0A=
/* Look for a Hayes ESP board. */=0A=
***************=0A=
*** 607,636 ****=0A=
sc->sc_fifolen =3D 1024;=0A=
=0A=
/* Set 16550 compatibility mode */=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETMODE);=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2, =0A=
HAYESP_MODE_FIFO|HAYESP_MODE_RTS|=0A=
HAYESP_MODE_SCALE);=0A=
=0A=
/* Set RTS/CTS flow control */=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETFLOWTYPE);=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_FLOW_RTS);=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_FLOW_CTS);=0A=
=0A=
/* Set flow control levels */=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETRXFLOW);=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2, =0A=
HAYESP_HIBYTE(HAYESP_RXHIWMARK));=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_LOBYTE(HAYESP_RXHIWMARK));=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_HIBYTE(HAYESP_RXLOWMARK));=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_LOBYTE(HAYESP_RXLOWMARK));=0A=
}=0A=
#endif=0A=
--- 721,750 ----=0A=
sc->sc_fifolen =3D 1024;=0A=
=0A=
/* Set 16550 compatibility mode */=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETMODE);=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2, =0A=
HAYESP_MODE_FIFO|HAYESP_MODE_RTS|=0A=
HAYESP_MODE_SCALE);=0A=
=0A=
/* Set RTS/CTS flow control */=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETFLOWTYPE);=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_FLOW_RTS);=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_FLOW_CTS);=0A=
=0A=
/* Set flow control levels */=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETRXFLOW);=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2, =0A=
HAYESP_HIBYTE(HAYESP_RXHIWMARK));=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_LOBYTE(HAYESP_RXHIWMARK));=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_HIBYTE(HAYESP_RXLOWMARK));=0A=
! com_write_reg(sc->sc_aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
HAYESP_LOBYTE(HAYESP_RXLOWMARK));=0A=
}=0A=
#endif=0A=
***************=0A=
*** 753,759 ****=0A=
sc->sc_ier =3D IER_ERXRDY; /* interrupt on break */=0A=
else=0A=
sc->sc_ier =3D 0;=0A=
! bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier);=0A=
=0A=
if (sc->disable) {=0A=
#ifdef DIAGNOSTIC=0A=
--- 867,873 ----=0A=
sc->sc_ier =3D IER_ERXRDY; /* interrupt on break */=0A=
else=0A=
sc->sc_ier =3D 0;=0A=
! com_write_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh, com_ier, =
sc->sc_ier);=0A=
=0A=
if (sc->disable) {=0A=
#ifdef DIAGNOSTIC=0A=
***************=0A=
*** 829,838 ****=0A=
=0A=
/* Turn on interrupts. */=0A=
sc->sc_ier =3D IER_ERXRDY | IER_ERLS | IER_EMSC;=0A=
! bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier);=0A=
=0A=
/* Fetch the current modem control status, needed later. */=0A=
! sc->sc_msr =3D bus_space_read_1(sc->sc_iot, sc->sc_ioh, com_msr);=0A=
=0A=
/* Clear PPS capture state on first open. */=0A=
sc->sc_ppsmask =3D 0;=0A=
--- 943,954 ----=0A=
=0A=
/* Turn on interrupts. */=0A=
sc->sc_ier =3D IER_ERXRDY | IER_ERLS | IER_EMSC;=0A=
! com_write_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh, com_ier,=0A=
! sc->sc_ier);=0A=
=0A=
/* Fetch the current modem control status, needed later. */=0A=
! sc->sc_msr =3D com_read_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh,=0A=
! com_msr);=0A=
=0A=
/* Clear PPS capture state on first open. */=0A=
sc->sc_ppsmask =3D 0;=0A=
***************=0A=
*** 1560,1573 ****=0A=
#endif=0A=
timo =3D 50000;=0A=
/* flush any pending I/O */=0A=
! while (ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_RXRDY)=0A=
&& --timo)=0A=
#ifdef DIAGNOSTIC=0A=
reg =3D=0A=
#else=0A=
(void)=0A=
#endif=0A=
! bus_space_read_1(iot, ioh, com_data);=0A=
#ifdef DIAGNOSTIC=0A=
if (!timo)=0A=
printf("%s: com_iflush timeout %02x\n", sc->sc_dev.dv_xname,=0A=
--- 1676,1689 ----=0A=
#endif=0A=
timo =3D 50000;=0A=
/* flush any pending I/O */=0A=
! while (ISSET(com_read_reg(sc->sc_aops, iot, ioh, com_lsr), LSR_RXRDY)=0A=
&& --timo)=0A=
#ifdef DIAGNOSTIC=0A=
reg =3D=0A=
#else=0A=
(void)=0A=
#endif=0A=
! com_read_reg(sc->sc_aops, iot, ioh, com_data);=0A=
#ifdef DIAGNOSTIC=0A=
if (!timo)=0A=
printf("%s: com_iflush timeout %02x\n", sc->sc_dev.dv_xname,=0A=
***************=0A=
*** 1581,1612 ****=0A=
{=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
bus_space_handle_t ioh =3D sc->sc_ioh;=0A=
=0A=
/* XXXXX necessary? */=0A=
com_iflush(sc);=0A=
=0A=
! bus_space_write_1(iot, ioh, com_ier, 0);=0A=
=0A=
if (ISSET(sc->sc_hwflags, COM_HW_FLOW)) {=0A=
! bus_space_write_1(iot, ioh, com_lcr, LCR_EERS);=0A=
! bus_space_write_1(iot, ioh, com_efr, sc->sc_efr);=0A=
}=0A=
! bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr | LCR_DLAB);=0A=
! bus_space_write_1(iot, ioh, com_dlbl, sc->sc_dlbl);=0A=
! bus_space_write_1(iot, ioh, com_dlbh, sc->sc_dlbh);=0A=
! bus_space_write_1(iot, ioh, com_lcr, sc->sc_lcr);=0A=
! bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr_active =3D =
sc->sc_mcr);=0A=
! bus_space_write_1(iot, ioh, com_fifo, sc->sc_fifo);=0A=
#ifdef COM_HAYESP=0A=
if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) {=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETPRESCALER);=0A=
! bus_space_write_1(iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
sc->sc_prescaler);=0A=
}=0A=
#endif=0A=
=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
=0A=
int=0A=
--- 1697,1729 ----=0A=
{=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
bus_space_handle_t ioh =3D sc->sc_ioh;=0A=
+ struct com_accessops *aops =3D sc->sc_aops;=0A=
=0A=
/* XXXXX necessary? */=0A=
com_iflush(sc);=0A=
=0A=
! com_write_reg(aops, iot, ioh, com_ier, 0);=0A=
=0A=
if (ISSET(sc->sc_hwflags, COM_HW_FLOW)) {=0A=
! com_write_reg(aops, iot, ioh, com_lcr, LCR_EERS);=0A=
! com_write_reg(aops, iot, ioh, com_efr, sc->sc_efr);=0A=
}=0A=
! com_write_reg(aops, iot, ioh, com_lcr, sc->sc_lcr | LCR_DLAB);=0A=
! com_write_reg(aops, iot, ioh, com_dlbl, sc->sc_dlbl);=0A=
! com_write_reg(aops, iot, ioh, com_dlbh, sc->sc_dlbh);=0A=
! com_write_reg(aops, iot, ioh, com_lcr, sc->sc_lcr);=0A=
! com_write_reg(aops, iot, ioh, com_mcr, sc->sc_mcr_active =3D =
sc->sc_mcr);=0A=
! com_write_reg(aops, iot, ioh, com_fifo, sc->sc_fifo);=0A=
#ifdef COM_HAYESP=0A=
if (ISSET(sc->sc_hwflags, COM_HW_HAYESP)) {=0A=
! com_write_reg(aops, iot, sc->sc_hayespioh, HAYESP_CMD1,=0A=
HAYESP_SETPRESCALER);=0A=
! com_write_reg(aops, iot, sc->sc_hayespioh, HAYESP_CMD2,=0A=
sc->sc_prescaler);=0A=
}=0A=
#endif=0A=
=0A=
! com_write_reg(aops, iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
=0A=
int=0A=
***************=0A=
*** 1656,1661 ****=0A=
--- 1773,1779 ----=0A=
{=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
bus_space_handle_t ioh =3D sc->sc_ioh;=0A=
+ struct com_accessops *aops =3D sc->sc_aops;=0A=
=0A=
if (sc->sc_mcr_rts =3D=3D 0)=0A=
return;=0A=
***************=0A=
*** 1667,1673 ****=0A=
SET(sc->sc_mcr, sc->sc_mcr_rts);=0A=
SET(sc->sc_mcr_active, sc->sc_mcr_rts);=0A=
}=0A=
! bus_space_write_1(iot, ioh, com_mcr, sc->sc_mcr_active);=0A=
}=0A=
=0A=
=0A=
--- 1785,1791 ----=0A=
SET(sc->sc_mcr, sc->sc_mcr_rts);=0A=
SET(sc->sc_mcr_active, sc->sc_mcr_rts);=0A=
}=0A=
! com_write_reg(aops, iot, ioh, com_mcr, sc->sc_mcr_active);=0A=
}=0A=
=0A=
=0A=
***************=0A=
*** 1678,1683 ****=0A=
--- 1796,1802 ----=0A=
struct com_softc *sc =3D device_lookup(&com_cd, COMUNIT(tp->t_dev));=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
bus_space_handle_t ioh =3D sc->sc_ioh;=0A=
+ struct com_accessops *aops =3D sc->sc_aops;=0A=
int s;=0A=
=0A=
if (COM_ISALIVE(sc) =3D=3D 0)=0A=
***************=0A=
*** 1720,1726 ****=0A=
/* Enable transmit completion interrupts if necessary. */=0A=
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {=0A=
SET(sc->sc_ier, IER_ETXRDY);=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
=0A=
/* Output the first chunk of the contiguous buffer. */=0A=
--- 1839,1845 ----=0A=
/* Enable transmit completion interrupts if necessary. */=0A=
if (!ISSET(sc->sc_ier, IER_ETXRDY)) {=0A=
SET(sc->sc_ier, IER_ETXRDY);=0A=
! com_write_reg(aops, iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
=0A=
/* Output the first chunk of the contiguous buffer. */=0A=
***************=0A=
*** 1730,1736 ****=0A=
n =3D sc->sc_tbc;=0A=
if (n > sc->sc_fifolen)=0A=
n =3D sc->sc_fifolen;=0A=
! bus_space_write_multi_1(iot, ioh, com_data, sc->sc_tba, n);=0A=
sc->sc_tbc -=3D n;=0A=
sc->sc_tba +=3D n;=0A=
}=0A=
--- 1849,1855 ----=0A=
n =3D sc->sc_tbc;=0A=
if (n > sc->sc_fifolen)=0A=
n =3D sc->sc_fifolen;=0A=
! com_write_multi(aops, iot, ioh, com_data, sc->sc_tba, n);=0A=
sc->sc_tbc -=3D n;=0A=
sc->sc_tba +=3D n;=0A=
}=0A=
***************=0A=
*** 1871,1877 ****=0A=
if (ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {=0A=
CLR(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);=0A=
SET(sc->sc_ier, IER_ERXRDY);=0A=
! bus_space_write_1(sc->sc_iot, sc->sc_ioh, com_ier, sc->sc_ier);=0A=
}=0A=
if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) {=0A=
CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED);=0A=
--- 1990,1996 ----=0A=
if (ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {=0A=
CLR(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);=0A=
SET(sc->sc_ier, IER_ERXRDY);=0A=
! com_write_reg(sc->sc_aops, sc->sc_iot, sc->sc_ioh, com_ier, =
sc->sc_ier);=0A=
}=0A=
if (ISSET(sc->sc_rx_flags, RX_IBUF_BLOCKED)) {=0A=
CLR(sc->sc_rx_flags, RX_IBUF_BLOCKED);=0A=
***************=0A=
*** 2018,2023 ****=0A=
--- 2137,2143 ----=0A=
struct com_softc *sc =3D arg;=0A=
bus_space_tag_t iot =3D sc->sc_iot;=0A=
bus_space_handle_t ioh =3D sc->sc_ioh;=0A=
+ struct com_accessops *aops =3D sc->sc_aops;=0A=
u_char *put, *end;=0A=
u_int cc;=0A=
u_char lsr, iir;=0A=
***************=0A=
*** 2026,2032 ****=0A=
return (0);=0A=
=0A=
COM_LOCK(sc);=0A=
! iir =3D bus_space_read_1(iot, ioh, com_iir);=0A=
if (ISSET(iir, IIR_NOPEND)) {=0A=
COM_UNLOCK(sc);=0A=
return (0);=0A=
--- 2146,2152 ----=0A=
return (0);=0A=
=0A=
COM_LOCK(sc);=0A=
! iir =3D com_read_reg(aops, iot, ioh, com_iir);=0A=
if (ISSET(iir, IIR_NOPEND)) {=0A=
COM_UNLOCK(sc);=0A=
return (0);=0A=
***************=0A=
*** 2039,2045 ****=0A=
again: do {=0A=
u_char msr, delta;=0A=
=0A=
! lsr =3D bus_space_read_1(iot, ioh, com_lsr);=0A=
if (ISSET(lsr, LSR_BI)) {=0A=
int cn_trapped =3D 0;=0A=
cn_check_magic(sc->sc_tty->t_dev,=0A=
--- 2159,2165 ----=0A=
again: do {=0A=
u_char msr, delta;=0A=
=0A=
! lsr =3D com_read_reg(aops, iot, ioh, com_lsr);=0A=
if (ISSET(lsr, LSR_BI)) {=0A=
int cn_trapped =3D 0;=0A=
cn_check_magic(sc->sc_tty->t_dev,=0A=
***************=0A=
*** 2058,2069 ****=0A=
!ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {=0A=
while (cc > 0) {=0A=
int cn_trapped =3D 0;=0A=
! put[0] =3D bus_space_read_1(iot, ioh, com_data);=0A=
put[1] =3D lsr;=0A=
cn_check_magic(sc->sc_tty->t_dev,=0A=
put[0], com_cnm_state);=0A=
if (cn_trapped) {=0A=
! lsr =3D bus_space_read_1(iot, ioh, com_lsr);=0A=
if (!ISSET(lsr, LSR_RCV_MASK))=0A=
break;=0A=
=0A=
--- 2178,2190 ----=0A=
!ISSET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED)) {=0A=
while (cc > 0) {=0A=
int cn_trapped =3D 0;=0A=
! put[0] =3D com_read_reg(aops, iot, ioh,com_data);=0A=
put[1] =3D lsr;=0A=
cn_check_magic(sc->sc_tty->t_dev,=0A=
put[0], com_cnm_state);=0A=
if (cn_trapped) {=0A=
! lsr =3D com_read_reg(aops, iot, ioh,=0A=
! com_lsr);=0A=
if (!ISSET(lsr, LSR_RCV_MASK))=0A=
break;=0A=
=0A=
***************=0A=
*** 2074,2080 ****=0A=
put =3D sc->sc_rbuf;=0A=
cc--;=0A=
=0A=
! lsr =3D bus_space_read_1(iot, ioh, com_lsr);=0A=
if (!ISSET(lsr, LSR_RCV_MASK))=0A=
break;=0A=
}=0A=
--- 2195,2201 ----=0A=
put =3D sc->sc_rbuf;=0A=
cc--;=0A=
=0A=
! lsr =3D com_read_reg(aops, iot, ioh, com_lsr);=0A=
if (!ISSET(lsr, LSR_RCV_MASK))=0A=
break;=0A=
}=0A=
***************=0A=
*** 2107,2124 ****=0A=
if (!cc) {=0A=
SET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);=0A=
CLR(sc->sc_ier, IER_ERXRDY);=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
} else {=0A=
if ((iir & IIR_IMASK) =3D=3D IIR_RXRDY) {=0A=
! bus_space_write_1(iot, ioh, com_ier, 0);=0A=
delay(10);=0A=
! bus_space_write_1(iot, ioh, com_ier,sc->sc_ier);=0A=
continue;=0A=
}=0A=
}=0A=
=0A=
! msr =3D bus_space_read_1(iot, ioh, com_msr);=0A=
delta =3D msr ^ sc->sc_msr;=0A=
sc->sc_msr =3D msr;=0A=
/*=0A=
--- 2228,2247 ----=0A=
if (!cc) {=0A=
SET(sc->sc_rx_flags, RX_IBUF_OVERFLOWED);=0A=
CLR(sc->sc_ier, IER_ERXRDY);=0A=
! com_write_reg(aops, iot, ioh, com_ier,=0A=
! sc->sc_ier);=0A=
}=0A=
} else {=0A=
if ((iir & IIR_IMASK) =3D=3D IIR_RXRDY) {=0A=
! com_write_reg(aops, iot, ioh, com_ier, 0);=0A=
delay(10);=0A=
! com_write_reg(aops, iot, ioh, com_ier,=0A=
! sc->sc_ier);=0A=
continue;=0A=
}=0A=
}=0A=
=0A=
! msr =3D com_read_reg(aops, iot, ioh, com_msr);=0A=
delta =3D msr ^ sc->sc_msr;=0A=
sc->sc_msr =3D msr;=0A=
/*=0A=
***************=0A=
*** 2186,2192 ****=0A=
=0A=
sc->sc_st_check =3D 1;=0A=
}=0A=
! } while (ISSET((iir =3D bus_space_read_1(iot, ioh, com_iir)), =
IIR_RXRDY)=0A=
|| ((iir & IIR_IMASK) =3D=3D 0));=0A=
=0A=
/*=0A=
--- 2309,2315 ----=0A=
=0A=
sc->sc_st_check =3D 1;=0A=
}=0A=
! } while (ISSET((iir =3D com_read_reg(aops, iot, ioh, =
com_iir)),IIR_RXRDY)=0A=
|| ((iir & IIR_IMASK) =3D=3D 0));=0A=
=0A=
/*=0A=
***************=0A=
*** 2213,2226 ****=0A=
n =3D sc->sc_tbc;=0A=
if (n > sc->sc_fifolen)=0A=
n =3D sc->sc_fifolen;=0A=
! bus_space_write_multi_1(iot, ioh, com_data, sc->sc_tba, n);=0A=
sc->sc_tbc -=3D n;=0A=
sc->sc_tba +=3D n;=0A=
} else {=0A=
/* Disable transmit completion interrupts if necessary. */=0A=
if (ISSET(sc->sc_ier, IER_ETXRDY)) {=0A=
CLR(sc->sc_ier, IER_ETXRDY);=0A=
! bus_space_write_1(iot, ioh, com_ier, sc->sc_ier);=0A=
}=0A=
if (sc->sc_tx_busy) {=0A=
sc->sc_tx_busy =3D 0;=0A=
--- 2336,2351 ----=0A=
n =3D sc->sc_tbc;=0A=
if (n > sc->sc_fifolen)=0A=
n =3D sc->sc_fifolen;=0A=
! com_write_multi(aops, iot, ioh, com_data,=0A=
! sc->sc_tba, n);=0A=
sc->sc_tbc -=3D n;=0A=
sc->sc_tba +=3D n;=0A=
} else {=0A=
/* Disable transmit completion interrupts if necessary. */=0A=
if (ISSET(sc->sc_ier, IER_ETXRDY)) {=0A=
CLR(sc->sc_ier, IER_ETXRDY);=0A=
! com_write_reg(aops, iot, ioh, com_ier,=0A=
! sc->sc_ier);=0A=
}=0A=
if (sc->sc_tx_busy) {=0A=
sc->sc_tx_busy =3D 0;=0A=
***************=0A=
*** 2229,2235 ****=0A=
}=0A=
}=0A=
=0A=
! if (!ISSET((iir =3D bus_space_read_1(iot, ioh, com_iir)), IIR_NOPEND))=0A=
goto again;=0A=
=0A=
COM_UNLOCK(sc);=0A=
--- 2354,2360 ----=0A=
}=0A=
}=0A=
=0A=
! if (!ISSET((iir =3D com_read_reg(aops, iot, ioh, com_iir)), =
IIR_NOPEND))=0A=
goto again;=0A=
=0A=
COM_UNLOCK(sc);=0A=
***************=0A=
*** 2269,2278 ****=0A=
static int com_readaheadcount =3D 0;=0A=
=0A=
int=0A=
! com_common_getc(dev, iot, ioh)=0A=
dev_t dev;=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
{=0A=
int s =3D splserial();=0A=
u_char stat, c;=0A=
--- 2394,2404 ----=0A=
static int com_readaheadcount =3D 0;=0A=
=0A=
int=0A=
! com_common_getc(dev, iot, ioh, aops)=0A=
dev_t dev;=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
+ struct com_accessops *aops;=0A=
{=0A=
int s =3D splserial();=0A=
u_char stat, c;=0A=
***************=0A=
*** 2291,2301 ****=0A=
}=0A=
=0A=
/* block until a character becomes available */=0A=
! while (!ISSET(stat =3D bus_space_read_1(iot, ioh, com_lsr), =
LSR_RXRDY))=0A=
;=0A=
=0A=
! c =3D bus_space_read_1(iot, ioh, com_data);=0A=
! stat =3D bus_space_read_1(iot, ioh, com_iir);=0A=
{=0A=
int cn_trapped =3D 0; /* unused */=0A=
#ifdef DDB=0A=
--- 2417,2427 ----=0A=
}=0A=
=0A=
/* block until a character becomes available */=0A=
! while (!ISSET(stat =3D com_read_reg(aops, iot, ioh, com_lsr), =
LSR_RXRDY))=0A=
;=0A=
=0A=
! c =3D com_read_reg(aops, iot, ioh, com_data);=0A=
! stat =3D com_read_reg(aops, iot, ioh, com_iir);=0A=
{=0A=
int cn_trapped =3D 0; /* unused */=0A=
#ifdef DDB=0A=
***************=0A=
*** 2309,2318 ****=0A=
}=0A=
=0A=
void=0A=
! com_common_putc(dev, iot, ioh, c)=0A=
dev_t dev;=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
int c;=0A=
{=0A=
int s =3D splserial();=0A=
--- 2435,2445 ----=0A=
}=0A=
=0A=
void=0A=
! com_common_putc(dev, iot, ioh, aops, c)=0A=
dev_t dev;=0A=
bus_space_tag_t iot;=0A=
bus_space_handle_t ioh;=0A=
+ struct com_accessops *aops;=0A=
int c;=0A=
{=0A=
int s =3D splserial();=0A=
***************=0A=
*** 2320,2344 ****=0A=
=0A=
int cin, stat;=0A=
if (com_readaheadcount < MAX_READAHEAD =0A=
! && ISSET(stat =3D bus_space_read_1(iot, ioh, com_lsr), =
LSR_RXRDY)) {=0A=
int cn_trapped =3D 0;=0A=
! cin =3D bus_space_read_1(iot, ioh, com_data);=0A=
! stat =3D bus_space_read_1(iot, ioh, com_iir);=0A=
cn_check_magic(dev, cin, com_cnm_state);=0A=
com_readahead[com_readaheadcount++] =3D cin;=0A=
}=0A=
=0A=
/* wait for any pending transmission to finish */=0A=
timo =3D 150000;=0A=
! while (!ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY) && =
--timo)=0A=
continue;=0A=
=0A=
! bus_space_write_1(iot, ioh, com_data, c);=0A=
COM_BARRIER(iot, ioh, BR | BW);=0A=
=0A=
/* wait for this transmission to complete */=0A=
timo =3D 1500000;=0A=
! while (!ISSET(bus_space_read_1(iot, ioh, com_lsr), LSR_TXRDY) && =
--timo)=0A=
continue;=0A=
=0A=
splx(s);=0A=
--- 2447,2471 ----=0A=
=0A=
int cin, stat;=0A=
if (com_readaheadcount < MAX_READAHEAD =0A=
! && ISSET(stat =3D com_read_reg(aops, iot, ioh, com_lsr), =
LSR_RXRDY)) {=0A=
int cn_trapped =3D 0;=0A=
! cin =3D com_read_reg(aops, iot, ioh, com_data);=0A=
! stat =3D com_read_reg(aops, iot, ioh, com_iir);=0A=
cn_check_magic(dev, cin, com_cnm_state);=0A=
com_readahead[com_readaheadcount++] =3D cin;=0A=
}=0A=
=0A=
/* wait for any pending transmission to finish */=0A=
timo =3D 150000;=0A=
! while (!ISSET(com_read_reg(aops, iot, ioh, com_lsr), LSR_TXRDY) && =
--timo)=0A=
continue;=0A=
=0A=
! com_write_reg(aops, iot, ioh, com_data, c);=0A=
COM_BARRIER(iot, ioh, BR | BW);=0A=
=0A=
/* wait for this transmission to complete */=0A=
timo =3D 1500000;=0A=
! while (!ISSET(com_read_reg(aops, iot, ioh, com_lsr), LSR_TXRDY) && =
--timo)=0A=
continue;=0A=
=0A=
splx(s);=0A=
***************=0A=
*** 2348,2376 ****=0A=
* Initialize UART for use as console or KGDB line.=0A=
*/=0A=
int=0A=
! cominit(iot, iobase, rate, frequency, cflag, iohp)=0A=
bus_space_tag_t iot;=0A=
bus_addr_t iobase;=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
bus_space_handle_t *iohp;=0A=
{=0A=
bus_space_handle_t ioh;=0A=
=0A=
if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh))=0A=
return (ENOMEM); /* ??? */=0A=
=0A=
! bus_space_write_1(iot, ioh, com_lcr, LCR_EERS);=0A=
! bus_space_write_1(iot, ioh, com_efr, 0);=0A=
! bus_space_write_1(iot, ioh, com_lcr, LCR_DLAB);=0A=
rate =3D comspeed(rate, frequency);=0A=
! bus_space_write_1(iot, ioh, com_dlbl, rate);=0A=
! bus_space_write_1(iot, ioh, com_dlbh, rate >> 8);=0A=
! bus_space_write_1(iot, ioh, com_lcr, cflag2lcr(cflag));=0A=
! bus_space_write_1(iot, ioh, com_mcr, MCR_DTR | MCR_RTS);=0A=
! bus_space_write_1(iot, ioh, com_fifo,=0A=
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1);=0A=
! bus_space_write_1(iot, ioh, com_ier, 0);=0A=
=0A=
*iohp =3D ioh;=0A=
return (0);=0A=
--- 2475,2504 ----=0A=
* Initialize UART for use as console or KGDB line.=0A=
*/=0A=
int=0A=
! cominit(iot, iobase, rate, frequency, cflag, iohp, aops)=0A=
bus_space_tag_t iot;=0A=
bus_addr_t iobase;=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
bus_space_handle_t *iohp;=0A=
+ struct com_accessops *aops;=0A=
{=0A=
bus_space_handle_t ioh;=0A=
=0A=
if (bus_space_map(iot, iobase, COM_NPORTS, 0, &ioh))=0A=
return (ENOMEM); /* ??? */=0A=
=0A=
! com_write_reg(aops, iot, ioh, com_lcr, LCR_EERS);=0A=
! com_write_reg(aops, iot, ioh, com_efr, 0);=0A=
! com_write_reg(aops, iot, ioh, com_lcr, LCR_DLAB);=0A=
rate =3D comspeed(rate, frequency);=0A=
! com_write_reg(aops, iot, ioh, com_dlbl, rate);=0A=
! com_write_reg(aops, iot, ioh, com_dlbh, rate >> 8);=0A=
! com_write_reg(aops, iot, ioh, com_lcr, cflag2lcr(cflag));=0A=
! com_write_reg(aops, iot, ioh, com_mcr, MCR_DTR | MCR_RTS);=0A=
! com_write_reg(aops, iot, ioh, com_fifo,=0A=
FIFO_ENABLE | FIFO_RCV_RST | FIFO_XMT_RST | FIFO_TRIGGER_1);=0A=
! com_write_reg(aops, iot, ioh, com_ier, 0);=0A=
=0A=
*iohp =3D ioh;=0A=
return (0);=0A=
***************=0A=
*** 2392,2400 ****=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
{=0A=
int res;=0A=
=0A=
! res =3D cominit(iot, iobase, rate, frequency, cflag, &comconsioh);=0A=
if (res)=0A=
return (res);=0A=
=0A=
--- 2520,2539 ----=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
{=0A=
+ return comcnattachx(iot, com_defaops, iobase, rate, frequency, cflag);=0A=
+ }=0A=
+ =0A=
+ int=0A=
+ comcnattachx(iot, aops, iobase, rate, frequency, cflag)=0A=
+ bus_space_tag_t iot;=0A=
+ struct com_accessops *aops;=0A=
+ bus_addr_t iobase;=0A=
+ int rate, frequency;=0A=
+ tcflag_t cflag;=0A=
+ {=0A=
int res;=0A=
=0A=
! res =3D cominit(iot, iobase, rate, frequency, cflag, &comconsioh, =
aops);=0A=
if (res)=0A=
return (res);=0A=
=0A=
***************=0A=
*** 2403,2408 ****=0A=
--- 2542,2548 ----=0A=
cn_set_magic("\047\001"); /* default magic is BREAK */=0A=
=0A=
comconstag =3D iot;=0A=
+ comconsaops =3D aops;=0A=
comconsaddr =3D iobase;=0A=
comconsrate =3D rate;=0A=
comconscflag =3D cflag;=0A=
***************=0A=
*** 2414,2420 ****=0A=
comcngetc(dev)=0A=
dev_t dev;=0A=
{=0A=
! return (com_common_getc(dev, comconstag, comconsioh));=0A=
}=0A=
=0A=
/*=0A=
--- 2554,2560 ----=0A=
comcngetc(dev)=0A=
dev_t dev;=0A=
{=0A=
! return (com_common_getc(dev, comconstag, comconsioh, comconsaops));=0A=
}=0A=
=0A=
/*=0A=
***************=0A=
*** 2425,2431 ****=0A=
dev_t dev;=0A=
int c;=0A=
{=0A=
! com_common_putc(dev, comconstag, comconsioh, c);=0A=
}=0A=
=0A=
void=0A=
--- 2565,2571 ----=0A=
dev_t dev;=0A=
int c;=0A=
{=0A=
! com_common_putc(dev, comconstag, comconsioh, comconsaops, c);=0A=
}=0A=
=0A=
void=0A=
***************=0A=
*** 2437,2445 ****=0A=
}=0A=
=0A=
#ifdef KGDB=0A=
int=0A=
! com_kgdb_attach(iot, iobase, rate, frequency, cflag)=0A=
bus_space_tag_t iot;=0A=
bus_addr_t iobase;=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
--- 2577,2598 ----=0A=
}=0A=
=0A=
#ifdef KGDB=0A=
+ int=0A=
+ com_kgdb_attach(iot, iobase, rate, frequency, cflag, aops)=0A=
+ bus_space_tag_t iot;=0A=
+ bus_addr_t iobase;=0A=
+ int rate, frequency;=0A=
+ tcflag_t cflag;=0A=
+ struct com_accessops *aops;=0A=
+ {=0A=
+ return com_kgdb_attachx(iot, com_defaops, iobase, rate, frequency,=0A=
+ cflag, aops);=0A=
+ }=0A=
+ =0A=
int=0A=
! com_kgdb_attachx(iot, aops, iobase, rate, frequency, cflag, aops)=0A=
bus_space_tag_t iot;=0A=
+ struct com_accessops *aops;=0A=
bus_addr_t iobase;=0A=
int rate, frequency;=0A=
tcflag_t cflag;=0A=
***************=0A=
*** 2449,2455 ****=0A=
if (iot =3D=3D comconstag && iobase =3D=3D comconsaddr)=0A=
return (EBUSY); /* cannot share with console */=0A=
=0A=
! res =3D cominit(iot, iobase, rate, frequency, cflag, &com_kgdb_ioh);=0A=
if (res)=0A=
return (res);=0A=
=0A=
--- 2602,2608 ----=0A=
if (iot =3D=3D comconstag && iobase =3D=3D comconsaddr)=0A=
return (EBUSY); /* cannot share with console */=0A=
=0A=
! res =3D cominit(iot, iobase, rate, frequency, cflag, =
&com_kgdb_ioh,aops);=0A=
if (res)=0A=
return (res);=0A=
=0A=
***************=0A=
*** 2458,2463 ****=0A=
--- 2611,2617 ----=0A=
=0A=
com_kgdb_iot =3D iot;=0A=
com_kgdb_addr =3D iobase;=0A=
+ com_kgdb_aops =3D aops;=0A=
=0A=
return (0);=0A=
}=0A=
***************=0A=
*** 2467,2473 ****=0A=
com_kgdb_getc(arg)=0A=
void *arg;=0A=
{=0A=
! return (com_common_getc(NODEV, com_kgdb_iot, com_kgdb_ioh));=0A=
}=0A=
=0A=
/* ARGSUSED */=0A=
--- 2621,2628 ----=0A=
com_kgdb_getc(arg)=0A=
void *arg;=0A=
{=0A=
! return (com_common_getc(NODEV, com_kgdb_iot, com_kgdb_ioh,=0A=
! com_kgdb_aops));=0A=
}=0A=
=0A=
/* ARGSUSED */=0A=
***************=0A=
*** 2476,2482 ****=0A=
void *arg;=0A=
int c;=0A=
{=0A=
! com_common_putc(NODEV, com_kgdb_iot, com_kgdb_ioh, c);=0A=
}=0A=
#endif /* KGDB */=0A=
=0A=
--- 2631,2637 ----=0A=
void *arg;=0A=
int c;=0A=
{=0A=
! com_common_putc(NODEV, com_kgdb_iot, com_kgdb_ioh, com_kgdb_aops, c);=0A=
}=0A=
#endif /* KGDB */=0A=
=0A=
------=_NextPart_000_0189_01C1598A.F3FD57B0--