Unit USB
Return to Unit Reference
Description
USB
This unit implements the USB core software that does not depend on the specific host controller hardware and is not specific to any single USB device or platform.
Features and limitations:
- This driver is written to be compatible with USB 2.0. USB 3.0 devices work correctly when operating in USB 2.0 compatible mode, actual support for USB 3.0 host controllers and native super speed modes will require some modification to this driver.
- Not all USB transfer types and speeds are supported yet. This depends on the Host Controller Driver, see USBRequestSubmit.
- This driver does not attempt to do any intelligent power management, bandwidth allocation, or transfer scheduling. Devices are always set to their first listed configuration regardless of power requirements. Requests are simply passed to the Host Controller Driver in the order submitted, the Host Controller Driver is responsible for doing any more intelligent scheduling if desired.
- This driver does not support multiple configurations per USB device. If a device happens to have multiple configurations, the first one will be assigned (see devices below for more information).
- By design, it is possible to implement a host controller driver for different host controller hardware without changing any of this code, as long as the host controller driver provides the functions declared in TUSBHost (Start, Stop, Reset, Submit and Cancel).
- By design, this driver has a hard-coded dependency on the USB hub driver because USB is useless without hubs.
To initialize this core USB driver, USBInit must be called by the system startup code. See that function for details.
If the flag USB_AUTOSTART is not set then USBStart must be called to start the USB core. See that function for details.
The other functions exported by this core USB driver are mostly intended to be used by USB device drivers.
Debugging messages in this driver can be enabled by changing the value of USB_DEFAULT_LOG_LEVEL and by enabling the USB_DEBUG define in GlobalDefines.
Be careful when enabling USB debugging as the USB core can generate a lot of messages due to constant polling of interrupt endpoints on devices such as hubs, keyboards and mice.
USB Device
USB devices are the generic implementation of anything that can be connected to the USB bus. All USB devices require a driver to implement the specific behaviour of the device but at the generic level each device will have:
- One or more configurations available. The USB core will first offer the device to drivers without a configuration being selected, the driver may choose a specific configuration if required otherwise the core will simply select the first available configuration.
- One or more interfaces available. On devices with multiple interfaces, the USB core supports different drivers binding to different interfaces. This way combination devices are supported.
- One or more endpoints available. All devices must have a control endpoint and most devices will have one or more bulk, interrupt or isochronous endpoints as well. The USB core will only communicate with the control endpoint to perform generic operations like reading the desriptors and assigning a device addresss.
Drivers are expected to understand which endpoints they need to communicate with to provide the device specific functionality.
Devices are considered dynamic by the USB core and can be connected or disconnected at any time. The hub driver is responsible for attaching and detaching devices in response to hub status change events and for binding or unbinding drivers as devices are added or removed.
USB Host
USB hosts implement the hardware level interface that supports sending USB requests to the hardware and receiving responses. All handling of interrupts, DMA, transaction sequence, errors and resubmitting/retrying requests is done by the USB host driver. All host drivers must implement the functions defined in TUSBHost (Start, Stop, Reset, Submit and Cancel) and must register themselves with the USB core by calling USBHostRegister. When the USB core is started each registered host driver will be called via the Start function so it can initialize itself and allocate locks, buffers and other resources required to interact with the hardware.
A host driver can also be registered after the USB core has been started and it will be given the opportunity to start itself immediately. In this way USB hosts can potentially be hot pluggable.
Each host driver must also implement a root hub which respresents the port or ports that are directly connected to the controller hardware. In many cases this will not be a real hub but will be simulated in the host driver so that the hub driver can interact with it as though it was a standard hub device.
Constants
To be documented
Type definitions
To be documented
Public variables
To be documented
Function declarations
Initialization functions
procedure USBInit;
Note | None documented |
---|
function USBStart:LongWord;
Note | None documented |
---|
function USBStop:LongWord;
Note | None documented |
---|
procedure USBAsyncStart(Host:PUSBHost);
Note | None documented |
---|
USB device, driver and host functions
function USBDeviceGetAddress(Device:PUSBDevice):Byte;
Device | The USB device to get the address for |
---|---|
Return | Device address or 0 on failure |
function USBDeviceSetAddress(Device:PUSBDevice; Address:Byte):LongWord;
Device | The USB device to set the address for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceGetDescriptor(Device:PUSBDevice; bRequest,bmRequestType:Byte; wValue,wIndex:Word; Data:Pointer; Length:Word):LongWord;
Device | The USB device to read the descriptor ?rom |
---|---|
bRequest | See USBControlRequest |
bmRequestType | See USBControlRequest |
wValue | See USBControlRequest |
wIndex | See USBControlRequest |
Data | See USBControlRequest |
Length | See USBControlRequest |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceGetDeviceDescriptor(Device:PUSBDevice; Data:Pointer; Length:Word):LongWord;
Device | The USB device to read the device descriptor ?rom |
---|---|
Data | See USBControlRequest |
Length | See USBControlRequest |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceCreateDeviceDescriptor(Device:PUSBDevice; Length:Word):LongWord;
Device | The USB device to create the device descriptor for |
---|---|
Length | The length of the descriptor to create |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceReadDeviceDescriptor(Device:PUSBDevice; Length:Word):LongWord; inline;
Device | The USB device to read the device descriptor ?rom |
---|---|
Length | The amount of the descriptor to read which may be less than the full size |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceReadDeviceDescriptorEx(Device:PUSBDevice; Length:Word; AllowShort:Boolean):LongWord;
Device | The USB device to read the device descriptor ?rom |
---|---|
Length | The amount of the descriptor to read which may be less than the full size |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceCreateConfigurations(Device:PUSBDevice):LongWord;
Device | The USB device to create the configurations for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceReadConfigurations(Device:PUSBDevice):LongWord;
Device | The USB device to read the configurations for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceCreateConfiguration(Device:PUSBDevice; Index:Byte; Size:Word):LongWord;
Device | The USB device to create the configuration for |
---|---|
Index | The index of the configuration to create |
Size | The size of the configuration descriptor to create |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceReadConfiguration(Device:PUSBDevice; Index:Byte):LongWord;
Device | The USB device to read the configuration for |
---|---|
Index | The index of the configuration to read |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceGetStringDescriptor(Device:PUSBDevice; Index:Byte; Data:Pointer; Length:Word):LongWord;
Device | The USB device to read the string descriptor ?rom |
---|---|
Index | The index of the string descriptor to read |
Data | See USBControlRequest |
Length | See USBControlRequest |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceReadStringDescriptor(Device:PUSBDevice; Index:Byte):String;
Note | None documented |
---|
function USBDeviceReadStringDescriptorW(Device:PUSBDevice; Index:Byte):UnicodeString;
Note | None documented |
---|
function USBDeviceGetConfigurationDescriptor(Device:PUSBDevice; Index:Byte;Data:Pointer; Length:Word):LongWord;
Device | The USB device to read the configuration descriptor ?rom |
---|---|
Index | The index of the configuration descriptor to read |
Data | See USBControlRequest |
Length | See USBControlRequest |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceGetConfiguration(Device:PUSBDevice; var ConfigurationValue:Byte):LongWord;
Device | The USB device to get the current configuration for |
---|---|
ConfigurationValue | The current configuration (As per bConfigurationValue in the configuration descriptor) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceSetConfiguration(Device:PUSBDevice; ConfigurationValue:Byte):LongWord;
Device | The USB device to set the configuration for |
---|---|
ConfigurationValue | The configuration to set (As per bConfigurationValue in the configuration descriptor) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceFindConfigurationByValue(Device:PUSBDevice; ConfigurationValue:Byte):PUSBConfiguration;
Device | The USB device to find the configuration for |
---|---|
ConfigurationValue | The configuration value to find (As per bConfigurationValue in the configuration descriptor) |
Return | USB Configuration if completed or nil on failure |
function USBDeviceGetInterface(Device:PUSBDevice; Index:Byte; var AlternateSetting:Byte):LongWord;
Device | The USB device to get the interface alternate setting for |
---|---|
Index | The index of the interface to get (As per bInterfaceNumber in the interface descriptor) |
AlternateSetting | The current alternate setting of the specified interface (As per bAlternateSetting in the interface descriptor) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceFindInterfaceByIndex(Device:PUSBDevice; Index:Byte):PUSBInterface;
Device | The USB device to find the interface ?rom |
---|---|
Index | The index of the interface to find (As per bInterfaceNumber in the interface descriptor) |
Return | The interface for the matching interface of nil if no interface matched |
function USBDeviceFindInterfaceByClass(Device:PUSBDevice; InterfaceClass,InterfaceSubClass,InterfaceProtocol:Byte):PUSBInterface;
Device | The USB device to find the interface ?rom |
---|---|
InterrfaceClass | The interface class to match |
InterfaceSubClass | The interface subclass to match |
InterfaceProtocol | The interface protocol to match |
Return | The interface for the matching interface of nil if no interface matched |
function USBDeviceFindEndpointByIndex(Device:PUSBDevice; Interrface:PUSBInterface; Index:Byte):PUSBEndpointDescriptor;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Index | The index of the endpoint to find (First endpoint is zero) |
Return | The endpoint for the matching endpoint of nil if no endpoint matched |
function USBDeviceFindEndpointByType(Device:PUSBDevice; Interrface:PUSBInterface; Direction,TransferType:Byte):PUSBEndpointDescriptor;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Direction | The direction of the endpoint to find (eg USB_DIRECTION_OUT) |
TransferType | The transfer type of the endpoint to find (eg USB_TRANSFER_TYPE_BULK) |
Return | The endpoint for the matching endpoint of nil if no endpoint matched |
function USBDeviceFindEndpointByTypeEx(Device:PUSBDevice; Interrface:PUSBInterface; Direction,TransferType:Byte; var Index:Byte):PUSBEndpointDescriptor;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Direction | The direction of the endpoint to find (eg USB_DIRECTION_OUT) |
TransferType | The transfer type of the endpoint to find (eg USB_TRANSFER_TYPE_BULK) |
Index | The index returned ?rom the last call, pass 0 on the first call |
Return | The endpoint for the matching endpoint of nil if no endpoint matched |
function USBDeviceCountEndpointsByType(Device:PUSBDevice; Interrface:PUSBInterface; Direction,TransferType:Byte):Byte;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Direction | The direction of the endpoint to find (eg USB_DIRECTION_OUT) |
TransferType | The transfer type of the endpoint to find (eg USB_TRANSFER_TYPE_BULK) |
Return | The number of matching endpoints on the specified interface |
function USBDeviceFindAlternateByIndex(Device:PUSBDevice; Interrface:PUSBInterface; Index:Byte):PUSBAlternate;
Device | The USB device to find the alternate setting ?rom |
---|---|
Interrface | The interface to find the alternate setting ?rom |
Index | The index of the alternate setting to find (First alternate setting is zero) |
Return | The alternate setting for the matching alternate setting of nil if no alternate setting matched |
function USBDeviceFindAlternateEndpointByIndex(Device:PUSBDevice; Interrface:PUSBInterface; Alternate:PUSBAlternate; Index:Byte):PUSBEndpointDescriptor;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Alternate | The alternate setting to find the endpoint ?rom |
Index | The index of the endpoint to find (First endpoint is zero) |
Return | The endpoint for the matching endpoint of nil if no endpoint matched |
function USBDeviceFindAlternateEndpointByType(Device:PUSBDevice; Interrface:PUSBInterface; Alternate:PUSBAlternate; Direction,TransferType:Byte):PUSBEndpointDescriptor;
Device | The USB device to find the endpoint ?rom |
---|---|
Interrface | The interface to find the endpoint ?rom |
Alternate | The alternate setting to find the endpoint ?rom |
Direction | The direction of the endpoint to find (eg USB_DIRECTION_OUT) |
TransferType | The transfer type of the endpoint to find (eg USB_TRANSFER_TYPE_BULK) |
Return | The endpoint for the matching endpoint of nil if no endpoint matched |
function USBDeviceSetInterface(Device:PUSBDevice; Index,AlternateSetting:Byte):LongWord;
Device | The USB device to set the interface alternate setting for |
---|---|
Index | The index of the interface to set (As per bInterfaceNumber in the interface descriptor) |
AlternateSetting | The alternate setting to set on the specified interface (As per bAlternateSetting in the interface descriptor) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceSetFeature(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Feature,Index:Word):LongWord;
Device | The USB device to enable the feature for |
---|---|
Endpoint | The endpoint to enable the feature on |
Feature | The feature to enable |
Index | To be documented |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceClearFeature(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Feature:Word):LongWord;
Device | The USB device to disable the feature for |
---|---|
Endpoint | The endpoint to disable the feature on |
Feature | The feature to disable |
Index | To be documented |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceSetState(Device:PUSBDevice; State:LongWord):LongWord;
Device | The USB device to set the state for |
---|---|
Status | The new state to set and notify |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceSetStatus(Device:PUSBDevice; Status:LongWord):LongWord;
Device | The USB device to set the status for |
---|---|
Status | The new status to set and notify |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceBind(Device:PUSBDevice):LongWord;
Device | The device to attempt to bind a driver to |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceUnbind(Device:PUSBDevice; Driver:PUSBDriver):LongWord;
Device | The device to unbind a driver ?rom |
---|---|
Driver | The driver to unbind the device ?rom (nil to unbind ?rom current driver) |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceAttach(Device:PUSBDevice):LongWord;
Device | New USB device to configure and initialize |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceDetach(Device:PUSBDevice):LongWord;
Device | The USB device to shutdown and detach |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBDeviceAllocate(Host:PUSBHost; Parent:PUSBDevice):PUSBDevice;
Host | The Host this device is attached to |
---|---|
Parent | The Parent device (Hub) this device is attached to (nil if this device is a root hub) |
Return | Pointer to new Device entry or nil if device could not be created |
function USBDeviceRelease(Device:PUSBDevice):LongWord;
Device | The device to deregister and destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function USBDeviceFind(USBId:LongWord):PUSBDevice;
Note | None documented |
---|
function USBDeviceFindByName(const Name:String):PUSBDevice; inline;
Note | None documented |
---|
function USBDeviceFindByDescription(const Description:String):PUSBDevice; inline;
Note | None documented |
---|
function USBDeviceEnumerate(Callback:TUSBDeviceEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function USBDeviceNotification(Device:PUSBDevice; Callback:TUSBDeviceNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | None documented |
---|
function USBDriverCreate:PUSBDriver;
Return | Pointer to new Driver entry or nil if driver could not be created |
---|
function USBDriverCreateEx(Size:LongWord):PUSBDriver;
Size | Size in bytes to allocate for new driver (Including the driver entry) |
---|---|
Return | Pointer to new Driver entry or nil if driver could not be created |
function USBDriverDestroy(Driver:PUSBDriver):LongWord;
Note | None documented |
---|
function USBDriverRegister(Driver:PUSBDriver):LongWord;
Note | None documented |
---|
function USBDriverFind(DriverId:LongWord):PUSBDriver;
Note | None documented |
---|
function USBDriverFindByName(const Name:String):PUSBDriver; inline;
Note | None documented |
---|
function USBDriverEnumerate(Callback:TUSBDriverEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function USBHostSetState(Host:PUSBHost; State:LongWord):LongWord;
Host | The USB host to set the state for |
---|---|
State | The new state to set and notify |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBHostCreate:PUSBHost;
Return | Pointer to new Host entry or nil if host could not be created |
---|
function USBHostCreateEx(Size:LongWord):PUSBHost;
Size | Size in bytes to allocate for new host (Including the host entry) |
---|---|
Return | Pointer to new Host entry or nil if host could not be created |
function USBHostDestroy(Host:PUSBHost):LongWord;
Note | None documented |
---|
function USBHostRegister(Host:PUSBHost):LongWord;
Note | None documented |
---|
function USBHostFind(HostId:LongWord):PUSBHost;
Note | None documented |
---|
function USBHostFindByName(const Name:String):PUSBHost; inline;
Note | None documented |
---|
function USBHostFindByDescription(const Description:String):PUSBHost; inline;
Note | None documented |
---|
function USBHostEnumerate(Callback:TUSBHostEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function USBHostNotification(Host:PUSBHost; Callback:TUSBHostNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | None documented |
---|
function USBBufferAllocate(Device:PUSBDevice; Size:LongWord):Pointer; inline;
Device | The device that the request will be sent to |
---|---|
Size | The size of the data buffer to allocate |
Return | The newly allocated buffer or nil on failure |
function USBBufferAllocateEx(Device:PUSBDevice; Size:LongWord; var Flags:LongWord):Pointer;
Device | The device that the request will be sent to |
---|---|
Size | The size of the data buffer to allocate |
Flags | The returned flags for the allocated buffer (eg USB_REQUEST_FLAG_SHARED) |
Return | The newly allocated buffer or nil on failure |
function USBBufferValidate(Device:PUSBDevice; Buffer:Pointer; Size:LongWord; var Flags:LongWord):LongWord;
Device | The device that the request will be sent to |
---|---|
Buffer | The data buffer to validate |
Size | The size of the data buffer |
Flags | The returned flags for the validated buffer (eg USB_REQUEST_FLAG_SHARED) |
Return | USB_STATUS_SUCCESS on success or another error code on failure |
function USBRequestAllocate(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Callback:TUSBRequestCompleted; Size:LongWord; DriverData:Pointer):PUSBRequest; inline;
Device | The USB device this request will be sent to |
---|---|
Endpoint | The Endpoint descriptor this request will be sent to (Or nil for the default control endpoint) |
Callback | The callback function to be called on completion of the request |
Size | The size of the data buffer for the request |
DriverData | Device driver private data for the callback (Optional) |
Return | The newly allocated request or nil on failure |
function USBRequestAllocateEx(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Callback:TUSBRequestCompleted; var Data:Pointer; Size:LongWord; DriverData:Pointer):PUSBRequest;
Device | The USB device this request will be sent to |
---|---|
Endpoint | The Endpoint descriptor this request will be sent to (Or nil for the default control endpoint) |
Callback | The callback function to be called on completion of the request |
Data | The returned data buffer allocated for the request (Or nil if size is zero)(Pass an existing buffer to prevent allocation) |
Size | The size of the data buffer for the request |
DriverData | Device driver private data for the callback (Optional) |
Return | The newly allocated request or nil on failure |
function USBRequestRelease(Request:PUSBRequest):LongWord;
Request | The request to be released |
---|---|
Return | USB_STATUS_SUCCESS on success or another error code on failure |
function USBRequestInitialize(Request:PUSBRequest; Callback:TUSBRequestCompleted; Data:Pointer; Size:LongWord; DriverData:Pointer):LongWord;
Request | The request to be initialized |
---|---|
Callback | The callback function to be called on completion of the request |
Data | The returned data buffer allocated for the request (Or nil if size is zero) |
Size | The size of the data buffer for the request |
DriverData | Device driver private data for the callback (Optional) |
Return | USB_STATUS_SUCCESS on success or another error code on failure |
function USBRequestSubmit(Request:PUSBRequest):LongWord;
Request | The request to be submitted |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | The request will be completed asynchronously by the host controller and the completion callback will be called when the request has either succeeded or failed |
function USBRequestCancel(Request:PUSBRequest):LongWord;
Request | The request to be cancelled |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
procedure USBRequestComplete(Request:PUSBRequest);
Request | The USB request which has completed |
---|
USB hub functions
function USBHubCreatePorts(Hub:PUSBHub):LongWord;
Hub | The hub to initialize ports for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBHubPowerOnPorts(Hub:PUSBHub):LongWord;
Hub | The hub to power on ports for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
function USBHubCreateHubDescriptor(Hub:PUSBHub):LongWord;
Hub | The hub to create the descriptor for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | The class specific hub descriptor is not the same as the device descriptor |
function USBHubReadHubDescriptor(Hub:PUSBHub):LongWord;
Hub | The hub to read the descriptor for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | The class specific hub descriptor is not the same as the device descriptor |
function USBHubLock(Hub:PUSBHub):LongWord;
Hub | The hub to lock |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function USBHubUnlock(Hub:PUSBHub):LongWord;
Hub | The hub to unlock |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function USBHubSetState(Hub:PUSBHub; State:LongWord):LongWord;
Hub | The hub to set the state for |
---|---|
State | The new state to set and notify |
Return | ERROR_SUCCESS if completed or another error code on failure |
function USBHubAllocate(Device:PUSBDevice):PUSBHub;
Device | The USB device that represents this hub |
---|---|
Return | Pointer to new Hub entry or nil if hub could not be created |
function USBHubRelease(Hub:PUSBHub):LongWord;
Hub | The hub to deregister and destroy |
---|---|
Return | ERROR_SUCCESS if completed or another error code on failure |
function USBHubFind(HubId:LongWord):PUSBHub;
Note | None documented |
---|
function USBHubFindByName(const Name:String):PUSBHub; inline;
Note | None documented |
---|
function USBHubFindByDescription(const Description:String):PUSBHub; inline;
Note | None documented |
---|
function USBHubEnumerate(Callback:TUSBHubEnumerate; Data:Pointer):LongWord;
Note | None documented |
---|
function USBHubNotification(Hub:PUSBHub; Callback:TUSBHubNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Note | None documented |
---|
procedure USBHubBindDevices(Device:PUSBDevice; Callback:TUSBDeviceBind);
Device | USB device at which to start the enueration |
---|---|
Callback | Bind callback function to execute for each device |
procedure USBHubUnbindDevices(Device:PUSBDevice; Driver:PUSBDriver; Callback:TUSBDeviceUnbind);
Device | USB device at which to start the enumeration |
---|---|
Callback | Unbind callback function to execute for each device |
procedure USBHubEnumerateDevices(Device:PUSBDevice; Callback:TUSBDeviceEnumerate; Data:Pointer);
Device | USB device at which to start the enumeration |
---|---|
Callback | Enumerate callback function to execute for each device |
function USBHubPortReset(Port:PUSBPort):LongWord;
Port | USB port to reset |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock |
function USBHubPortGetStatus(Port:PUSBPort):LongWord;
Port | USB port to read status for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock |
function USBHubPortSetFeature(Port:PUSBPort; Feature:Word):LongWord;
Port | USB port to enable the feature on |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock |
function USBHubPortClearFeature(Port:PUSBPort; Feature:Word):LongWord;
Port | USB port to disable the feature on |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock |
function USBHubPortChangeFeature(Port:PUSBPort; Feature:Word; Enable:Boolean):LongWord;
Port | USB port to enable or disable the feature on |
---|---|
Feature | The feature to enable or disable |
Enable | True to enable the feature or False to disable the feature |
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock |
function USBHubPortAttachDevice(Port:PUSBPort):LongWord;
Port | USB port to attach the new device to |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock. Only called in response to a status change on the hub. |
function USBHubPortStatusChanged(Port:PUSBPort):LongWord;
Port | USB port to process the status change for |
---|---|
Return | USB_STATUS_SUCCESS if completed or another error code on failure |
Note | Caller must hold the hub lock. Only called in response to a status change on the hub. |
function USBHubExecute(Parameter:Pointer):PtrInt;
Note | One status change request exists for each hub currently connected and is created and submitted by the hub driver when it binds to a new hub device. When a hub is disconnected the hub driver will remove the request when the hub is detached and destroyed. |
---|
function USBHubDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Device | The USB device to attempt to bind to |
---|---|
Interrface | The USB interface to attempt to bind to (or nil for whole device) |
Return | USB_STATUS_SUCCESS if completed, USB_STATUS_DEVICE_UNSUPPORTED if unsupported or another error code on failure |
USB device, driver and host helper functions
function USBDeviceGetCount:LongWord; inline;
Note | None documented |
---|
function USBDeviceCheck(Device:PUSBDevice):PUSBDevice;
Note | None documented |
---|
function USBDriverGetCount:LongWord; inline;
Note | None documented |
---|
function USBDriverCheck(Driver:PUSBDriver):PUSBDriver;
Note | None documented |
---|
function USBHostGetCount:LongWord; inline;
Note | None documented |
---|
function USBHostCheck(Host:PUSBHost):PUSBHost;
Note | None documented |
---|
function USBIsHub(Device:PUSBDevice):Boolean;
Note | None documented |
---|
function USBIsRootHub(Device:PUSBDevice):Boolean;
Note | None documented |
---|
function USBIsControlRequest(Request:PUSBRequest):Boolean;
Note | None documented |
---|
function USBIsBulkRequest(Request:PUSBRequest):Boolean;
Note | None documented |
---|
function USBIsInterruptRequest(Request:PUSBRequest):Boolean;
Note | None documented |
---|
function USBIsIsochronousRequest(Request:PUSBRequest):Boolean;
Note | None documented |
---|
function USBIsInEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Note | None documented |
---|
function USBIsOutEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Note | None documented |
---|
function USBIsBulkEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Note | None documented |
---|
function USBIsInterruptEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Note | None documented |
---|
function USBIsIsochronousEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Note | None documented |
---|
function USBDeviceToString(Device:PUSBDevice):String;
Device | USB device to get a description of |
---|---|
Return | A string describing the device |
function USBStatusToString(Status:LongWord):String;
Note | None documented |
---|
function USBClassCodeToString(ClassCode:Integer):String;
Note | None documented |
---|
function USBSubClassCodeToString(ClassCode,SubClassCode:Integer):String;
Note | None documented |
---|
function USBProtocolCodeToString(ClassCode,ProtocolCode:Integer):String;
Note | None documented |
---|
function USBSpeedToString(Speed:Integer):String;
Note | None documented |
---|
function USBTransferTypeToString(TransferType:Integer):String;
Note | None documented |
---|
function USBDirectionToString(Direction:Integer):String;
Note | None documented |
---|
function USBPortStatusConnectedToString(Status:Word):String;
Note | None documented |
---|
function USBHubCharacteristicsToString(HubCharacteristics:Word):String;
Note | None documented |
---|
function USBDeviceTypeToString(USBType:LongWord):String;
Note | None documented |
---|
function USBDeviceStateToString(USBState:LongWord):String;
Note | None documented |
---|
function USBDeviceStatusToString(USBStatus:LongWord):String;
Note | None documented |
---|
function USBDeviceStateToNotification(State:LongWord):LongWord;
Note | None documented |
---|
function USBDeviceStatusToNotification(Status:LongWord):LongWord;
Note | None documented |
---|
function USBHostTypeToString(HostType:LongWord):String;
Note | None documented |
---|
function USBHostStateToString(HostState:LongWord):String;
Note | None documented |
---|
function USBHostStateToNotification(State:LongWord):LongWord;
Note | None documented |
---|
procedure USBLog(Level:LongWord; Device:PUSBDevice; const AText:String);
Note | None documented |
---|
procedure USBLogInfo(Device:PUSBDevice;const AText:String);
Note | None documented |
---|
procedure USBLogError(Device:PUSBDevice;const AText:String);
Note | None documented |
---|
procedure USBLogDebug(Device:PUSBDevice;const AText:String);
Note | None documented |
---|
procedure USBLogDeviceConfiguration(Device:PUSBDevice);
Note | None documented |
---|
procedure USBLogDeviceDescriptor(Device:PUSBDevice; Descriptor:PUSBDeviceDescriptor);
Note | None documented |
---|
procedure USBLogConfigurationDescriptor(Device:PUSBDevice; Descriptor:PUSBConfigurationDescriptor);
Note | None documented |
---|
procedure USBLogInterfaceDescriptor(Device:PUSBDevice; Descriptor:PUSBInterfaceDescriptor);
Note | None documented |
---|
procedure USBLogEndpointDescriptor(Device:PUSBDevice; Descriptor:PUSBEndpointDescriptor);
Note | None documented |
---|
function USBLogDevices:LongWord;
Return | ERROR_SUCCESS if completed or another error code on failure |
---|
function USBLogDeviceCallback(Device:PUSBDevice; Data:Pointer):LongWord;
Note | None documented |
---|
function USBLogTreeCallback(Device:PUSBDevice; Data:Pointer):LongWord;
Note | None documented |
---|
USB hub helper functions
function USBHubGetCount:LongWord; inline;
Note | None documented |
---|
function USBHubCheck(Hub:PUSBHub):PUSBHub;
Note | None documented |
---|
function USBHubStateToNotification(State:LongWord):LongWord;
Note | None documented |
---|