usb_serial.h (187176) | usb_serial.h (188413) |
---|---|
1/* $NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $ */ | 1/* $NetBSD: ucomvar.h,v 1.9 2001/01/23 21:56:17 augustss Exp $ */ |
2/* $FreeBSD: head/sys/dev/usb2/serial/usb2_serial.h 187176 2009-01-13 19:03:47Z thompsa $ */ | 2/* $FreeBSD: head/sys/dev/usb2/serial/usb2_serial.h 188413 2009-02-09 22:05:25Z thompsa $ */ |
3 4/*- 5 * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 63 unchanged lines hidden (view full) --- 74 75/* Module interface related macros */ 76#define UCOM_MODVER 1 77 78#define UCOM_MINVER 1 79#define UCOM_PREFVER UCOM_MODVER 80#define UCOM_MAXVER 1 81 | 3 4/*- 5 * Copyright (c) 2001-2002, Shunsuke Akiyama <akiyama@jp.FreeBSD.org>. 6 * All rights reserved. 7 * 8 * Redistribution and use in source and binary forms, with or without 9 * modification, are permitted provided that the following conditions 10 * are met: --- 63 unchanged lines hidden (view full) --- 74 75/* Module interface related macros */ 76#define UCOM_MODVER 1 77 78#define UCOM_MINVER 1 79#define UCOM_PREFVER UCOM_MODVER 80#define UCOM_MAXVER 1 81 |
82struct usb2_device; |
|
82struct usb2_com_softc; | 83struct usb2_com_softc; |
84struct usb2_device_request; |
|
83struct thread; 84 | 85struct thread; 86 |
85/* NOTE: Only callbacks with "_cfg_" in its name are called 86 * from a config thread, and are allowed to sleep! The other 87 * callbacks are _not_ allowed to sleep! 88 * | 87/* |
89 * NOTE: There is no guarantee that "usb2_com_cfg_close()" will 90 * be called after "usb2_com_cfg_open()" if the device is detached 91 * while it is open! 92 */ 93struct usb2_com_callback { 94 void (*usb2_com_cfg_get_status) (struct usb2_com_softc *, uint8_t *plsr, uint8_t *pmsr); 95 void (*usb2_com_cfg_set_dtr) (struct usb2_com_softc *, uint8_t); 96 void (*usb2_com_cfg_set_rts) (struct usb2_com_softc *, uint8_t); --- 17 unchanged lines hidden (view full) --- 114#define ULSR_TXRDY 0x20 /* Transmitter buffer empty */ 115#define ULSR_BI 0x10 /* Break detected */ 116#define ULSR_FE 0x08 /* Framing error: bad stop bit */ 117#define ULSR_PE 0x04 /* Parity error */ 118#define ULSR_OE 0x02 /* Overrun, lost incoming byte */ 119#define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */ 120#define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */ 121 | 88 * NOTE: There is no guarantee that "usb2_com_cfg_close()" will 89 * be called after "usb2_com_cfg_open()" if the device is detached 90 * while it is open! 91 */ 92struct usb2_com_callback { 93 void (*usb2_com_cfg_get_status) (struct usb2_com_softc *, uint8_t *plsr, uint8_t *pmsr); 94 void (*usb2_com_cfg_set_dtr) (struct usb2_com_softc *, uint8_t); 95 void (*usb2_com_cfg_set_rts) (struct usb2_com_softc *, uint8_t); --- 17 unchanged lines hidden (view full) --- 113#define ULSR_TXRDY 0x20 /* Transmitter buffer empty */ 114#define ULSR_BI 0x10 /* Break detected */ 115#define ULSR_FE 0x08 /* Framing error: bad stop bit */ 116#define ULSR_PE 0x04 /* Parity error */ 117#define ULSR_OE 0x02 /* Overrun, lost incoming byte */ 118#define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */ 119#define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */ 120 |
122/* 123 * List of serial adapter commands or deferred function calls: 124 */ 125enum { 126 USB_COM_CFG_START_TRANSFERS, 127 USB_COM_CFG_OPEN, 128 USB_COM_CFG_CLOSE, 129 USB_COM_CFG_BREAK_ON, 130 USB_COM_CFG_BREAK_OFF, 131 USB_COM_CFG_DTR_ON, 132 USB_COM_CFG_DTR_OFF, 133 USB_COM_CFG_RTS_ON, 134 USB_COM_CFG_RTS_OFF, 135 USB_COM_CFG_STATUS_CHANGE, 136 USB_COM_CFG_PARAM, 137 USB_COM_CFG_MAX, | 121struct usb2_com_cfg_task { 122 struct usb2_proc_msg hdr; 123 struct usb2_com_softc *sc; |
138}; 139 | 124}; 125 |
140struct usb2_com_command_msg { 141 struct usb2_proc_msg hdr; /* must be first */ 142 struct usb2_com_softc *cc_softc; | 126struct usb2_com_param_task { 127 struct usb2_proc_msg hdr; 128 struct usb2_com_softc *sc; 129 struct termios termios_copy; |
143}; 144 145struct usb2_com_super_softc { | 130}; 131 132struct usb2_com_super_softc { |
146 struct usb2_process sc_config_td; | 133 struct usb2_process sc_tq; |
147}; 148 149struct usb2_com_softc { | 134}; 135 136struct usb2_com_softc { |
150 struct usb2_com_command_msg sc_cmds[2*USB_COM_CFG_MAX]; 151 struct termios sc_termios_copy; | 137 /* 138 * NOTE: To avoid loosing level change information we use two 139 * tasks instead of one for all commands. 140 * 141 * Level changes are transitions like: 142 * 143 * ON->OFF 144 * OFF->ON 145 * OPEN->CLOSE 146 * CLOSE->OPEN 147 */ 148 struct usb2_com_cfg_task sc_start_task[2]; 149 struct usb2_com_cfg_task sc_open_task[2]; 150 struct usb2_com_cfg_task sc_close_task[2]; 151 struct usb2_com_cfg_task sc_line_state_task[2]; 152 struct usb2_com_cfg_task sc_status_task[2]; 153 struct usb2_com_param_task sc_param_task[2]; |
152 struct cv sc_cv; 153 const struct usb2_com_callback *sc_callback; 154 struct usb2_com_super_softc *sc_super; 155 struct tty *sc_tty; | 154 struct cv sc_cv; 155 const struct usb2_com_callback *sc_callback; 156 struct usb2_com_super_softc *sc_super; 157 struct tty *sc_tty; |
156 struct mtx *sc_parent_mtx; | 158 struct mtx *sc_mtx; |
157 void *sc_parent; 158 uint32_t sc_unit; 159 uint32_t sc_local_unit; 160 uint16_t sc_portno; 161 uint8_t sc_flag; 162#define UCOM_FLAG_RTS_IFLOW 0x01 /* use RTS input flow control */ 163#define UCOM_FLAG_GONE 0x02 /* the device is gone */ 164#define UCOM_FLAG_ATTACHED 0x04 /* set if attached */ 165#define UCOM_FLAG_GP_DATA 0x08 /* set if get and put data is possible */ 166#define UCOM_FLAG_WR_START 0x10 /* set if write start was issued */ 167#define UCOM_FLAG_LL_READY 0x20 /* set if low layer is ready */ 168#define UCOM_FLAG_HL_READY 0x40 /* set if high layer is ready */ 169 uint8_t sc_lsr; 170 uint8_t sc_msr; 171 uint8_t sc_mcr; 172 uint8_t sc_ttyfreed; /* set when TTY has been freed */ | 159 void *sc_parent; 160 uint32_t sc_unit; 161 uint32_t sc_local_unit; 162 uint16_t sc_portno; 163 uint8_t sc_flag; 164#define UCOM_FLAG_RTS_IFLOW 0x01 /* use RTS input flow control */ 165#define UCOM_FLAG_GONE 0x02 /* the device is gone */ 166#define UCOM_FLAG_ATTACHED 0x04 /* set if attached */ 167#define UCOM_FLAG_GP_DATA 0x08 /* set if get and put data is possible */ 168#define UCOM_FLAG_WR_START 0x10 /* set if write start was issued */ 169#define UCOM_FLAG_LL_READY 0x20 /* set if low layer is ready */ 170#define UCOM_FLAG_HL_READY 0x40 /* set if high layer is ready */ 171 uint8_t sc_lsr; 172 uint8_t sc_msr; 173 uint8_t sc_mcr; 174 uint8_t sc_ttyfreed; /* set when TTY has been freed */ |
173 uint8_t sc_last_cmd_flag[USB_COM_CFG_MAX]; | 175 /* programmed line state bits */ 176 uint8_t sc_pls_set; /* set bits */ 177 uint8_t sc_pls_clr; /* cleared bits */ 178 uint8_t sc_pls_curr; /* last state */ 179#define UCOM_LS_DTR 0x01 180#define UCOM_LS_RTS 0x02 181#define UCOM_LS_BREAK 0x04 |
174}; 175 | 182}; 183 |
176int usb2_com_attach(struct usb2_com_super_softc *ssc, 177 struct usb2_com_softc *sc, uint32_t sub_units, void *parent, 178 const struct usb2_com_callback *callback, struct mtx *p_mtx); 179void usb2_com_detach(struct usb2_com_super_softc *ssc, 180 struct usb2_com_softc *sc, uint32_t sub_units); 181void usb2_com_status_change(struct usb2_com_softc *); 182uint8_t usb2_com_get_data(struct usb2_com_softc *sc, struct usb2_page_cache *pc, 183 uint32_t offset, uint32_t len, uint32_t *actlen); 184void usb2_com_put_data(struct usb2_com_softc *sc, struct usb2_page_cache *pc, 185 uint32_t offset, uint32_t len); 186uint8_t usb2_com_cfg_sleep(struct usb2_com_softc *sc, uint32_t timeout); 187uint8_t usb2_com_cfg_is_gone(struct usb2_com_softc *sc); | 184#define usb2_com_cfg_do_request(udev,com,req,ptr,flags,timo) \ 185 usb2_do_request_proc(udev,&(com)->sc_super->sc_tq,req,ptr,flags,NULL,timo) |
188 | 186 |
187int usb2_com_attach(struct usb2_com_super_softc *, 188 struct usb2_com_softc *, uint32_t, void *, 189 const struct usb2_com_callback *callback, struct mtx *); 190void usb2_com_detach(struct usb2_com_super_softc *, 191 struct usb2_com_softc *, uint32_t); 192void usb2_com_status_change(struct usb2_com_softc *); 193uint8_t usb2_com_get_data(struct usb2_com_softc *, struct usb2_page_cache *, 194 uint32_t, uint32_t, uint32_t *); 195void usb2_com_put_data(struct usb2_com_softc *, struct usb2_page_cache *, 196 uint32_t, uint32_t); 197uint8_t usb2_com_cfg_is_gone(struct usb2_com_softc *); |
|
189#endif /* _USB2_SERIAL_H_ */ | 198#endif /* _USB2_SERIAL_H_ */ |