summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorthompsa <thompsa@FreeBSD.org>2009-01-13 19:03:47 +0000
committerthompsa <thompsa@FreeBSD.org>2009-01-13 19:03:47 +0000
commitb1d0bacc6a02bbf7d239be34106924d571c8414a (patch)
tree0c4cbd9a4b0b0dc8d17c60ab574b8104c88220d2 /sys
parent53c862677a07295b6d3d5e77f94488d812f9c1eb (diff)
downloadFreeBSD-src-b1d0bacc6a02bbf7d239be34106924d571c8414a.zip
FreeBSD-src-b1d0bacc6a02bbf7d239be34106924d571c8414a.tar.gz
MFp4: //depot/projects/usb@155917
Remove dependancy towards the USB config thread in the USB serial core. Use USB process msignalling instead. Saves a little memory and hopefully makes the code more understandable. Submitted by: Hans Petter Selasky
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/usb2/serial/u3g2.c1
-rw-r--r--sys/dev/usb2/serial/uark2.c1
-rw-r--r--sys/dev/usb2/serial/ubsa2.c1
-rw-r--r--sys/dev/usb2/serial/ubser2.c1
-rw-r--r--sys/dev/usb2/serial/uchcom2.c1
-rw-r--r--sys/dev/usb2/serial/ucycom2.c1
-rw-r--r--sys/dev/usb2/serial/ufoma2.c1
-rw-r--r--sys/dev/usb2/serial/uftdi2.c1
-rw-r--r--sys/dev/usb2/serial/ugensa2.c1
-rw-r--r--sys/dev/usb2/serial/uipaq2.c1
-rw-r--r--sys/dev/usb2/serial/ulpt2.c1
-rw-r--r--sys/dev/usb2/serial/umct2.c1
-rw-r--r--sys/dev/usb2/serial/umodem2.c1
-rw-r--r--sys/dev/usb2/serial/umoscom2.c1
-rw-r--r--sys/dev/usb2/serial/uplcom2.c1
-rw-r--r--sys/dev/usb2/serial/usb2_serial.c258
-rw-r--r--sys/dev/usb2/serial/usb2_serial.h27
-rw-r--r--sys/dev/usb2/serial/uvisor2.c1
-rw-r--r--sys/dev/usb2/serial/uvscom2.c1
19 files changed, 209 insertions, 93 deletions
diff --git a/sys/dev/usb2/serial/u3g2.c b/sys/dev/usb2/serial/u3g2.c
index 4e0bfab..ba81b06 100644
--- a/sys/dev/usb2/serial/u3g2.c
+++ b/sys/dev/usb2/serial/u3g2.c
@@ -44,7 +44,6 @@
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uark2.c b/sys/dev/usb2/serial/uark2.c
index bd775b4..ffd554f 100644
--- a/sys/dev/usb2/serial/uark2.c
+++ b/sys/dev/usb2/serial/uark2.c
@@ -34,7 +34,6 @@
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ubsa2.c b/sys/dev/usb2/serial/ubsa2.c
index 31e6d72..fc36405 100644
--- a/sys/dev/usb2/serial/ubsa2.c
+++ b/sys/dev/usb2/serial/ubsa2.c
@@ -73,7 +73,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ubser2.c b/sys/dev/usb2/serial/ubser2.c
index 6435796..de2e4c0 100644
--- a/sys/dev/usb2/serial/ubser2.c
+++ b/sys/dev/usb2/serial/ubser2.c
@@ -87,7 +87,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uchcom2.c b/sys/dev/usb2/serial/uchcom2.c
index fef2a89..25da39c 100644
--- a/sys/dev/usb2/serial/uchcom2.c
+++ b/sys/dev/usb2/serial/uchcom2.c
@@ -81,7 +81,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ucycom2.c b/sys/dev/usb2/serial/ucycom2.c
index 78a1ec0..f18df2c 100644
--- a/sys/dev/usb2/serial/ucycom2.c
+++ b/sys/dev/usb2/serial/ucycom2.c
@@ -47,7 +47,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ufoma2.c b/sys/dev/usb2/serial/ufoma2.c
index e0f4b3e..3397d49 100644
--- a/sys/dev/usb2/serial/ufoma2.c
+++ b/sys/dev/usb2/serial/ufoma2.c
@@ -93,7 +93,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uftdi2.c b/sys/dev/usb2/serial/uftdi2.c
index b686ec5..52a948c 100644
--- a/sys/dev/usb2/serial/uftdi2.c
+++ b/sys/dev/usb2/serial/uftdi2.c
@@ -59,7 +59,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ugensa2.c b/sys/dev/usb2/serial/ugensa2.c
index 8be929b..417166a 100644
--- a/sys/dev/usb2/serial/ugensa2.c
+++ b/sys/dev/usb2/serial/ugensa2.c
@@ -54,7 +54,6 @@
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uipaq2.c b/sys/dev/usb2/serial/uipaq2.c
index 064a639..be1a0cc 100644
--- a/sys/dev/usb2/serial/uipaq2.c
+++ b/sys/dev/usb2/serial/uipaq2.c
@@ -62,7 +62,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/ulpt2.c b/sys/dev/usb2/serial/ulpt2.c
index 4b9f44b..0cf0989 100644
--- a/sys/dev/usb2/serial/ulpt2.c
+++ b/sys/dev/usb2/serial/ulpt2.c
@@ -55,7 +55,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/umct2.c b/sys/dev/usb2/serial/umct2.c
index 8e20ee7..ad0b800 100644
--- a/sys/dev/usb2/serial/umct2.c
+++ b/sys/dev/usb2/serial/umct2.c
@@ -56,7 +56,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/umodem2.c b/sys/dev/usb2/serial/umodem2.c
index 3720e23..00e3429 100644
--- a/sys/dev/usb2/serial/umodem2.c
+++ b/sys/dev/usb2/serial/umodem2.c
@@ -92,7 +92,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/umoscom2.c b/sys/dev/usb2/serial/umoscom2.c
index d2343f1..c5d8f95 100644
--- a/sys/dev/usb2/serial/umoscom2.c
+++ b/sys/dev/usb2/serial/umoscom2.c
@@ -28,7 +28,6 @@
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uplcom2.c b/sys/dev/usb2/serial/uplcom2.c
index 6e556e5..17ac396 100644
--- a/sys/dev/usb2/serial/uplcom2.c
+++ b/sys/dev/usb2/serial/uplcom2.c
@@ -95,7 +95,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/usb2_serial.c b/sys/dev/usb2/serial/usb2_serial.c
index 7a2f2e1..565c70b 100644
--- a/sys/dev/usb2/serial/usb2_serial.c
+++ b/sys/dev/usb2/serial/usb2_serial.c
@@ -78,13 +78,10 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/include/usb2_cdc.h>
#define USB_DEBUG_VAR usb2_com_debug
-#define usb2_config_td_cc usb2_com_config_copy
-#define usb2_config_td_softc usb2_com_softc
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_busdma.h>
#include <dev/usb2/core/usb2_util.h>
@@ -99,30 +96,26 @@ SYSCTL_INT(_hw_usb2_ucom, OID_AUTO, debug, CTLFLAG_RW,
&usb2_com_debug, 0, "ucom debug level");
#endif
-struct usb2_com_config_copy {
- struct usb2_com_softc *cc_softc;
- uint8_t cc_flag0;
- uint8_t cc_flag1;
- uint8_t cc_flag2;
- uint8_t cc_flag3;
-};
-
-static usb2_config_td_command_t usb2_com_config_copy;
-static usb2_config_td_command_t usb2_com_cfg_start_transfers;
-static usb2_config_td_command_t usb2_com_cfg_open;
-static usb2_config_td_command_t usb2_com_cfg_close;
-static usb2_config_td_command_t usb2_com_cfg_break;
-static usb2_config_td_command_t usb2_com_cfg_dtr;
-static usb2_config_td_command_t usb2_com_cfg_rts;
-static usb2_config_td_command_t usb2_com_cfg_status_change;
-static usb2_config_td_command_t usb2_com_cfg_param;
+static usb2_proc_callback_t usb2_com_cfg_start_transfers;
+static usb2_proc_callback_t usb2_com_cfg_open;
+static usb2_proc_callback_t usb2_com_cfg_close;
+static usb2_proc_callback_t usb2_com_cfg_break_on;
+static usb2_proc_callback_t usb2_com_cfg_break_off;
+static usb2_proc_callback_t usb2_com_cfg_dtr_on;
+static usb2_proc_callback_t usb2_com_cfg_dtr_off;
+static usb2_proc_callback_t usb2_com_cfg_rts_on;
+static usb2_proc_callback_t usb2_com_cfg_rts_off;
+static usb2_proc_callback_t usb2_com_cfg_status_change;
+static usb2_proc_callback_t usb2_com_cfg_param;
static uint8_t usb2_com_units_alloc(uint32_t, uint32_t *);
static void usb2_com_units_free(uint32_t, uint32_t);
static int usb2_com_attach_sub(struct usb2_com_softc *);
static void usb2_com_detach_sub(struct usb2_com_softc *);
-static void usb2_com_queue_command(struct usb2_com_softc *,
- usb2_config_td_command_t *, int);
+static void usb2_com_queue_command(struct usb2_com_softc *sc,
+ uint8_t cmd);
+static void usb2_com_wait_command(struct usb2_com_softc *sc,
+ uint8_t cmd);
static void usb2_com_shutdown(struct usb2_com_softc *);
static void usb2_com_start_transfers(struct usb2_com_softc *);
static void usb2_com_break(struct usb2_com_softc *, uint8_t);
@@ -251,9 +244,7 @@ usb2_com_attach(struct usb2_com_super_softc *ssc, struct usb2_com_softc *sc,
if (usb2_com_units_alloc(sub_units, &root_unit)) {
return (ENOMEM);
}
- if (usb2_config_td_setup
- (&ssc->sc_config_td, sc, p_mtx, NULL,
- sizeof(struct usb2_com_config_copy), 24 * sub_units)) {
+ if (usb2_proc_setup(&ssc->sc_config_td, p_mtx, USB_PRI_MED)) {
usb2_com_units_free(root_unit, sub_units);
return (ENOMEM);
}
@@ -285,7 +276,7 @@ usb2_com_detach(struct usb2_com_super_softc *ssc, struct usb2_com_softc *sc,
{
uint32_t n;
- usb2_config_td_drain(&ssc->sc_config_td);
+ usb2_proc_drain(&ssc->sc_config_td);
for (n = 0; n < sub_units; n++, sc++) {
if (sc->sc_flag & UCOM_FLAG_ATTACHED) {
@@ -298,8 +289,7 @@ usb2_com_detach(struct usb2_com_super_softc *ssc, struct usb2_com_softc *sc,
sc->sc_flag &= ~UCOM_FLAG_ATTACHED;
}
}
-
- usb2_config_td_unsetup(&ssc->sc_config_td);
+ usb2_proc_unsetup(&ssc->sc_config_td);
}
static int
@@ -307,6 +297,7 @@ usb2_com_attach_sub(struct usb2_com_softc *sc)
{
struct tty *tp;
int error = 0;
+ uint8_t n;
char buf[32]; /* temporary TTY device name buffer */
tp = tty_alloc(&usb2_com_class, sc, sc->sc_parent_mtx);
@@ -336,6 +327,39 @@ usb2_com_attach_sub(struct usb2_com_softc *sc)
DPRINTF("ttycreate: %s\n", buf);
usb2_cv_init(&sc->sc_cv, "usb2_com");
+ /*
+ * Set all function callback pointers for deferred COM
+ * operations:
+ */
+ for (n = 0; n != 2; n++) {
+ sc->sc_cmds[(2*USB_COM_CFG_START_TRANSFERS) + n].hdr.pm_callback =
+ &usb2_com_cfg_start_transfers;
+ sc->sc_cmds[(2*USB_COM_CFG_OPEN) + n].hdr.pm_callback =
+ &usb2_com_cfg_open;
+ sc->sc_cmds[(2*USB_COM_CFG_CLOSE) + n].hdr.pm_callback =
+ &usb2_com_cfg_close;
+ sc->sc_cmds[(2*USB_COM_CFG_BREAK_ON) + n].hdr.pm_callback =
+ &usb2_com_cfg_break_on;
+ sc->sc_cmds[(2*USB_COM_CFG_BREAK_OFF) + n].hdr.pm_callback =
+ &usb2_com_cfg_break_off;
+ sc->sc_cmds[(2*USB_COM_CFG_DTR_ON) + n].hdr.pm_callback =
+ &usb2_com_cfg_dtr_on;
+ sc->sc_cmds[(2*USB_COM_CFG_DTR_OFF) + n].hdr.pm_callback =
+ &usb2_com_cfg_dtr_off;
+ sc->sc_cmds[(2*USB_COM_CFG_RTS_ON) + n].hdr.pm_callback =
+ &usb2_com_cfg_rts_on;
+ sc->sc_cmds[(2*USB_COM_CFG_RTS_OFF) + n].hdr.pm_callback =
+ &usb2_com_cfg_rts_off;
+ sc->sc_cmds[(2*USB_COM_CFG_STATUS_CHANGE) + n].hdr.pm_callback =
+ &usb2_com_cfg_status_change;
+ sc->sc_cmds[(2*USB_COM_CFG_PARAM) + n].hdr.pm_callback =
+ &usb2_com_cfg_param;
+ }
+
+ /* initialise all callback pointer arguments */
+ for (n = 0; n != (2*USB_COM_CFG_MAX); n++) {
+ sc->sc_cmds[n].cc_softc = sc;
+ }
done:
return (error);
}
@@ -379,27 +403,41 @@ usb2_com_detach_sub(struct usb2_com_softc *sc)
usb2_cv_destroy(&sc->sc_cv);
}
+/*
+ * The following function queues a command for deferred execution.
+ * The following function must be called locked.
+ */
static void
-usb2_com_config_copy(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_queue_command(struct usb2_com_softc *sc, uint8_t cmd)
{
- cc->cc_softc = sc + (refcount % UCOM_SUB_UNIT_MAX);
- cc->cc_flag0 = (refcount / (1 * UCOM_SUB_UNIT_MAX)) % 2;
- cc->cc_flag1 = (refcount / (2 * UCOM_SUB_UNIT_MAX)) % 2;
- cc->cc_flag2 = (refcount / (4 * UCOM_SUB_UNIT_MAX)) % 2;
- cc->cc_flag3 = (refcount / (8 * UCOM_SUB_UNIT_MAX)) % 2;
+ struct usb2_com_super_softc *ssc = sc->sc_super;
+
+ if (usb2_proc_is_gone(&ssc->sc_config_td)) {
+ DPRINTF("proc is gone\n");
+ return; /* nothing to do */
+ }
+
+ if (usb2_proc_msignal(&ssc->sc_config_td,
+ &sc->sc_cmds[2*cmd], &sc->sc_cmds[(2*cmd)+1])) {
+ /* ignore */
+ }
}
+/*
+ * The following function waits until a command has been executed.
+ * The following function must be called locked.
+ */
static void
-usb2_com_queue_command(struct usb2_com_softc *sc, usb2_config_td_command_t *cmd, int flag)
+usb2_com_wait_command(struct usb2_com_softc *sc, uint8_t cmd)
{
struct usb2_com_super_softc *ssc = sc->sc_super;
- usb2_config_td_queue_command
- (&ssc->sc_config_td, &usb2_com_config_copy,
- cmd, (cmd == &usb2_com_cfg_status_change) ? 1 : 0,
- ((sc->sc_local_unit % UCOM_SUB_UNIT_MAX) +
- (flag ? UCOM_SUB_UNIT_MAX : 0)));
+ if (usb2_proc_is_gone(&ssc->sc_config_td)) {
+ DPRINTF("proc is gone\n");
+ return; /* nothing to do */
+ }
+ usb2_proc_mwait(&ssc->sc_config_td,
+ &sc->sc_cmds[2*cmd], &sc->sc_cmds[(2*cmd)+1]);
}
static void
@@ -420,6 +458,8 @@ usb2_com_shutdown(struct usb2_com_softc *sc)
}
/*
+ * This function will sleep "timeout" system ticks.
+ *
* Return values:
* 0: normal delay
* else: config thread is gone
@@ -428,8 +468,26 @@ uint8_t
usb2_com_cfg_sleep(struct usb2_com_softc *sc, uint32_t timeout)
{
struct usb2_com_super_softc *ssc = sc->sc_super;
+ uint8_t is_gone;
+
+ is_gone = usb2_proc_is_gone(&ssc->sc_config_td);
+ if (is_gone)
+ goto done; /* we are detaching */
+ if (timeout == 0)
+ timeout = 1; /* one tick is the least timeout */
+
+ mtx_unlock(sc->sc_parent_mtx);
+
+ if (pause("UCOMWAIT", timeout)) {
+ /* ignore */
+ }
- return (usb2_config_td_sleep(&ssc->sc_config_td, timeout));
+ mtx_lock(sc->sc_parent_mtx);
+
+ /* refresh gone status */
+ is_gone = usb2_proc_is_gone(&ssc->sc_config_td);
+done:
+ return (is_gone);
}
/*
@@ -442,13 +500,15 @@ usb2_com_cfg_is_gone(struct usb2_com_softc *sc)
{
struct usb2_com_super_softc *ssc = sc->sc_super;
- return (usb2_config_td_is_gone(&ssc->sc_config_td));
+ return (usb2_proc_is_gone(&ssc->sc_config_td));
}
static void
-usb2_com_cfg_start_transfers(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_start_transfers(struct usb2_proc_msg *_cc)
{
+ struct usb2_com_command_msg *cc = (void *)_cc;
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
if (!(sc->sc_flag & UCOM_FLAG_LL_READY)) {
@@ -485,14 +545,16 @@ usb2_com_start_transfers(struct usb2_com_softc *sc)
(sc->sc_callback->usb2_com_start_write) (sc);
}
if (!(sc->sc_flag & UCOM_FLAG_GP_DATA)) {
- usb2_com_queue_command(sc, &usb2_com_cfg_start_transfers, 0);
+ usb2_com_queue_command(sc, USB_COM_CFG_START_TRANSFERS);
}
}
static void
-usb2_com_cfg_open(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_open(struct usb2_proc_msg *_cc)
{
+ struct usb2_com_command_msg *cc = (void *)_cc;
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
DPRINTF("\n");
@@ -550,7 +612,7 @@ usb2_com_open(struct tty *tp)
sc->sc_msr = 0;
sc->sc_mcr = 0;
- usb2_com_queue_command(sc, &usb2_com_cfg_open, 0);
+ usb2_com_queue_command(sc, USB_COM_CFG_OPEN);
usb2_com_start_transfers(sc);
@@ -564,9 +626,11 @@ usb2_com_open(struct tty *tp)
}
static void
-usb2_com_cfg_close(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_close(struct usb2_proc_msg *_cc)
{
+ struct usb2_com_command_msg *cc = (void *)_cc;
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
DPRINTF("\n");
@@ -588,7 +652,6 @@ static void
usb2_com_close(struct tty *tp)
{
struct usb2_com_softc *sc = tty_softc(tp);
- struct usb2_com_super_softc *ssc = sc->sc_super;
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -600,8 +663,9 @@ usb2_com_close(struct tty *tp)
}
usb2_com_shutdown(sc);
- usb2_com_queue_command(sc, &usb2_com_cfg_close, 0);
- usb2_config_td_sync(&ssc->sc_config_td);
+ /* Queue and wait for close command to complete */
+ usb2_com_queue_command(sc, USB_COM_CFG_CLOSE);
+ usb2_com_wait_command(sc, USB_COM_CFG_CLOSE);
sc->sc_flag &= ~(UCOM_FLAG_HL_READY |
UCOM_FLAG_WR_START |
@@ -704,22 +768,35 @@ usb2_com_modem(struct tty *tp, int sigon, int sigoff)
}
static void
-usb2_com_cfg_break(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_break(struct usb2_com_command_msg *cc, uint8_t onoff)
{
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
if (!(sc->sc_flag & UCOM_FLAG_LL_READY)) {
return;
}
- DPRINTF("onoff=%d\n", cc->cc_flag0);
+ DPRINTF("onoff=%d\n", onoff);
if (sc->sc_callback->usb2_com_cfg_set_break) {
- (sc->sc_callback->usb2_com_cfg_set_break) (sc, cc->cc_flag0);
+ (sc->sc_callback->usb2_com_cfg_set_break) (sc, onoff);
}
}
static void
+usb2_com_cfg_break_on(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_break((void *)_cc, 1);
+}
+
+static void
+usb2_com_cfg_break_off(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_break((void *)_cc, 0);
+}
+
+static void
usb2_com_break(struct usb2_com_softc *sc, uint8_t onoff)
{
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -729,26 +806,40 @@ usb2_com_break(struct usb2_com_softc *sc, uint8_t onoff)
}
DPRINTF("onoff = %d\n", onoff);
- usb2_com_queue_command(sc, &usb2_com_cfg_break, onoff);
+ usb2_com_queue_command(sc, onoff ?
+ USB_COM_CFG_BREAK_ON : USB_COM_CFG_BREAK_OFF);
}
static void
-usb2_com_cfg_dtr(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_dtr(struct usb2_com_command_msg *cc, uint8_t onoff)
{
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
if (!(sc->sc_flag & UCOM_FLAG_LL_READY)) {
return;
}
- DPRINTF("onoff=%d\n", cc->cc_flag0);
+ DPRINTF("onoff=%d\n", onoff);
if (sc->sc_callback->usb2_com_cfg_set_dtr) {
- (sc->sc_callback->usb2_com_cfg_set_dtr) (sc, cc->cc_flag0);
+ (sc->sc_callback->usb2_com_cfg_set_dtr) (sc, onoff);
}
}
static void
+usb2_com_cfg_dtr_on(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_dtr((void *)_cc, 1);
+}
+
+static void
+usb2_com_cfg_dtr_off(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_dtr((void *)_cc, 0);
+}
+
+static void
usb2_com_dtr(struct usb2_com_softc *sc, uint8_t onoff)
{
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -758,26 +849,40 @@ usb2_com_dtr(struct usb2_com_softc *sc, uint8_t onoff)
}
DPRINTF("onoff = %d\n", onoff);
- usb2_com_queue_command(sc, &usb2_com_cfg_dtr, onoff);
+ usb2_com_queue_command(sc, onoff ?
+ USB_COM_CFG_DTR_ON : USB_COM_CFG_DTR_OFF);
}
static void
-usb2_com_cfg_rts(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_rts(struct usb2_com_command_msg *cc, uint8_t onoff)
{
+ struct usb2_com_softc *sc;
+
sc = cc->cc_softc;
- DPRINTF("onoff=%d\n", cc->cc_flag0);
+ DPRINTF("onoff=%d\n", onoff);
if (!(sc->sc_flag & UCOM_FLAG_LL_READY)) {
return;
}
if (sc->sc_callback->usb2_com_cfg_set_rts) {
- (sc->sc_callback->usb2_com_cfg_set_rts) (sc, cc->cc_flag0);
+ (sc->sc_callback->usb2_com_cfg_set_rts) (sc, onoff);
}
}
static void
+usb2_com_cfg_rts_on(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_rts((void *)_cc, 1);
+}
+
+static void
+usb2_com_cfg_rts_off(struct usb2_proc_msg *_cc)
+{
+ usb2_com_cfg_rts((void *)_cc, 0);
+}
+
+static void
usb2_com_rts(struct usb2_com_softc *sc, uint8_t onoff)
{
mtx_assert(sc->sc_parent_mtx, MA_OWNED);
@@ -787,13 +892,15 @@ usb2_com_rts(struct usb2_com_softc *sc, uint8_t onoff)
}
DPRINTF("onoff = %d\n", onoff);
- usb2_com_queue_command(sc, &usb2_com_cfg_rts, onoff);
+ usb2_com_queue_command(sc, onoff ?
+ USB_COM_CFG_RTS_ON : USB_COM_CFG_RTS_OFF);
}
static void
-usb2_com_cfg_status_change(struct usb2_com_softc *sc,
- struct usb2_com_config_copy *cc, uint16_t refcount)
+usb2_com_cfg_status_change(struct usb2_proc_msg *_cc)
{
+ struct usb2_com_command_msg *cc = (void *)_cc;
+ struct usb2_com_softc *sc;
struct tty *tp;
uint8_t new_msr;
@@ -847,13 +954,14 @@ usb2_com_status_change(struct usb2_com_softc *sc)
}
DPRINTF("\n");
- usb2_com_queue_command(sc, &usb2_com_cfg_status_change, 0);
+ usb2_com_queue_command(sc, USB_COM_CFG_STATUS_CHANGE);
}
static void
-usb2_com_cfg_param(struct usb2_com_softc *sc, struct usb2_com_config_copy *cc,
- uint16_t refcount)
+usb2_com_cfg_param(struct usb2_proc_msg *_cc)
{
+ struct usb2_com_command_msg *cc = (void *)_cc;
+ struct usb2_com_softc *sc;
struct termios t_copy;
sc = cc->cc_softc;
@@ -924,7 +1032,7 @@ usb2_com_param(struct tty *tp, struct termios *t)
sc->sc_flag &= ~UCOM_FLAG_GP_DATA;
/* Queue baud rate programming command first */
- usb2_com_queue_command(sc, &usb2_com_cfg_param, 0);
+ usb2_com_queue_command(sc, USB_COM_CFG_PARAM);
/* Queue transfer enable command last */
usb2_com_start_transfers(sc);
diff --git a/sys/dev/usb2/serial/usb2_serial.h b/sys/dev/usb2/serial/usb2_serial.h
index 073208c..3c87a4f 100644
--- a/sys/dev/usb2/serial/usb2_serial.h
+++ b/sys/dev/usb2/serial/usb2_serial.h
@@ -119,11 +119,35 @@ struct usb2_com_callback {
#define ULSR_RXRDY 0x01 /* Byte ready in Receive Buffer */
#define ULSR_RCV_MASK 0x1f /* Mask for incoming data or error */
+/*
+ * List of serial adapter commands or deferred function calls:
+ */
+enum {
+ USB_COM_CFG_START_TRANSFERS,
+ USB_COM_CFG_OPEN,
+ USB_COM_CFG_CLOSE,
+ USB_COM_CFG_BREAK_ON,
+ USB_COM_CFG_BREAK_OFF,
+ USB_COM_CFG_DTR_ON,
+ USB_COM_CFG_DTR_OFF,
+ USB_COM_CFG_RTS_ON,
+ USB_COM_CFG_RTS_OFF,
+ USB_COM_CFG_STATUS_CHANGE,
+ USB_COM_CFG_PARAM,
+ USB_COM_CFG_MAX,
+};
+
+struct usb2_com_command_msg {
+ struct usb2_proc_msg hdr; /* must be first */
+ struct usb2_com_softc *cc_softc;
+};
+
struct usb2_com_super_softc {
- struct usb2_config_td sc_config_td;
+ struct usb2_process sc_config_td;
};
struct usb2_com_softc {
+ struct usb2_com_command_msg sc_cmds[2*USB_COM_CFG_MAX];
struct termios sc_termios_copy;
struct cv sc_cv;
const struct usb2_com_callback *sc_callback;
@@ -146,6 +170,7 @@ struct usb2_com_softc {
uint8_t sc_msr;
uint8_t sc_mcr;
uint8_t sc_ttyfreed; /* set when TTY has been freed */
+ uint8_t sc_last_cmd_flag[USB_COM_CFG_MAX];
};
int usb2_com_attach(struct usb2_com_super_softc *ssc,
diff --git a/sys/dev/usb2/serial/uvisor2.c b/sys/dev/usb2/serial/uvisor2.c
index 3fb5d45..d844a8c 100644
--- a/sys/dev/usb2/serial/uvisor2.c
+++ b/sys/dev/usb2/serial/uvisor2.c
@@ -66,7 +66,6 @@
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
diff --git a/sys/dev/usb2/serial/uvscom2.c b/sys/dev/usb2/serial/uvscom2.c
index 7f92c54..fc2fa47 100644
--- a/sys/dev/usb2/serial/uvscom2.c
+++ b/sys/dev/usb2/serial/uvscom2.c
@@ -48,7 +48,6 @@ __FBSDID("$FreeBSD$");
#include <dev/usb2/core/usb2_core.h>
#include <dev/usb2/core/usb2_debug.h>
#include <dev/usb2/core/usb2_process.h>
-#include <dev/usb2/core/usb2_config_td.h>
#include <dev/usb2/core/usb2_request.h>
#include <dev/usb2/core/usb2_lookup.h>
#include <dev/usb2/core/usb2_util.h>
OpenPOWER on IntegriCloud