Modify the FreeBSD USB kernel code so that it can be compiled directly

into the FreeBSD boot loader, typically for non-USB aware BIOSes, EFI systems
or embedded platforms. This is also useful for out of the system compilation
of the FreeBSD USB stack for various purposes. The USB kernel files can
now optionally include a global header file which should include all needed
definitions required to compile the FreeBSD USB stack. When the global USB
header file is included, no other USB header files will be included by
default.

Add new file containing the USB stack configuration for the
FreeBSD loader build.

Replace some __FBSDID()'s by /* $FreeBSD$ */ comments. Now all
USB files follow the same style.

Use cases:
 - console in loader via USB
 - loading kernel via USB

Discussed with:		Hiroki Sato, hrs @ EuroBSDCon
This commit is contained in:
hselasky 2013-01-30 15:26:04 +00:00
parent 3e5ced1b98
commit 0fbe163015
52 changed files with 310 additions and 54 deletions

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2007-2008 Hans Petter Selasky. All rights reserved.
*
@ -44,6 +42,9 @@ __FBSDID("$FreeBSD$");
* endpoints, Function-address and more.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -79,6 +80,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/at91dci.h>
#define AT9100_DCI_BUS2SC(bus) \

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2009 Hans Petter Selasky. All rights reserved.
*
@ -36,6 +34,9 @@ __FBSDID("$FreeBSD$");
* endpoints, Function-address and more.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -71,6 +72,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/atmegadci.h>
#define ATMEGA_BUS2SC(bus) \

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2009 Hans Petter Selasky. All rights reserved.
*
@ -35,7 +33,9 @@ __FBSDID("$FreeBSD$");
* NOTE: When the chip detects BUS-reset it will also reset the
* endpoints, Function-address and more.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -71,6 +71,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/avr32dci.h>
#define AVR32_BUS2SC(bus) \

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2012 Hans Petter Selasky. All rights reserved.
* Copyright (c) 2010-2011 Aleksandr Rybalko. All rights reserved.
@ -41,9 +42,9 @@
* internal reset.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -79,6 +80,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/dwc_otg.h>
#include <dev/usb/controller/dwc_otgreg.h>

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
* Copyright (c) 2004 The NetBSD Foundation, Inc. All rights reserved.
@ -43,9 +44,9 @@
* 1) command failures are not recovered correctly
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -81,6 +82,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/ehci.h>
#include <dev/usb/controller/ehcireg.h>

View File

