summaryrefslogtreecommitdiffstats
path: root/sys/dev/usb/usb_sw_transfer.c
diff options
context:
space:
mode:
Diffstat (limited to 'sys/dev/usb/usb_sw_transfer.c')
-rw-r--r--sys/dev/usb/usb_sw_transfer.c143
1 files changed, 0 insertions, 143 deletions
diff --git a/sys/dev/usb/usb_sw_transfer.c b/sys/dev/usb/usb_sw_transfer.c
index 9fcb69a..03f14a2 100644
--- a/sys/dev/usb/usb_sw_transfer.c
+++ b/sys/dev/usb/usb_sw_transfer.c
@@ -24,146 +24,3 @@
* SUCH DAMAGE.
*/
-#include <dev/usb/usb_mfunc.h>
-#include <dev/usb/usb.h>
-#include <dev/usb/usb_error.h>
-
-#define USB_DEBUG_VAR usb2_debug
-
-#include <dev/usb/usb_core.h>
-#include <dev/usb/usb_process.h>
-#include <dev/usb/usb_busdma.h>
-#include <dev/usb/usb_transfer.h>
-#include <dev/usb/usb_sw_transfer.h>
-#include <dev/usb/usb_device.h>
-#include <dev/usb/usb_debug.h>
-
-#include <dev/usb/usb_controller.h>
-#include <dev/usb/usb_bus.h>
-
-/*------------------------------------------------------------------------*
- * usb2_sw_transfer - factored out code
- *
- * This function is basically used for the Virtual Root HUB, and can
- * emulate control, bulk and interrupt endpoints. Data is exchanged
- * using the "std->ptr" and "std->len" fields, that allows kernel
- * virtual memory to be transferred. All state is kept in the
- * structure pointed to by the "std" argument passed to this
- * function. The "func" argument points to a function that is called
- * back in the various states, so that the application using this
- * function can get a chance to select the outcome. The "func"
- * function is allowed to sleep, exiting all mutexes. If this function
- * will sleep the "enter" and "start" methods must be marked
- * non-cancelable, hence there is no extra cancelled checking in this
- * function.
- *------------------------------------------------------------------------*/
-void
-usb2_sw_transfer(struct usb2_sw_transfer *std,
- usb2_sw_transfer_func_t *func)
-{
- struct usb2_xfer *xfer;
- usb2_frlength_t len;
- uint8_t shortpkt = 0;
-
- xfer = std->xfer;
- if (xfer == NULL) {
- /* the transfer is gone */
- DPRINTF("xfer gone\n");
- return;
- }
- USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED);
-
- std->xfer = NULL;
-
- /* check for control transfer */
- if (xfer->flags_int.control_xfr) {
- /* check if we are transferring the SETUP packet */
- if (xfer->flags_int.control_hdr) {
-
- /* copy out the USB request */
-
- if (xfer->frlengths[0] == sizeof(std->req)) {
- usb2_copy_out(xfer->frbuffers, 0,
- &std->req, sizeof(std->req));
- } else {
- std->err = USB_ERR_INVAL;
- goto done;
- }
-
- xfer->aframes = 1;
-
- std->err = 0;
- std->state = USB_SW_TR_SETUP;
-
- (func) (xfer, std);
-
- if (std->err) {
- goto done;
- }
- } else {
- /* skip the first frame in this case */
- xfer->aframes = 1;
- }
- }
- std->err = 0;
- std->state = USB_SW_TR_PRE_DATA;
-
- (func) (xfer, std);
-
- if (std->err) {
- goto done;
- }
- /* Transfer data. Iterate accross all frames. */
- while (xfer->aframes != xfer->nframes) {
-
- len = xfer->frlengths[xfer->aframes];
-
- if (len > std->len) {
- len = std->len;
- shortpkt = 1;
- }
- if (len > 0) {
- if ((xfer->endpoint & (UE_DIR_IN | UE_DIR_OUT)) == UE_DIR_IN) {
- usb2_copy_in(xfer->frbuffers + xfer->aframes, 0,
- std->ptr, len);
- } else {
- usb2_copy_out(xfer->frbuffers + xfer->aframes, 0,
- std->ptr, len);
- }
- }
- std->ptr += len;
- std->len -= len;
- xfer->frlengths[xfer->aframes] = len;
- xfer->aframes++;
-
- if (shortpkt) {
- break;
- }
- }
-
- std->err = 0;
- std->state = USB_SW_TR_POST_DATA;
-
- (func) (xfer, std);
-
- if (std->err) {
- goto done;
- }
- /* check if the control transfer is complete */
- if (xfer->flags_int.control_xfr &&
- !xfer->flags_int.control_act) {
-
- std->err = 0;
- std->state = USB_SW_TR_STATUS;
-
- (func) (xfer, std);
-
- if (std->err) {
- goto done;
- }
- }
-done:
- DPRINTF("done err=%s\n", usb2_errstr(std->err));
- std->state = USB_SW_TR_PRE_CALLBACK;
- (func) (xfer, std);
-}
OpenPOWER on IntegriCloud