MdeModulePkg: Apply uncrustify changes
REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3737 Apply uncrustify changes to .c/.h files in the MdeModulePkg package Cc: Andrew Fish <afish@apple.com> Cc: Leif Lindholm <leif@nuviainc.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Signed-off-by: Michael Kubacki <michael.kubacki@microsoft.com> Reviewed-by: Liming Gao <gaoliming@byosoft.com.cn>
This commit is contained in:
committed by
mergify[bot]
parent
7c7184e201
commit
1436aea4d5
@@ -9,7 +9,6 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
|
||||
|
||||
#include "UsbBus.h"
|
||||
|
||||
|
||||
/**
|
||||
Free the interface setting descriptor.
|
||||
|
||||
@@ -21,8 +20,8 @@ UsbFreeInterfaceDesc (
|
||||
IN USB_INTERFACE_SETTING *Setting
|
||||
)
|
||||
{
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
|
||||
if (Setting->Endpoints != NULL) {
|
||||
//
|
||||
@@ -47,7 +46,6 @@ UsbFreeInterfaceDesc (
|
||||
FreePool (Setting);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a configuration descriptor with its interface
|
||||
descriptors. It may be initialized partially.
|
||||
@@ -57,12 +55,12 @@ UsbFreeInterfaceDesc (
|
||||
**/
|
||||
VOID
|
||||
UsbFreeConfigDesc (
|
||||
IN USB_CONFIG_DESC *Config
|
||||
IN USB_CONFIG_DESC *Config
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN SetIndex;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN SetIndex;
|
||||
|
||||
if (Config->Interfaces != NULL) {
|
||||
//
|
||||
@@ -91,10 +89,8 @@ UsbFreeConfigDesc (
|
||||
}
|
||||
|
||||
FreePool (Config);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Free a device descriptor with its configurations.
|
||||
|
||||
@@ -103,10 +99,10 @@ UsbFreeConfigDesc (
|
||||
**/
|
||||
VOID
|
||||
UsbFreeDevDesc (
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
IN USB_DEVICE_DESC *DevDesc
|
||||
)
|
||||
{
|
||||
UINTN Index;
|
||||
UINTN Index;
|
||||
|
||||
if (DevDesc->Configs != NULL) {
|
||||
for (Index = 0; Index < DevDesc->Desc.NumConfigurations; Index++) {
|
||||
@@ -121,7 +117,6 @@ UsbFreeDevDesc (
|
||||
FreePool (DevDesc);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Create a descriptor.
|
||||
|
||||
@@ -135,46 +130,46 @@ UsbFreeDevDesc (
|
||||
**/
|
||||
VOID *
|
||||
UsbCreateDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
IN UINT8 Type,
|
||||
OUT UINTN *Consumed
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
IN UINT8 Type,
|
||||
OUT UINTN *Consumed
|
||||
)
|
||||
{
|
||||
USB_DESC_HEAD *Head;
|
||||
UINTN DescLen;
|
||||
UINTN CtrlLen;
|
||||
UINTN Offset;
|
||||
VOID *Desc;
|
||||
USB_DESC_HEAD *Head;
|
||||
UINTN DescLen;
|
||||
UINTN CtrlLen;
|
||||
UINTN Offset;
|
||||
VOID *Desc;
|
||||
|
||||
DescLen = 0;
|
||||
CtrlLen = 0;
|
||||
*Consumed = 0;
|
||||
|
||||
switch (Type) {
|
||||
case USB_DESC_TYPE_DEVICE:
|
||||
DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_DEVICE_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_DEVICE:
|
||||
DescLen = sizeof (EFI_USB_DEVICE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_DEVICE_DESC);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_CONFIG_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_CONFIG:
|
||||
DescLen = sizeof (EFI_USB_CONFIG_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_CONFIG_DESC);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_INTERFACE:
|
||||
DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_INTERFACE_SETTING);
|
||||
break;
|
||||
case USB_DESC_TYPE_INTERFACE:
|
||||
DescLen = sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_INTERFACE_SETTING);
|
||||
break;
|
||||
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_ENDPOINT_DESC);
|
||||
break;
|
||||
case USB_DESC_TYPE_ENDPOINT:
|
||||
DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
|
||||
CtrlLen = sizeof (USB_ENDPOINT_DESC);
|
||||
break;
|
||||
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
default:
|
||||
ASSERT (FALSE);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
//
|
||||
@@ -231,19 +226,18 @@ UsbCreateDesc (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
Desc = AllocateZeroPool ((UINTN) CtrlLen);
|
||||
Desc = AllocateZeroPool ((UINTN)CtrlLen);
|
||||
if (Desc == NULL) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
CopyMem (Desc, Head, (UINTN) DescLen);
|
||||
CopyMem (Desc, Head, (UINTN)DescLen);
|
||||
|
||||
*Consumed = Offset;
|
||||
|
||||
return Desc;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse an interface descriptor and its endpoints.
|
||||
|
||||
@@ -256,23 +250,23 @@ UsbCreateDesc (
|
||||
**/
|
||||
USB_INTERFACE_SETTING *
|
||||
UsbParseInterfaceDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
OUT UINTN *Consumed
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len,
|
||||
OUT UINTN *Consumed
|
||||
)
|
||||
{
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
UINTN NumEp;
|
||||
UINTN Used;
|
||||
UINTN Offset;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_ENDPOINT_DESC *Ep;
|
||||
UINTN Index;
|
||||
UINTN NumEp;
|
||||
UINTN Used;
|
||||
UINTN Offset;
|
||||
|
||||
*Consumed = 0;
|
||||
Setting = UsbCreateDesc (DescBuf, Len, USB_DESC_TYPE_INTERFACE, &Used);
|
||||
|
||||
if (Setting == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create interface descriptor\n"));
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -281,16 +275,21 @@ UsbParseInterfaceDesc (
|
||||
//
|
||||
// Create an array to hold the interface's endpoints
|
||||
//
|
||||
NumEp = Setting->Desc.NumEndpoints;
|
||||
NumEp = Setting->Desc.NumEndpoints;
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
|
||||
Setting->Desc.InterfaceNumber, Setting->Desc.AlternateSetting, (UINT32)NumEp));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbParseInterfaceDesc: interface %d(setting %d) has %d endpoints\n",
|
||||
Setting->Desc.InterfaceNumber,
|
||||
Setting->Desc.AlternateSetting,
|
||||
(UINT32)NumEp
|
||||
));
|
||||
|
||||
if (NumEp == 0) {
|
||||
goto ON_EXIT;
|
||||
}
|
||||
|
||||
Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
|
||||
Setting->Endpoints = AllocateZeroPool (sizeof (USB_ENDPOINT_DESC *) * NumEp);
|
||||
|
||||
if (Setting->Endpoints == NULL) {
|
||||
goto ON_ERROR;
|
||||
@@ -303,15 +302,14 @@ UsbParseInterfaceDesc (
|
||||
Ep = UsbCreateDesc (DescBuf + Offset, Len - Offset, USB_DESC_TYPE_ENDPOINT, &Used);
|
||||
|
||||
if (Ep == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseInterfaceDesc: failed to create endpoint(index %d)\n", (UINT32)Index));
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
Setting->Endpoints[Index] = Ep;
|
||||
Offset += Used;
|
||||
Setting->Endpoints[Index] = Ep;
|
||||
Offset += Used;
|
||||
}
|
||||
|
||||
|
||||
ON_EXIT:
|
||||
*Consumed = Offset;
|
||||
return Setting;
|
||||
@@ -321,7 +319,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Parse the configuration descriptor and its interfaces.
|
||||
|
||||
@@ -333,16 +330,16 @@ ON_ERROR:
|
||||
**/
|
||||
USB_CONFIG_DESC *
|
||||
UsbParseConfigDesc (
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len
|
||||
IN UINT8 *DescBuf,
|
||||
IN UINTN Len
|
||||
)
|
||||
{
|
||||
USB_CONFIG_DESC *Config;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN NumIf;
|
||||
UINTN Consumed;
|
||||
USB_CONFIG_DESC *Config;
|
||||
USB_INTERFACE_SETTING *Setting;
|
||||
USB_INTERFACE_DESC *Interface;
|
||||
UINTN Index;
|
||||
UINTN NumIf;
|
||||
UINTN Consumed;
|
||||
|
||||
ASSERT (DescBuf != NULL);
|
||||
|
||||
@@ -355,15 +352,19 @@ UsbParseConfigDesc (
|
||||
//
|
||||
// Initialize an array of setting for the configuration's interfaces.
|
||||
//
|
||||
NumIf = Config->Desc.NumInterfaces;
|
||||
Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
|
||||
NumIf = Config->Desc.NumInterfaces;
|
||||
Config->Interfaces = AllocateZeroPool (sizeof (USB_INTERFACE_DESC *) * NumIf);
|
||||
|
||||
if (Config->Interfaces == NULL) {
|
||||
goto ON_ERROR;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbParseConfigDesc: config %d has %d interfaces\n",
|
||||
Config->Desc.ConfigurationValue, (UINT32)NumIf));
|
||||
DEBUG ((
|
||||
DEBUG_INFO,
|
||||
"UsbParseConfigDesc: config %d has %d interfaces\n",
|
||||
Config->Desc.ConfigurationValue,
|
||||
(UINT32)NumIf
|
||||
));
|
||||
|
||||
for (Index = 0; Index < NumIf; Index++) {
|
||||
Interface = AllocateZeroPool (sizeof (USB_INTERFACE_DESC));
|
||||
@@ -394,11 +395,10 @@ UsbParseConfigDesc (
|
||||
Setting = UsbParseInterfaceDesc (DescBuf, Len, &Consumed);
|
||||
|
||||
if (Setting == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: warning: failed to get interface setting, stop parsing now.\n"));
|
||||
break;
|
||||
|
||||
} else if (Setting->Desc.InterfaceNumber >= NumIf) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
|
||||
DEBUG ((DEBUG_ERROR, "UsbParseConfigDesc: malformatted interface descriptor\n"));
|
||||
|
||||
UsbFreeInterfaceDesc (Setting);
|
||||
goto ON_ERROR;
|
||||
@@ -427,7 +427,6 @@ ON_ERROR:
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
USB standard control transfer support routine. This
|
||||
function is used by USB device. It is possible that
|
||||
@@ -450,15 +449,15 @@ ON_ERROR:
|
||||
**/
|
||||
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
|
||||
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_USB_DEVICE_REQUEST DevReq;
|
||||
@@ -468,13 +467,13 @@ UsbCtrlRequest (
|
||||
|
||||
ASSERT ((UsbDev != NULL) && (UsbDev->Bus != NULL));
|
||||
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
|
||||
DevReq.Request = (UINT8) Request;
|
||||
DevReq.Value = Value;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = (UINT16) Length;
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (Direction, Type, Target);
|
||||
DevReq.Request = (UINT8)Request;
|
||||
DevReq.Value = Value;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = (UINT16)Length;
|
||||
|
||||
Len = Length;
|
||||
Len = Length;
|
||||
Status = UsbHcControlTransfer (
|
||||
UsbDev->Bus,
|
||||
UsbDev->Address,
|
||||
@@ -492,7 +491,6 @@ UsbCtrlRequest (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the standard descriptors.
|
||||
|
||||
@@ -510,15 +508,15 @@ UsbCtrlRequest (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbCtrlGetDesc (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINTN DescType,
|
||||
IN UINTN DescIndex,
|
||||
IN UINT16 LangId,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINTN DescType,
|
||||
IN UINTN DescIndex,
|
||||
IN UINT16 LangId,
|
||||
OUT VOID *Buf,
|
||||
IN UINTN Length
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -526,7 +524,7 @@ UsbCtrlGetDesc (
|
||||
USB_REQ_TYPE_STANDARD,
|
||||
USB_TARGET_DEVICE,
|
||||
USB_REQ_GET_DESCRIPTOR,
|
||||
(UINT16) ((DescType << 8) | DescIndex),
|
||||
(UINT16)((DescType << 8) | DescIndex),
|
||||
LangId,
|
||||
Buf,
|
||||
Length
|
||||
@@ -535,7 +533,6 @@ UsbCtrlGetDesc (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Return the max packet size for endpoint zero. This function
|
||||
is the first function called to get descriptors during bus
|
||||
@@ -549,13 +546,12 @@ UsbCtrlGetDesc (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbGetMaxPacketSize0 (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
EFI_USB_DEVICE_DESCRIPTOR DevDesc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
|
||||
//
|
||||
// Get the first 8 bytes of the device descriptor which contains
|
||||
@@ -569,6 +565,7 @@ UsbGetMaxPacketSize0 (
|
||||
UsbDev->MaxPacket0 = 1 << 9;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
UsbDev->MaxPacket0 = DevDesc.MaxPacketSize0;
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
@@ -579,7 +576,6 @@ UsbGetMaxPacketSize0 (
|
||||
return EFI_DEVICE_ERROR;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Get the device descriptor for the device.
|
||||
|
||||
@@ -591,11 +587,11 @@ UsbGetMaxPacketSize0 (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbGetDevDesc (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
EFI_STATUS Status;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DevDesc = AllocateZeroPool (sizeof (USB_DEVICE_DESC));
|
||||
|
||||
@@ -603,14 +599,14 @@ UsbGetDevDesc (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
Status = UsbCtrlGetDesc (
|
||||
UsbDev,
|
||||
USB_DESC_TYPE_DEVICE,
|
||||
0,
|
||||
0,
|
||||
DevDesc,
|
||||
sizeof (EFI_USB_DEVICE_DESCRIPTOR)
|
||||
);
|
||||
Status = UsbCtrlGetDesc (
|
||||
UsbDev,
|
||||
USB_DESC_TYPE_DEVICE,
|
||||
0,
|
||||
0,
|
||||
DevDesc,
|
||||
sizeof (EFI_USB_DEVICE_DESCRIPTOR)
|
||||
);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
gBS->FreePool (DevDesc);
|
||||
@@ -621,7 +617,6 @@ UsbGetDevDesc (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the indexed string for the language. It requires two
|
||||
steps to get a string, first to get the string's length. Then
|
||||
@@ -636,14 +631,14 @@ UsbGetDevDesc (
|
||||
**/
|
||||
EFI_USB_STRING_DESCRIPTOR *
|
||||
UsbGetOneString (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index,
|
||||
IN UINT16 LangId
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index,
|
||||
IN UINT16 LangId
|
||||
)
|
||||
{
|
||||
EFI_USB_STRING_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
UINT8 *Buf;
|
||||
EFI_USB_STRING_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
UINT8 *Buf;
|
||||
|
||||
//
|
||||
// First get two bytes which contains the string length.
|
||||
@@ -656,7 +651,8 @@ UsbGetOneString (
|
||||
if (EFI_ERROR (Status) ||
|
||||
(Desc.Length < OFFSET_OF (EFI_USB_STRING_DESCRIPTOR, Length) + sizeof (Desc.Length)) ||
|
||||
(Desc.Length % 2 != 0)
|
||||
) {
|
||||
)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -680,10 +676,9 @@ UsbGetOneString (
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return (EFI_USB_STRING_DESCRIPTOR *) Buf;
|
||||
return (EFI_USB_STRING_DESCRIPTOR *)Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build the language ID table for string descriptors.
|
||||
|
||||
@@ -694,14 +689,14 @@ UsbGetOneString (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbBuildLangTable (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_STRING_DESCRIPTOR *Desc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN Max;
|
||||
UINT16 *Point;
|
||||
EFI_USB_STRING_DESCRIPTOR *Desc;
|
||||
EFI_STATUS Status;
|
||||
UINTN Index;
|
||||
UINTN Max;
|
||||
UINT16 *Point;
|
||||
|
||||
//
|
||||
// The string of language ID zero returns the supported languages
|
||||
@@ -719,8 +714,8 @@ UsbBuildLangTable (
|
||||
|
||||
Status = EFI_SUCCESS;
|
||||
|
||||
Max = (Desc->Length - 2) / 2;
|
||||
Max = MIN(Max, USB_MAX_LANG_ID);
|
||||
Max = (Desc->Length - 2) / 2;
|
||||
Max = MIN (Max, USB_MAX_LANG_ID);
|
||||
|
||||
Point = Desc->String;
|
||||
for (Index = 0; Index < Max; Index++) {
|
||||
@@ -735,7 +730,6 @@ ON_EXIT:
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Retrieve the indexed configure for the device. USB device
|
||||
returns the configuration together with the interfaces for
|
||||
@@ -750,13 +744,13 @@ ON_EXIT:
|
||||
**/
|
||||
EFI_USB_CONFIG_DESCRIPTOR *
|
||||
UsbGetOneConfig (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Index
|
||||
)
|
||||
{
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
VOID *Buf;
|
||||
EFI_USB_CONFIG_DESCRIPTOR Desc;
|
||||
EFI_STATUS Status;
|
||||
VOID *Buf;
|
||||
|
||||
//
|
||||
// First get four bytes which contains the total length
|
||||
@@ -765,13 +759,17 @@ UsbGetOneConfig (
|
||||
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, &Desc, 8);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get descript length(%d) %r\n",
|
||||
Desc.TotalLength, Status));
|
||||
DEBUG ((
|
||||
DEBUG_ERROR,
|
||||
"UsbGetOneConfig: failed to get descript length(%d) %r\n",
|
||||
Desc.TotalLength,
|
||||
Status
|
||||
));
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
|
||||
DEBUG ((DEBUG_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength));
|
||||
|
||||
//
|
||||
// Reject if TotalLength even cannot cover itself.
|
||||
@@ -789,7 +787,7 @@ UsbGetOneConfig (
|
||||
Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_CONFIG, Index, 0, Buf, Desc.TotalLength);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbGetOneConfig: failed to get full descript %r\n", Status));
|
||||
|
||||
FreePool (Buf);
|
||||
return NULL;
|
||||
@@ -798,7 +796,6 @@ UsbGetOneConfig (
|
||||
return Buf;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Build the whole array of descriptors. This function must
|
||||
be called after UsbGetMaxPacketSize0 returns the max packet
|
||||
@@ -812,15 +809,15 @@ UsbGetOneConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbBuildDescTable (
|
||||
IN USB_DEVICE *UsbDev
|
||||
IN USB_DEVICE *UsbDev
|
||||
)
|
||||
{
|
||||
EFI_USB_CONFIG_DESCRIPTOR *Config;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
UINT8 NumConfig;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
EFI_USB_CONFIG_DESCRIPTOR *Config;
|
||||
USB_DEVICE_DESC *DevDesc;
|
||||
USB_CONFIG_DESC *ConfigDesc;
|
||||
UINT8 NumConfig;
|
||||
EFI_STATUS Status;
|
||||
UINT8 Index;
|
||||
|
||||
//
|
||||
// Get the device descriptor, then allocate the configure
|
||||
@@ -829,7 +826,7 @@ UsbBuildDescTable (
|
||||
Status = UsbGetDevDesc (UsbDev);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get device descriptor - %r\n", Status));
|
||||
return Status;
|
||||
}
|
||||
|
||||
@@ -844,7 +841,7 @@ UsbBuildDescTable (
|
||||
return EFI_OUT_OF_RESOURCES;
|
||||
}
|
||||
|
||||
DEBUG (( DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
|
||||
DEBUG ((DEBUG_INFO, "UsbBuildDescTable: device has %d configures\n", NumConfig));
|
||||
|
||||
//
|
||||
// Read each configurations, then parse them
|
||||
@@ -853,7 +850,7 @@ UsbBuildDescTable (
|
||||
Config = UsbGetOneConfig (UsbDev, Index);
|
||||
|
||||
if (Config == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to get configure (index %d)\n", Index));
|
||||
|
||||
//
|
||||
// If we can get the default descriptor, it is likely that the
|
||||
@@ -866,12 +863,12 @@ UsbBuildDescTable (
|
||||
break;
|
||||
}
|
||||
|
||||
ConfigDesc = UsbParseConfigDesc ((UINT8 *) Config, Config->TotalLength);
|
||||
ConfigDesc = UsbParseConfigDesc ((UINT8 *)Config, Config->TotalLength);
|
||||
|
||||
FreePool (Config);
|
||||
|
||||
if (ConfigDesc == NULL) {
|
||||
DEBUG (( DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
|
||||
DEBUG ((DEBUG_ERROR, "UsbBuildDescTable: failed to parse configure (index %d)\n", Index));
|
||||
|
||||
//
|
||||
// If we can get the default descriptor, it is likely that the
|
||||
@@ -894,13 +891,12 @@ UsbBuildDescTable (
|
||||
Status = UsbBuildLangTable (UsbDev);
|
||||
|
||||
if (EFI_ERROR (Status)) {
|
||||
DEBUG (( DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
|
||||
DEBUG ((DEBUG_INFO, "UsbBuildDescTable: get language ID table %r\n", Status));
|
||||
}
|
||||
|
||||
return EFI_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the device's address.
|
||||
|
||||
@@ -913,11 +909,11 @@ UsbBuildDescTable (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetAddress (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 Address
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -934,7 +930,6 @@ UsbSetAddress (
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Set the device's configuration. This function changes
|
||||
the device's internal state. UsbSelectConfig changes
|
||||
@@ -949,11 +944,11 @@ UsbSetAddress (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbSetConfig (
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
IN USB_DEVICE *UsbDev,
|
||||
IN UINT8 ConfigIndex
|
||||
)
|
||||
{
|
||||
EFI_STATUS Status;
|
||||
EFI_STATUS Status;
|
||||
|
||||
Status = UsbCtrlRequest (
|
||||
UsbDev,
|
||||
@@ -965,12 +960,11 @@ UsbSetConfig (
|
||||
0,
|
||||
NULL,
|
||||
0
|
||||
);
|
||||
);
|
||||
|
||||
return Status;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
Usb UsbIo interface to clear the feature. This is should
|
||||
only be used by HUB which is considered a device driver
|
||||
@@ -987,21 +981,21 @@ UsbSetConfig (
|
||||
**/
|
||||
EFI_STATUS
|
||||
UsbIoClearFeature (
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
IN EFI_USB_IO_PROTOCOL *UsbIo,
|
||||
IN UINTN Target,
|
||||
IN UINT16 Feature,
|
||||
IN UINT16 Index
|
||||
)
|
||||
{
|
||||
EFI_USB_DEVICE_REQUEST DevReq;
|
||||
UINT32 UsbResult;
|
||||
EFI_STATUS Status;
|
||||
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
|
||||
DevReq.Request = USB_REQ_CLEAR_FEATURE;
|
||||
DevReq.Value = Feature;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = 0;
|
||||
DevReq.RequestType = USB_REQUEST_TYPE (EfiUsbNoData, USB_REQ_TYPE_STANDARD, Target);
|
||||
DevReq.Request = USB_REQ_CLEAR_FEATURE;
|
||||
DevReq.Value = Feature;
|
||||
DevReq.Index = Index;
|
||||
DevReq.Length = 0;
|
||||
|
||||
Status = UsbIo->UsbControlTransfer (
|
||||
UsbIo,
|
||||
|
Reference in New Issue
Block a user