PERFORCE change 159392 for review
Hans Petter Selasky
hselasky at FreeBSD.org
Wed Mar 18 11:15:27 PDT 2009
http://perforce.freebsd.org/chv.cgi?CH=159392
Change 159392 by hselasky at hselasky_laptop001 on 2009/03/18 18:14:45
USB CORE shrinking.
Refactor how we get the usb2_xfer_root structure from a
usb2_dma_parent_tag structure. This saves a pointer and speeds up
conversion.
Add more defines which control inclusion and exclusion of code. This
currently allows shrinking the USB stack into less than 70 kilobytes
including an OS for embedded purpose. Defines added:
USB_HAVE_STRINGS
USB_HAVE_BUSDMA
USB_HAVE_COMPAT_LINUX
USB_HAVE_USER_IO
USB_HAVE_MBUF
The defines can be overwritten via "opt_usb.h". The kernel "options"
file has not been updated yet.
Affected files ...
.. //depot/projects/usb/src/sys/dev/usb/controller/at91dci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#6 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/musb_otg.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/usb_controller.c#4 edit
.. //depot/projects/usb/src/sys/dev/usb/controller/uss820dci.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_busdma.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_busdma.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_core.h#5 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_debug.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_device.c#7 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_device.h#7 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_request.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#129 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_transfer.h#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_util.c#2 edit
.. //depot/projects/usb/src/sys/dev/usb/usb_util.h#2 edit
Differences ...
==== //depot/projects/usb/src/sys/dev/usb/controller/at91dci.c#2 (text+ko) ====
@@ -70,7 +70,7 @@
USB_P2U(&(((struct at91dci_softc *)0)->sc_bus))))
#define AT9100_DCI_PC2SC(pc) \
- AT9100_DCI_BUS2SC((pc)->tag_parent->info->bus)
+ AT9100_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
#if USB_DEBUG
static int at91dcidebug = 0;
==== //depot/projects/usb/src/sys/dev/usb/controller/atmegadci.c#6 (text+ko) ====
@@ -63,7 +63,7 @@
USB_P2U(&(((struct atmegadci_softc *)0)->sc_bus))))
#define ATMEGA_PC2SC(pc) \
- ATMEGA_BUS2SC((pc)->tag_parent->info->bus)
+ ATMEGA_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
#if USB_DEBUG
static int atmegadci_debug = 0;
==== //depot/projects/usb/src/sys/dev/usb/controller/musb_otg.c#2 (text+ko) ====
@@ -64,7 +64,7 @@
USB_P2U(&(((struct musbotg_softc *)0)->sc_bus))))
#define MUSBOTG_PC2SC(pc) \
- MUSBOTG_BUS2SC((pc)->tag_parent->info->bus)
+ MUSBOTG_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
#if USB_DEBUG
static int musbotgdebug = 0;
==== //depot/projects/usb/src/sys/dev/usb/controller/usb_controller.c#4 (text+ko) ====
@@ -50,15 +50,6 @@
static void usb2_attach_sub(device_t, struct usb2_bus *);
static void usb2_post_init(void *);
-static void usb2_bus_mem_flush_all_cb(struct usb2_bus *,
- struct usb2_page_cache *, struct usb2_page *, uint32_t,
- uint32_t);
-static void usb2_bus_mem_alloc_all_cb(struct usb2_bus *,
- struct usb2_page_cache *, struct usb2_page *, uint32_t,
- uint32_t);
-static void usb2_bus_mem_free_all_cb(struct usb2_bus *,
- struct usb2_page_cache *, struct usb2_page *, uint32_t,
- uint32_t);
static void usb2_bus_roothub(struct usb2_proc_msg *pm);
/* static variables */
@@ -488,16 +479,19 @@
/*------------------------------------------------------------------------*
* usb2_bus_mem_flush_all_cb
*------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
static void
usb2_bus_mem_flush_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
struct usb2_page *pg, uint32_t size, uint32_t align)
{
usb2_pc_cpu_flush(pc);
}
+#endif
/*------------------------------------------------------------------------*
* usb2_bus_mem_flush_all - factored out code
*------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
void
usb2_bus_mem_flush_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
{
@@ -505,10 +499,12 @@
cb(bus, &usb2_bus_mem_flush_all_cb);
}
}
+#endif
/*------------------------------------------------------------------------*
* usb2_bus_mem_alloc_all_cb
*------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
static void
usb2_bus_mem_alloc_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
struct usb2_page *pg, uint32_t size, uint32_t align)
@@ -520,6 +516,7 @@
bus->alloc_failed = 1;
}
}
+#endif
/*------------------------------------------------------------------------*
* usb2_bus_mem_alloc_all - factored out code
@@ -542,9 +539,10 @@
TAILQ_INIT(&bus->intr_q.head);
+#if USB_HAVE_BUSDMA
usb2_dma_tag_setup(bus->dma_parent_tag, bus->dma_tags,
- dmat, &bus->bus_mtx, NULL, NULL, 32, USB_BUS_DMA_TAG_MAX);
-
+ dmat, &bus->bus_mtx, NULL, 32, USB_BUS_DMA_TAG_MAX);
+#endif
if ((bus->devices_max > USB_MAX_DEVICES) ||
(bus->devices_max < USB_MIN_DEVICES) ||
(bus->devices == NULL)) {
@@ -552,9 +550,11 @@
"initialised properly!\n");
bus->alloc_failed = 1; /* failure */
}
+#if USB_HAVE_BUSDMA
if (cb) {
cb(bus, &usb2_bus_mem_alloc_all_cb);
}
+#endif
if (bus->alloc_failed) {
usb2_bus_mem_free_all(bus, cb);
}
@@ -564,12 +564,14 @@
/*------------------------------------------------------------------------*
* usb2_bus_mem_free_all_cb
*------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
static void
usb2_bus_mem_free_all_cb(struct usb2_bus *bus, struct usb2_page_cache *pc,
struct usb2_page *pg, uint32_t size, uint32_t align)
{
usb2_pc_free_mem(pc);
}
+#endif
/*------------------------------------------------------------------------*
* usb2_bus_mem_free_all - factored out code
@@ -577,10 +579,12 @@
void
usb2_bus_mem_free_all(struct usb2_bus *bus, usb2_bus_mem_cb_t *cb)
{
+#if USB_HAVE_BUSDMA
if (cb) {
cb(bus, &usb2_bus_mem_free_all_cb);
}
usb2_dma_tag_unsetup(bus->dma_parent_tag);
+#endif
mtx_destroy(&bus->bus_mtx);
}
==== //depot/projects/usb/src/sys/dev/usb/controller/uss820dci.c#2 (text+ko) ====
@@ -59,7 +59,7 @@
USB_P2U(&(((struct uss820dci_softc *)0)->sc_bus))))
#define USS820_DCI_PC2SC(pc) \
- USS820_DCI_BUS2SC((pc)->tag_parent->info->bus)
+ USS820_DCI_BUS2SC(USB_DMATAG_TO_XROOT((pc)->tag_parent)->bus)
#if USB_DEBUG
static int uss820dcidebug = 0;
==== //depot/projects/usb/src/sys/dev/usb/usb_busdma.c#2 (text+ko) ====
@@ -42,20 +42,20 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
+#if USB_HAVE_BUSDMA
static void usb2_dma_tag_create(struct usb2_dma_tag *, uint32_t, uint32_t);
static void usb2_dma_tag_destroy(struct usb2_dma_tag *);
+#endif
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
static void usb2_dma_lock_cb(void *, bus_dma_lock_op_t);
-static int32_t usb2_m_copy_in_cb(void *, void *, uint32_t);
static void usb2_pc_alloc_mem_cb(void *, bus_dma_segment_t *, int, int);
static void usb2_pc_load_mem_cb(void *, bus_dma_segment_t *, int, int);
static void usb2_pc_common_mem_cb(void *, bus_dma_segment_t *, int, int,
uint8_t);
#endif
-#ifdef __NetBSD__
-static int32_t usb2_m_copy_in_cb(void *, caddr_t, uint32_t);
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
static void usb2_pc_common_mem_cb(struct usb2_page_cache *,
bus_dma_segment_t *, int, int, uint8_t);
#endif
@@ -72,6 +72,7 @@
{
struct usb2_page *page;
+#if USB_HAVE_BUSDMA
if (pc->page_start) {
/* Case 1 - something has been loaded into DMA */
@@ -106,14 +107,16 @@
res->buffer = USB_ADD_BYTES(page->buffer, offset);
}
- } else {
+ return;
+ }
+#endif
+ /* Case 2 - Plain PIO */
- /* Case 2 - Plain PIO */
-
- res->buffer = USB_ADD_BYTES(pc->buffer, offset);
- res->length = 0 - 1;
- res->physaddr = 0;
- }
+ res->buffer = USB_ADD_BYTES(pc->buffer, offset);
+ res->length = 0 - 1;
+#if USB_HAVE_BUSDMA
+ res->physaddr = 0;
+#endif
}
/*------------------------------------------------------------------------*
@@ -147,6 +150,7 @@
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
int
usb2_copy_in_user(struct usb2_page_cache *cache, uint32_t offset,
const void *ptr, uint32_t len)
@@ -171,10 +175,12 @@
}
return (0); /* success */
}
+#endif
/*------------------------------------------------------------------------*
* usb2_m_copy_in - copy a mbuf chain directly into DMA-able memory
*------------------------------------------------------------------------*/
+#if USB_HAVE_MBUF
struct usb2_m_copy_in_arg {
struct usb2_page_cache *cache;
uint32_t dst_offset;
@@ -203,10 +209,12 @@
error = m_apply(m, src_offset, src_len, &usb2_m_copy_in_cb, &arg);
}
+#endif
/*------------------------------------------------------------------------*
* usb2_uiomove - factored out code
*------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
int
usb2_uiomove(struct usb2_page_cache *pc, struct uio *uio,
uint32_t pc_offset, uint32_t len)
@@ -235,6 +243,7 @@
}
return (error);
}
+#endif
/*------------------------------------------------------------------------*
* usb2_copy_out - copy directly from DMA-able memory
@@ -267,6 +276,7 @@
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
+#if USB_HAVE_USER_IO
int
usb2_copy_out_user(struct usb2_page_cache *cache, uint32_t offset,
void *ptr, uint32_t len)
@@ -291,6 +301,7 @@
}
return (0); /* success */
}
+#endif
/*------------------------------------------------------------------------*
* usb2_bzero - zero DMA-able memory
@@ -314,8 +325,7 @@
}
}
-
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
/*------------------------------------------------------------------------*
* usb2_dma_lock_cb - dummy callback
@@ -692,7 +702,7 @@
struct usb2_dma_tag *utag;
/* get info */
- info = pc->tag_parent->info;
+ info = USB_DMATAG_TO_XROOT(pc->tag_parent);
/* sanity check */
if (info == NULL) {
@@ -732,7 +742,7 @@
#endif
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
/*------------------------------------------------------------------------*
* usb2_dma_tag_create - allocate a DMA tag
@@ -1063,7 +1073,7 @@
struct usb2_dma_tag *utag;
/* get info */
- info = pc->tag_parent->info;
+ info = USB_DMATAG_TO_XROOT(pc->tag_parent);
/* sanity check */
if (info == NULL) {
@@ -1107,6 +1117,8 @@
#endif
+#if USB_HAVE_BUSDMA
+
/*------------------------------------------------------------------------*
* usb2_dma_tag_find - factored out code
*------------------------------------------------------------------------*/
@@ -1149,8 +1161,7 @@
usb2_dma_tag_setup(struct usb2_dma_parent_tag *udpt,
struct usb2_dma_tag *udt, bus_dma_tag_t dmat,
struct mtx *mtx, usb2_dma_callback_t *func,
- struct usb2_xfer_root *info, uint8_t ndmabits,
- uint8_t nudt)
+ uint8_t ndmabits, uint8_t nudt)
{
bzero(udpt, sizeof(*udpt));
@@ -1168,7 +1179,6 @@
/* store some information */
udpt->mtx = mtx;
- udpt->info = info;
udpt->func = func;
udpt->tag = dmat;
udpt->utag_first = udt;
@@ -1350,7 +1360,7 @@
{
struct usb2_xfer_root *info;
- info = udpt->info;
+ info = USB_DMATAG_TO_XROOT(udpt);
mtx_assert(info->xfer_mtx, MA_OWNED);
@@ -1424,3 +1434,5 @@
pc++;
}
}
+
+#endif
==== //depot/projects/usb/src/sys/dev/usb/usb_busdma.h#2 (text+ko) ====
@@ -60,8 +60,10 @@
* address of a memory page having size USB_PAGE_SIZE.
*/
struct usb2_page {
+#if USB_HAVE_BUSDMA
bus_size_t physaddr;
void *buffer; /* non Kernel Virtual Address */
+#endif
};
/*
@@ -71,7 +73,9 @@
*/
struct usb2_page_search {
void *buffer;
+#if USB_HAVE_BUSDMA
bus_size_t physaddr;
+#endif
uint32_t length;
};
@@ -81,62 +85,67 @@
*/
struct usb2_page_cache {
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
bus_dma_tag_t tag;
bus_dmamap_t map;
#endif
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
bus_dma_tag_t tag;
bus_dmamap_t map;
bus_dma_segment_t *p_seg;
#endif
+#if USB_HAVE_BUSDMA
struct usb2_page *page_start;
+#endif
struct usb2_dma_parent_tag *tag_parent; /* always set */
void *buffer; /* virtual buffer pointer */
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(_NetBSD__)
int n_seg;
#endif
+#if USB_HAVE_BUSDMA
uint32_t page_offset_buf;
uint32_t page_offset_end;
uint8_t isread:1; /* set if we are currently reading
* from the memory. Else write. */
uint8_t ismultiseg:1; /* set if we can have multiple
* segments */
+#endif
};
/*
* The following structure describes the parent USB DMA tag.
*/
struct usb2_dma_parent_tag {
-#ifdef __FreeBSD__
+#if USB_HAVE_BUSDMA && defined(__FreeBSD__)
struct cv cv[1]; /* internal condition variable */
#endif
-
+#if USB_HAVE_BUSDMA
bus_dma_tag_t tag; /* always set */
struct mtx *mtx; /* private mutex, always set */
- struct usb2_xfer_root *info; /* used by the callback function */
usb2_dma_callback_t *func; /* load complete callback function */
struct usb2_dma_tag *utag_first;/* pointer to first USB DMA tag */
-
uint8_t dma_error; /* set if DMA load operation failed */
uint8_t dma_bits; /* number of DMA address lines */
uint8_t utag_max; /* number of USB DMA tags */
+#endif
};
/*
* The following structure describes an USB DMA tag.
*/
struct usb2_dma_tag {
-#ifdef __NetBSD__
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
bus_dma_segment_t *p_seg;
#endif
+#if USB_HAVE_BUSDMA
struct usb2_dma_parent_tag *tag_parent;
bus_dma_tag_t tag;
uint32_t align;
uint32_t size;
-#ifdef __NetBSD__
+#endif
+#if USB_HAVE_BUSDMA && defined(__NetBSD__)
uint32_t n_seg;
#endif
};
@@ -168,8 +177,7 @@
void *ptr, uint32_t len);
void usb2_dma_tag_setup(struct usb2_dma_parent_tag *udpt,
struct usb2_dma_tag *udt, bus_dma_tag_t dmat, struct mtx *mtx,
- usb2_dma_callback_t *func, struct usb2_xfer_root *info,
- uint8_t ndmabits, uint8_t nudt);
+ usb2_dma_callback_t *func, uint8_t ndmabits, uint8_t nudt);
void usb2_dma_tag_unsetup(struct usb2_dma_parent_tag *udpt);
void usb2_get_page(struct usb2_page_cache *pc, uint32_t offset,
struct usb2_page_search *res);
==== //depot/projects/usb/src/sys/dev/usb/usb_core.h#5 (text+ko) ====
@@ -32,16 +32,84 @@
#ifndef _USB2_CORE_H_
#define _USB2_CORE_H_
+/* Allow defines in "opt_usb.h" to override configuration */
+
+#include "opt_usb.h"
+#include "opt_bus.h"
+
/* Default USB configuration */
-#ifndef USB_USE_CONDVAR
-#define USB_USE_CONDVAR 0
+/*
+ * The following macro defines if the code shall use cv_xxx() instead
+ * of msleep() and wakeup().
+ */
+#ifndef USB_HAVE_CONDVAR
+#define USB_HAVE_CONDVAR 0
#endif
+/*
+ * The following macro defines if the code shall support
+ * /dev/usb/x.y.z.
+ */
#ifndef USB_HAVE_UGEN
#define USB_HAVE_UGEN 1
#endif
+/*
+ * The following macro defines if the code shall support any forms of
+ * ASCII strings.
+ */
+#ifndef USB_HAVE_STRINGS
+#define USB_HAVE_STRINGS 1
+#endif
+
+/*
+ * The following macro defines if the code shall support BUS-DMA.
+ */
+#ifndef USB_HAVE_BUSDMA
+#define USB_HAVE_BUSDMA 1
+#endif
+
+/*
+ * The following macro defines if the code shall support the Linux
+ * compatibility layer.
+ */
+#ifndef USB_HAVE_COMPAT_LINUX
+#define USB_HAVE_COMPAT_LINUX 1
+#endif
+
+/*
+ * The following macro defines if the code shall support
+ * userland data transfer via copyin() and copyout()
+ */
+#ifndef USB_HAVE_USER_IO
+#define USB_HAVE_USER_IO 1
+#endif
+
+/*
+ * The following macro defines if the code shall support copy in via
+ * bsd-mbufs to USB.
+ */
+#ifndef USB_HAVE_MBUF
+#define USB_HAVE_MBUF 1
+#endif
+
+/*
+ * The following macro defines if the code shall compile a table
+ * describing USB vendor and product IDs.
+ */
+#ifndef USB_VERBOSE
+#define USB_VERBOSE 1
+#endif
+
+/*
+ * The following macro defines if USB debugging support shall be
+ * compiled for the USB core and all drivers.
+ */
+#ifndef USB_DEBUG
+#define USB_DEBUG 1
+#endif
+
#ifndef USB_TD_GET_PROC
#define USB_TD_GET_PROC(td) (td)->td_proc
#endif
@@ -76,8 +144,6 @@
#include <dev/usb/usb_revision.h>
#include "usb_if.h"
-#include "opt_usb.h"
-#include "opt_bus.h"
#define USB_STACK_VERSION 2000 /* 2.0 */
@@ -95,10 +161,6 @@
#define USB_MAX_IPACKET 8 /* maximum size of the initial USB
* data packet */
-#ifndef USB_VERBOSE
-#define USB_VERBOSE 1
-#endif
-
#define USB_HUB_MAX_DEPTH 5
/* USB transfer states */
@@ -226,12 +288,14 @@
uint8_t short_frames_ok:1; /* filtered version */
uint8_t short_xfer_ok:1; /* filtered version */
+#if USB_HAVE_BUSDMA
uint8_t bdma_enable:1; /* filtered version (only set if
* hardware supports DMA) */
uint8_t bdma_no_post_sync:1; /* set if the USB callback wrapper
* should not do the BUS-DMA post sync
* operation */
uint8_t bdma_setup:1; /* set if BUS-DMA has been setup */
+#endif
uint8_t isochronous_xfr:1; /* set if isochronous transfer */
uint8_t usb2_mode:1; /* shadow copy of "udev->usb2_mode" */
uint8_t curr_dma_set:1; /* used by USB HC/DC driver */
==== //depot/projects/usb/src/sys/dev/usb/usb_debug.h#2 (text+ko) ====
@@ -35,11 +35,6 @@
/* Declare global USB debug variable. */
extern int usb2_debug;
-/* Force debugging until further */
-#ifndef USB_DEBUG
-#define USB_DEBUG 1
-#endif
-
/* Check if USB debugging is enabled. */
#ifdef USB_DEBUG_VAR
#if (USB_DEBUG != 0)
==== //depot/projects/usb/src/sys/dev/usb/usb_device.c#7 (text+ko) ====
@@ -45,9 +45,11 @@
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_util.h>
#include <dev/usb/usb_mbuf.h>
+#include <dev/usb/usb_msctest.h>
+#if USB_HAVE_UGEN
#include <dev/usb/usb_dev.h>
-#include <dev/usb/usb_msctest.h>
#include <dev/usb/usb_generic.h>
+#endif
#include <dev/usb/quirk/usb_quirk.h>
@@ -69,7 +71,9 @@
static void usb2_suspend_resume_sub(struct usb2_device *, device_t,
uint8_t);
static void usb2_clear_stall_proc(struct usb2_proc_msg *_pm);
+#if USB_HAVE_STRINGS
static void usb2_check_strings(struct usb2_device *);
+#endif
static usb2_error_t usb2_fill_iface_data(struct usb2_device *, uint8_t,
uint8_t);
static void usb2_notify_addq(const char *type, struct usb2_device *);
@@ -483,11 +487,13 @@
/* mtx_assert() */
+#if USB_HAVE_COMPAT_LINUX
/* free Linux compat device, if any */
if (udev->linux_dev) {
usb_linux_free_device(udev->linux_dev);
udev->linux_dev = NULL;
}
+#endif
/* free all pipes, if any */
usb2_free_pipe_data(udev, 0, 0);
@@ -1585,6 +1591,7 @@
/* assume 100mA bus powered for now. Changed when configured. */
udev->power = USB_MIN_POWER;
+#if USB_HAVE_STRINGS
/* get serial number string */
err = usb2_req_get_string_any
(udev, NULL, (char *)scratch_ptr,
@@ -1608,6 +1615,7 @@
/* finish up all the strings */
usb2_check_strings(udev);
+#endif
if (udev->flags.usb2_mode == USB_MODE_HOST) {
uint8_t config_index;
@@ -2033,6 +2041,7 @@
}
}
+#if USB_HAVE_STRINGS
#if USB_VERBOSE
/*
* Descriptions of of known vendors and devices ("products").
@@ -2129,6 +2138,7 @@
sizeof(udev->product), "product 0x%04x", product_id);
}
}
+#endif
/*
* Returns:
==== //depot/projects/usb/src/sys/dev/usb/usb_device.h#7 (text+ko) ====
@@ -28,6 +28,7 @@
#define _USB2_DEVICE_H_
struct usb2_symlink;
+struct usb_device; /* linux compat */
#define USB_DEFAULT_XFER_MAX 2
@@ -114,7 +115,9 @@
struct usb2_device *parent_hub;
struct usb2_config_descriptor *cdesc; /* full config descr */
struct usb2_hub *hub; /* only if this is a hub */
+#if USB_HAVE_COMPAT_LINUX
struct usb_device *linux_dev;
+#endif
struct usb2_xfer *default_xfer[USB_DEFAULT_XFER_MAX];
struct usb2_temp_data *usb2_template_ptr;
struct usb2_pipe *pipe_curr; /* current clear stall pipe */
==== //depot/projects/usb/src/sys/dev/usb/usb_request.c#2 (text+ko) ====
@@ -265,6 +265,10 @@
if (actlen) {
*actlen = 0;
}
+#if (USB_HAVE_USER_IO == 0)
+ if (flags & USB_USER_DATA_PTR)
+ return (USB_ERR_INVAL);
+#endif
if (udev->flags.usb2_mode == USB_MODE_DEVICE) {
DPRINTF("USB device mode\n");
(usb2_temp_get_desc_p) (udev, req, &desc, &temp);
@@ -278,13 +282,14 @@
*actlen = length;
}
if (length > 0) {
+#if USB_HAVE_USER_IO
if (flags & USB_USER_DATA_PTR) {
if (copyout(desc, data, length)) {
return (USB_ERR_INVAL);
}
- } else {
+ } else
+#endif
bcopy(desc, data, length);
- }
}
return (0); /* success */
}
@@ -340,6 +345,7 @@
if (temp > 0) {
if (!(req->bmRequestType & UT_READ)) {
+#if USB_HAVE_USER_IO
if (flags & USB_USER_DATA_PTR) {
USB_XFER_UNLOCK(xfer);
err = usb2_copy_in_user(xfer->frbuffers + 1,
@@ -349,9 +355,10 @@
err = USB_ERR_INVAL;
break;
}
- } else {
- usb2_copy_in(xfer->frbuffers + 1, 0, data, temp);
- }
+ } else
+#endif
+ usb2_copy_in(xfer->frbuffers + 1,
+ 0, data, temp);
}
xfer->nframes = 2;
} else {
@@ -409,6 +416,7 @@
}
if (temp > 0) {
if (req->bmRequestType & UT_READ) {
+#if USB_HAVE_USER_IO
if (flags & USB_USER_DATA_PTR) {
USB_XFER_UNLOCK(xfer);
err = usb2_copy_out_user(xfer->frbuffers + 1,
@@ -418,10 +426,10 @@
err = USB_ERR_INVAL;
break;
}
- } else {
+ } else
+#endif
usb2_copy_out(xfer->frbuffers + 1,
0, data, temp);
- }
}
}
/*
==== //depot/projects/usb/src/sys/dev/usb/usb_transfer.c#129 (text+ko) ====
@@ -192,6 +192,7 @@
* 0: Success
* Else: Failure
*------------------------------------------------------------------------*/
+#if USB_HAVE_BUSDMA
uint8_t
usb2_transfer_setup_sub_malloc(struct usb2_setup_params *parm,
struct usb2_page_cache **ppc, uint32_t size, uint32_t align,
@@ -302,6 +303,7 @@
parm->dma_page_ptr = pg;
return (0);
}
+#endif
/*------------------------------------------------------------------------*
* usb2_transfer_setup_sub - transfer setup subroutine
@@ -644,6 +646,7 @@
if (parm->bufsize_max < parm->bufsize) {
parm->bufsize_max = parm->bufsize;
}
+#if USB_HAVE_BUSDMA
if (xfer->flags_int.bdma_enable) {
/*
* Setup "dma_page_ptr".
@@ -671,6 +674,7 @@
parm->dma_page_ptr += (2 * n_frbuffers);
parm->dma_page_ptr += (parm->bufsize / USB_PAGE_SIZE);
}
+#endif
if (zmps) {
/* correct maximum data length */
xfer->max_data_length = 0;
@@ -695,7 +699,7 @@
for (x = 0; x != n_frbuffers; x++) {
xfer->frbuffers[x].tag_parent =
&xfer->xroot->dma_parent_tag;
-
+#if USB_HAVE_BUSDMA
if (xfer->flags_int.bdma_enable &&
(parm->bufsize_max > 0)) {
@@ -706,6 +710,7 @@
goto done;
}
}
+#endif
}
}
done:
@@ -816,28 +821,31 @@
info->memory_base = buf;
info->memory_size = parm.size[0];
+#if USB_HAVE_BUSDMA
info->dma_page_cache_start = USB_ADD_BYTES(buf, parm.size[4]);
info->dma_page_cache_end = USB_ADD_BYTES(buf, parm.size[5]);
+#endif
info->xfer_page_cache_start = USB_ADD_BYTES(buf, parm.size[5]);
info->xfer_page_cache_end = USB_ADD_BYTES(buf, parm.size[2]);
usb2_cv_init(&info->cv_drain, "WDRAIN");
info->xfer_mtx = xfer_mtx;
-
+#if USB_HAVE_BUSDMA
usb2_dma_tag_setup(&info->dma_parent_tag,
parm.dma_tag_p, udev->bus->dma_parent_tag[0].tag,
- xfer_mtx, &usb2_bdma_done_event, info, 32, parm.dma_tag_max);
+ xfer_mtx, &usb2_bdma_done_event, 32, parm.dma_tag_max);
+#endif
info->bus = udev->bus;
info->udev = udev;
TAILQ_INIT(&info->done_q.head);
info->done_q.command = &usb2_callback_wrapper;
-
+#if USB_HAVE_BUSDMA
TAILQ_INIT(&info->dma_q.head);
info->dma_q.command = &usb2_bdma_work_loop;
-
+#endif
info->done_m[0].hdr.pm_callback = &usb2_callback_proc;
info->done_m[0].xroot = info;
info->done_m[1].hdr.pm_callback = &usb2_callback_proc;
@@ -1085,6 +1093,7 @@
USB_BUS_UNLOCK(info->bus);
+#if USB_HAVE_BUSDMA
/* free DMA'able memory, if any */
pc = info->dma_page_cache_start;
while (pc != info->dma_page_cache_end) {
@@ -1101,6 +1110,7 @@
/* free all DMA tags */
usb2_dma_tag_unsetup(&info->dma_parent_tag);
+#endif
usb2_cv_destroy(&info->cv_drain);
@@ -1162,9 +1172,10 @@
usb2_transfer_drain(xfer);
+#if USB_HAVE_BUSDMA
if (xfer->flags_int.bdma_enable)
needs_delay = 1;
-
+#endif
/*
* NOTE: default pipe does not have an
* interface, even if pipe->iface_index == 0
@@ -1413,9 +1424,10 @@
/* clear "did_close" flag */
xfer->flags_int.did_close = 0;
+#if USB_HAVE_BUSDMA
/* clear "bdma_setup" flag */
xfer->flags_int.bdma_setup = 0;
-
+#endif
/* by default we cannot cancel any USB transfer immediately */
xfer->flags_int.can_cancel_immed = 0;
@@ -1508,11 +1520,13 @@
* Check if BUS-DMA support is enabled and try to load virtual
* buffers into DMA, if any:
*/
+#if USB_HAVE_BUSDMA
if (xfer->flags_int.bdma_enable) {
/* insert the USB transfer last in the BUS-DMA queue */
usb2_command_wrapper(&xfer->xroot->dma_q, xfer);
return;
}
+#endif
/*
* Enter the USB transfer into the Host Controller or
* Device Controller schedule:
@@ -1924,12 +1938,13 @@
} else {
/* set transferred state */
xfer->usb2_state = USB_ST_TRANSFERRED;
-
+#if USB_HAVE_BUSDMA
/* sync DMA memory, if any */
if (xfer->flags_int.bdma_enable &&
(!xfer->flags_int.bdma_no_post_sync)) {
usb2_bdma_post_sync(xfer);
}
+#endif
}
}
@@ -2043,8 +2058,6 @@
void
usb2_transfer_done(struct usb2_xfer *xfer, usb2_error_t error)
{
- struct usb2_xfer_queue *pq;
-
USB_BUS_LOCK_ASSERT(xfer->xroot->bus, MA_OWNED);
DPRINTF("err=%s\n", usb2_errstr(error));
@@ -2071,7 +2084,10 @@
*/
usb2_transfer_dequeue(xfer);
+#if USB_HAVE_BUSDMA
if (mtx_owned(xfer->xroot->xfer_mtx)) {
+ struct usb2_xfer_queue *pq;
+
/*
* If the private USB lock is not locked, then we assume
* that the BUS-DMA load stage has been passed:
@@ -2083,6 +2099,7 @@
usb2_command_wrapper(pq, NULL);
}
}
+#endif
>>> TRUNCATED FOR MAIL (1000 lines) <<<
More information about the p4-projects
mailing list