6 typedef struct NS16550
*NS16550_t
;
8 const NS16550_t COM_PORTS
[] = { (NS16550_t
) COM1
,
13 volatile struct NS16550
*
14 NS16550_init(int chan
)
16 volatile struct NS16550
*com_port
;
17 volatile unsigned char xx
;
18 com_port
= (struct NS16550
*) COM_PORTS
[chan
];
19 /* See if port is present */
23 if (com_port
->ier
!= 0x0F) return ((struct NS16550
*)0);
26 com_port
->lcr
= 0x80; /* Access baud rate */
27 com_port
->dll
= 0xc; /* 9600 baud */
28 com_port
->dlm
= 0xc >> 8;
29 com_port
->lcr
= 0x03; /* 8 data, 1 stop, no parity */
30 com_port
->mcr
= 0x03; /* RTS/DTR */
31 com_port
->fcr
= 0x07; /* Clear & enable FIFOs */
36 NS16550_putc(volatile struct NS16550
*com_port
, unsigned char c
)
39 while ((com_port
->lsr
& LSR_THRE
) == 0) ;
44 NS16550_getc(volatile struct NS16550
*com_port
)
46 while ((com_port
->lsr
& LSR_DR
) == 0) ;
47 return (com_port
->rbr
);
50 NS16550_tstc(volatile struct NS16550
*com_port
)
52 return ((com_port
->lsr
& LSR_DR
) != 0);