@ -36,6 +36,9 @@
* NOTE: The current implementation only supports Device Side Mode!
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -71,6 +74,8 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/musb_otg.h>
#define MUSBOTG_INTR_ENDPT 1

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
* Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
@ -25,9 +26,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* USB Open Host Controller driver.
*
@ -35,6 +33,9 @@ __FBSDID("$FreeBSD$");
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -70,6 +71,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/ohci.h>
#include <dev/usb/controller/ohcireg.h>

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
* Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
@ -25,9 +26,6 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*
* USB Universal Host Controller driver.
* Handles e.g. PIIX3 and PIIX4.
@ -38,6 +36,9 @@ __FBSDID("$FreeBSD$");
* ftp://download.intel.com/design/intarch/datashts/29056201.pdf
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -73,6 +74,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/uhci.h>
#include <dev/usb/controller/uhcireg.h>

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include "opt_ddb.h"
#include <sys/stdint.h>
@ -62,6 +65,7 @@
#include <dev/usb/usb_bus.h>
#include <dev/usb/usb_pf.h>
#include "usb_if.h"
#endif /* USB_GLOBAL_INCLUDE_FILE */
/* function prototypes */
@ -84,10 +88,12 @@ SYSCTL_INT(_hw_usb_ctrl, OID_AUTO, debug, CTLFLAG_RW, &usb_ctrl_debug, 0,
"Debug level");
#endif
#if USB_HAVE_ROOT_MOUNT_HOLD
static int usb_no_boot_wait = 0;
TUNABLE_INT("hw.usb.no_boot_wait", &usb_no_boot_wait);
SYSCTL_INT(_hw_usb, OID_AUTO, no_boot_wait, CTLFLAG_RD|CTLFLAG_TUN, &usb_no_boot_wait, 0,
"No USB device enumerate waiting at boot.");
#endif
static int usb_no_suspend_wait = 0;
TUNABLE_INT("hw.usb.no_suspend_wait", &usb_no_suspend_wait);
@ -144,6 +150,7 @@ usb_probe(device_t dev)
return (0);
}
#if USB_HAVE_ROOT_MOUNT_HOLD
static void
usb_root_mount_rel(struct usb_bus *bus)
{
@ -153,6 +160,7 @@ usb_root_mount_rel(struct usb_bus *bus)
bus->bus_roothold = NULL;
}
}
#endif
/*------------------------------------------------------------------------*
* usb_attach
@ -169,11 +177,12 @@ usb_attach(device_t dev)
return (ENXIO);
}
#if USB_HAVE_ROOT_MOUNT_HOLD
if (usb_no_boot_wait == 0) {
/* delay vfs_mountroot until the bus is explored */
bus->bus_roothold = root_mount_hold(device_get_nameunit(dev));
}
#endif
usb_attach_sub(dev, bus);
return (0); /* return success */
@ -196,8 +205,10 @@ usb_detach(device_t dev)
/* Stop power watchdog */
usb_callout_drain(&bus->power_wdog);
#if USB_HAVE_ROOT_MOUNT_HOLD
/* Let the USB explore process detach all devices. */
usb_root_mount_rel(bus);
#endif
USB_BUS_LOCK(bus);
@ -363,7 +374,9 @@ usb_bus_explore(struct usb_proc_msg *pm)
(udev->hub->explore) (udev);
USB_BUS_LOCK(bus);
}
#if USB_HAVE_ROOT_MOUNT_HOLD
usb_root_mount_rel(bus);
#endif
}
/*------------------------------------------------------------------------*
@ -630,7 +643,9 @@ usb_bus_attach(struct usb_proc_msg *pm)
default:
device_printf(bus->bdev, "Unsupported USB revision\n");
#if USB_HAVE_ROOT_MOUNT_HOLD
usb_root_mount_rel(bus);
#endif
return;
}
@ -672,7 +687,9 @@ usb_bus_attach(struct usb_proc_msg *pm)
if (err) {
device_printf(bus->bdev, "Root HUB problem, error=%s\n",
usbd_errstr(err));
#if USB_HAVE_ROOT_MOUNT_HOLD
usb_root_mount_rel(bus);
#endif
}
/* set softc - we are ready */

View File

@ -32,6 +32,9 @@
* NOTE: The datasheet does not document everything.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -67,6 +70,8 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/uss820dci.h>
#define USS820_DCI_BUS2SC(bus) \

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
@ -38,9 +39,9 @@
* way we avoid too much diveration among USB drivers.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -76,6 +77,8 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#include <dev/usb/controller/xhci.h>
#include <dev/usb/controller/xhcireg.h>

View File

@ -36,6 +36,9 @@
* Linux USB gadget stack.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -62,6 +65,7 @@
#define USB_DEBUG_VAR ustorage_fs_debug
#include <dev/usb/usb_debug.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#ifdef USB_DEBUG
static int ustorage_fs_debug = 0;

View File

@ -29,6 +29,9 @@
* USB templates.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -67,6 +70,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
MODULE_DEPEND(usb_template, usb, 1, 1, 1);
MODULE_VERSION(usb_template, 1);

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
@ -30,6 +28,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB template for an USB Audio Device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
INDEX_AUDIO_LANG,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2007 Hans Petter Selasky <hselasky@FreeBSD.org>
* All rights reserved.
@ -31,6 +29,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB templates for a CDC USB ethernet device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -55,6 +56,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
STRING_LANG_INDEX,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
@ -30,6 +28,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB template for an USB Keyboard Device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
INDEX_LANG,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
@ -30,6 +28,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB template for an USB Modem Device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
INDEX_LANG,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2010 Hans Petter Selasky. All rights reserved.
*
@ -30,6 +28,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB template for an USB Mouse Device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_cdc.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
INDEX_LANG,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
* All rights reserved.
@ -31,6 +29,9 @@ __FBSDID("$FreeBSD$");
* This file contains the USB templates for an USB Mass Storage Device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -54,6 +55,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usbdi.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
STRING_LANG_INDEX,

