185 lines
5.5 KiB
C
185 lines
5.5 KiB
C
/*++
|
|
|
|
Copyright (c) 1996 Microsoft Corporation
|
|
|
|
Module Name:
|
|
|
|
USB_DFW.H
|
|
|
|
Abstract:
|
|
|
|
Extracted structures from USBDI.H to allow apps to use the struct alignment of their
|
|
choice for the common device framework structures. Due to the problems w/ byte alignment,
|
|
apps that use the USBDI.H file cannot always end up with the same alignment if all the
|
|
proper env variables aren't set. So, this file is created to pull o ut the interesting
|
|
stuff and allow apps to use it.
|
|
|
|
BUGBUG :
|
|
Need to fix this somehow so that we can import USBDI.H directly. The trick is to
|
|
figure out which vars must be set properly to get the #include <PSHPACK1.H> to do the right things
|
|
because now even though that #include is in USBDI.H, it isn't causing the right things to happen
|
|
because of incorrectly set env vars.
|
|
|
|
|
|
Environment:
|
|
|
|
Kernel & user mode
|
|
|
|
Revision History:
|
|
|
|
8-4-96 : created by Kosar Jaff
|
|
|
|
--*/
|
|
|
|
#ifndef __USB_DFW_H__
|
|
#define __USB_DFW_H__
|
|
|
|
//
|
|
// USB descriptor types, bDescriptorType field
|
|
// in USB descriptor structure
|
|
//
|
|
|
|
#define USB_DEVICE_DESCRIPTOR_TYPE 0x01
|
|
#define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
|
|
#define USB_STRING_DESCRIPTOR_TYPE 0x03
|
|
#define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
|
|
#define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
|
|
|
|
#define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d<<8 | i))
|
|
|
|
//
|
|
// Values for bmAttributes field of an
|
|
// endpoint descriptor
|
|
//
|
|
|
|
#define USB_ENDPOINT_TYPE_MASK 0x03
|
|
|
|
#define USB_ENDPOINT_TYPE_CONTROL 0x00
|
|
#define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
|
|
#define USB_ENDPOINT_TYPE_BULK 0x02
|
|
#define USB_ENDPOINT_TYPE_INTERRUPT 0x03
|
|
|
|
//
|
|
// Endpoint direction bit, stored in address
|
|
//
|
|
|
|
#define USB_ENDPOINT_DIRECTION_MASK 0x80
|
|
|
|
// test direction bit in the bEndpointAddress field of
|
|
// an endpoint descriptor.
|
|
#define USB_ENDPOINT_DIRECTION_OUT(addr) (!((addr) & USB_ENDPOINT_DIRECTION_MASK))
|
|
#define USB_ENDPOINT_DIRECTION_IN(addr) ((addr) & USB_ENDPOINT_DIRECTION_MASK)
|
|
|
|
//
|
|
// USB defined request codes
|
|
// see chapter 9 of the USB 1.0 specifcation for
|
|
// more information.
|
|
//
|
|
|
|
// These are the correct values based on the USB 1.0
|
|
// specification
|
|
|
|
#define USB_REQUEST_GET_STATUS 0x00
|
|
#define USB_REQUEST_CLEAR_FEATURE 0x01
|
|
|
|
#define USB_REQUEST_SET_FEATURE 0x03
|
|
|
|
#define USB_REQUEST_SET_ADDRESS 0x05
|
|
#define USB_REQUEST_GET_DESCRIPTOR 0x06
|
|
#define USB_REQUEST_SET_DESCRIPTOR 0x07
|
|
#define USB_REQUEST_GET_CONFIGURATION 0x08
|
|
#define USB_REQUEST_SET_CONFIGURATION 0x09
|
|
#define USB_REQUEST_GET_INTERFACE 0x0A
|
|
#define USB_REQUEST_SET_INTERFACE 0x0B
|
|
#define USB_REQUEST_SYNC_FRAME 0x0C
|
|
|
|
|
|
//#include <PSHPACK1.H>
|
|
|
|
typedef struct _USB_DEVICE_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
USHORT bcdUSB;
|
|
UCHAR bDeviceClass;
|
|
UCHAR bDeviceSubClass;
|
|
UCHAR bDeviceProtocol;
|
|
UCHAR bMaxPacketSize0;
|
|
USHORT idVendor;
|
|
USHORT idProduct;
|
|
USHORT bcdDevice;
|
|
UCHAR iManufacturer;
|
|
UCHAR iProduct;
|
|
UCHAR iSerialNumber;
|
|
UCHAR bNumConfigurations;
|
|
} USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
|
|
|
|
typedef struct _USB_ENDPOINT_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
UCHAR bEndpointAddress;
|
|
UCHAR bmAttributes;
|
|
USHORT wMaxPacketSize;
|
|
UCHAR bInterval;
|
|
} USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
|
|
|
|
//
|
|
// values for bmAttributes Field in
|
|
// USB_CONFIGURATION_DESCRIPTOR
|
|
//
|
|
|
|
#define BUS_POWERED 0x80
|
|
#define SELF_POWERED 0x40
|
|
#define REMOTE_WAKEUP 0x20
|
|
|
|
typedef struct _USB_CONFIGURATION_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
USHORT wTotalLength;
|
|
UCHAR bNumInterfaces;
|
|
UCHAR bConfigurationValue;
|
|
UCHAR iConfiguration;
|
|
UCHAR bmAttributes;
|
|
UCHAR MaxPower;
|
|
} USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
|
|
|
|
typedef struct _USB_INTERFACE_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
UCHAR bInterfaceNumber;
|
|
UCHAR bAlternateSetting;
|
|
UCHAR bNumEndpoints;
|
|
UCHAR bInterfaceClass;
|
|
UCHAR bInterfaceSubClass;
|
|
UCHAR bInterfaceProtocol;
|
|
UCHAR iInterface;
|
|
} USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
|
|
|
|
typedef struct _USB_STRING_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
WCHAR bString[1];
|
|
} USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
|
|
|
|
typedef struct _USB_COMMON_DESCRIPTOR {
|
|
UCHAR bLength;
|
|
UCHAR bDescriptorType;
|
|
} USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
|
|
|
|
typedef struct _USB_HUB_DESCRIPTOR {
|
|
UCHAR bDescriptorLength; // Length of this descriptor
|
|
UCHAR bDescriptorType; // Hub configuration type
|
|
UCHAR bNumberOfPorts; // number of ports on this hub
|
|
USHORT wHubCharacteristics; // Hub Charateristics
|
|
UCHAR bPowerOnToPowerGood; // port power on till power good in 2ms
|
|
UCHAR bHubControlCurrent; // max current in mA
|
|
//
|
|
// room for 255 ports power control and removable bitmask
|
|
UCHAR bRemoveAndPowerMask[64];
|
|
} USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
|
|
|
|
|
|
//#include <POPPACK.H>
|
|
|
|
|
|
#endif // __USB_DFW_H__
|