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
[Expand]
procedure USBInit;
Description: Performs basic initialization of the USB core driver, after this devices, hosts and drivers can be registered however nothing will work until USBStart is called
[Expand]
function USBStart:LongWord;
Description: Starts all registered USB hosts, starts the USB hub thread and begins the USB enumeration process. USB enumeration will continue after this function returns as devices are discovered by changes in hub status.
[Expand]
function USBStop:LongWord;
Description: To be documented
[Expand]
procedure USBAsyncStart(Host:PUSBHost);
Description: To be documented
USB device, driver and host functions
[Expand]
function USBDeviceGetAddress(Device:PUSBDevice):Byte;
Description: Get the bus address for the specified device
Device
|
The USB device to get the address for
|
Return
|
Device address or 0 on failure
|
[Expand]
function USBDeviceSetAddress(Device:PUSBDevice; Address:Byte):LongWord;
Description: Set the bus address for the specified device
Device
|
The USB device to set the address for
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceGetDescriptor(Device:PUSBDevice; bRequest,bmRequestType:Byte; wValue,wIndex:Word; Data:Pointer; Length:Word):LongWord;
Description: Read any descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceGetDeviceDescriptor(Device:PUSBDevice; Data:Pointer; Length:Word):LongWord;
Description: Read all or part of the device descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceCreateDeviceDescriptor(Device:PUSBDevice; Length:Word):LongWord;
Description: Allocate a device descriptor for the specified device
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
|
[Expand]
function USBDeviceReadDeviceDescriptor(Device:PUSBDevice; Length:Word):LongWord; inline;
Description: Read all or part of the device descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceReadDeviceDescriptorEx(Device:PUSBDevice; Length:Word; AllowShort:Boolean):LongWord;
Description: Read all or part of the device descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceCreateConfigurations(Device:PUSBDevice):LongWord;
Description: Allocate the available configurations for this device
Device
|
The USB device to create the configurations for
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceReadConfigurations(Device:PUSBDevice):LongWord;
Description: Read and parse the available configurations for this device
Device
|
The USB device to read the configurations for
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceCreateConfiguration(Device:PUSBDevice; Index:Byte; Size:Word):LongWord;
Description: Allocate the specified configuration for this device
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
|
[Expand]
function USBDeviceReadConfiguration(Device:PUSBDevice; Index:Byte):LongWord;
Description: Read and parse the specified configuration for this device
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
|
[Expand]
function USBDeviceGetStringDescriptor(Device:PUSBDevice; Index:Byte; Data:Pointer; Length:Word):LongWord;
Description: Read all or part of the specified string descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceReadStringDescriptor(Device:PUSBDevice; Index:Byte):String;
Description: To be documented
[Expand]
function USBDeviceReadStringDescriptorW(Device:PUSBDevice; Index:Byte):UnicodeString;
Description: To be documented
[Expand]
function USBDeviceGetConfigurationDescriptor(Device:PUSBDevice; Index:Byte;Data:Pointer; Length:Word):LongWord;
Description: Read all or part of the specified configuration descriptor ?rom the specified device using USBControlRequest
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
|
[Expand]
function USBDeviceGetConfiguration(Device:PUSBDevice; var ConfigurationValue:Byte):LongWord;
Description: Get the current configuration for the specified device
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
|
[Expand]
function USBDeviceSetConfiguration(Device:PUSBDevice; ConfigurationValue:Byte):LongWord;
Description: Set the configuration for the specified device
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
|
[Expand]
function USBDeviceFindConfigurationByValue(Device:PUSBDevice; ConfigurationValue:Byte):PUSBConfiguration;
Description: Find the configuration represented by configuration value for the specified device
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
|
[Expand]
function USBDeviceGetInterface(Device:PUSBDevice; Index:Byte; var AlternateSetting:Byte):LongWord;
Description: Get the interface alternate setting for the specified device
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
|
[Expand]
function USBDeviceFindInterfaceByIndex(Device:PUSBDevice; Index:Byte):PUSBInterface;
Description: Find the interface with the specified index on the specified device
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
|
[Expand]
function USBDeviceFindInterfaceByClass(Device:PUSBDevice; InterfaceClass,InterfaceSubClass,InterfaceProtocol:Byte):PUSBInterface;
Description: Find an interface of the specified class, subclass and protocol on the specified device
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
|
[Expand]
function USBDeviceFindEndpointByIndex(Device:PUSBDevice; Interrface:PUSBInterface; Index:Byte):PUSBEndpointDescriptor;
Description: Find the endpoint with the specified index on the specified interface of the specified device
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
|
[Expand]
function USBDeviceFindEndpointByType(Device:PUSBDevice; Interrface:PUSBInterface; Direction,TransferType:Byte):PUSBEndpointDescriptor;
Description: Find an endpoint of the specified type and direction on the specified interface of the specified device
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
|
[Expand]
function USBDeviceSetInterface(Device:PUSBDevice; Index,AlternateSetting:Byte):LongWord;
Description: Set the interface alternate setting for the specified device
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
|
[Expand]
function USBDeviceSetFeature(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Feature,Index:Word):LongWord;
Description: Enable a feature on the specified endpoint on the specified device
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
|
[Expand]
function USBDeviceClearFeature(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Feature:Word):LongWord;
Description: Disable a feature on the specified endpoint on the specified device
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
|
[Expand]
function USBDeviceSetState(Device:PUSBDevice; State:LongWord):LongWord;
Description: Set the state of the specified device and send a notification
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
|
[Expand]
function USBDeviceSetStatus(Device:PUSBDevice; Status:LongWord):LongWord;
Description: Set the status of the specified device and send a notification
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
|
[Expand]
function USBDeviceBind(Device:PUSBDevice):LongWord;
Description: Attempt to bind a device to one of the registers drivers
Device
|
The device to attempt to bind a driver to
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceAttach(Device:PUSBDevice):LongWord;
Description: Configure and initialize a newly attached USB device
Device
|
New USB device to configure and initialize
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceDetach(Device:PUSBDevice):LongWord;
Description: Shutdown and detach a USB device
Device
|
The USB device to shutdown and detach
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBDeviceAllocate(Host:PUSBHost; Parent:PUSBDevice):PUSBDevice;
Description: Create and Register a new Device entry in the Device table}
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
|
[Expand]
function USBDeviceFind(USBId:LongWord):PUSBDevice;
Description: To be documented
[Expand]
function USBDeviceFindByName(const Name:String):PUSBDevice; inline;
Description: To be documented
[Expand]
function USBDeviceFindByDescription(const Description:String):PUSBDevice; inline;
Description: To be documented
[Expand]
function USBDeviceEnumerate(Callback:TUSBDeviceEnumerate; Data:Pointer):LongWord;
Description: To be documented
[Expand]
function USBDeviceNotification(Device:PUSBDevice; Callback:TUSBDeviceNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
[Expand]
function USBDriverCreate:PUSBDriver;
Description: Create a new Driver entry
Return
|
Pointer to new Driver entry or nil if driver could not be created
|
[Expand]
function USBDriverCreateEx(Size:LongWord):PUSBDriver;
Description: Create a new Driver entry}
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
|
[Expand]
function USBDriverDestroy(Driver:PUSBDriver):LongWord;
Description: Destroy an existing Driver entry
[Expand]
function USBDriverRegister(Driver:PUSBDriver):LongWord;
Description: Register a new Driver in the Driver table
[Expand]
function USBDriverFind(DriverId:LongWord):PUSBDriver;
Description: To be documented
[Expand]
function USBDriverFindByName(const Name:String):PUSBDriver; inline;
Description: To be documented
[Expand]
function USBDriverEnumerate(Callback:TUSBDriverEnumerate; Data:Pointer):LongWord;
Description: To be documented
[Expand]
function USBHostSetState(Host:PUSBHost; State:LongWord):LongWord;
Description: Set the state of the specified host and send a notification}
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
|
[Expand]
function USBHostCreate:PUSBHost;
Description: Create a new Host entry
Return
|
Pointer to new Host entry or nil if host could not be created
|
[Expand]
function USBHostCreateEx(Size:LongWord):PUSBHost;
Description: Create a new Host entry
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
|
[Expand]
function USBHostDestroy(Host:PUSBHost):LongWord;
Description: Destroy an existing Host entry
[Expand]
function USBHostRegister(Host:PUSBHost):LongWord;
Description: Register a new Host in the Host table
[Expand]
function USBHostFind(HostId:LongWord):PUSBHost;
Description: To be documented
[Expand]
function USBHostFindByName(const Name:String):PUSBHost; inline;
Description: To be documented
[Expand]
function USBHostFindByDescription(const Description:String):PUSBHost; inline;
Description: To be documented
[Expand]
function USBHostEnumerate(Callback:TUSBHostEnumerate; Data:Pointer):LongWord;
Description: To be documented
[Expand]
function USBHostNotification(Host:PUSBHost; Callback:TUSBHostNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
[Expand]
function USBBufferAllocate(Device:PUSBDevice; Size:LongWord):Pointer; inline;
Description: Allocate a data buffer for a USB request
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
|
[Expand]
function USBBufferAllocateEx(Device:PUSBDevice; Size:LongWord; var Flags:LongWord):Pointer;
Description: Allocate a data buffer for a USB request
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
|
[Expand]
function USBBufferValidate(Device:PUSBDevice; Buffer:Pointer; Size:LongWord; var Flags:LongWord):LongWord;
Description: Validate a data buffer for a USB request against the USB host requirements
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
|
[Expand]
function USBRequestAllocate(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Callback:TUSBRequestCompleted; Size:LongWord; DriverData:Pointer):PUSBRequest; inline;
Description: Allocate a new USB request
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
|
[Expand]
function USBRequestAllocateEx(Device:PUSBDevice; Endpoint:PUSBEndpointDescriptor; Callback:TUSBRequestCompleted; var Data:Pointer; Size:LongWord; DriverData:Pointer):PUSBRequest;
Description: Allocate a new USB request
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
|
[Expand]
function USBRequestRelease(Request:PUSBRequest):LongWord;
Description: Release and destroy a USB request
Request
|
The request to be released
|
Return
|
USB_STATUS_SUCCESS on success or another error code on failure
|
[Expand]
function USBRequestInitialize(Request:PUSBRequest; Callback:TUSBRequestCompleted; Data:Pointer; Size:LongWord; DriverData:Pointer):LongWord;
Description: Initialize or Reinitialize an existing USB request
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
|
[Expand]
function USBRequestSubmit(Request:PUSBRequest):LongWord;
Description: Submit a USB request to a host controller for execution
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
|
[Expand]
function USBRequestCancel(Request:PUSBRequest):LongWord;
Description: Cancel a USB request previously submitted to a host controller
Request
|
The request to be cancelled
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
procedure USBRequestComplete(Request:PUSBRequest);
Description: Called by a host controller when a USB request completes
Request
|
The USB request which has completed
|
USB hub functions
[Expand]
function USBHubCreatePorts(Hub:PUSBHub):LongWord;
Description: Create and initialize the ports for a Hub
Hub
|
The hub to initialize ports for
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBHubPowerOnPorts(Hub:PUSBHub):LongWord;
Description: Power on all ports on a Hub
Hub
|
The hub to power on ports for
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
[Expand]
function USBHubCreateHubDescriptor(Hub:PUSBHub):LongWord;
Description: Allocate the hub descriptor for the specified hub
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
|
[Expand]
function USBHubReadHubDescriptor(Hub:PUSBHub):LongWord;
Description: Read the hub descriptor for the specified hub
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
|
[Expand]
function USBHubLock(Hub:PUSBHub):LongWord;
Description: Lock the specified Hub to prevent changes
Hub
|
The hub to lock
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function USBHubUnlock(Hub:PUSBHub):LongWord;
Description: Unlock the specified Hub to allow changes
Hub
|
The hub to unlock
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function USBHubSetState(Hub:PUSBHub; State:LongWord):LongWord;
Description: Set the state of the specified hub and send a notification
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
|
[Expand]
function USBHubAllocate(Device:PUSBDevice):PUSBHub;
Description: Create and Register a new Hub device
Device
|
The USB device that represents this hub
|
Return
|
Pointer to new Hub entry or nil if hub could not be created
|
[Expand]
function USBHubRelease(Hub:PUSBHub):LongWord;
Description: Deregister and Destroy a Hub device
Hub
|
The hub to deregister and destroy
|
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function USBHubFind(HubId:LongWord):PUSBHub;
Description: To be documented
[Expand]
function USBHubFindByName(const Name:String):PUSBHub; inline;
Description: To be documented
[Expand]
function USBHubFindByDescription(const Description:String):PUSBHub; inline;
Description: To be documented
[Expand]
function USBHubEnumerate(Callback:TUSBHubEnumerate; Data:Pointer):LongWord;
Description: To be documented
[Expand]
function USBHubNotification(Hub:PUSBHub; Callback:TUSBHubNotification; Data:Pointer; Notification,Flags:LongWord):LongWord;
Description: To be documented
[Expand]
procedure USBHubBindDevices(Device:PUSBDevice; Callback:TUSBDeviceBind);
Description: Enumerate each device in the USB tree and call a bind callback for each one
Device
|
USB device at which to start the enueration
|
Callback
|
Bind callback function to execute for each device
|
[Expand]
procedure USBHubUnbindDevices(Device:PUSBDevice; Driver:PUSBDriver; Callback:TUSBDeviceUnbind);
Description: Enumerate each device in the USB tree and call an unbind callback for each one
Device
|
USB device at which to start the enumeration
|
Callback
|
Unbind callback function to execute for each device
|
[Expand]
procedure USBHubEnumerateDevices(Device:PUSBDevice; Callback:TUSBDeviceEnumerate; Data:Pointer);
Description: Enumerate each device in the USB tree and call an enumerate callback for each one
Device
|
USB device at which to start the enumeration
|
Callback
|
Enumerate callback function to execute for each device
|
[Expand]
function USBHubPortReset(Port:PUSBPort):LongWord;
Description: Reset a the specified USB port
Port
|
USB port to reset
|
Return
|
USB_STATUS_SUCCESS if completed or another error code on failure
|
Note
|
Caller must hold the hub lock
|
[Expand]
function USBHubPortGetStatus(Port:PUSBPort):LongWord;
Description: Read the status of the specified USB port
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
|
[Expand]
function USBHubPortSetFeature(Port:PUSBPort; Feature:Word):LongWord;
Description: Enable a feature on the specified USB port
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
|
[Expand]
function USBHubPortClearFeature(Port:PUSBPort; Feature:Word):LongWord;
Description: Disable a feature on the specified USB port
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
|
[Expand]
function USBHubPortChangeFeature(Port:PUSBPort; Feature:Word; Enable:Boolean):LongWord;
Description: Enable or disable a feature on the specified USB port
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
|
[Expand]
function USBHubPortAttachDevice(Port:PUSBPort):LongWord;
Description: Attach a newly connected USB device to the specified USB port
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.
|
[Expand]
function USBHubPortStatusChanged(Port:PUSBPort):LongWord;
Description: Process a status change for the specified USB port
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.
|
[Expand]
function USBHubExecute(Parameter:Pointer):PtrInt;
Description: The Hub thread procedure which is responsible for receiving completed hub status change requests, processing them for changes and then resubmitting the request
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.
|
[Expand]
function USBHubDriverBind(Device:PUSBDevice; Interrface:PUSBInterface):LongWord;
Description: Bind the Hub driver to a USB device if it is suitable}
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
[Expand]
function USBDeviceGetCount:LongWord; inline;
Description: Get the current device count
[Expand]
function USBDeviceCheck(Device:PUSBDevice):PUSBDevice;
Description: Check if the supplied Device is in the device table
[Expand]
function USBDriverGetCount:LongWord; inline;
Description: Get the current driver count
[Expand]
function USBDriverCheck(Driver:PUSBDriver):PUSBDriver;
Description: Check if the supplied Driver is in the driver table
[Expand]
function USBHostGetCount:LongWord; inline;
Description: Get the current host count
[Expand]
function USBHostCheck(Host:PUSBHost):PUSBHost;
Description: Check if the supplied Host is in the host table
[Expand]
function USBIsHub(Device:PUSBDevice):Boolean;
Description: Returns True if Device is a Hub or False if not
[Expand]
function USBIsRootHub(Device:PUSBDevice):Boolean;
Description: Returns True if Device is a Root Hub or False if not
[Expand]
function USBIsControlRequest(Request:PUSBRequest):Boolean;
Description: Returns True if Request is a control request or False if not
[Expand]
function USBIsBulkRequest(Request:PUSBRequest):Boolean;
Description: Returns True if Request is a bulk request or False if not
[Expand]
function USBIsInterruptRequest(Request:PUSBRequest):Boolean;
Description: Returns True if Request is an interrupt request or False if not
[Expand]
function USBIsIsochronousRequest(Request:PUSBRequest):Boolean;
Description: Returns True if Request is an isochronous request or False if not
[Expand]
function USBIsInEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Description: Returns True is Endpoint is an IN endpoint or False if not
[Expand]
function USBIsOutEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Description: Returns True is Endpoint is an OUT endpoint or False if not
[Expand]
function USBIsBulkEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Description: Returns True is Endpoint is a BULK endpoint or False if not
[Expand]
function USBIsInterruptEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Description: Returns True is Endpoint is a INTERRUPT endpoint or False if not
[Expand]
function USBIsIsochronousEndpoint(Endpoint:PUSBEndpointDescriptor):Boolean;
Description: Returns True is Endpoint is a ISOCHRONOUS endpoint or False if not
[Expand]
function USBDeviceToString(Device:PUSBDevice):String;
Description: Return a description of a USB device
Device
|
USB device to get a description of
|
Return
|
A string describing the device
|
[Expand]
function USBStatusToString(Status:LongWord):String;
Description: Translates a USB status code into a string
[Expand]
function USBClassCodeToString(ClassCode:Integer):String;
Description: Translates a USB class code into a string
[Expand]
function USBSubClassCodeToString(ClassCode,SubClassCode:Integer):String;
Description: Translates a USB sub class code into a string
[Expand]
function USBProtocolCodeToString(ClassCode,ProtocolCode:Integer):String;
Description: Translates a USB protocol code into a string
[Expand]
function USBSpeedToString(Speed:Integer):String;
Description: Translates a USB speed constant into a string
[Expand]
function USBTransferTypeToString(TransferType:Integer):String;
Description: Translates a USB transfer type constant into a string
[Expand]
function USBDirectionToString(Direction:Integer):String;
Description: Translates a USB direction constant into a string
[Expand]
function USBPortStatusConnectedToString(Status:Word):String;
Description: To be documented
[Expand]
function USBHubCharacteristicsToString(HubCharacteristics:Word):String;
Description: To be documented
[Expand]
function USBDeviceTypeToString(USBType:LongWord):String;
Description: To be documented
[Expand]
function USBDeviceStateToString(USBState:LongWord):String;
Description: To be documented
[Expand]
function USBDeviceStatusToString(USBStatus:LongWord):String;
Description: To be documented
[Expand]
function USBDeviceStateToNotification(State:LongWord):LongWord;
Description: Convert a Device state value into the notification code for device notifications
[Expand]
function USBDeviceStatusToNotification(Status:LongWord):LongWord;
Description: Convert a Device status value into the notification code for device notifications
[Expand]
function USBHostTypeToString(HostType:LongWord):String;
Description: To be documented
[Expand]
function USBHostStateToString(HostState:LongWord):String;
Description: To be documented
[Expand]
function USBHostStateToNotification(State:LongWord):LongWord;
Description: Convert a Host state value into the notification code for device notifications
[Expand]
procedure USBLog(Level:LongWord; Device:PUSBDevice; const AText:String);
Description: To be documented
[Expand]
procedure USBLogInfo(Device:PUSBDevice;const AText:String);
Description: To be documented
[Expand]
procedure USBLogError(Device:PUSBDevice;const AText:String);
Description: To be documented
[Expand]
procedure USBLogDebug(Device:PUSBDevice;const AText:String);
Description: To be documented
[Expand]
procedure USBLogDeviceConfiguration(Device:PUSBDevice);
Description: To be documented
[Expand]
procedure USBLogDeviceDescriptor(Device:PUSBDevice; Descriptor:PUSBDeviceDescriptor);
Description: To be documented
[Expand]
procedure USBLogConfigurationDescriptor(Device:PUSBDevice; Descriptor:PUSBConfigurationDescriptor);
Description: To be documented
[Expand]
procedure USBLogInterfaceDescriptor(Device:PUSBDevice; Descriptor:PUSBInterfaceDescriptor);
Description: To be documented
[Expand]
procedure USBLogEndpointDescriptor(Device:PUSBDevice; Descriptor:PUSBEndpointDescriptor);
Description: To be documented
[Expand]
function USBLogDevices:LongWord;
Description: Print information about all devices attached to the USB
Return
|
ERROR_SUCCESS if completed or another error code on failure
|
[Expand]
function USBLogDeviceCallback(Device:PUSBDevice; Data:Pointer):LongWord;
Description: To be documented
[Expand]
function USBLogTreeCallback(Device:PUSBDevice; Data:Pointer):LongWord;
Description: To be documented
USB hub helper functions
[Expand]
function USBHubGetCount:LongWord; inline;
Description: Get the current hub count
[Expand]
function USBHubCheck(Hub:PUSBHub):PUSBHub;
Description: Check if the supplied Hub is in the hub table
[Expand]
function USBHubStateToNotification(State:LongWord):LongWord;
Description: Convert a Hub state value into the notification code for device notifications
Return to Unit Reference