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

Go to the source code of this file.

Functions

EFI_STATUS UsbHcGetCapability (IN USB_BUS *UsbBus, OUT UINT8 *MaxSpeed, OUT UINT8 *NumOfPort, OUT UINT8 *Is64BitCapable)
 
EFI_STATUS UsbHcGetRootHubPortStatus (IN USB_BUS *UsbBus, IN UINT8 PortIndex, OUT EFI_USB_PORT_STATUS *PortStatus)
 
EFI_STATUS UsbHcSetRootHubPortFeature (IN USB_BUS *UsbBus, IN UINT8 PortIndex, IN EFI_USB_PORT_FEATURE Feature)
 
EFI_STATUS UsbHcClearRootHubPortFeature (IN USB_BUS *UsbBus, IN UINT8 PortIndex, IN EFI_USB_PORT_FEATURE Feature)
 
EFI_STATUS UsbHcControlTransfer (IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN EFI_USB_DEVICE_REQUEST *Request, IN EFI_USB_DATA_DIRECTION Direction, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
 
EFI_STATUS UsbHcBulkTransfer (IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN UINT8 BufferNum, IN OUT VOID *Data[], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
 
EFI_STATUS UsbHcAsyncInterruptTransfer (IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN BOOLEAN IsNewTransfer, IN OUT UINT8 *DataToggle, IN UINTN PollingInterval, IN UINTN DataLength, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, IN EFI_ASYNC_USB_TRANSFER_CALLBACK Callback, IN VOID *Context OPTIONAL)
 
EFI_STATUS UsbHcSyncInterruptTransfer (IN USB_BUS *UsbBus, IN UINT8 DevAddr, IN UINT8 EpAddr, IN UINT8 DevSpeed, IN UINTN MaxPacket, IN OUT VOID *Data, IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, IN EFI_USB2_HC_TRANSACTION_TRANSLATOR *Translator, OUT UINT32 *UsbResult)
 
EFI_STATUS UsbOpenHostProtoByChild (IN USB_BUS *Bus, IN EFI_HANDLE Child)
 
VOID UsbCloseHostProtoByChild (IN USB_BUS *Bus, IN EFI_HANDLE Child)
 
EFI_TPL UsbGetCurrentTpl (VOID)
 
EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetUsbDPFromFullDP (IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
 
BOOLEAN EFIAPI SearchUsbDPInList (IN EFI_DEVICE_PATH_PROTOCOL *UsbDP, IN LIST_ENTRY *UsbIoDPList)
 
EFI_STATUS EFIAPI AddUsbDPToList (IN EFI_DEVICE_PATH_PROTOCOL *UsbDP, IN LIST_ENTRY *UsbIoDPList)
 
BOOLEAN EFIAPI MatchUsbClass (IN USB_CLASS_DEVICE_PATH *UsbClassDevicePathPtr, IN USB_INTERFACE *UsbIf)
 
BOOLEAN MatchUsbWwid (IN USB_WWID_DEVICE_PATH *UsbWWIDDevicePathPtr, IN USB_INTERFACE *UsbIf)
 
EFI_STATUS EFIAPI UsbBusFreeUsbDPList (IN LIST_ENTRY *UsbIoDPList)
 
EFI_STATUS EFIAPI UsbBusAddWantedUsbIoDP (IN EFI_USB_BUS_PROTOCOL *UsbBusId, IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath)
 
BOOLEAN EFIAPI UsbBusIsWantedUsbIO (IN USB_BUS *Bus, IN USB_INTERFACE *UsbIf)
 
EFI_STATUS EFIAPI UsbBusRecursivelyConnectWantedUsbIo (IN EFI_USB_BUS_PROTOCOL *UsbBusId)
 

Variables

USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath
 

Detailed Description

Wrapper function for usb host controller interface.

Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UsbUtility.c.

Function Documentation

◆ AddUsbDPToList()

EFI_STATUS EFIAPI AddUsbDPToList ( IN EFI_DEVICE_PATH_PROTOCOL UsbDP,
IN LIST_ENTRY UsbIoDPList 
)

Add a usb device path into the DEVICE_PATH_LIST_ITEM list.

Parameters
UsbDPa usb device path of DEVICE_PATH_LIST_ITEM.
UsbIoDPLista DEVICE_PATH_LIST_ITEM list.
Return values
EFI_INVALID_PARAMETERIf parameters are invalid, return this value.
EFI_SUCCESSIf Add operation is successful, return this value.

Definition at line 688 of file UsbUtility.c.

◆ GetUsbDPFromFullDP()

EFI_DEVICE_PATH_PROTOCOL *EFIAPI GetUsbDPFromFullDP ( IN EFI_DEVICE_PATH_PROTOCOL DevicePath)

Create a new device path which only contain the first Usb part of the DevicePath.

Parameters
DevicePathA full device path which contain the usb nodes.
Returns
A new device path which only contain the Usb part of the DevicePath.

Definition at line 564 of file UsbUtility.c.

◆ MatchUsbClass()

BOOLEAN EFIAPI MatchUsbClass ( IN USB_CLASS_DEVICE_PATH UsbClassDevicePathPtr,
IN USB_INTERFACE UsbIf 
)

Check whether usb device, whose interface is UsbIf, matches the usb class which indicated by UsbClassDevicePathPtr whose is a short form usb class device path.

Parameters
UsbClassDevicePathPtra short form usb class device path.
UsbIfa usb device interface.
Return values
TRUEthe usb device match the usb class.
FALSEthe usb device does not match the usb class.

Definition at line 732 of file UsbUtility.c.

◆ MatchUsbWwid()

BOOLEAN MatchUsbWwid ( IN USB_WWID_DEVICE_PATH UsbWWIDDevicePathPtr,
IN USB_INTERFACE UsbIf 
)

Check whether usb device, whose interface is UsbIf, matches the usb WWID requirement which indicated by UsbWWIDDevicePathPtr whose is a short form usb WWID device path.

Parameters
UsbWWIDDevicePathPtra short form usb WWID device path.
UsbIfa usb device interface.
Return values
TRUEthe usb device match the usb WWID requirement.
FALSEthe usb device does not match the usb WWID requirement.

Definition at line 810 of file UsbUtility.c.

◆ SearchUsbDPInList()

BOOLEAN EFIAPI SearchUsbDPInList ( IN EFI_DEVICE_PATH_PROTOCOL UsbDP,
IN LIST_ENTRY UsbIoDPList 
)

Check whether a usb device path is in a DEVICE_PATH_LIST_ITEM list.

Parameters
UsbDPa usb device path of DEVICE_PATH_LIST_ITEM.
UsbIoDPLista DEVICE_PATH_LIST_ITEM list.
Return values
TRUEthere is a DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP.
FALSEthere is no DEVICE_PATH_LIST_ITEM in UsbIoDPList which contains the passed in UsbDP.

Definition at line 636 of file UsbUtility.c.

◆ UsbBusAddWantedUsbIoDP()

EFI_STATUS EFIAPI UsbBusAddWantedUsbIoDP ( IN EFI_USB_BUS_PROTOCOL UsbBusId,
IN EFI_DEVICE_PATH_PROTOCOL RemainingDevicePath 
)

Store a wanted usb child device info (its Usb part of device path) which is indicated by RemainingDevicePath in a Usb bus which is indicated by UsbBusId.

Parameters
UsbBusIdPoint to EFI_USB_BUS_PROTOCOL interface.
RemainingDevicePathThe remaining device patch.
Return values
EFI_SUCCESSAdd operation is successful.
EFI_INVALID_PARAMETERThe parameters are invalid.

Definition at line 951 of file UsbUtility.c.

◆ UsbBusFreeUsbDPList()

EFI_STATUS EFIAPI UsbBusFreeUsbDPList ( IN LIST_ENTRY UsbIoDPList)

Free a DEVICE_PATH_LIST_ITEM list.

Parameters
UsbIoDPLista DEVICE_PATH_LIST_ITEM list pointer.
Return values
EFI_INVALID_PARAMETERIf parameters are invalid, return this value.
EFI_SUCCESSIf free operation is successful, return this value.

Definition at line 902 of file UsbUtility.c.

◆ UsbBusIsWantedUsbIO()

BOOLEAN EFIAPI UsbBusIsWantedUsbIO ( IN USB_BUS Bus,
IN USB_INTERFACE UsbIf 
)

Check whether a usb child device is the wanted device in a bus.

Parameters
BusThe Usb bus's private data pointer.
UsbIfThe usb child device interface.
Return values
TrueIf a usb child device is the wanted device in a bus.
FalseIf a usb child device is NOT the wanted device in a bus.

Definition at line 1022 of file UsbUtility.c.

◆ UsbBusRecursivelyConnectWantedUsbIo()

EFI_STATUS EFIAPI UsbBusRecursivelyConnectWantedUsbIo ( IN EFI_USB_BUS_PROTOCOL UsbBusId)

Recursively connect every wanted usb child device to ensure they all fully connected. Check all the child Usb IO handles in this bus, recursively connecte if it is wanted usb child device.

Parameters
UsbBusIdPoint to EFI_USB_BUS_PROTOCOL interface.
Return values
EFI_SUCCESSConnect is done successfully.
EFI_INVALID_PARAMETERThe parameter is invalid.

Definition at line 1134 of file UsbUtility.c.

◆ UsbCloseHostProtoByChild()

VOID UsbCloseHostProtoByChild ( IN USB_BUS Bus,
IN EFI_HANDLE  Child 
)

Close the USB host controller protocol BY_CHILD.

Parameters
BusThe USB bus driver.
ChildThe child handle.

Definition at line 511 of file UsbUtility.c.

◆ UsbGetCurrentTpl()

EFI_TPL UsbGetCurrentTpl ( VOID  )

return the current TPL, copied from the EDKII glue lib.

Parameters
VOID.
Returns
Current TPL.

Definition at line 542 of file UsbUtility.c.

◆ UsbHcAsyncInterruptTransfer()

EFI_STATUS UsbHcAsyncInterruptTransfer ( IN USB_BUS UsbBus,
IN UINT8  DevAddr,
IN UINT8  EpAddr,
IN UINT8  DevSpeed,
IN UINTN  MaxPacket,
IN BOOLEAN  IsNewTransfer,
IN OUT UINT8 *  DataToggle,
IN UINTN  PollingInterval,
IN UINTN  DataLength,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator,
IN EFI_ASYNC_USB_TRANSFER_CALLBACK  Callback,
IN VOID *Context  OPTIONAL 
)

Queue or cancel an asynchronous interrupt transfer.

Parameters
UsbBusThe USB bus driver.
DevAddrThe target device address.
EpAddrThe target endpoint address, with direction encoded in bit 7.
DevSpeedThe device's speed.
MaxPacketThe endpoint's max packet size.
IsNewTransferWhether this is a new request. If not, cancel the old request.
DataToggleData toggle to use on input, next toggle on output.
PollingIntervalThe interval to poll the interrupt transfer (in ms).
DataLengthThe length of periodical data receive.
TranslatorThe transaction translator for low/full speed device.
CallbackFunction to call when data is received.
ContextThe context to the callback.
Return values
EFI_SUCCESSThe asynchronous transfer is queued.
OthersFailed to queue the transfer.

Definition at line 335 of file UsbUtility.c.

◆ UsbHcBulkTransfer()

EFI_STATUS UsbHcBulkTransfer ( IN USB_BUS UsbBus,
IN UINT8  DevAddr,
IN UINT8  EpAddr,
IN UINT8  DevSpeed,
IN UINTN  MaxPacket,
IN UINT8  BufferNum,
IN OUT VOID *  Data[],
IN OUT UINTN DataLength,
IN OUT UINT8 *  DataToggle,
IN UINTN  TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator,
OUT UINT32 *  UsbResult 
)

Execute a bulk transfer to the device's endpoint.

Parameters
UsbBusThe USB bus driver.
DevAddrThe target device address.
EpAddrThe target endpoint address, with direction encoded in bit 7.
DevSpeedThe device's speed.
MaxPacketThe endpoint's max packet size.
BufferNumThe number of data buffer.
DataArray of pointers to data buffer.
DataLengthThe length of data buffer.
DataToggleOn input, the initial data toggle to use, also return the next toggle on output.
TimeOutThe time to wait until timeout.
TranslatorThe transaction translator for low/full speed device.
UsbResultThe result of USB execution.
Return values
EFI_SUCCESSThe bulk transfer is finished without error.
OthersFailed to execute bulk transfer, result in UsbResult.

Definition at line 263 of file UsbUtility.c.

◆ UsbHcClearRootHubPortFeature()

EFI_STATUS UsbHcClearRootHubPortFeature ( IN USB_BUS UsbBus,
IN UINT8  PortIndex,
IN EFI_USB_PORT_FEATURE  Feature 
)

Clear the root hub port feature.

Parameters
UsbBusThe USB bus driver.
PortIndexThe port index.
FeatureThe port feature to clear.
Return values
EFI_SUCCESSThe port feature is clear.
OthersFailed to clear port feature.

Definition at line 153 of file UsbUtility.c.

◆ UsbHcControlTransfer()

EFI_STATUS UsbHcControlTransfer ( IN USB_BUS UsbBus,
IN UINT8  DevAddr,
IN UINT8  DevSpeed,
IN UINTN  MaxPacket,
IN EFI_USB_DEVICE_REQUEST Request,
IN EFI_USB_DATA_DIRECTION  Direction,
IN OUT VOID *  Data,
IN OUT UINTN DataLength,
IN UINTN  TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator,
OUT UINT32 *  UsbResult 
)

Execute a control transfer to the device.

Parameters
UsbBusThe USB bus driver.
DevAddrThe device address.
DevSpeedThe device speed.
MaxPacketMaximum packet size of endpoint 0.
RequestThe control transfer request.
DirectionThe direction of data stage.
DataThe buffer holding data.
DataLengthThe length of the data.
TimeOutTimeout (in ms) to wait until timeout.
TranslatorThe transaction translator for low/full speed device.
UsbResultThe result of transfer.
Return values
EFI_SUCCESSThe control transfer finished without error.
OthersThe control transfer failed, reason returned in UsbReslt.

Definition at line 190 of file UsbUtility.c.

◆ UsbHcGetCapability()

EFI_STATUS UsbHcGetCapability ( IN USB_BUS UsbBus,
OUT UINT8 *  MaxSpeed,
OUT UINT8 *  NumOfPort,
OUT UINT8 *  Is64BitCapable 
)

Get the capability of the host controller.

Parameters
UsbBusThe usb driver.
MaxSpeedThe maximum speed this host controller supports.
NumOfPortThe number of the root hub port.
Is64BitCapableWhether this controller support 64 bit addressing.
Return values
EFI_SUCCESSThe host controller capability is returned.
OthersFailed to retrieve the host controller capability.

Definition at line 57 of file UsbUtility.c.

◆ UsbHcGetRootHubPortStatus()

EFI_STATUS UsbHcGetRootHubPortStatus ( IN USB_BUS UsbBus,
IN UINT8  PortIndex,
OUT EFI_USB_PORT_STATUS PortStatus 
)

Get the root hub port state.

Parameters
UsbBusThe USB bus driver.
PortIndexThe index of port.
PortStatusThe variable to save port state.
Return values
EFI_SUCCESSThe root port state is returned in.
OthersFailed to get the root hub port state.

Definition at line 95 of file UsbUtility.c.

◆ UsbHcSetRootHubPortFeature()

EFI_STATUS UsbHcSetRootHubPortFeature ( IN USB_BUS UsbBus,
IN UINT8  PortIndex,
IN EFI_USB_PORT_FEATURE  Feature 
)

Set the root hub port feature.

Parameters
UsbBusThe USB bus driver.
PortIndexThe port index.
FeatureThe port feature to set.
Return values
EFI_SUCCESSThe port feature is set.
OthersFailed to set port feature.

Definition at line 124 of file UsbUtility.c.

◆ UsbHcSyncInterruptTransfer()

EFI_STATUS UsbHcSyncInterruptTransfer ( IN USB_BUS UsbBus,
IN UINT8  DevAddr,
IN UINT8  EpAddr,
IN UINT8  DevSpeed,
IN UINTN  MaxPacket,
IN OUT VOID *  Data,
IN OUT UINTN DataLength,
IN OUT UINT8 *  DataToggle,
IN UINTN  TimeOut,
IN EFI_USB2_HC_TRANSACTION_TRANSLATOR Translator,
OUT UINT32 *  UsbResult 
)

Execute a synchronous interrupt transfer to the target endpoint.

Parameters
UsbBusThe USB bus driver.
DevAddrThe target device address.
EpAddrThe target endpoint address, with direction encoded in bit 7.
DevSpeedThe device's speed.
MaxPacketThe endpoint's max packet size.
DataPointer to data buffer.
DataLengthThe length of data buffer.
DataToggleOn input, the initial data toggle to use, also return the next toggle on output.
TimeOutThe time to wait until timeout.
TranslatorThe transaction translator for low/full speed device.
UsbResultThe result of USB execution.
Return values
EFI_SUCCESSThe synchronous interrupt transfer is OK.
OthersFailed to execute the synchronous interrupt transfer.

Definition at line 411 of file UsbUtility.c.

◆ UsbOpenHostProtoByChild()

EFI_STATUS UsbOpenHostProtoByChild ( IN USB_BUS Bus,
IN EFI_HANDLE  Child 
)

Open the USB host controller protocol BY_CHILD.

Parameters
BusThe USB bus driver.
ChildThe child handle.
Returns
The open protocol return.

Definition at line 471 of file UsbUtility.c.

Variable Documentation

◆ mAllUsbClassDevicePath

USB_CLASS_FORMAT_DEVICE_PATH mAllUsbClassDevicePath
Initial value:
= {
{
{
{
(UINT8)(sizeof (USB_CLASS_DEVICE_PATH)),
(UINT8)((sizeof (USB_CLASS_DEVICE_PATH)) >> 8)
}
},
0xffff,
0xffff,
0xff,
0xff,
0xff
},
{
END_DEVICE_PATH_TYPE,
END_ENTIRE_DEVICE_PATH_SUBTYPE,
{
END_DEVICE_PATH_LENGTH,
0
}
}
}
#define MSG_USB_CLASS_DP
Definition: DevicePath.h:434
#define MESSAGING_DEVICE_PATH
Definition: DevicePath.h:321

Definition at line 17 of file UsbUtility.c.