Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 29 Jun 2008 17:45:31 GMT
From:      Hans Petter Selasky <hselasky@FreeBSD.org>
To:        Perforce Change Reviews <perforce@FreeBSD.org>
Subject:   PERFORCE change 144297 for review
Message-ID:  <200806291745.m5THjV8p084760@repoman.freebsd.org>

next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=144297

Change 144297 by hselasky@hselasky_laptop001 on 2008/06/29 17:45:19

	
	Update README.TXT. USB bus is now "usbus" and UHUB is now "ushub".
	Add MODULE_VERSION to usb2_core.c .

Affected files ...

.. //depot/projects/usb/src/sys/dev/usb2/core/README.TXT#2 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#3 edit
.. //depot/projects/usb/src/sys/dev/usb2/core/usb2_if.m#2 edit
.. //depot/projects/usb/src/sys/modules/usb2/core/Makefile#2 edit

Differences ...

==== //depot/projects/usb/src/sys/dev/usb2/core/README.TXT#2 (text+ko) ====

@@ -6,33 +6,33 @@
 
 +--------------------------------------------------------------+
 |                                                              |
-|  "usbd_transfer_setup"   -  This function will allocate all  |
+|  "usb2_transfer_setup"   -  This function will allocate all  |
 |                             necessary DMA memory and might   |
 |                             sleep!                           |
 |                                                              |
-|  "usbd_transfer_unsetup" -  This function will stop the USB  |
+|  "usb2_transfer_unsetup" -  This function will stop the USB  |
 |                             transfer, if it is currently     |
 |                             active, release all DMA          |
 |                             memory and might sleep!          |
 |                                                              |
-|  "usbd_transfer_start"   -  This function will start an USB  |
+|  "usb2_transfer_start"   -  This function will start an USB  |
 |                             transfer, if not already started.|
 |                             This function is always          |
 |                             non-blocking. **                 |
 |                                                              |
-|  "usbd_transfer_stop"    -  This function will stop an USB   |
+|  "usb2_transfer_stop"    -  This function will stop an USB   |
 |                             transfer, if not already stopped.|
 |                             The callback function will be    |
 |                             called before this function      |
 |                             returns. This function is always |
 |                             non-blocking. **                 |
 |                                                              |
-|  "usbd_transfer_drain"   -  This function will stop an USB   |
+|  "usb2_transfer_drain"   -  This function will stop an USB   |
 |                             transfer, if not already stopped |
 |                             and wait for any additional      |
 |                             DMA load operations to complete. |
 |                             Buffers that are loaded into DMA |
-|                             using "usbd_set_frame_data" can  |
+|                             using "usb2_set_frame_data" can  |
 |                             safely be freed after that       |
 |                             this function has returned. This |
 |                             function can block the caller.   |
@@ -44,7 +44,7 @@
 |        to the USB transfer structure pointer.                |
 +--------------------------------------------------------------+
 
-Reference: /sys/dev/usb/usb_transfer.c 
+Reference: /sys/dev/usb2/core/usb2_transfer.c 
 
 /*
  * A simple USB callback state-machine:
@@ -61,25 +61,25 @@
  */
 
 void
