summaryrefslogtreecommitdiff
path: root/static/netbsd/man4/usb.4 4.html
diff options
context:
space:
mode:
authorJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 19:55:15 -0400
committerJacob McDonnell <jacob@jacobmcdonnell.com>2026-04-25 19:55:15 -0400
commit253e67c8b3a72b3a4757fdbc5845297628db0a4a (patch)
treeadf53b66087aa30dfbf8bf391a1dadb044c3bf4d /static/netbsd/man4/usb.4 4.html
parenta9157ce950dfe2fc30795d43b9d79b9d1bffc48b (diff)
docs: Added All NetBSD Manuals
Diffstat (limited to 'static/netbsd/man4/usb.4 4.html')
-rw-r--r--static/netbsd/man4/usb.4 4.html554
1 files changed, 554 insertions, 0 deletions
diff --git a/static/netbsd/man4/usb.4 4.html b/static/netbsd/man4/usb.4 4.html
new file mode 100644
index 00000000..1a488946
--- /dev/null
+++ b/static/netbsd/man4/usb.4 4.html
@@ -0,0 +1,554 @@
+<table class="head">
+ <tr>
+ <td class="head-ltitle">USB(4)</td>
+ <td class="head-vol">Device Drivers Manual</td>
+ <td class="head-rtitle">USB(4)</td>
+ </tr>
+</table>
+<div class="manual-text">
+<section class="Sh">
+<h1 class="Sh" id="NAME"><a class="permalink" href="#NAME">NAME</a></h1>
+<p class="Pp"><code class="Nm">usb</code> &#x2014; <span class="Nd">Universal
+ Serial Bus driver</span></p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SYNOPSIS"><a class="permalink" href="#SYNOPSIS">SYNOPSIS</a></h1>
+<p class="Pp"><code class="Cd">ehci* at cardbus? function ?</code>
+ <br/>
+ <code class="Cd">ehci* at pci? dev ? function ?</code>
+ <br/>
+ <code class="Cd">ohci* at cardbus? function ?</code>
+ <br/>
+ <code class="Cd">ohci* at pci? dev ? function ?</code>
+ <br/>
+ <code class="Cd">xhci* at pci? dev ? function ?</code>
+ <br/>
+ <code class="Cd">slhci* at isa? port ? irq ?</code>
+ <br/>
+ <code class="Cd">slhci* at pcmcia? function ?</code>
+ <br/>
+ <code class="Cd">uhci* at cardbus? function ?</code>
+ <br/>
+ <code class="Cd">uhci* at pci? dev ? function ?</code>
+ <br/>
+ <code class="Cd">usb* at ehci?</code>
+ <br/>
+ <code class="Cd">usb* at ohci?</code>
+ <br/>
+ <code class="Cd">usb* at uhci?</code>
+ <br/>
+ <code class="Cd">usb* at slhci?</code>
+ <br/>
+ <code class="Cd">uhub* at usb?</code>
+ <br/>
+ <code class="Cd">uhub* at uhub? port ? configuration ? interface ? vendor ?
+ product ? release ?</code>
+ <br/>
+ <code class="Cd">XX* at uhub? port ? configuration ? interface ? vendor ?
+ product ? release ?</code></p>
+<p class="Pp">
+ <br/>
+ <code class="Cd">options USBVERBOSE</code></p>
+<p class="Pp">
+ <br/>
+ <code class="In">#include &lt;<a class="In">dev/usb/usb.h</a>&gt;</code>
+ <br/>
+ <code class="In">#include
+ &lt;<a class="In">dev/usb/usbhid.h</a>&gt;</code></p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="DESCRIPTION"><a class="permalink" href="#DESCRIPTION">DESCRIPTION</a></h1>
+<p class="Pp"><span class="Ux">NetBSD</span> provides machine-independent bus
+ support and drivers for USB devices.</p>
+<p class="Pp">The <span class="Ux">NetBSD</span> <code class="Nm">usb</code>
+ driver has three layers (like <a class="Xr">scsi(4)</a> and
+ <a class="Xr">pcmcia(4)</a>): the controller, the bus, and the device layer.
+ The controller attaches to a physical bus (like <a class="Xr">pci(4)</a>).
+ The USB bus attaches to the controller and the root hub attaches to the bus.
+ Further devices, which may include further hubs, attach to other hubs. The
+ attachment forms the same tree structure as the physical USB device tree.
+ For each USB device there may be additional drivers attached to it.</p>
+<p class="Pp">The <code class="Cm">uhub</code> device controls USB hubs and must
+ always be present since there is at least a root hub in any USB system.</p>
+<p class="Pp"><span class="Ux">NetBSD</span> supports the following
+ machine-independent USB drivers:</p>
+<section class="Ss">
+<h2 class="Ss" id="Storage_devices"><a class="permalink" href="#Storage_devices">Storage
+ devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">umass(4)</a></dt>
+ <dd>USB Mass Storage Devices, e.g., external disk drives</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Wired_network_interfaces"><a class="permalink" href="#Wired_network_interfaces">Wired
+ network interfaces</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">aue(4)</a></dt>
+ <dd>ADMtek AN986/ADM8511 Pegasus family 10/100 USB Ethernet device</dd>
+ <dt><a class="Xr">axe(4)</a></dt>
+ <dd>ASIX Electronics AX88172/AX88178/AX88772 10/100/Gigabit USB Ethernet
+ device</dd>
+ <dt><a class="Xr">axen(4)</a></dt>
+ <dd>ASIX Electronics AX88178a/AX88179 10/100/Gigabit USB Ethernet device</dd>
+ <dt><a class="Xr">cdce(4)</a></dt>
+ <dd>USB Communication Device Class Ethernet device</dd>
+ <dt><a class="Xr">cue(4)</a></dt>
+ <dd>CATC USB-EL1201A USB Ethernet device</dd>
+ <dt><a class="Xr">kue(4)</a></dt>
+ <dd>Kawasaki LSI KL5KUSB101B USB Ethernet device</dd>
+ <dt><a class="Xr">mos(4)</a></dt>
+ <dd>MosChip MCS7730/7830/7832 10/100 USB Ethernet device</dd>
+ <dt><a class="Xr">mue(4)</a></dt>
+ <dd>Microchip LAN75xx/LAN78xx 10/100/Gigabit USB Ethernet device</dd>
+ <dt><a class="Xr">ncm(4)</a></dt>
+ <dd>USB Network Control Model Ethernet device</dd>
+ <dt><a class="Xr">udav(4)</a></dt>
+ <dd>Davicom DM9601 10/100 USB Ethernet device</dd>
+ <dt><a class="Xr">ure(4)</a></dt>
+ <dd>Realtek RTL8152/RTL8153 10/100/Gigabit USB Ethernet device</dd>
+ <dt><a class="Xr">url(4)</a></dt>
+ <dd>Realtek RTL8150L 10/100 USB Ethernet device</dd>
+ <dt><a class="Xr">urndis(4)</a></dt>
+ <dd>USB Remote NDIS Ethernet device</dd>
+ <dt><a class="Xr">usmsc(4)</a></dt>
+ <dd>SMSC LAN95xx 10/100 USB Ethernet device</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Wireless_network_interfaces"><a class="permalink" href="#Wireless_network_interfaces">Wireless
+ network interfaces</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">atu(4)</a></dt>
+ <dd>Atmel AT76C50x IEEE 802.11b wireless network device</dd>
+ <dt><a class="Xr">ral(4)</a></dt>
+ <dd>Ralink Technology USB IEEE 802.11b/g wireless network device</dd>
+ <dt><a class="Xr">rum(4)</a></dt>
+ <dd>Ralink Technology USB IEEE 802.11a/b/g wireless network device</dd>
+ <dt><a class="Xr">run(4)</a></dt>
+ <dd>Ralink Technology USB IEEE 802.11a/b/g/n wireless network device</dd>
+ <dt><a class="Xr">ubt(4)</a></dt>
+ <dd>USB Bluetooth dongles</dd>
+ <dt><a class="Xr">upgt(4)</a></dt>
+ <dd>Conexant/Intersil PrismGT SoftMAC USB 802.11b/g wireless network
+ device</dd>
+ <dt><a class="Xr">urtwn(4)</a></dt>
+ <dd>Realtek RTL8188CU/RTL8192CU USB IEEE 802.11b/g/n wireless network
+ device</dd>
+ <dt><a class="Xr">zyd(4)</a></dt>
+ <dd>ZyDAS ZD1211/ZD1211B USB IEEE 802.11b/g wireless network device</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Serial_and_parallel_interfaces"><a class="permalink" href="#Serial_and_parallel_interfaces">Serial
+ and parallel interfaces</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">uark(4)</a></dt>
+ <dd>Arkmicro Technologies ARK3116 based USB serial adapters</dd>
+ <dt><a class="Xr">ubsa(4)</a></dt>
+ <dd>Belkin USB serial adapter</dd>
+ <dt><a class="Xr">uchcom(4)</a></dt>
+ <dd>WinChipHead CH341/340 based USB serial adapter</dd>
+ <dt><a class="Xr">ucom(4)</a></dt>
+ <dd>USB tty support</dd>
+ <dt><a class="Xr">ucycom(4)</a></dt>
+ <dd>Cypress microcontroller based USB serial adapter</dd>
+ <dt><a class="Xr">uftdi(4)</a></dt>
+ <dd>FT8U100AX USB serial adapter</dd>
+ <dt><a class="Xr">ugensa(4)</a></dt>
+ <dd>USB generic serial adapter</dd>
+ <dt><a class="Xr">uipaq(4)</a></dt>
+ <dd>iPAQ USB units</dd>
+ <dt><a class="Xr">ukyopon(4)</a></dt>
+ <dd>USB Kyocera AIR-EDGE PHONE device</dd>
+ <dt><a class="Xr">ulpt(4)</a></dt>
+ <dd>USB printer support</dd>
+ <dt><a class="Xr">umct(4)</a></dt>
+ <dd>MCT USB-RS232 USB serial adapter</dd>
+ <dt><a class="Xr">umodem(4)</a></dt>
+ <dd>USB modem support</dd>
+ <dt><a class="Xr">uplcom(4)</a></dt>
+ <dd>Prolific PL-2303 USB serial adapter</dd>
+ <dt><a class="Xr">uslsa(4)</a></dt>
+ <dd>Silicon Laboratories CP2101/CP2102 based USB serial adapter</dd>
+ <dt><a class="Xr">uvisor(4)</a></dt>
+ <dd>USB Handspring Visor</dd>
+ <dt><a class="Xr">uvscom(4)</a></dt>
+ <dd>SUNTAC Slipper U VS-10U USB serial adapter</dd>
+ <dt><a class="Xr">uxrcom(4)</a></dt>
+ <dd>Exar XR21V141x USB serial adapter</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Cellular_WAN_interfaces"><a class="permalink" href="#Cellular_WAN_interfaces">Cellular
+ WAN interfaces</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">u3g(4)</a></dt>
+ <dd>USB 3G modems</dd>
+ <dt><a class="Xr">uhmodem(4)</a></dt>
+ <dd>Huawei 3G wireless modems</dd>
+ <dt><a class="Xr">uhso(4)</a></dt>
+ <dd>Option N.V. Wireless WAN modems</dd>
+ <dt><a class="Xr">umb(4)</a></dt>
+ <dd>USB Mobile Broadband Interface Model (MBIM) devices</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Audio_devices"><a class="permalink" href="#Audio_devices">Audio
+ devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">uaudio(4)</a></dt>
+ <dd>USB audio devices</dd>
+ <dt><a class="Xr">umidi(4)</a></dt>
+ <dd>USB MIDI devices</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Video_devices"><a class="permalink" href="#Video_devices">Video
+ devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">pseye(4)</a></dt>
+ <dd>Sony PlayStation Eye webcam device driver</dd>
+ <dt><a class="Xr">udl(4)</a></dt>
+ <dd>DisplayLink DL-1x0/1x5 USB display devices</dd>
+ <dt><a class="Xr">uvideo(4)</a></dt>
+ <dd>USB video class devices (e.g. webcams, capture cards)</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Radio_receiver_devices"><a class="permalink" href="#Radio_receiver_devices">Radio
+ receiver devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">slurm(4)</a></dt>
+ <dd>Silicon Labs USB FM radios</dd>
+ <dt><a class="Xr">udsbr(4)</a></dt>
+ <dd>D-Link DSB-R100 USB radio device</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Human_Interface_Devices"><a class="permalink" href="#Human_Interface_Devices">Human
+ Interface Devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">uatp(4)</a></dt>
+ <dd>Apple trackpads</dd>
+ <dt><a class="Xr">uep(4)</a></dt>
+ <dd>eGalax touch panel controllers</dd>
+ <dt><a class="Xr">uhid(4)</a></dt>
+ <dd>Generic driver for Human Interface Devices</dd>
+ <dt><a class="Xr">uhidev(4)</a></dt>
+ <dd>Base driver for all Human Interface Devices</dd>
+ <dt><a class="Xr">uintuos(4)</a></dt>
+ <dd>Wacom Intuos drawing tablets</dd>
+ <dt><a class="Xr">ukbd(4)</a></dt>
+ <dd>USB keyboards that follow the boot protocol</dd>
+ <dt><a class="Xr">ums(4)</a></dt>
+ <dd>USB mouse devices</dd>
+ <dt><a class="Xr">uthum(4)</a></dt>
+ <dd>TEMPer and TEMPerHUM temperature and humidity sensors</dd>
+ <dt><a class="Xr">uts(4)</a></dt>
+ <dd>Generic driver for touchscreens and touch digitizers</dd>
+</dl>
+</div>
+</section>
+<section class="Ss">
+<h2 class="Ss" id="Miscellaneous_devices"><a class="permalink" href="#Miscellaneous_devices">Miscellaneous
+ devices</a></h2>
+<div class="Bd-indent">
+<dl class="Bl-tag Bl-compact">
+ <dt><a class="Xr">stuirda(4)</a></dt>
+ <dd>Sigmaltel 4116/4220 USB-IrDA bridge</dd>
+ <dt><a class="Xr">ualea(4)</a></dt>
+ <dd>USB Araneus Alea I/II random number generators</dd>
+ <dt><a class="Xr">uberry(4)</a></dt>
+ <dd>Battery charging RIM BlackBerry phones via USB</dd>
+ <dt><a class="Xr">ugen(4)</a></dt>
+ <dd>USB generic devices</dd>
+ <dt><a class="Xr">uipad(4)</a></dt>
+ <dd>Battery charging iOS devices via USB</dd>
+ <dt><a class="Xr">uirda(4)</a></dt>
+ <dd>USB IrDA bridges</dd>
+ <dt><a class="Xr">upl(4)</a></dt>
+ <dd>Prolific based host-to-host adapters</dd>
+ <dt><a class="Xr">usscanner(4)</a></dt>
+ <dd>SCSI-over-USB scanners</dd>
+ <dt><a class="Xr">ustir(4)</a></dt>
+ <dd>SigmaTel STIr4200 USB IrDA bridges</dd>
+ <dt><a class="Xr">utoppy(4)</a></dt>
+ <dd>Topfield TF5000PVR range of digital video recorders</dd>
+</dl>
+</div>
+</section>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="INTRODUCTION_TO_USB"><a class="permalink" href="#INTRODUCTION_TO_USB">INTRODUCTION
+ TO USB</a></h1>
+<p class="Pp">The USB 1.x is a 12 Mb/s serial bus with 1.5 Mb/s for low speed
+ devices. USB 2.x handles 480 Mb/s. Each USB has a host controller that is
+ the master of the bus; all other devices on the bus only speak when spoken
+ to.</p>
+<p class="Pp">There can be up to 127 devices (apart from the host controller) on
+ a bus, each with its own address. The addresses are assigned dynamically by
+ the host when each device is attached to the bus.</p>
+<p class="Pp">Within each device there can be up to 16 endpoints. Each endpoint
+ is individually addressed and the addresses are static. Each of these
+ endpoints will communicate in one of four different modes: control,
+ isochronous, bulk, or interrupt. A device always has at least one endpoint.
+ This endpoint has address 0 and is a control endpoint and is used to give
+ commands to and extract basic data, such as descriptors, from the device.
+ Each endpoint, except the control endpoint, is unidirectional.</p>
+<p class="Pp">The endpoints in a device are grouped into interfaces. An
+ interface is a logical unit within a device; e.g., a compound device with
+ both a keyboard and a trackball would present one interface for each. An
+ interface can sometimes be set into different modes, called alternate
+ settings, which affects how it operates. Different alternate settings can
+ have different endpoints within it.</p>
+<p class="Pp">A device may operate in different configurations. Depending on the
+ configuration the device may present different sets of endpoints and
+ interfaces.</p>
+<p class="Pp">Each device located on a hub has several
+ <a class="Xr">config(1)</a> locators:</p>
+<dl class="Bl-tag Bl-compact">
+ <dt><code class="Cd">port</code></dt>
+ <dd>this is the number of the port on closest upstream hub.</dd>
+ <dt><code class="Cd">configuration</code></dt>
+ <dd>this is the configuration the device must be in for this driver to attach.
+ This locator does not set the configuration; it is iterated by the bus
+ enumeration.</dd>
+ <dt><code class="Cd">interface</code></dt>
+ <dd>this is the interface number within a device that an interface driver
+ attaches to.</dd>
+ <dt><code class="Cd">vendor</code></dt>
+ <dd>this is the 16 bit vendor id of the device.</dd>
+ <dt><code class="Cd">product</code></dt>
+ <dd>this is the 16 bit product id of the device.</dd>
+ <dt><code class="Cd">release</code></dt>
+ <dd>this is the 16 bit release (revision) number of the device.</dd>
+</dl>
+The first locator can be used to pin down a particular device according to its
+ physical position in the device tree. The last three locators can be used to
+ pin down a particular device according to what device it actually is.
+<p class="Pp">The bus enumeration of the USB bus proceeds in several steps:</p>
+<ol class="Bl-enum">
+ <li>Any device specific driver can attach to the device.</li>
+ <li>If none is found, any device class specific driver can attach.</li>
+ <li>If none is found, all configurations are iterated over. For each
+ configuration all the interface are iterated over and interface drivers
+ can attach. If any interface driver attached in a certain configuration
+ the iteration over configurations is stopped.</li>
+ <li>If still no drivers have been found, the generic USB driver can
+ attach.</li>
+</ol>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="USB_CONTROLLER_INTERFACE"><a class="permalink" href="#USB_CONTROLLER_INTERFACE">USB
+ CONTROLLER INTERFACE</a></h1>
+<p class="Pp">Use the following to get access to the USB specific structures and
+ defines.</p>
+<div class="Bd Pp Li">
+<pre>#include &lt;dev/usb/usb.h&gt;</pre>
+</div>
+<p class="Pp">The <span class="Pa">/dev/usbN</span> can be opened and a few
+ operations can be performed on it. The <a class="Xr">poll(2)</a> system call
+ will say that I/O is possible on the controller device when a USB device has
+ been connected or disconnected to the bus.</p>
+<p class="Pp">The following <a class="Xr">ioctl(2)</a> commands are supported on
+ the controller device:</p>
+<dl class="Bl-tag">
+ <dt id="USB_DEVICEINFO"><a class="permalink" href="#USB_DEVICEINFO"><code class="Dv">USB_DEVICEINFO</code></a>
+ <var class="Fa">struct usb_device_info</var></dt>
+ <dd>This command can be used to retrieve some information about a device on
+ the bus. The <var class="Va">addr</var> field should be filled before the
+ call and the other fields will be filled by information about the device
+ on that address. Should no such device exist an error is reported.
+ <div class="Bd Pp Li">
+ <pre>struct usb_device_info {
+ uint8_t udi_bus;
+ uint8_t udi_addr;
+ usb_event_cookie_t udi_cookie;
+ char udi_product[USB_MAX_ENCODED_STRING_LEN];
+ char udi_vendor[USB_MAX_ENCODED_STRING_LEN];
+ char udi_release[8];
+ char udi_serial[USB_MAX_ENCODED_STRING_LEN];
+ uint16_t udi_productNo;
+ uint16_t udi_vendorNo;
+ uint16_t udi_releaseNo;
+ uint8_t udi_class;
+ uint8_t udi_subclass;
+ uint8_t udi_protocol;
+ uint8_t udi_config;
+ uint8_t udi_speed;
+#define USB_SPEED_LOW 1
+#define USB_SPEED_FULL 2
+#define USB_SPEED_HIGH 3
+ int udi_power;
+ int udi_nports;
+ char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
+ uint8_t udi_ports[16];
+#define USB_PORT_ENABLED 0xff
+#define USB_PORT_SUSPENDED 0xfe
+#define USB_PORT_POWERED 0xfd
+#define USB_PORT_DISABLED 0xfc
+};</pre>
+ </div>
+ <p class="Pp">The <var class="Va">product</var>,
+ <var class="Va">vendor</var>, <var class="Va">release</var>, and
+ <var class="Va">serial</var> fields contain self-explanatory
+ descriptions of the device.</p>
+ <p class="Pp">The <var class="Va">class</var> field contains the device
+ class.</p>
+ <p class="Pp">The <var class="Va">config</var> field shows the current
+ configuration of the device.</p>
+ <p class="Pp">The <var class="Va">lowspeed</var> field is set if the device
+ is a USB low speed device.</p>
+ <p class="Pp">The <var class="Va">power</var> field shows the power
+ consumption in milli-amps drawn at 5 volts, or zero if the device is
+ self powered.</p>
+ <p class="Pp">If the device is a hub the <var class="Va">nports</var> field
+ is non-zero and the <var class="Va">ports</var> field contains the
+ addresses of the connected devices. If no device is connected to a port
+ one of the <var class="Va">USB_PORT_*</var> values indicates its
+ status.</p>
+ </dd>
+ <dt id="USB_DEVICESTATS"><a class="permalink" href="#USB_DEVICESTATS"><code class="Dv">USB_DEVICESTATS</code></a>
+ <var class="Fa">struct usb_device_stats</var></dt>
+ <dd>This command retrieves statistics about the controller.
+ <div class="Bd Pp Li">
+ <pre>struct usb_device_stats {
+ u_long uds_requests[4];
+};</pre>
+ </div>
+ <p class="Pp">The <var class="Va">requests</var> field is indexed by the
+ transfer kind, i.e. <var class="Va">UE_*</var>, and indicates how many
+ transfers of each kind have been completed by the controller.</p>
+ </dd>
+ <dt id="USB_REQUEST"><a class="permalink" href="#USB_REQUEST"><code class="Dv">USB_REQUEST</code></a>
+ <var class="Fa">struct usb_ctl_request</var></dt>
+ <dd>This command can be used to execute arbitrary requests on the control
+ pipe. This is
+ <a class="permalink" href="#DANGEROUS"><i class="Em" id="DANGEROUS">DANGEROUS</i></a>
+ and should be used with great care since it can destroy the bus
+ integrity.</dd>
+</dl>
+<p class="Pp" id="UGETW">The include file
+ <code class="In">&lt;<a class="In">dev/usb/usb.h</a>&gt;</code> contains
+ definitions for the types used by the various <a class="Xr">ioctl(2)</a>
+ calls. The naming convention of the fields for the various USB descriptors
+ exactly follows the naming in the USB specification. Byte sized fields can
+ be accessed directly, but word (16 bit) sized fields must be access by the
+ <a class="permalink" href="#UGETW"><code class="Fn">UGETW</code></a>(<var class="Fa">field</var>)
+ and
+ <a class="permalink" href="#USETW"><code class="Fn" id="USETW">USETW</code></a>(<var class="Fa">field</var>,
+ <var class="Fa">value</var>) macros to handle byte order and alignment
+ properly.</p>
+<p class="Pp">The include file
+ <code class="In">&lt;<a class="In">dev/usb/usbhid.h</a>&gt;</code> similarly
+ contains the definitions for Human Interface Devices (HID).</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="USB_EVENT_INTERFACE"><a class="permalink" href="#USB_EVENT_INTERFACE">USB
+ EVENT INTERFACE</a></h1>
+<p class="Pp">All USB events are reported via the
+ <span class="Pa">/dev/usb</span> device. This devices can be opened for
+ reading and each <a class="Xr">read(2)</a> will yield an event record (if
+ something has happened). The <a class="Xr">poll(2)</a> system call can be
+ used to determine if an event record is available for reading.</p>
+<p class="Pp">The event record has the following definition:</p>
+<div class="Bd Pp Li">
+<pre>struct usb_event {
+ int ue_type;
+#define USB_EVENT_CTRLR_ATTACH 1
+#define USB_EVENT_CTRLR_DETACH 2
+#define USB_EVENT_DEVICE_ATTACH 3
+#define USB_EVENT_DEVICE_DETACH 4
+#define USB_EVENT_DRIVER_ATTACH 5
+#define USB_EVENT_DRIVER_DETACH 6
+ struct timespec ue_time;
+ union {
+ struct {
+ int ue_bus;
+ } ue_ctrlr;
+ struct usb_device_info ue_device;
+ struct {
+ usb_event_cookie_t ue_cookie;
+ char ue_devname[16];
+ } ue_driver;
+ } u;
+};</pre>
+</div>
+<p class="Pp">The <var class="Va">ue_type</var> field identifies the type of
+ event that is described. The possible events are attach/detach of a host
+ controller, a device, or a device driver. The union contains information
+ pertinent to the different types of events.</p>
+<p class="Pp">The <var class="Va">ue_bus</var> contains the number of the USB
+ bus for host controller events.</p>
+<p class="Pp">The <var class="Va">ue_device</var> record contains information
+ about the device in a device event event.</p>
+<p class="Pp">The <var class="Va">ue_cookie</var> is an opaque value that
+ uniquely determines which device a device driver has been attached to (i.e.,
+ it equals the cookie value in the device that the driver attached to). The
+ <var class="Va">ue_devname</var> contains the name of the device (driver) as
+ seen in, e.g., kernel messages.</p>
+<p class="Pp">Note that there is a separation between device and device driver
+ events. A device event is generated when a physical USB device is attached
+ or detached. A single USB device may have zero, one, or many device drivers
+ associated with it.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="KERNEL_THREADS"><a class="permalink" href="#KERNEL_THREADS">KERNEL
+ THREADS</a></h1>
+<p class="Pp">For each USB bus, i.e., for each host controller, there is a
+ kernel thread that handles attach and detach of devices on that bus. The
+ thread is named <var class="Va">usbN</var> where <var class="Va">N</var> is
+ the bus number.</p>
+<p class="Pp">In addition there is a kernel thread,
+ <var class="Va">usbtask</var>, which handles various minor tasks that are
+ initiated from an interrupt context, but need to sleep, e.g., time-out abort
+ of transfers.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="SEE_ALSO"><a class="permalink" href="#SEE_ALSO">SEE
+ ALSO</a></h1>
+<p class="Pp"><a class="Xr">usbhidaction(1)</a>, <a class="Xr">usbhidctl(1)</a>,
+ <a class="Xr">cardbus(4)</a>, <a class="Xr">ehci(4)</a>,
+ <a class="Xr">isa(4)</a>, <a class="Xr">ohci(4)</a>,
+ <a class="Xr">pci(4)</a>, <a class="Xr">pcmcia(4)</a>,
+ <a class="Xr">slhci(4)</a>, <a class="Xr">uhci(4)</a>,
+ <a class="Xr">xhci(4)</a>, <a class="Xr">usbdevs(8)</a></p>
+<p class="Pp"><cite class="Rs"><span class="RsT">Universal Serial Bus
+ Specifications Documents</span>,
+ <a class="RsU" href="http://www.usb.org/developers/docs/">http://www.usb.org/developers/docs/</a>.</cite></p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="HISTORY"><a class="permalink" href="#HISTORY">HISTORY</a></h1>
+<p class="Pp">The <code class="Nm">usb</code> driver appeared in
+ <span class="Ux">NetBSD 1.4</span>.</p>
+</section>
+<section class="Sh">
+<h1 class="Sh" id="BUGS"><a class="permalink" href="#BUGS">BUGS</a></h1>
+<p class="Pp">There should be a serial number locator, but
+ <span class="Ux">NetBSD</span> does not have string valued locators.</p>
+</section>
+</div>
+<table class="foot">
+ <tr>
+ <td class="foot-date">April 1, 2025</td>
+ <td class="foot-os">NetBSD 10.1</td>
+ </tr>
+</table>