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

Go to the source code of this file.

Functions

VOID UsbFreeInterfaceDesc (IN USB_INTERFACE_SETTING *Setting)
 
VOID UsbFreeConfigDesc (IN USB_CONFIG_DESC *Config)
 
VOID UsbFreeDevDesc (IN USB_DEVICE_DESC *DevDesc)
 
VOID * UsbCreateDesc (IN UINT8 *DescBuf, IN UINTN Len, IN UINT8 Type, OUT UINTN *Consumed)
 
USB_INTERFACE_SETTINGUsbParseInterfaceDesc (IN UINT8 *DescBuf, IN UINTN Len, OUT UINTN *Consumed)
 
USB_CONFIG_DESCUsbParseConfigDesc (IN UINT8 *DescBuf, IN UINTN Len)
 
EFI_STATUS UsbCtrlRequest (IN USB_DEVICE *UsbDev, IN EFI_USB_DATA_DIRECTION Direction, IN UINTN Type, IN UINTN Target, IN UINTN Request, IN UINT16 Value, IN UINT16 Index, IN OUT VOID *Buf, IN UINTN Length)
 
EFI_STATUS UsbCtrlGetDesc (IN USB_DEVICE *UsbDev, IN UINTN DescType, IN UINTN DescIndex, IN UINT16 LangId, OUT VOID *Buf, IN UINTN Length)
 
EFI_STATUS UsbGetMaxPacketSize0 (IN USB_DEVICE *UsbDev)
 
EFI_STATUS UsbGetDevDesc (IN USB_DEVICE *UsbDev)
 
EFI_USB_STRING_DESCRIPTORUsbGetOneString (IN USB_DEVICE *UsbDev, IN UINT8 Index, IN UINT16 LangId)
 
EFI_STATUS UsbBuildLangTable (IN USB_DEVICE *UsbDev)
 
EFI_USB_CONFIG_DESCRIPTORUsbGetOneConfig (IN USB_DEVICE *UsbDev, IN UINT8 Index)
 
EFI_STATUS UsbBuildDescTable (IN USB_DEVICE *UsbDev)
 
EFI_STATUS UsbSetAddress (IN USB_DEVICE *UsbDev, IN UINT8 Address)
 
EFI_STATUS UsbSetConfig (IN USB_DEVICE *UsbDev, IN UINT8 ConfigIndex)
 
EFI_STATUS UsbIoClearFeature (IN EFI_USB_IO_PROTOCOL *UsbIo, IN UINTN Target, IN UINT16 Feature, IN UINT16 Index)
 

Detailed Description

Manage Usb Descriptor List

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

Definition in file UsbDesc.c.

Function Documentation

◆ UsbBuildDescTable()

EFI_STATUS UsbBuildDescTable ( IN USB_DEVICE UsbDev)

Build the whole array of descriptors. This function must be called after UsbGetMaxPacketSize0 returns the max packet size correctly for endpoint 0.

Parameters
UsbDevThe Usb device.
Return values
EFI_SUCCESSThe descriptor table is build.
EFI_OUT_OF_RESOURCESFailed to allocate resource for the descriptor.

Definition at line 811 of file UsbDesc.c.

◆ UsbBuildLangTable()

EFI_STATUS UsbBuildLangTable ( IN USB_DEVICE UsbDev)

Build the language ID table for string descriptors.

Parameters
UsbDevThe Usb device.
Return values
EFI_UNSUPPORTEDThis device doesn't support string table.

Definition at line 691 of file UsbDesc.c.

◆ UsbCreateDesc()

VOID * UsbCreateDesc ( IN UINT8 *  DescBuf,
IN UINTN  Len,
IN UINT8  Type,
OUT UINTN Consumed 
)

Create a descriptor.

Parameters
DescBufThe buffer of raw descriptor.
LenThe length of the raw descriptor buffer.
TypeThe type of descriptor to create.
ConsumedNumber of bytes consumed.
Returns
Created descriptor or NULL.

Definition at line 132 of file UsbDesc.c.

◆ UsbCtrlGetDesc()

EFI_STATUS UsbCtrlGetDesc ( IN USB_DEVICE UsbDev,
IN UINTN  DescType,
IN UINTN  DescIndex,
IN UINT16  LangId,
OUT VOID *  Buf,
IN UINTN  Length 
)

Get the standard descriptors.

Parameters
UsbDevThe USB device to read descriptor from.
DescTypeThe type of descriptor to read.
DescIndexThe index of descriptor to read.
LangIdLanguage ID, only used to get string, otherwise set it to 0.
BufThe buffer to hold the descriptor read.
LengthThe length of the buffer.
Return values
EFI_SUCCESSThe descriptor is read OK.
OthersFailed to retrieve the descriptor.

Definition at line 510 of file UsbDesc.c.

◆ UsbCtrlRequest()

EFI_STATUS UsbCtrlRequest ( IN USB_DEVICE UsbDev,
IN EFI_USB_DATA_DIRECTION  Direction,
IN UINTN  Type,
IN UINTN  Target,
IN UINTN  Request,
IN UINT16  Value,
IN UINT16  Index,
IN OUT VOID *  Buf,
IN UINTN  Length 
)

USB standard control transfer support routine. This function is used by USB device. It is possible that the device's interfaces are still waiting to be enumerated.

Parameters
UsbDevThe usb device.
DirectionThe direction of data transfer.
TypeStandard / class specific / vendor specific.
TargetThe receiving target.
RequestWhich request.
ValueThe wValue parameter of the request.
IndexThe wIndex parameter of the request.
BufThe buffer to receive data into / transmit from.
LengthThe length of the buffer.
Return values
EFI_SUCCESSThe control request is executed.
EFI_DEVICE_ERRORFailed to execute the control transfer.