-usbd_default_callback(struct usbd_xfer *xfer)
+usb2_default_callback(struct usb2_xfer *xfer)
 {
 	/*
 	 * NOTE: it is not allowed to return
-	 * before "USBD_CHECK_STATUS()",
+	 * before "USB_CHECK_STATUS()",
 	 * even if the system is tearing down!
 	 */
-  switch (USBD_GET_STATE(xfer)) {
-  case USBD_ST_SETUP: 
+  switch (USB_GET_STATE(xfer)) {
+  case USB_ST_SETUP: 
 	/*
 	 * Setup xfer->frlengths[], xfer->nframes
 	 * and write data to xfer->frbuffers[], if any
 	 */
 
 	/**/
-	usbd_start_hardware(xfer);
+	usb2_start_hardware(xfer);
 	return;
 
-  case USBD_ST_TRANSFERRED: 
+  case USB_ST_TRANSFERRED: 
 	/* 
 	 * Read data from xfer->frbuffers[], if any.
 	 * "xfer->frlengths[]" should now have been
@@ -106,39 +106,39 @@
 Example1: SETUP + STATUS
  xfer->nframes = 1;
  xfer->frlenghts[0] = 8;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 Example2: SETUP + DATA + STATUS
  xfer->nframes = 2;
  xfer->frlenghts[0] = 8;
  xfer->frlenghts[1] = 1;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 Example3: SETUP + DATA + STATUS - split
 1st callback:
  xfer->nframes = 1;
  xfer->frlenghts[0] = 8;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 2nd callback:
  /* IMPORTANT: frbuffer[0] must still point at the setup packet! */
  xfer->nframes = 2;
  xfer->frlenghts[0] = 0;
  xfer->frlenghts[1] = 1;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 Example4: SETUP + STATUS - split
 1st callback:
  xfer->nframes = 1;
  xfer->frlenghts[0] = 8;
  xfer->flags.manual_status = 1;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 2nd callback:
  xfer->nframes = 1;
  xfer->frlenghts[0] = 0;
  xfer->flags.manual_status = 0;
- usbd_start_hardware(xfer);
+ usb2_start_hardware(xfer);
 
 
 === General USB transfer notes ===
@@ -149,7 +149,7 @@
 back. Recursion is handled like this that when the callback that wants to 
 recurse returns it is called one more time. 
  
- 2) After that the "usbd_start_hardware()" function has been called in
+ 2) After that the "usb2_start_hardware()" function has been called in
 the callback one can always depend on that "tr_error" or "tr_transferred"
 will get jumped afterwards. Always!
  
@@ -157,25 +157,37 @@
 driver. Else one should not use sleeping functions unless one has to. It is 
 very difficult with sleep, because one has to think that the device might have 
 detached when the thread returns from sleep. 
+
+ 4) Polling.
+
+  use_polling
+	This flag can be used with any callback and will cause the
+	"usb2_transfer_start()" function to wait using "DELAY()",
+	without exiting any mutexes, until the transfer is finished or
+	has timed out. This flag can be changed during operation.
+
+	NOTE: If polling is used the "timeout" field should be non-zero!
+	NOTE: USB_ERR_CANCELLED is returned in case of timeout
+	      instead of USB_ERR_TIMEOUT!
+
+
  
 USB device driver examples: 
 
-/sys/dev/usb/ugen.c
-/sys/dev/usb/ulpt.c
-/sys/dev/usb/uhid.c
-/sys/dev/usb/...
+/sys/dev/usb2/ethernet/if_axe.c
+/sys/dev/usb2/ethernet/if_aue.c
 
 QUICK REFERENCE
 ===============
 
 
 /*------------------------------------------------------------------------*
- * usbd_status_t 
- * usbd_transfer_setup(udev, ifaces, pxfer, setup_start,
+ * usb2_error_t 
+ * usb2_transfer_setup(udev, ifaces, pxfer, setup_start,
  *                     n_setup, priv_sc, priv_mtx)
  *------------------------------------------------------------------------*/
 
-- "udev" is a pointer to "struct usbd_device".
+- "udev" is a pointer to "struct usb2_device".
 
 - "ifaces" array of interface index numbers to use. See "if_index".
 
@@ -195,7 +207,7 @@
 
 /*------------------------------------------------------------------------*
  * void
- * usbd_transfer_unsetup(pxfer, n_setup)
+ * usb2_transfer_unsetup(pxfer, n_setup)
  *------------------------------------------------------------------------*/
 
 - "pxfer" is a pointer to an array of USB transfer pointers, that may
@@ -205,12 +217,12 @@
   should be unsetup
 
 NOTE: This function can sleep, waiting for active mutexes to become unlocked!
-NOTE: It is not allowed to call "usbd_transfer_unsetup" from the callback
+NOTE: It is not allowed to call "usb2_transfer_unsetup" from the callback
       of a USB transfer.
 
 /*------------------------------------------------------------------------*
  * void
- * usbd_transfer_start(xfer)
+ * usb2_transfer_start(xfer)
  *------------------------------------------------------------------------*/
 
 - "xfer" is pointer to a USB transfer that should be started
@@ -219,7 +231,7 @@
 
 /*------------------------------------------------------------------------*
  * void
- * usbd_transfer_stop(xfer)
+ * usb2_transfer_stop(xfer)
  *------------------------------------------------------------------------*/
 
 - "xfer" is a pointer to a USB transfer that should be stopped
@@ -227,12 +239,12 @@
 NOTE: this function must be called with "priv_mtx" locked
 
 NOTE: if the transfer was in progress, the callback will called with 
-      "xfer->error=USBD_ERR_CANCELLED", before this function returns
+      "xfer->error=USB_ERR_CANCELLED", before this function returns
 
 /*------------------------------------------------------------------------*
- * struct usbd_config {
+ * struct usb2_config {
  *   type, endpoint, direction, interval, timeout, frames, index
- *   flags, bufsize, cb
+ *   flags, bufsize, callback
  * };
  *------------------------------------------------------------------------*/
 