View File

@ -1,6 +1,4 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/* $FreeBSD$ */
/*-
* Copyright (c) 2008 Hans Petter Selasky <hselasky@FreeBSD.org>
* All rights reserved.
@ -38,6 +36,9 @@ __FBSDID("$FreeBSD$");
* operating system the VID and PID of your device.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -60,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/template/usb_template.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#define MTP_BREQUEST 0x08

View File

@ -40,22 +40,28 @@
#define _USB_STANDARD_H_
#if defined(_KERNEL)
#ifndef USB_GLOBAL_INCLUDE_FILE
#include "opt_usb.h"
#endif
/* Declare parent SYSCTL USB node. */
#ifdef SYSCTL_DECL
SYSCTL_DECL(_hw_usb);
#endif
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/malloc.h>
#endif
MALLOC_DECLARE(M_USB);
MALLOC_DECLARE(M_USBDEV);
MALLOC_DECLARE(M_USBHC);
#endif /* _KERNEL */
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <dev/usb/usb_endian.h>
#include <dev/usb/usb_freebsd.h>
#endif
#define USB_STACK_VERSION 2000 /* 2.0 */

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -59,6 +62,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#if USB_HAVE_BUSDMA
static void usb_dma_tag_create(struct usb_dma_tag *, usb_size_t, usb_size_t);

View File

@ -27,10 +27,12 @@
#ifndef _USB_BUSDMA_H_
#define _USB_BUSDMA_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/uio.h>
#include <sys/mbuf.h>
#include <machine/bus.h>
#endif
/* defines */

View File

