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:
Michael Kubacki
2021-12-05 14:54:02 -08:00
committed by mergify[bot]
parent 7c7184e201
commit 1436aea4d5
994 changed files with 107608 additions and 101311 deletions

View File

@@ -14,7 +14,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
//
// UsbIo PPI interface function
//
PEI_USB_IO_PPI mUsbIoPpi = {
PEI_USB_IO_PPI mUsbIoPpi = {
PeiUsbControlTransfer,
PeiUsbBulkTransfer,
PeiUsbGetInterfaceDescriptor,
@@ -22,7 +22,7 @@ PEI_USB_IO_PPI mUsbIoPpi = {
PeiUsbPortReset
};
EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
(EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
&gPeiUsbIoPpiGuid,
NULL
@@ -42,9 +42,9 @@ EFI_PEI_PPI_DESCRIPTOR mUsbIoPpiList = {
**/
EFI_STATUS
PeiUsbEnumeration (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
);
/**
@@ -62,10 +62,10 @@ PeiUsbEnumeration (
**/
EFI_STATUS
PeiConfigureUsbDevice (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 Port,
IN OUT UINT8 *DeviceAddress
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 Port,
IN OUT UINT8 *DeviceAddress
);
/**
@@ -81,8 +81,8 @@ PeiConfigureUsbDevice (
**/
EFI_STATUS
PeiUsbGetAllConfiguration (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice
);
/**
@@ -100,11 +100,11 @@ PeiUsbGetAllConfiguration (
**/
EFI_STATUS
GetExpectedDescriptor (
IN UINT8 *Buffer,
IN UINTN Length,
IN UINT8 DescType,
IN UINT8 DescLength,
OUT UINTN *ParsedBytes
IN UINT8 *Buffer,
IN UINTN Length,
IN UINT8 DescType,
IN UINT8 DescLength,
OUT UINTN *ParsedBytes
);
/**
@@ -121,14 +121,14 @@ GetExpectedDescriptor (
EFI_STATUS
EFIAPI
PeimInitializeUsb (
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
IN EFI_PEI_FILE_HANDLE FileHandle,
IN CONST EFI_PEI_SERVICES **PeiServices
)
{
EFI_STATUS Status;
UINTN Index;
PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
EFI_STATUS Status;
UINTN Index;
PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi;
PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi;
if (!EFI_ERROR (PeiServicesRegisterForShadow (FileHandle))) {
return EFI_SUCCESS;
@@ -147,7 +147,7 @@ PeimInitializeUsb (
&gPeiUsbHostControllerPpiGuid,
Index,
NULL,
(VOID **) &UsbHcPpi
(VOID **)&UsbHcPpi
);
if (EFI_ERROR (Status)) {
//
@@ -155,7 +155,8 @@ PeimInitializeUsb (
//
break;
}
PeiUsbEnumeration ((EFI_PEI_SERVICES **) PeiServices, UsbHcPpi, NULL);
PeiUsbEnumeration ((EFI_PEI_SERVICES **)PeiServices, UsbHcPpi, NULL);
Index++;
}
@@ -168,7 +169,7 @@ PeimInitializeUsb (
&gPeiUsb2HostControllerPpiGuid,
Index,
NULL,
(VOID **) &Usb2HcPpi
(VOID **)&Usb2HcPpi
);
if (EFI_ERROR (Status)) {
//
@@ -176,7 +177,8 @@ PeimInitializeUsb (
//
break;
}
PeiUsbEnumeration ((EFI_PEI_SERVICES **) PeiServices, NULL, Usb2HcPpi);
PeiUsbEnumeration ((EFI_PEI_SERVICES **)PeiServices, NULL, Usb2HcPpi);
Index++;
}
}
@@ -203,9 +205,9 @@ PeimInitializeUsb (
**/
EFI_STATUS
PeiHubEnumeration (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 *CurrentAddress
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 *CurrentAddress
)
{
UINTN Index;
@@ -218,19 +220,17 @@ PeiHubEnumeration (
UINTN InterfaceIndex;
UINTN EndpointIndex;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
DEBUG ((DEBUG_INFO, "PeiHubEnumeration: DownStreamPortNo: %x\n", PeiUsbDevice->DownStreamPortNo));
for (Index = 0; Index < PeiUsbDevice->DownStreamPortNo; Index++) {
Status = PeiHubGetPortStatus (
PeiServices,
UsbIoPpi,
(UINT8) (Index + 1),
(UINT32 *) &PortStatus
);
PeiServices,
UsbIoPpi,
(UINT8)(Index + 1),
(UINT32 *)&PortStatus
);
if (EFI_ERROR (Status)) {
continue;
@@ -248,22 +248,22 @@ PeiHubEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
NewPeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
NewPeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
ZeroMem (NewPeiUsbDevice, sizeof (PEI_USB_DEVICE));
NewPeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
NewPeiUsbDevice->DeviceAddress = 0;
NewPeiUsbDevice->MaxPacketSize0 = 8;
NewPeiUsbDevice->DataToggle = 0;
NewPeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
NewPeiUsbDevice->DeviceAddress = 0;
NewPeiUsbDevice->MaxPacketSize0 = 8;
NewPeiUsbDevice->DataToggle = 0;
CopyMem (
&(NewPeiUsbDevice->UsbIoPpi),
&mUsbIoPpi,
@@ -275,39 +275,40 @@ PeiHubEnumeration (
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
NewPeiUsbDevice->UsbIoPpiList.Ppi = &NewPeiUsbDevice->UsbIoPpi;
NewPeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
NewPeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
NewPeiUsbDevice->UsbHcPpi = PeiUsbDevice->UsbHcPpi;
NewPeiUsbDevice->Usb2HcPpi = PeiUsbDevice->Usb2HcPpi;
NewPeiUsbDevice->Tier = (UINT8) (PeiUsbDevice->Tier + 1);
NewPeiUsbDevice->Tier = (UINT8)(PeiUsbDevice->Tier + 1);
NewPeiUsbDevice->IsHub = 0x0;
NewPeiUsbDevice->DownStreamPortNo = 0x0;
if (((PortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) == 0) ||
((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0)) {
((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0))
{
//
// If the port already has reset change flag and is connected and enabled, skip the port reset logic.
//
PeiResetHubPort (PeiServices, UsbIoPpi, (UINT8)(Index + 1));
PeiHubGetPortStatus (
PeiServices,
UsbIoPpi,
(UINT8) (Index + 1),
(UINT32 *) &PortStatus
);
PeiServices,
UsbIoPpi,
(UINT8)(Index + 1),
(UINT32 *)&PortStatus
);
} else {
PeiHubClearPortFeature (
PeiServices,
UsbIoPpi,
(UINT8) (Index + 1),
(UINT8)(Index + 1),
EfiUsbPortResetChange
);
}
NewPeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
NewPeiUsbDevice->DeviceSpeed = (UINT8)PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed));
if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
NewPeiUsbDevice->MaxPacketSize0 = 512;
} else if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
NewPeiUsbDevice->MaxPacketSize0 = 64;
@@ -317,12 +318,12 @@ PeiHubEnumeration (
NewPeiUsbDevice->MaxPacketSize0 = 8;
}
if(NewPeiUsbDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
if (NewPeiUsbDevice->DeviceSpeed != EFI_USB_SPEED_HIGH) {
if (PeiUsbDevice->DeviceSpeed == EFI_USB_SPEED_HIGH) {
NewPeiUsbDevice->Translator.TranslatorPortNumber = (UINT8)Index;
NewPeiUsbDevice->Translator.TranslatorHubAddress = *CurrentAddress;
} else {
CopyMem(&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof(EFI_USB2_HC_TRANSACTION_TRANSLATOR));
CopyMem (&(NewPeiUsbDevice->Translator), &(PeiUsbDevice->Translator), sizeof (EFI_USB2_HC_TRANSACTION_TRANSLATOR));
}
}
@@ -330,21 +331,22 @@ PeiHubEnumeration (
// Configure that Usb Device
//
Status = PeiConfigureUsbDevice (
PeiServices,
NewPeiUsbDevice,
(UINT8) (Index + 1),
CurrentAddress
);
PeiServices,
NewPeiUsbDevice,
(UINT8)(Index + 1),
CurrentAddress
);
if (EFI_ERROR (Status)) {
continue;
}
DEBUG ((DEBUG_INFO, "PeiHubEnumeration: PeiConfigureUsbDevice Success\n"));
Status = PeiServicesInstallPpi (&NewPeiUsbDevice->UsbIoPpiList);
if (NewPeiUsbDevice->InterfaceDesc->InterfaceClass == 0x09) {
NewPeiUsbDevice->IsHub = 0x1;
NewPeiUsbDevice->IsHub = 0x1;
Status = PeiDoHubConfig (PeiServices, NewPeiUsbDevice);
if (EFI_ERROR (Status)) {
@@ -359,19 +361,20 @@ PeiHubEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem ((VOID *)(UINTN)AllocateAddress, NewPeiUsbDevice, sizeof (PEI_USB_DEVICE));
NewPeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
NewPeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
NewPeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
NewPeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
NewPeiUsbDevice->UsbIoPpiList.Ppi = &NewPeiUsbDevice->UsbIoPpi;
NewPeiUsbDevice->InterfaceDesc = NewPeiUsbDevice->InterfaceDescList[InterfaceIndex];
NewPeiUsbDevice->InterfaceDesc = NewPeiUsbDevice->InterfaceDescList[InterfaceIndex];
for (EndpointIndex = 0; EndpointIndex < NewPeiUsbDevice->InterfaceDesc->NumEndpoints; EndpointIndex++) {
NewPeiUsbDevice->EndpointDesc[EndpointIndex] = NewPeiUsbDevice->EndpointDescList[InterfaceIndex][EndpointIndex];
}
@@ -379,7 +382,7 @@ PeiHubEnumeration (
Status = PeiServicesInstallPpi (&NewPeiUsbDevice->UsbIoPpiList);
if (NewPeiUsbDevice->InterfaceDesc->InterfaceClass == 0x09) {
NewPeiUsbDevice->IsHub = 0x1;
NewPeiUsbDevice->IsHub = 0x1;
Status = PeiDoHubConfig (PeiServices, NewPeiUsbDevice);
if (EFI_ERROR (Status)) {
@@ -393,7 +396,6 @@ PeiHubEnumeration (
}
}
return EFI_SUCCESS;
}
@@ -411,9 +413,9 @@ PeiHubEnumeration (
**/
EFI_STATUS
PeiUsbEnumeration (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi
)
{
UINT8 NumOfRootPort;
@@ -430,15 +432,15 @@ PeiUsbEnumeration (
CurrentAddress = 0;
if (Usb2HcPpi != NULL) {
Usb2HcPpi->GetRootHubPortNumber (
PeiServices,
Usb2HcPpi,
(UINT8 *) &NumOfRootPort
);
PeiServices,
Usb2HcPpi,
(UINT8 *)&NumOfRootPort
);
} else if (UsbHcPpi != NULL) {
UsbHcPpi->GetRootHubPortNumber (
PeiServices,
UsbHcPpi,
(UINT8 *) &NumOfRootPort
(UINT8 *)&NumOfRootPort
);
} else {
ASSERT (FALSE);
@@ -453,19 +455,20 @@ PeiUsbEnumeration (
//
if (Usb2HcPpi != NULL) {
Usb2HcPpi->GetRootHubPortStatus (
PeiServices,
Usb2HcPpi,
(UINT8) Index,
&PortStatus
);
PeiServices,
Usb2HcPpi,
(UINT8)Index,
&PortStatus
);
} else {
UsbHcPpi->GetRootHubPortStatus (
PeiServices,
UsbHcPpi,
(UINT8) Index,
(UINT8)Index,
&PortStatus
);
}
DEBUG ((DEBUG_INFO, "USB Status --- Port: %x ConnectChange[%04x] Status[%04x]\n", Index, PortStatus.PortChangeStatus, PortStatus.PortStatus));
//
// Only handle connection/enable/overcurrent/reset change.
@@ -475,22 +478,22 @@ PeiUsbEnumeration (
} else {
if (IsPortConnect (PortStatus.PortStatus)) {
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
PeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
PeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
ZeroMem (PeiUsbDevice, sizeof (PEI_USB_DEVICE));
PeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
PeiUsbDevice->DeviceAddress = 0;
PeiUsbDevice->MaxPacketSize0 = 8;
PeiUsbDevice->DataToggle = 0;
PeiUsbDevice->Signature = PEI_USB_DEVICE_SIGNATURE;
PeiUsbDevice->DeviceAddress = 0;
PeiUsbDevice->MaxPacketSize0 = 8;
PeiUsbDevice->DataToggle = 0;
CopyMem (
&(PeiUsbDevice->UsbIoPpi),
&mUsbIoPpi,
@@ -501,15 +504,16 @@ PeiUsbEnumeration (
&mUsbIoPpiList,
sizeof (EFI_PEI_PPI_DESCRIPTOR)
);
PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
PeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
PeiUsbDevice->UsbHcPpi = UsbHcPpi;
PeiUsbDevice->Usb2HcPpi = Usb2HcPpi;
PeiUsbDevice->IsHub = 0x0;
PeiUsbDevice->DownStreamPortNo = 0x0;
PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
PeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
PeiUsbDevice->UsbHcPpi = UsbHcPpi;
PeiUsbDevice->Usb2HcPpi = Usb2HcPpi;
PeiUsbDevice->IsHub = 0x0;
PeiUsbDevice->DownStreamPortNo = 0x0;
if (((PortStatus.PortChangeStatus & USB_PORT_STAT_C_RESET) == 0) ||
((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0)) {
((PortStatus.PortStatus & (USB_PORT_STAT_CONNECTION | USB_PORT_STAT_ENABLE)) == 0))
{
//
// If the port already has reset change flag and is connected and enabled, skip the port reset logic.
//
@@ -525,39 +529,39 @@ PeiUsbEnumeration (
Usb2HcPpi->GetRootHubPortStatus (
PeiServices,
Usb2HcPpi,
(UINT8) Index,
(UINT8)Index,
&PortStatus
);
} else {
UsbHcPpi->GetRootHubPortStatus (
PeiServices,
UsbHcPpi,
(UINT8) Index,
(UINT8)Index,
&PortStatus
);
}
} else {
if (Usb2HcPpi != NULL) {
Usb2HcPpi->ClearRootHubPortFeature (
PeiServices,
Usb2HcPpi,
(UINT8) Index,
EfiUsbPortResetChange
);
PeiServices,
Usb2HcPpi,
(UINT8)Index,
EfiUsbPortResetChange
);
} else {
UsbHcPpi->ClearRootHubPortFeature (
PeiServices,
UsbHcPpi,
(UINT8) Index,
(UINT8)Index,
EfiUsbPortResetChange
);
}
}
PeiUsbDevice->DeviceSpeed = (UINT8) PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
PeiUsbDevice->DeviceSpeed = (UINT8)PeiUsbGetDeviceSpeed (PortStatus.PortStatus);
DEBUG ((DEBUG_INFO, "Device Speed =%d\n", PeiUsbDevice->DeviceSpeed));
if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)){
if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_SUPER_SPEED)) {
PeiUsbDevice->MaxPacketSize0 = 512;
} else if (USB_BIT_IS_SET (PortStatus.PortStatus, USB_PORT_STAT_HIGH_SPEED)) {
PeiUsbDevice->MaxPacketSize0 = 64;
@@ -571,15 +575,16 @@ PeiUsbEnumeration (
// Configure that Usb Device
//
Status = PeiConfigureUsbDevice (
PeiServices,
PeiUsbDevice,
Index,
&CurrentAddress
);
PeiServices,
PeiUsbDevice,
Index,
&CurrentAddress
);
if (EFI_ERROR (Status)) {
continue;
}
DEBUG ((DEBUG_INFO, "PeiUsbEnumeration: PeiConfigureUsbDevice Success\n"));
Status = PeiServicesInstallPpi (&PeiUsbDevice->UsbIoPpiList);
@@ -600,19 +605,20 @@ PeiUsbEnumeration (
// Begin to deal with the new device
//
MemPages = sizeof (PEI_USB_DEVICE) / EFI_PAGE_SIZE + 1;
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
Status = PeiServicesAllocatePages (
EfiBootServicesCode,
MemPages,
&AllocateAddress
);
if (EFI_ERROR (Status)) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem ((VOID *)(UINTN)AllocateAddress, PeiUsbDevice, sizeof (PEI_USB_DEVICE));
PeiUsbDevice = (PEI_USB_DEVICE *) ((UINTN) AllocateAddress);
PeiUsbDevice->AllocateAddress = (UINTN) AllocateAddress;
PeiUsbDevice = (PEI_USB_DEVICE *)((UINTN)AllocateAddress);
PeiUsbDevice->AllocateAddress = (UINTN)AllocateAddress;
PeiUsbDevice->UsbIoPpiList.Ppi = &PeiUsbDevice->UsbIoPpi;
PeiUsbDevice->InterfaceDesc = PeiUsbDevice->InterfaceDescList[InterfaceIndex];
PeiUsbDevice->InterfaceDesc = PeiUsbDevice->InterfaceDescList[InterfaceIndex];
for (EndpointIndex = 0; EndpointIndex < PeiUsbDevice->InterfaceDesc->NumEndpoints; EndpointIndex++) {
PeiUsbDevice->EndpointDesc[EndpointIndex] = PeiUsbDevice->EndpointDescList[InterfaceIndex][EndpointIndex];
}
@@ -656,16 +662,16 @@ PeiUsbEnumeration (
**/
EFI_STATUS
PeiConfigureUsbDevice (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 Port,
IN OUT UINT8 *DeviceAddress
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice,
IN UINT8 Port,
IN OUT UINT8 *DeviceAddress
)
{
EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
EFI_STATUS Status;
PEI_USB_IO_PPI *UsbIoPpi;
UINT8 Retry;
EFI_USB_DEVICE_DESCRIPTOR DeviceDescriptor;
EFI_STATUS Status;
PEI_USB_IO_PPI *UsbIoPpi;
UINT8 Retry;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
Status = EFI_SUCCESS;
@@ -674,7 +680,7 @@ PeiConfigureUsbDevice (
// Get USB device descriptor
//
for (Retry = 0; Retry < 3; Retry ++) {
for (Retry = 0; Retry < 3; Retry++) {
Status = PeiUsbGetDescriptor (
PeiServices,
UsbIoPpi,
@@ -701,18 +707,19 @@ PeiConfigureUsbDevice (
PeiUsbDevice->MaxPacketSize0 = DeviceDescriptor.MaxPacketSize0;
}
(*DeviceAddress) ++;
(*DeviceAddress)++;
Status = PeiUsbSetDeviceAddress (
PeiServices,
UsbIoPpi,
*DeviceAddress
);
PeiServices,
UsbIoPpi,
*DeviceAddress
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbSetDeviceAddress Failed: %r\n", Status));
return Status;
}
MicroSecondDelay (USB_SET_DEVICE_ADDRESS_STALL);
PeiUsbDevice->DeviceAddress = *DeviceAddress;
@@ -721,13 +728,13 @@ PeiConfigureUsbDevice (
// Get whole USB device descriptor
//
Status = PeiUsbGetDescriptor (
PeiServices,
UsbIoPpi,
(USB_DT_DEVICE << 8),
0,
(UINT16) sizeof (EFI_USB_DEVICE_DESCRIPTOR),
&DeviceDescriptor
);
PeiServices,
UsbIoPpi,
(USB_DT_DEVICE << 8),
0,
(UINT16)sizeof (EFI_USB_DEVICE_DESCRIPTOR),
&DeviceDescriptor
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGetDescriptor First Failed\n"));
@@ -738,18 +745,19 @@ PeiConfigureUsbDevice (
// Get its default configuration and its first interface
//
Status = PeiUsbGetAllConfiguration (
PeiServices,
PeiUsbDevice
);
PeiServices,
PeiUsbDevice
);
if (EFI_ERROR (Status)) {
return Status;
}
MicroSecondDelay (USB_GET_CONFIG_DESCRIPTOR_STALL);
Status = PeiUsbSetConfiguration (
PeiServices,
UsbIoPpi
);
PeiServices,
UsbIoPpi
);
if (EFI_ERROR (Status)) {
return Status;
@@ -771,20 +779,20 @@ PeiConfigureUsbDevice (
**/
EFI_STATUS
PeiUsbGetAllConfiguration (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_DEVICE *PeiUsbDevice
)
{
EFI_STATUS Status;
EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
PEI_USB_IO_PPI *UsbIoPpi;
UINT16 ConfigDescLength;
UINT8 *Ptr;
UINTN SkipBytes;
UINTN LengthLeft;
UINTN InterfaceIndex;
UINTN Index;
UINTN NumOfEndpoint;
EFI_STATUS Status;
EFI_USB_CONFIG_DESCRIPTOR *ConfigDesc;
PEI_USB_IO_PPI *UsbIoPpi;
UINT16 ConfigDescLength;
UINT8 *Ptr;
UINTN SkipBytes;
UINTN LengthLeft;
UINTN InterfaceIndex;
UINTN Index;
UINTN NumOfEndpoint;
UsbIoPpi = &PeiUsbDevice->UsbIoPpi;
@@ -792,22 +800,23 @@ PeiUsbGetAllConfiguration (
// First get its 4-byte configuration descriptor
//
Status = PeiUsbGetDescriptor (
PeiServices,
UsbIoPpi,
(USB_DT_CONFIG << 8), // Value
0, // Index
4, // Length
PeiUsbDevice->ConfigurationData
);
PeiServices,
UsbIoPpi,
(USB_DT_CONFIG << 8), // Value
0, // Index
4, // Length
PeiUsbDevice->ConfigurationData
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor First Failed\n"));
return Status;
}
MicroSecondDelay (USB_GET_CONFIG_DESCRIPTOR_STALL);
ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *) PeiUsbDevice->ConfigurationData;
ConfigDescLength = ConfigDesc->TotalLength;
ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *)PeiUsbDevice->ConfigurationData;
ConfigDescLength = ConfigDesc->TotalLength;
//
// Reject if TotalLength even cannot cover itself.
@@ -827,52 +836,52 @@ PeiUsbGetAllConfiguration (
// Then we get the total descriptors for this configuration
//
Status = PeiUsbGetDescriptor (
PeiServices,
UsbIoPpi,
(USB_DT_CONFIG << 8),
0,
ConfigDescLength,
PeiUsbDevice->ConfigurationData
);
PeiServices,
UsbIoPpi,
(USB_DT_CONFIG << 8),
0,
ConfigDescLength,
PeiUsbDevice->ConfigurationData
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "PeiUsbGet Config Descriptor all Failed\n"));
return Status;
}
//
// Parse this configuration descriptor
// First get the current config descriptor;
//
Status = GetExpectedDescriptor (
PeiUsbDevice->ConfigurationData,
ConfigDescLength,
USB_DT_CONFIG,
(UINT8) sizeof (EFI_USB_CONFIG_DESCRIPTOR),
&SkipBytes
);
PeiUsbDevice->ConfigurationData,
ConfigDescLength,
USB_DT_CONFIG,
(UINT8)sizeof (EFI_USB_CONFIG_DESCRIPTOR),
&SkipBytes
);
if (EFI_ERROR (Status)) {
return Status;
}
Ptr = PeiUsbDevice->ConfigurationData + SkipBytes;
PeiUsbDevice->ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *) Ptr;
Ptr = PeiUsbDevice->ConfigurationData + SkipBytes;
PeiUsbDevice->ConfigDesc = (EFI_USB_CONFIG_DESCRIPTOR *)Ptr;
Ptr += sizeof (EFI_USB_CONFIG_DESCRIPTOR);
Ptr += sizeof (EFI_USB_CONFIG_DESCRIPTOR);
LengthLeft = ConfigDescLength - SkipBytes - sizeof (EFI_USB_CONFIG_DESCRIPTOR);
for (InterfaceIndex = 0; InterfaceIndex < PeiUsbDevice->ConfigDesc->NumInterfaces; InterfaceIndex++) {
//
// Get the interface descriptor
//
Status = GetExpectedDescriptor (
Ptr,
LengthLeft,
USB_DT_INTERFACE,
(UINT8) sizeof (EFI_USB_INTERFACE_DESCRIPTOR),
&SkipBytes
);
Ptr,
LengthLeft,
USB_DT_INTERFACE,
(UINT8)sizeof (EFI_USB_INTERFACE_DESCRIPTOR),
&SkipBytes
);
if (EFI_ERROR (Status)) {
return Status;
@@ -880,11 +889,12 @@ PeiUsbGetAllConfiguration (
Ptr += SkipBytes;
if (InterfaceIndex == 0) {
PeiUsbDevice->InterfaceDesc = (EFI_USB_INTERFACE_DESCRIPTOR *) Ptr;
PeiUsbDevice->InterfaceDesc = (EFI_USB_INTERFACE_DESCRIPTOR *)Ptr;
}
PeiUsbDevice->InterfaceDescList[InterfaceIndex] = (EFI_USB_INTERFACE_DESCRIPTOR *) Ptr;
Ptr += sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
PeiUsbDevice->InterfaceDescList[InterfaceIndex] = (EFI_USB_INTERFACE_DESCRIPTOR *)Ptr;
Ptr += sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
LengthLeft -= SkipBytes;
LengthLeft -= sizeof (EFI_USB_INTERFACE_DESCRIPTOR);
@@ -899,12 +909,12 @@ PeiUsbGetAllConfiguration (
// Get the endpoint descriptor
//
Status = GetExpectedDescriptor (
Ptr,
LengthLeft,
USB_DT_ENDPOINT,
(UINT8) sizeof (EFI_USB_ENDPOINT_DESCRIPTOR),
&SkipBytes
);
Ptr,
LengthLeft,
USB_DT_ENDPOINT,
(UINT8)sizeof (EFI_USB_ENDPOINT_DESCRIPTOR),
&SkipBytes
);
if (EFI_ERROR (Status)) {
return Status;
@@ -912,11 +922,12 @@ PeiUsbGetAllConfiguration (
Ptr += SkipBytes;
if (InterfaceIndex == 0) {
PeiUsbDevice->EndpointDesc[Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *) Ptr;
PeiUsbDevice->EndpointDesc[Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *)Ptr;
}
PeiUsbDevice->EndpointDescList[InterfaceIndex][Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *) Ptr;
Ptr += sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
PeiUsbDevice->EndpointDescList[InterfaceIndex][Index] = (EFI_USB_ENDPOINT_DESCRIPTOR *)Ptr;
Ptr += sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
LengthLeft -= SkipBytes;
LengthLeft -= sizeof (EFI_USB_ENDPOINT_DESCRIPTOR);
}
@@ -940,15 +951,15 @@ PeiUsbGetAllConfiguration (
**/
EFI_STATUS
GetExpectedDescriptor (
IN UINT8 *Buffer,
IN UINTN Length,
IN UINT8 DescType,
IN UINT8 DescLength,
OUT UINTN *ParsedBytes
IN UINT8 *Buffer,
IN UINTN Length,
IN UINT8 DescType,
IN UINT8 DescLength,
OUT UINTN *ParsedBytes
)
{
USB_DESC_HEAD *Head;
UINTN Offset;
USB_DESC_HEAD *Head;
UINTN Offset;
//
// Total length is too small that cannot hold the single descriptor header plus data.
@@ -1020,17 +1031,16 @@ GetExpectedDescriptor (
**/
VOID
ResetRootPort (
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
IN UINT8 PortNum,
IN UINT8 RetryIndex
IN EFI_PEI_SERVICES **PeiServices,
IN PEI_USB_HOST_CONTROLLER_PPI *UsbHcPpi,
IN PEI_USB2_HOST_CONTROLLER_PPI *Usb2HcPpi,
IN UINT8 PortNum,
IN UINT8 RetryIndex
)
{
EFI_STATUS Status;
UINTN Index;
EFI_USB_PORT_STATUS PortStatus;
EFI_STATUS Status;
UINTN Index;
EFI_USB_PORT_STATUS PortStatus;
if (Usb2HcPpi != NULL) {
MicroSecondDelay (200 * 1000);
@@ -1039,11 +1049,11 @@ ResetRootPort (
// reset root port
//
Status = Usb2HcPpi->SetRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortReset
);
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortReset
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "SetRootHubPortFeature EfiUsbPortReset Failed\n"));
@@ -1060,11 +1070,11 @@ ResetRootPort (
// clear reset root port
//
Status = Usb2HcPpi->ClearRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortReset
);
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortReset
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "ClearRootHubPortFeature EfiUsbPortReset Failed\n"));
@@ -1103,35 +1113,35 @@ ResetRootPort (
}
Usb2HcPpi->ClearRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortResetChange
);
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortResetChange
);
Usb2HcPpi->ClearRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortConnectChange
);
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortConnectChange
);
//
// Set port enable
//
Usb2HcPpi->SetRootHubPortFeature(
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortEnable
);
Usb2HcPpi->SetRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortEnable
);
Usb2HcPpi->ClearRootHubPortFeature (
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortEnableChange
);
PeiServices,
Usb2HcPpi,
PortNum,
EfiUsbPortEnableChange
);
MicroSecondDelay ((RetryIndex + 1) * 50 * 1000);
} else {
@@ -1221,7 +1231,7 @@ ResetRootPort (
//
// Set port enable
//
UsbHcPpi->SetRootHubPortFeature(
UsbHcPpi->SetRootHubPortFeature (
PeiServices,
UsbHcPpi,
PortNum,
@@ -1237,5 +1247,6 @@ ResetRootPort (
MicroSecondDelay ((RetryIndex + 1) * 50 * 1000);
}
return;
}