@@ -271,7 +283,7 @@
 	"0" no transfer pre-delay.
 	"Else" a delay as given by this field in milliseconds is
 	inserted before the hardware is started when
-	"usbd_start_hardware()" is called.
+	"usb2_start_hardware()" is called.
 	NOTE: The transfer timeout, if any, is started after that
 	the pre-delay has elapsed! 
 
@@ -297,10 +309,10 @@
   "ep_index" should be used.
 
 - The "if_index" field allows you to select which of the interface
-  numbers in the "ifaces" array parameter passed to "usbd_transfer_setup"
+  numbers in the "ifaces" array parameter passed to "usb2_transfer_setup"
   that should be used when setting up the given USB transfer.
 
-- The "flags" field has type "struct usbd_xfer_flags" and allows one
+- The "flags" field has type "struct usb2_xfer_flags" and allows one
   to set initial flags an USB transfer. Valid flags are:
 
   force_short_xfer
@@ -314,23 +326,13 @@
 	to be less than "xfer->sumlen" upon completion of a transfer.
 	This flag can be changed during operation.
 
-  use_polling
-	This flag can be used with any callback and will cause the
-	"usbd_transfer_start()" function to wait using "DELAY()",
-	without exiting any mutexes, until the transfer is finished or
-	has timed out. This flag can be changed during operation.
-
-	NOTE: If polling is used the "timeout" field should be non-zero!
-	NOTE: USBD_ERR_CANCELLED is returned in case of timeout
-	      instead of USBD_ERR_TIMEOUT!
-
   pipe_bof
 	This flag causes a failing USB transfer to remain first
 	in the PIPE queue except in the case of "xfer->error" equal
-	to "USBD_ERR_CANCELLED". No other USB transfers in the affected
+	to "USB_ERR_CANCELLED". No other USB transfers in the affected
 	PIPE queue will be started until either:
 
-	1) The failing USB transfer is stopped using "usbd_transfer_stop()".
+	1) The failing USB transfer is stopped using "usb2_transfer_stop()".
 	2) The failing USB transfer performs a successful transfer.
 
 	The purpose of this flag is to avoid races when multiple
@@ -371,7 +373,7 @@
 	operation.
 
   no_pipe_ok
-	Setting this flag causes the USBD_ERR_NO_PIPE error to be
+	Setting this flag causes the USB_ERR_NO_PIPE error to be
 	ignored. This flag can not be changed during operation.
 
   stall_pipe
@@ -383,8 +385,8 @@
 	in USB device side mode except for control endpoints. This
 	flag is cleared when the stall command has been executed. This
 	flag can only be changed outside the callback function by
-	using the functions "usbd_transfer_set_stall()" and
-	"usbd_transfer_clear_stall()" !
+	using the functions "usb2_transfer_set_stall()" and
+	"usb2_transfer_clear_stall()" !
 
 - The "bufsize" field sets the total buffer size in bytes. If
   this field is zero, "wMaxPacketSize" will be used, multiplied by the
@@ -394,8 +396,7 @@
   NOTE: For control transfers "bufsize" includes
   the length of the request structure. 
 
-- The "cb[]" pointer array sets the USB callbacks for USB host mode
-  and USB device mode respectivly. This field is mandatory.
+- The "callback" pointer sets the USB callback. This field is mandatory.
 
 MUTEX NOTE:
 ===========

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_compat_linux.c#3 (text+ko) ====

@@ -98,8 +98,7 @@
 
 static devclass_t usb_linux_devclass;
 
-DRIVER_MODULE(usb_linux, uhub, usb_linux_driver, usb_linux_devclass, NULL, 0);
-MODULE_DEPEND(usb_linux, usb, 1, 1, 1);
+DRIVER_MODULE(usb_linux, ushub, usb_linux_driver, usb_linux_devclass, NULL, 0);
 
 /*------------------------------------------------------------------------*
  *	usb_linux_lookup_id
@@ -115,7 +114,6 @@
 	if (id == NULL) {
 		goto done;
 	}
-
 	/*
 	 * Keep on matching array entries until we find one with
 	 * "match_flags" equal to zero, which indicates the end of the
@@ -665,7 +663,7 @@
 
 	if (size && (req->bmRequestType & UT_WRITE)) {
 		/* move the data to a real buffer */