@ -25,6 +25,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -61,6 +64,7 @@
#include <dev/usb/usb_hub.h>
#include <dev/usb/usb_request.h>
#include <dev/usb/usb_debug.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
struct usb_linux_softc {
LIST_ENTRY(usb_linux_softc) sc_attached_list;

View File

@ -30,6 +30,9 @@
* http://www.usb.org/developers/devclass_docs/
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -51,6 +54,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
MALLOC_DEFINE(M_USB, "USB", "USB");
MALLOC_DEFINE(M_USBDEV, "USBdev", "USB device");

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -55,6 +58,7 @@
#include <ddb/ddb.h>
#include <ddb/db_sym.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/*
* Define this unconditionally in case a kernel module is loaded that

View File

@ -27,6 +27,9 @@
* usb_dev.c - An abstraction layer for creating devices under /dev/...
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -75,6 +78,7 @@
#include <sys/syscallsubr.h>
#include <machine/stdarg.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#if USB_HAVE_UGEN

View File

@ -27,11 +27,13 @@
#ifndef _USB_DEV_H_
#define _USB_DEV_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/file.h>
#include <sys/selinfo.h>
#include <sys/poll.h>
#include <sys/signalvar.h>
#include <sys/proc.h>
#endif
struct usb_fifo;
struct usb_mbuf;

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -78,6 +81,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/* function prototypes */

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -50,6 +53,7 @@
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_dynamic.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/* function prototypes */
static usb_handle_req_t usb_temp_get_desc_w;

View File

@ -27,8 +27,10 @@
#ifndef _USB_ENDIAN_H_
#define _USB_ENDIAN_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/stdint.h>
#include <sys/endian.h>
#endif
/*
* Declare the basic USB record types. USB records have an alignment

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -45,6 +48,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
static const char* usb_errstr_table[USB_ERR_MAX] = {
[USB_ERR_NORMAL_COMPLETION] = "USB_ERR_NORMAL_COMPLETION",

View File

@ -42,6 +42,7 @@
#define USB_HAVE_POWERD 1
#define USB_HAVE_MSCTEST 1
#define USB_HAVE_PF 1
#define USB_HAVE_ROOT_MOUNT_HOLD 1
#define USB_TD_GET_PROC(td) (td)->td_proc
#define USB_PROC_GET_GID(td) (td)->p_pgid

View File

@ -0,0 +1,83 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 2013 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
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
* ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
/*
* Including this file is mandatory for all USB related c-files in the loader.
*/
#ifndef _USB_FREEBSD_LOADER_H_
#define _USB_FREEBSD_LOADER_H_
/* Default USB configuration */
#define USB_HAVE_UGEN 0
#define USB_HAVE_DEVCTL 0
#define USB_HAVE_BUSDMA 1
#define USB_HAVE_COMPAT_LINUX 0
#define USB_HAVE_USER_IO 0
#define USB_HAVE_MBUF 0
#define USB_HAVE_TT_SUPPORT 1
#define USB_HAVE_POWERD 1
#define USB_HAVE_MSCTEST 0
#define USB_HAVE_PF 0
#define USB_HAVE_ROOT_MOUNT_HOLD 0
#define USB_TD_GET_PROC(td) (td)->td_proc
#define USB_PROC_GET_GID(td) (td)->p_pgid
#if (!defined(USB_HOST_ALIGN)) || (USB_HOST_ALIGN <= 0)
/* Use default value. */
#undef USB_HOST_ALIGN
#define USB_HOST_ALIGN 8 /* bytes, must be power of two */
#endif
/* Sanity check for USB_HOST_ALIGN: Verify power of two. */
#if ((-USB_HOST_ALIGN) & USB_HOST_ALIGN) != USB_HOST_ALIGN
#error "USB_HOST_ALIGN is not power of two."
#endif
#define USB_FS_ISOC_UFRAME_MAX 4 /* exclusive unit */
#define USB_BUS_MAX 256 /* units */
#define USB_MAX_DEVICES 128 /* units */
#define USB_IFACE_MAX 32 /* units */
#define USB_FIFO_MAX 128 /* units */
#define USB_MAX_EP_STREAMS 8 /* units */
#define USB_MAX_FS_ISOC_FRAMES_PER_XFER (120) /* units */
#define USB_MAX_HS_ISOC_FRAMES_PER_XFER (8*120) /* units */
#define USB_HUB_MAX_DEPTH 5
#define USB_EP0_BUFSIZE 1024 /* bytes */
#define USB_CS_RESET_LIMIT 20 /* failures = 20 * 50 ms = 1sec */
#define USB_MAX_AUTO_QUIRK 4 /* maximum number of dynamic quirks */
typedef uint32_t usb_timeout_t; /* milliseconds */
typedef uint32_t usb_frlength_t; /* bytes */
typedef uint32_t usb_frcount_t; /* units */
typedef uint32_t usb_size_t; /* bytes */
typedef uint32_t usb_ticks_t; /* system defined */
typedef uint16_t usb_power_mask_t; /* see "USB_HW_POWER_XXX" */
typedef uint16_t usb_stream_t; /* stream ID */
#endif /* _USB_FREEBSD_LOADER_H_ */

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -67,6 +70,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#if USB_HAVE_UGEN

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -61,6 +64,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/* function prototypes */

View File

@ -1,8 +1,5 @@
/* $FreeBSD$ */
/* $NetBSD: hid.c,v 1.17 2001/11/13 06:24:53 lukem Exp $ */
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
/*-
* Copyright (c) 1998 The NetBSD Foundation, Inc.
* All rights reserved.
@ -33,6 +30,9 @@ __FBSDID("$FreeBSD$");
* POSSIBILITY OF SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -64,6 +64,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_process.h>
#include <dev/usb/usb_device.h>
#include <dev/usb/usb_request.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
static void hid_clear_local(struct hid_item *);
static uint8_t hid_get_byte(struct hid_data *s, const uint16_t wSize);

View File

@ -30,6 +30,9 @@
* USB spec: http://www.usb.org/developers/docs/usbspec.zip
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -69,6 +72,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#define UHUB_INTR_INTERVAL 250 /* ms */
#define UHUB_N_TRANSFER 1

View File

@ -29,12 +29,14 @@
#ifndef _USB_IOCTL_H_
#define _USB_IOCTL_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/ioccom.h>
/* Building "kdump" depends on these includes */
#include <dev/usb/usb_endian.h>
#include <dev/usb/usb.h>
#endif
#define USB_DEVICE_NAME "usbctl"
#define USB_DEVICE_DIR "usb"

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -47,6 +50,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/*------------------------------------------------------------------------*
* usbd_lookup_id_by_info

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -47,6 +50,7 @@
#include <dev/usb/usbdi.h>
#include <dev/usb/usb_dev.h>
#include <dev/usb/usb_mbuf.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/*------------------------------------------------------------------------*
* usb_alloc_mbufs - allocate mbufs to an usbd interface queue

View File

@ -32,6 +32,9 @@
* mass storage quirks for not supported SCSI commands!
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -66,6 +69,7 @@
#include <dev/usb/usb_request.h>
#include <dev/usb/usb_util.h>
#include <dev/usb/quirk/usb_quirk.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
enum {
ST_COMMAND,

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -46,7 +49,7 @@
#include <dev/usb/usb.h>
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/*------------------------------------------------------------------------*
* usb_desc_foreach

View File

@ -31,9 +31,11 @@
* We don't want the following files included everywhere, that's why
* they are in a separate file.
*/
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <dev/pci/pcireg.h>
#include <dev/pci/pcivar.h>
#include <sys/rman.h>
#endif
#endif /* _USB_PCI_H_ */

View File

@ -1,3 +1,4 @@
/* $FreeBSD$ */
/*-
* Copyright (c) 1990, 1991, 1993
* The Regents of the University of California. All rights reserved.
@ -32,8 +33,9 @@
* SUCH DAMAGE.
*/
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/param.h>
#include <sys/kernel.h>
#include <sys/bus.h>
@ -59,6 +61,7 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usb_bus.h>
#include <dev/usb/usb_pf.h>
#include <dev/usb/usb_transfer.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
static void usbpf_init(void);
static void usbpf_uninit(void);

View File

@ -26,6 +26,9 @@
#define USB_DEBUG_VAR usb_proc_debug
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -55,6 +58,7 @@
#include <sys/proc.h>
#include <sys/kthread.h>
#include <sys/sched.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
#if (__FreeBSD_version < 700000)
#define thread_lock(td) mtx_lock_spin(&sched_lock)

View File

@ -27,9 +27,11 @@
#ifndef _USB_PROCESS_H_
#define _USB_PROCESS_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/interrupt.h>
#include <sys/priority.h>
#include <sys/runq.h>
#endif
/* defines */
#define USB_PRI_HIGH PI_SWI(SWI_NET)

View File

@ -26,6 +26,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -66,6 +69,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <sys/ctype.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
static int usb_no_cs_fail;

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -61,6 +64,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#include <dev/usb/usb_pf.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
struct usb_std_packet_size {
struct {

View File

@ -24,6 +24,9 @@
* SUCH DAMAGE.
*/
#ifdef USB_GLOBAL_INCLUDE_FILE
#include USB_GLOBAL_INCLUDE_FILE
#else
#include <sys/stdint.h>
#include <sys/stddef.h>
#include <sys/param.h>
@ -56,6 +59,7 @@
#include <dev/usb/usb_controller.h>
#include <dev/usb/usb_bus.h>
#endif /* USB_GLOBAL_INCLUDE_FILE */
/*------------------------------------------------------------------------*
* device_set_usb_desc

View File

@ -102,7 +102,9 @@ typedef void (usb_fifo_filter_t)(struct usb_fifo *fifo, struct usb_mbuf *m);
/* USB events */
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <sys/eventhandler.h>
#endif
typedef void (*usb_dev_configured_t)(void *, struct usb_device *,
struct usb_attach_arg *);
EVENTHANDLER_DECLARE(usb_dev_configured, usb_dev_configured_t);

View File

@ -29,7 +29,9 @@
#ifndef _USB_HID_H_
#define _USB_HID_H_
#ifndef USB_GLOBAL_INCLUDE_FILE
#include <dev/usb/usb_endian.h>
#endif
#define UR_GET_HID_DESCRIPTOR 0x06
#define UDESC_HID 0x21