Definition at line 451 of file UsbDesc.c.

◆ UsbFreeConfigDesc()

VOID UsbFreeConfigDesc ( IN USB_CONFIG_DESC Config)

Free a configuration descriptor with its interface descriptors. It may be initialized partially.

Parameters
ConfigThe configuration descriptor to free.

Definition at line 57 of file UsbDesc.c.

◆ UsbFreeDevDesc()

VOID UsbFreeDevDesc ( IN USB_DEVICE_DESC DevDesc)

Free a device descriptor with its configurations.

Parameters
DevDescThe device descriptor.

Definition at line 101 of file UsbDesc.c.

◆ UsbFreeInterfaceDesc()

VOID UsbFreeInterfaceDesc ( IN USB_INTERFACE_SETTING Setting)

Free the interface setting descriptor.

Parameters
SettingThe descriptor to free.

Definition at line 19 of file UsbDesc.c.

◆ UsbGetDevDesc()

EFI_STATUS UsbGetDevDesc ( IN USB_DEVICE UsbDev)

Get the device descriptor for the device.

Parameters
UsbDevThe Usb device to retrieve descriptor from.
Return values
EFI_SUCCESSThe device descriptor is returned.
EFI_OUT_OF_RESOURCESFailed to allocate memory.

Definition at line 589 of file UsbDesc.c.

◆ UsbGetMaxPacketSize0()

EFI_STATUS UsbGetMaxPacketSize0 ( IN USB_DEVICE UsbDev)

Return the max packet size for endpoint zero. This function is the first function called to get descriptors during bus enumeration.

Parameters
UsbDevThe usb device.
Return values
EFI_SUCCESSThe max packet size of endpoint zero is retrieved.
EFI_DEVICE_ERRORFailed to retrieve it.

Definition at line 548 of file UsbDesc.c.

◆ UsbGetOneConfig()

EFI_USB_CONFIG_DESCRIPTOR * UsbGetOneConfig ( IN USB_DEVICE UsbDev,
IN UINT8  Index 
)

Retrieve the indexed configure for the device. USB device returns the configuration together with the interfaces for this configuration. Configuration descriptor is also of variable length.

Parameters
UsbDevThe Usb interface.
IndexThe index of the configuration.
Returns
The created configuration descriptor.

Definition at line 746 of file UsbDesc.c.

◆ UsbGetOneString()

EFI_USB_STRING_DESCRIPTOR * UsbGetOneString ( IN USB_DEVICE UsbDev,
IN UINT8  Index,
IN UINT16  LangId 
)

Retrieve the indexed string for the language. It requires two steps to get a string, first to get the string's length. Then the string itself.

Parameters
UsbDevThe usb device.
IndexThe index the string to retrieve.
LangIdLanguage ID.
Returns
The created string descriptor or NULL.

Definition at line 633 of file UsbDesc.c.

◆ UsbIoClearFeature()

EFI_STATUS UsbIoClearFeature ( IN EFI_USB_IO_PROTOCOL UsbIo,
IN UINTN  Target,
IN UINT16  Feature,
IN UINT16  Index 
)

Usb UsbIo interface to clear the feature. This is should only be used by HUB which is considered a device driver on top of the UsbIo interface.

Parameters
UsbIoThe UsbIo interface.
TargetThe target of the transfer: endpoint/device.
FeatureThe feature to clear.
IndexThe wIndex parameter.
Return values
EFI_SUCCESSThe device feature is cleared.
OthersFailed to clear the feature.

Definition at line 983 of file UsbDesc.c.

◆ UsbParseConfigDesc()

USB_CONFIG_DESC * UsbParseConfigDesc ( IN UINT8 *  DescBuf,
IN UINTN  Len 
)

Parse the configuration descriptor and its interfaces.

Parameters
DescBufThe buffer of raw descriptor.
LenThe length of the raw descriptor buffer.
Returns
The created configuration descriptor.

Definition at line 332 of file UsbDesc.c.

◆ UsbParseInterfaceDesc()

USB_INTERFACE_SETTING * UsbParseInterfaceDesc ( IN UINT8 *  DescBuf,
IN UINTN  Len,
OUT UINTN Consumed 
)

Parse an interface descriptor and its endpoints.

Parameters
DescBufThe buffer of raw descriptor.
LenThe length of the raw descriptor buffer.
ConsumedThe number of raw descriptor consumed.
Returns
The create interface setting or NULL if failed.

Definition at line 252 of file UsbDesc.c.

◆ UsbSetAddress()

EFI_STATUS UsbSetAddress ( IN USB_DEVICE UsbDev,
IN UINT8  Address 
)

Set the device's address.

Parameters
UsbDevThe device to set address to.
AddressThe address to set.
Return values
EFI_SUCCESSThe device is set to the address.
OthersFailed to set the device address.

Definition at line 911 of file UsbDesc.c.

◆ UsbSetConfig()

EFI_STATUS UsbSetConfig ( IN USB_DEVICE UsbDev,
IN UINT8  ConfigIndex 
)

Set the device's configuration. This function changes the device's internal state. UsbSelectConfig changes the Usb bus's internal state.

Parameters
UsbDevThe USB device to set configure to.
ConfigIndexThe configure index to set.
Return values
EFI_SUCCESSThe device is configured now.
OthersFailed to set the device configure.

Definition at line 946 of file UsbDesc.c.