-		bcopy(data, req+1, size);
+		bcopy(data, req + 1, size);
 	}
 	if (type == UE_CONTROL) {
 		urb->pipe = uhe;
@@ -688,7 +686,7 @@
 			if (req->bmRequestType & UT_READ) {
 				urb->pipe = uhe_read;
 			}
-			urb->transfer_buffer = req+1;
+			urb->transfer_buffer = req + 1;
 			urb->transfer_buffer_length = size;
 
 			err = usb_start_wait_urb(urb, timeout, &actlen);
@@ -705,7 +703,7 @@
 			bzero(((uint8_t *)data) + actlen, size - actlen);
 		}
 		if (actlen) {
-			bcopy(req+1, data, actlen);
+			bcopy(req + 1, data, actlen);
 		}
 	}
 	usb_free_urb(urb);
@@ -735,8 +733,8 @@
 	if (alt_index >= p_ui->num_altsetting)
 		return (-EINVAL);
 	usb_linux_cleanup_interface(dev, p_ui);
-	err = -usb2_set_alt_interface_index(dev->bsd_udev, 
-		p_ui->bsd_iface_index, alt_index);
+	err = -usb2_set_alt_interface_index(dev->bsd_udev,
+	    p_ui->bsd_iface_index, alt_index);
 	if (err == 0) {
 		p_ui->cur_altsetting = p_ui->altsetting + alt_index;
 	}

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_core.c#3 (text+ko) ====

@@ -37,3 +37,5 @@
 MALLOC_DEFINE(M_USBHC, "USBHC", "USB host controller");
 
 devclass_t usb2_devclass_ptr;
+
+MODULE_VERSION(usb2_core, 1);

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_hub.c#3 (text+ko) ====

@@ -143,9 +143,8 @@
 	.size = sizeof(struct uhub_softc)
 };
 
-DRIVER_MODULE(uhub, usb, uhub_driver, uhub_devclass, 0, 0);
-DRIVER_MODULE(uhub, uhub, uhub_driver, uhub_devclass, NULL, 0);
-MODULE_DEPEND(uhub, usb, 1, 1, 1);
+DRIVER_MODULE(ushub, usbus, uhub_driver, uhub_devclass, 0, 0);
+DRIVER_MODULE(ushub, ushub, uhub_driver, uhub_devclass, NULL, 0);
 
 static void
 uhub_intr_clear_stall_callback(struct usb2_xfer *xfer)

==== //depot/projects/usb/src/sys/dev/usb2/core/usb2_if.m#2 (text+ko) ====

@@ -1,6 +1,5 @@
 #-
-# Copyright (c) 1992-1998 Nick Hibma <n_hibma@freebsd.org>
-# All rights reserved.
+# Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
 #
 # Redistribution and use in source and binary forms, with or without
 # modification, are permitted provided that the following conditions
@@ -25,22 +24,14 @@
 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 #
-# $FreeBSD: src/sys/dev/usb/usb_if.m,v 1.10 2005/01/06 01:43:29 imp Exp $
-#
 
 # USB interface description
 #
 
 #include <sys/bus.h>
 
-INTERFACE usb;
+INTERFACE usb2;
 
-# The device should start probing for new drivers again
-#
-METHOD int reconfigure {
-	device_t dev;
-};
-
 # The device received a control request
 #
 # Return values:
@@ -56,3 +47,4 @@
 	uint16_t offset; /* data offset */
 	uint8_t is_complete; /* set if transfer is complete */
 };
+

==== //depot/projects/usb/src/sys/modules/usb2/core/Makefile#2 (text+ko) ====

@@ -1,0 +1,30 @@
+S=     ${.CURDIR}/../../..
+
+.PATH: $S/dev/usb2/core
+
+KMOD=  usb2_core
+SRCS= 
+SRCS+= bus_if.h usb2_if.h device_if.h vnode_if.h opt_usb.h
+SRCS+= usb2_busdma.c
+SRCS+= usb2_compat_linux.c
+SRCS+= usb2_config_td.c
+SRCS+= usb2_core.c
+SRCS+= usb2_debug.c
+SRCS+= usb2_dev.c
+SRCS+= usb2_device.c
+SRCS+= usb2_dynamic.c
+SRCS+= usb2_error.c
+SRCS+= usb2_generic.c
+SRCS+= usb2_handle_request.c
+SRCS+= usb2_hub.c
+SRCS+= usb2_lookup.c
+SRCS+= usb2_mbuf.c
+SRCS+= usb2_parse.c
+SRCS+= usb2_process.c
+SRCS+= usb2_request.c
+SRCS+= usb2_sw_transfer.c
+SRCS+= usb2_transfer.c
+SRCS+= usb2_util.c
+
+.include <bsd.kmod.mk>
+



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200806291745.m5THjV8p084760>