Document the USB event API..

This commit is contained in:
augustss 2000-09-24 17:22:08 +00:00
parent b333be3980
commit a5f7c1b8fd
1 changed files with 68 additions and 1 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: usb.4,v 1.29 2000/09/23 20:26:48 augustss Exp $
.\" $NetBSD: usb.4,v 1.30 2000/09/24 17:22:08 augustss Exp $
.\"
.\" Copyright (c) 1999 The NetBSD Foundation, Inc.
.\" All rights reserved.
@ -376,6 +376,73 @@ The include file
similarly contains the definitions for
Human Interface Devices
.Pq Tn HID .
.Sh USB EVENT INTERFACE
All
.Tn USB
events are reported via the
.Pa /dev/usb
device. This devices can be opened for reading and each
.Xr read 2
will yield an event record (if something has happened).
The
.Xr poll 2
system call can be used to determine if an event record is available
for reading.
.Pp
The event record has the following definition:
.Bd -literal
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;
};
.Ed
The
.Va ue_type
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.
.br
The
.Va ue_bus
contains the number of the
.Tn USB
bus for host controller events.
.br
The
.Va ue_device
record contains information about the device in a device event event.
.br
The
.Va ue_cookie
is an opaque value that uniquely determines which 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
.Va ue_devname
contains the name of the device (driver) as seen in, e.g.,
kernel messages.
.Pp
Note that that there is a separation between device and device
driver events. A driver 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.
.Sh BUGS
There should be a serial number locator, but
.Nx