TianoCore EDK2 master
Loading...
Searching...
No Matches
UsbBus.c File Reference
#include "UsbBus.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI UsbIoControlTransfer (IN EFI_USB_IO_PROTOCOL *This, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN UINT32 Timeout, IN OUT VOID *Data OPTIONAL, IN UINTN DataLength OPTIONAL, OUT UINT32 *UsbStatus)
 
EFI_STATUS EFIAPI UsbIoBulkTransfer (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
 
EFI_STATUS EFIAPI UsbIoSyncInterruptTransfer (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
 
EFI_STATUS EFIAPI UsbIoAsyncInterruptTransfer (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN BOOLEAN IsNewTransfer, IN UINTN PollInterval OPTIONAL, IN UINTN DataLength OPTIONAL, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback OPTIONAL, IN VOID *Context OPTIONAL)
 
EFI_STATUS EFIAPI UsbIoIsochronousTransfer (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, OUT UINT32 *Status)
 
EFI_STATUS EFIAPI UsbIoAsyncIsochronousTransfer (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, IN VOID *Context OPTIONAL)
 
EFI_STATUS EFIAPI UsbIoGetDeviceDescriptor (IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor)
 
EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor (IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor)
 
EFI_STATUS EFIAPI UsbIoGetInterfaceDescriptor (IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_INTERFACE_DESCRIPTOR *Descriptor)
 
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor (IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
 
EFI_STATUS EFIAPI UsbIoGetSupportedLanguages (IN EFI_USB_IO_PROTOCOL *This, OUT UINT16 **LangIDTable, OUT UINT16 *TableSize)
 
EFI_STATUS EFIAPI UsbIoGetStringDescriptor (IN EFI_USB_IO_PROTOCOL *This, IN UINT16 LangID, IN UINT8 StringIndex, OUT CHAR16 **String)
 
EFI_STATUS EFIAPI UsbIoPortReset (IN EFI_USB_IO_PROTOCOL *This)
 
EFI_STATUS EFIAPI UsbBusBuildProtocol (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI UsbBusDriverEntryPoint (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
EFI_STATUS EFIAPI UsbBusControllerDriverSupported (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI UsbBusControllerDriverStart (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
EFI_STATUS EFIAPI UsbBusControllerDriverStop (IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
 

Variables

EFI_USB_IO_PROTOCOL mUsbIoProtocol
 
EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding
 

Detailed Description

Usb Bus Driver Binding and Bus IO Protocol.

Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
Copyright (C) 2024 Advanced Micro Devices, Inc. All rights reserved. SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbBus.c.

Function Documentation

◆ UsbBusBuildProtocol()

EFI_STATUS EFIAPI UsbBusBuildProtocol ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Install Usb Bus Protocol on host controller, and start the Usb bus.

Parameters
ThisThe USB bus driver binding instance.
ControllerThe controller to check.
RemainingDevicePathThe remaining device patch.
Return values
EFI_SUCCESSThe controller is controlled by the usb bus.
EFI_ALREADY_STARTEDThe controller is already controlled by the usb bus.
EFI_OUT_OF_RESOURCESFailed to allocate resources.

Definition at line 941 of file UsbBus.c.

◆ UsbBusControllerDriverStart()

EFI_STATUS EFIAPI UsbBusControllerDriverStart ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Start to process the controller.

Parameters
ThisThe USB bus driver binding instance.
ControllerThe controller to check.
RemainingDevicePathThe remaining device patch.
Return values
EFI_SUCCESSThe controller is controlled by the usb bus.
EFI_ALREADY_STARTEDThe controller is already controlled by the usb bus.
EFI_OUT_OF_RESOURCESFailed to allocate resources.

Definition at line 1315 of file UsbBus.c.

◆ UsbBusControllerDriverStop()

EFI_STATUS EFIAPI UsbBusControllerDriverStop ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN UINTN  NumberOfChildren,
IN EFI_HANDLE ChildHandleBuffer 
)

Stop handle the controller by this USB bus driver.

Parameters
ThisThe USB bus driver binding protocol.
ControllerThe controller to release.
NumberOfChildrenThe child of USB bus that opened controller BY_CHILD.
ChildHandleBufferThe array of child handle.
Return values
EFI_SUCCESSThe controller or children are stopped.
EFI_DEVICE_ERRORFailed to stop the driver.

Definition at line 1426 of file UsbBus.c.

◆ UsbBusControllerDriverSupported()

EFI_STATUS EFIAPI UsbBusControllerDriverSupported ( IN EFI_DRIVER_BINDING_PROTOCOL This,
IN EFI_HANDLE  Controller,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Check whether USB bus driver support this device.

Parameters
ThisThe USB bus driver binding protocol.
ControllerThe controller handle to check.
RemainingDevicePathThe remaining device path.
Return values
EFI_SUCCESSThe bus supports this controller.
EFI_UNSUPPORTEDThis device isn't supported.

Definition at line 1174 of file UsbBus.c.

◆ UsbBusDriverEntryPoint()

EFI_STATUS EFIAPI UsbBusDriverEntryPoint ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The USB bus driver entry pointer.

Parameters
ImageHandleThe driver image handle.
SystemTableThe system table.
Returns
EFI_SUCCESS The component name protocol is installed.
Others Failed to init the usb driver.

Definition at line 1146 of file UsbBus.c.

◆ UsbIoAsyncInterruptTransfer()

EFI_STATUS EFIAPI UsbIoAsyncInterruptTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  Endpoint,
IN BOOLEAN  IsNewTransfer,
IN UINTN PollInterval  OPTIONAL,
IN UINTN DataLength  OPTIONAL,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback  OPTIONAL,
IN VOID *Context  OPTIONAL 
)

Queue a new asynchronous interrupt transfer, or remove the old request if (IsNewTransfer == FALSE).

Parameters
ThisThe USB_IO instance.
EndpointThe device endpoint.
IsNewTransferWhether this is a new request, if it's old, remove the request.
PollIntervalThe interval to poll the transfer result, (in ms).
DataLengthThe length of perodic data transfer.
CallbackThe function to call periodically when transfer is ready.
ContextThe context to the callback.
Return values
EFI_SUCCESSNew transfer is queued or old request is removed.
EFI_INVALID_PARAMETERSome parameters are invalid.
OthersFailed to queue the new request or remove the old request.

Definition at line 413 of file UsbBus.c.

◆ UsbIoAsyncIsochronousTransfer()

EFI_STATUS EFIAPI UsbIoAsyncIsochronousTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  DeviceEndpoint,
IN OUT VOID *  Data,
IN UINTN  DataLength,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK  IsochronousCallBack,
IN VOID *Context  OPTIONAL 
)

Queue an asynchronous isochronous transfer.

Parameters
ThisThe USB_IO instance.
DeviceEndpointThe device endpoint.
DataThe data to transfer.
DataLengthThe length of perodic data transfer.
IsochronousCallBackThe function to call periodically when transfer is ready.
ContextThe context to the callback.
Return values
EFI_UNSUPPORTEDCurrently isochronous transfer isn't supported.

Definition at line 509 of file UsbBus.c.

◆ UsbIoBulkTransfer()

EFI_STATUS EFIAPI UsbIoBulkTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  Endpoint,
IN OUT VOID *  Data,
IN OUT UINTN DataLength,
IN UINTN  Timeout,
OUT UINT32 *  UsbStatus 
)

Execute a bulk transfer to the device endpoint.

Parameters
ThisThe USB IO instance.
EndpointThe device endpoint.
DataThe data to transfer.
DataLengthThe length of the data to transfer.
TimeoutTime to wait before timeout.
UsbStatusThe result of USB transfer.
Return values
EFI_SUCCESSThe bulk transfer is OK.
EFI_INVALID_PARAMETERSome parameters are invalid.
OthersFailed to execute transfer, reason returned in UsbStatus.

Definition at line 241 of file UsbBus.c.

◆ UsbIoControlTransfer()

EFI_STATUS EFIAPI UsbIoControlTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN EFI_USB_DEVICE_REQUEST Request,
IN EFI_USB_DATA_DIRECTION  Direction,
IN UINT32  Timeout,
IN OUT VOID *Data  OPTIONAL,
IN UINTN DataLength  OPTIONAL,
OUT UINT32 *  UsbStatus 
)

USB_IO function to execute a control transfer. This function will execute the USB transfer. If transfer successes, it will sync the internal state of USB bus with device state.

Parameters
ThisThe USB_IO instance
RequestThe control transfer request
DirectionDirection for data stage
TimeoutThe time to wait before timeout
DataThe buffer holding the data
DataLengthThen length of the data
UsbStatusUSB result
Return values
EFI_INVALID_PARAMETERThe parameters are invalid
EFI_SUCCESSThe control transfer succeeded.
OthersFailed to execute the transfer

Definition at line 59 of file UsbBus.c.

◆ UsbIoGetActiveConfigDescriptor()

EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor ( IN EFI_USB_IO_PROTOCOL This,
OUT EFI_USB_CONFIG_DESCRIPTOR Descriptor 
)

Return the configuration descriptor of the current active configuration.

Parameters
ThisThe USB IO instance.
DescriptorThe USB configuration descriptor.
Return values
EFI_SUCCESSThe active configuration descriptor is returned.
EFI_INVALID_PARAMETERSome parameter is invalid.
EFI_NOT_FOUNDCurrently no active configuration is selected.

Definition at line 570 of file UsbBus.c.

◆ UsbIoGetDeviceDescriptor()

EFI_STATUS EFIAPI UsbIoGetDeviceDescriptor ( IN EFI_USB_IO_PROTOCOL This,
OUT EFI_USB_DEVICE_DESCRIPTOR Descriptor 
)

Retrieve the device descriptor of the device.

Parameters
ThisThe USB IO instance.
DescriptorThe variable to receive the device descriptor.
Return values
EFI_SUCCESSThe device descriptor is returned.
EFI_INVALID_PARAMETERThe parameter is invalid.

Definition at line 533 of file UsbBus.c.

◆ UsbIoGetEndpointDescriptor()

EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  Index,
OUT EFI_USB_ENDPOINT_DESCRIPTOR Descriptor 
)

Retrieve the endpoint descriptor from this interface setting.

Parameters
ThisThe USB IO instance.
IndexThe index (start from zero) of the endpoint to retrieve.
DescriptorThe variable to receive the descriptor.
Return values
EFI_SUCCESSThe endpoint descriptor is returned.
EFI_INVALID_PARAMETERSome parameter is invalid.

Definition at line 649 of file UsbBus.c.

◆ UsbIoGetInterfaceDescriptor()

EFI_STATUS EFIAPI UsbIoGetInterfaceDescriptor ( IN EFI_USB_IO_PROTOCOL This,
OUT EFI_USB_INTERFACE_DESCRIPTOR Descriptor 
)

Retrieve the active interface setting descriptor for this USB IO instance.

Parameters
ThisThe USB IO instance.
DescriptorThe variable to receive active interface setting.
Return values
EFI_SUCCESSThe active interface setting is returned.
EFI_INVALID_PARAMETERSome parameter is invalid.

Definition at line 614 of file UsbBus.c.

◆ UsbIoGetStringDescriptor()

EFI_STATUS EFIAPI UsbIoGetStringDescriptor ( IN EFI_USB_IO_PROTOCOL This,
IN UINT16  LangID,
IN UINT8  StringIndex,
OUT CHAR16 **  String 
)

Retrieve an indexed string in the language of LangID.

Parameters
ThisThe USB IO instance.
LangIDThe language ID of the string to retrieve.
StringIndexThe index of the string.
StringThe variable to receive the string.
Return values
EFI_SUCCESSThe string is returned.
EFI_NOT_FOUNDNo such string existed.

Definition at line 730 of file UsbBus.c.

◆ UsbIoGetSupportedLanguages()

EFI_STATUS EFIAPI UsbIoGetSupportedLanguages ( IN EFI_USB_IO_PROTOCOL This,
OUT UINT16 **  LangIDTable,
OUT UINT16 *  TableSize 
)

Retrieve the supported language ID table from the device.

Parameters
ThisThe USB IO instance.
LangIDTableThe table to return the language IDs.
TableSizeThe size, in bytes, of the table LangIDTable.
Return values
EFI_SUCCESSThe language ID is return.

Definition at line 694 of file UsbBus.c.

◆ UsbIoIsochronousTransfer()

EFI_STATUS EFIAPI UsbIoIsochronousTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  DeviceEndpoint,
IN OUT VOID *  Data,
IN UINTN  DataLength,
OUT UINT32 *  Status 
)

Execute a synchronous isochronous transfer.

Parameters
ThisThe USB IO instance.
DeviceEndpointThe device endpoint.
DataThe data to transfer.
DataLengthThe length of the data to transfer.
UsbStatusThe result of USB transfer.
Return values
EFI_UNSUPPORTEDCurrently isochronous transfer isn't supported.

Definition at line 482 of file UsbBus.c.

◆ UsbIoPortReset()

EFI_STATUS EFIAPI UsbIoPortReset ( IN EFI_USB_IO_PROTOCOL This)

Reset the device, then if that succeeds, reconfigure the device with its address and current active configuration.

Parameters
ThisThe USB IO instance.
Return values
EFI_SUCCESSThe device is reset and configured.
OthersFailed to reset the device.

Definition at line 815 of file UsbBus.c.

◆ UsbIoSyncInterruptTransfer()

EFI_STATUS EFIAPI UsbIoSyncInterruptTransfer ( IN EFI_USB_IO_PROTOCOL This,
IN UINT8  Endpoint,
IN OUT VOID *  Data,
IN OUT UINTN DataLength,
IN UINTN  Timeout,
OUT UINT32 *  UsbStatus 
)

Execute a synchronous interrupt transfer.

Parameters
ThisThe USB IO instance.
EndpointThe device endpoint.
DataThe data to transfer.
DataLengthThe length of the data to transfer.
TimeoutTime to wait before timeout.
UsbStatusThe result of USB transfer.
Return values
EFI_SUCCESSThe synchronous interrupt transfer is OK.
EFI_INVALID_PARAMETERSome parameters are invalid.
OthersFailed to execute transfer, reason returned in UsbStatus.

Definition at line 335 of file UsbBus.c.

Variable Documentation

◆ mUsbBusDriverBinding

EFI_DRIVER_BINDING_PROTOCOL mUsbBusDriverBinding
Initial value:
= {
0xa,
}
#define NULL
Definition: Base.h:319
EFI_STATUS EFIAPI UsbBusControllerDriverSupported(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbBus.c:1174
EFI_STATUS EFIAPI UsbBusControllerDriverStop(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN UINTN NumberOfChildren, IN EFI_HANDLE *ChildHandleBuffer)
Definition: UsbBus.c:1426
EFI_STATUS EFIAPI UsbBusControllerDriverStart(IN EFI_DRIVER_BINDING_PROTOCOL *This, IN EFI_HANDLE Controller, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
Definition: UsbBus.c:1315

Definition at line 29 of file UsbBus.c.

◆ mUsbIoProtocol

EFI_USB_IO_PROTOCOL mUsbIoProtocol
Initial value:
= {
}
EFI_STATUS EFIAPI UsbIoAsyncInterruptTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN BOOLEAN IsNewTransfer, IN UINTN PollInterval OPTIONAL, IN UINTN DataLength OPTIONAL, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback OPTIONAL, IN VOID *Context OPTIONAL)
Definition: UsbBus.c:413
EFI_STATUS EFIAPI UsbIoSyncInterruptTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:335
EFI_STATUS EFIAPI UsbIoGetEndpointDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Index, OUT EFI_USB_ENDPOINT_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:649
EFI_STATUS EFIAPI UsbIoIsochronousTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, OUT UINT32 *Status)
Definition: UsbBus.c:482
EFI_STATUS EFIAPI UsbIoGetActiveConfigDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_CONFIG_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:570
EFI_STATUS EFIAPI UsbIoGetInterfaceDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_INTERFACE_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:614
EFI_STATUS EFIAPI UsbIoGetSupportedLanguages(IN EFI_USB_IO_PROTOCOL *This, OUT UINT16 **LangIDTable, OUT UINT16 *TableSize)
Definition: UsbBus.c:694
EFI_STATUS EFIAPI UsbIoGetStringDescriptor(IN EFI_USB_IO_PROTOCOL *This, IN UINT16 LangID, IN UINT8 StringIndex, OUT CHAR16 **String)
Definition: UsbBus.c:730
EFI_STATUS EFIAPI UsbIoAsyncIsochronousTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 DeviceEndpoint, IN OUT VOID *Data, IN UINTN DataLength, IN EFI_ASYNC_USB_TRANSFER_CALLBACK IsochronousCallBack, IN VOID *Context OPTIONAL)
Definition: UsbBus.c:509
EFI_STATUS EFIAPI UsbIoGetDeviceDescriptor(IN EFI_USB_IO_PROTOCOL *This, OUT EFI_USB_DEVICE_DESCRIPTOR *Descriptor)
Definition: UsbBus.c:533
EFI_STATUS EFIAPI UsbIoControlTransfer(IN EFI_USB_IO_PROTOCOL *This, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN UINT32 Timeout, IN OUT VOID *Data OPTIONAL, IN UINTN DataLength OPTIONAL, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:59
EFI_STATUS EFIAPI UsbIoBulkTransfer(IN EFI_USB_IO_PROTOCOL *This, IN UINT8 Endpoint, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN Timeout, OUT UINT32 *UsbStatus)
Definition: UsbBus.c:241
EFI_STATUS EFIAPI UsbIoPortReset(IN EFI_USB_IO_PROTOCOL *This)
Definition: UsbBus.c:815

Definition at line 13 of file UsbBus.c.