summaryrefslogtreecommitdiff
path: root/sys/dev/usb/usb.h
diff options
context:
space:
mode:
authorFederico G. Schwindt <fgsch@cvs.openbsd.org>2000-07-04 11:44:27 +0000
committerFederico G. Schwindt <fgsch@cvs.openbsd.org>2000-07-04 11:44:27 +0000
commit90c5f215cf041b9a7e9d4045a6ea32f686e8fc28 (patch)
tree3405ddc669be426cfa7c9e74b8a655cd8e4c936f /sys/dev/usb/usb.h
parentc543e41d0e0b608ebd7ae8249f32fc3b6ac1ad42 (diff)
sync with NetBSD... well almost. someone w/ the hw should check umass.
Diffstat (limited to 'sys/dev/usb/usb.h')
-rw-r--r--sys/dev/usb/usb.h51
1 files changed, 32 insertions, 19 deletions
diff --git a/sys/dev/usb/usb.h b/sys/dev/usb/usb.h
index 6830d1fd673..97ae2b8c702 100644
--- a/sys/dev/usb/usb.h
+++ b/sys/dev/usb/usb.h
@@ -1,4 +1,4 @@
-/* $OpenBSD: usb.h,v 1.9 2000/04/04 22:52:30 aaron Exp $ */
+/* $OpenBSD: usb.h,v 1.10 2000/07/04 11:44:24 fgsch Exp $ */
/* $NetBSD: usb.h,v 1.44 2000/04/03 13:40:05 augustss Exp $ */
/* $FreeBSD: src/sys/dev/usb/usb.h,v 1.14 1999/11/17 22:33:46 n_hibma Exp $ */
@@ -7,7 +7,7 @@
* All rights reserved.
*
* This code is derived from software contributed to The NetBSD Foundation
- * by Lennart Augustsson (augustss@carlstedt.se) at
+ * by Lennart Augustsson (lennart@augustsson.net) at
* Carlstedt Research & Technology.
*
* Redistribution and use in source and binary forms, with or without
@@ -77,36 +77,43 @@ MALLOC_DECLARE(M_USBHC);
/*
* The USB records contain some unaligned little-endian word
* components. The U[SG]ETW macros take care of both the alignment
- * and endian problem and should always be used to access 16 bit
+ * and endian problem and should always be used to access non-byte
* values.
*/
typedef u_int8_t uByte;
typedef u_int8_t uWord[2];
+typedef u_int8_t uDWord[4];
+
+#define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
+
+#if 1
#define UGETW(w) ((w)[0] | ((w)[1] << 8))
#define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
-#define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
-typedef u_int8_t uDWord[4];
#define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
#define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
(w)[1] = (u_int8_t)((v) >> 8), \
(w)[2] = (u_int8_t)((v) >> 16), \
(w)[3] = (u_int8_t)((v) >> 24))
+#else
/*
* On little-endian machines that can handle unanliged accesses
* (e.g. i386) these macros can be replaced by the following.
*/
-#if 0
#define UGETW(w) (*(u_int16_t *)(w))
#define USETW(w,v) (*(u_int16_t *)(w) = (v))
+#define UGETDW(w) (*(u_int32_t *)(w))
+#define USETDW(w,v) (*(u_int32_t *)(w) = (v))
#endif
+#define UPACKED __attribute__((__packed__))
+
typedef struct {
uByte bmRequestType;
uByte bRequest;
uWord wValue;
uWord wIndex;
uWord wLength;
-} usb_device_request_t;
+} UPACKED usb_device_request_t;
#define UT_WRITE 0x00
#define UT_READ 0x80
@@ -175,7 +182,7 @@ typedef struct {
uByte bLength;
uByte bDescriptorType;
uByte bDescriptorSubtype;
-} usb_descriptor_t;
+} UPACKED usb_descriptor_t;
typedef struct {
uByte bLength;
@@ -193,7 +200,7 @@ typedef struct {
uByte iProduct;
uByte iSerialNumber;
uByte bNumConfigurations;
-} usb_device_descriptor_t;
+} UPACKED usb_device_descriptor_t;
#define USB_DEVICE_DESCRIPTOR_SIZE 18
typedef struct {
@@ -209,7 +216,7 @@ typedef struct {
#define UC_REMOTE_WAKEUP 0x20
uByte bMaxPower; /* max current in 2 mA units */
#define UC_POWER_FACTOR 2
-} usb_config_descriptor_t;
+} UPACKED usb_config_descriptor_t;
#define USB_CONFIG_DESCRIPTOR_SIZE 9
typedef struct {
@@ -222,7 +229,7 @@ typedef struct {
uByte bInterfaceSubClass;
uByte bInterfaceProtocol;
uByte iInterface;
-} usb_interface_descriptor_t;
+} UPACKED usb_interface_descriptor_t;
#define USB_INTERFACE_DESCRIPTOR_SIZE 9
typedef struct {
@@ -249,14 +256,14 @@ typedef struct {
#define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
uWord wMaxPacketSize;
uByte bInterval;
-} usb_endpoint_descriptor_t;
+} UPACKED usb_endpoint_descriptor_t;
#define USB_ENDPOINT_DESCRIPTOR_SIZE 7
typedef struct {
uByte bLength;
uByte bDescriptorType;
uWord bString[127];
-} usb_string_descriptor_t;
+} UPACKED usb_string_descriptor_t;
#define USB_MAX_STRING_LEN 128
#define USB_LANGUAGE_TABLE 0 /* # of the string language id table */
@@ -299,9 +306,9 @@ typedef struct {
uByte DeviceRemovable[32]; /* max 255 ports */
#define UHD_NOT_REMOV(desc, i) \
(((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
- /* deprecated uByte PortPowerCtrlMask[]; */
-} usb_hub_descriptor_t;
-#define USB_HUB_DESCRIPTOR_SIZE 8
+ /* deprecated */ uByte PortPowerCtrlMask[1];
+} UPACKED usb_hub_descriptor_t;
+#define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
typedef struct {
uWord wStatus;
@@ -310,14 +317,14 @@ typedef struct {
#define UDS_REMOTE_WAKEUP 0x0002
/* Endpoint status flags */
#define UES_HALT 0x0001
-} usb_status_t;
+} UPACKED usb_status_t;
typedef struct {
uWord wHubStatus;
#define UHS_LOCAL_POWER 0x0001
#define UHS_OVER_CURRENT 0x0002
uWord wHubChange;
-} usb_hub_status_t;
+} UPACKED usb_hub_status_t;
typedef struct {
uWord wPortStatus;
@@ -334,7 +341,7 @@ typedef struct {
#define UPS_C_SUSPEND 0x0004
#define UPS_C_OVERCURRENT_INDICATOR 0x0008
#define UPS_C_PORT_RESET 0x0010
-} usb_port_status_t;
+} UPACKED usb_port_status_t;
/* Device class codes */
#define UDCLASS_AUDIO 0x00
@@ -428,6 +435,7 @@ typedef struct {
#define USB_RESUME_DELAY (20*5) /* ms */
#define USB_RESUME_WAIT 10 /* ms */
#define USB_RESUME_RECOVERY 10 /* ms */
+#define USB_EXTRA_POWER_UP_TIME 0 /* ms */
#else
/* Allow for marginal (i.e. non-conforming) devices. */
#define USB_PORT_RESET_DELAY 50 /* ms */
@@ -437,6 +445,7 @@ typedef struct {
#define USB_RESUME_DELAY (50*5) /* ms */
#define USB_RESUME_WAIT 50 /* ms */
#define USB_RESUME_RECOVERY 50 /* ms */
+#define USB_EXTRA_POWER_UP_TIME 20 /* ms */
#endif
#define USB_MIN_POWER 100 /* mA */
@@ -444,6 +453,10 @@ typedef struct {
#define USB_BUS_RESET_DELAY 100 /* ms XXX?*/
+
+#define USB_UNCONFIG_NO 0
+#define USB_UNCONFIG_INDEX (-1)
+
/*** ioctl() related stuff ***/
struct usb_ctl_request {