uart.h (1021B)
1 typedef struct uart Uart; 2 typedef struct uartphy Uartphy; 3 4 enum rs232sig { 5 SIG_DCD, 6 SIG_RXD, 7 SIG_TXD, 8 SIG_DTR, 9 SIG_DSR, 10 SIG_RTS, 11 SIG_CTS, 12 SIG_RI, 13 }; 14 15 enum parity { 16 OPARITY = 'o', 17 EPARITY = 'e', 18 NPARITY = 'n', 19 }; 20 21 struct uartstat { 22 /* TODO: add stats */ 23 int dummy; 24 }; 25 26 struct uart { 27 long rate; 28 int nbits; 29 int nstop; 30 int hang; 31 int ctsflow; 32 int parity; 33 int fifo; 34 int dtr; 35 int rts; 36 long clk; 37 void *base; 38 39 mutex_t m; 40 Uartphy *phy; 41 }; 42 43 struct uartphy { 44 char *name; 45 void (*init)(Uart *up, Attr *attr); 46 int (*setbauds)(Uart *up, long rate); 47 int (*signal)(Uart *up, int mask, int val); 48 int (*read)(Uart *up, void *buf, int n); 49 int (*write)(Uart *up, void *buf, int n); 50 int (*flush)(Uart *uart); 51 int (*setfifo)(Uart *uart, int size); 52 int (*numbits)(Uart *uart, int nbits); 53 int (*parity)(Uart *uart, int type); 54 int (*bitstop)(Uart *up, int nstops); 55 int (*obey)(Uart *uart, int type, int ena); 56 57 int (*status)(Uart *up, struct uartstat *st); 58 }; 59 60 extern void uartlink(Uartphy *phy, Attr *attr);