From 8fc250a95c62f3887a98101a45ad5fb7388ea5a5 Mon Sep 17 00:00:00 2001 From: SergeySlice Date: Sat, 7 May 2022 17:03:25 +0300 Subject: [PATCH] reconsideration of USB protocol revert UUID endianess to traitional Signed-off-by: SergeySlice --- Drivers/UsbBusDxe/ComponentName.c | 8 +- Drivers/UsbBusDxe/UsbBus.c | 28 +++--- Drivers/UsbBusDxe/UsbBus.h | 10 +-- Drivers/UsbBusDxe/UsbBusDxe.inf | 18 ++-- Drivers/UsbBusDxe/UsbBusDxe.uni | Bin 1934 -> 1168 bytes Drivers/UsbBusDxe/UsbBusDxeExtra.uni | Bin 1336 -> 568 bytes Drivers/UsbBusDxe/UsbDesc.c | 81 +++++++++++++----- Drivers/UsbBusDxe/UsbDesc.h | 8 +- Drivers/UsbBusDxe/UsbEnumer.c | 49 ++++++----- Drivers/UsbBusDxe/UsbHub.h | 12 +-- Drivers/UsbBusDxe/UsbUtility.c | 2 +- Drivers/UsbBusDxe/UsbUtility.h | 10 +-- Drivers/XhciDxe/Xhci.c | 24 ++++-- Drivers/XhciDxe/Xhci.h | 2 +- MdePkg/Include/Protocol/Usb2HostController.h | 2 +- .../ConfigPlist/Config_SystemParameters.h | 2 +- rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h | 2 +- rEFIt_UEFI/refit/main.cpp | 4 + 18 files changed, 142 insertions(+), 120 deletions(-) diff --git a/Drivers/UsbBusDxe/ComponentName.c b/Drivers/UsbBusDxe/ComponentName.c index dc0020863..642f93641 100644 --- a/Drivers/UsbBusDxe/ComponentName.c +++ b/Drivers/UsbBusDxe/ComponentName.c @@ -3,13 +3,7 @@ UEFI Component Name(2) protocol implementation for Usb Bus driver. Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/Drivers/UsbBusDxe/UsbBus.c b/Drivers/UsbBusDxe/UsbBus.c index 97ab4437f..9ecff4b2d 100644 --- a/Drivers/UsbBusDxe/UsbBus.c +++ b/Drivers/UsbBusDxe/UsbBus.c @@ -2,14 +2,8 @@ Usb Bus Driver Binding and Bus IO Protocol. -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -95,6 +89,7 @@ UsbIoControlTransfer ( USB_ENDPOINT_DESC *EpDesc; EFI_TPL OldTpl; EFI_STATUS Status; + UINTN RequestedDataLength; if (UsbStatus == NULL) { return EFI_INVALID_PARAMETER; @@ -105,6 +100,7 @@ UsbIoControlTransfer ( UsbIf = USB_INTERFACE_FROM_USBIO (This); Dev = UsbIf->Device; + RequestedDataLength = DataLength; Status = UsbHcControlTransfer ( Dev->Bus, Dev->Address, @@ -118,6 +114,18 @@ UsbIoControlTransfer ( &Dev->Translator, UsbStatus ); + // + // If the request completed sucessfully and the Direction of the request is + // EfiUsbDataIn or EfiUsbDataOut, then make sure the actual number of bytes + // transfered is the same as the number of bytes requested. If a different + // number of bytes were transfered, then return EFI_DEVICE_ERROR. + // + if (!EFI_ERROR(Status)) { + if (Direction != EfiUsbNoData && DataLength != RequestedDataLength) { + Status = EFI_DEVICE_ERROR; + goto ON_EXIT; + } + } if (EFI_ERROR(Status) || (*UsbStatus != EFI_USB_NOERROR)) { // @@ -282,7 +290,7 @@ UsbIoBulkTransfer ( Dev->Speed, EpDesc->Desc.MaxPacketSize, BufNum, - &Data, + Data, DataLength, &Toggle, Timeout, @@ -297,7 +305,7 @@ UsbIoBulkTransfer ( // Clear TT buffer when CTRL/BULK split transaction failes. // Clear the TRANSLATOR TT buffer, not parent's buffer // - ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices); +// ASSERT (Dev->Translator.TranslatorHubAddress < Dev->Bus->MaxDevices); if (Dev->Translator.TranslatorHubAddress != 0) { UsbHubCtrlClearTTBuffer ( Dev->Bus->Devices[Dev->Translator.TranslatorHubAddress], diff --git a/Drivers/UsbBusDxe/UsbBus.h b/Drivers/UsbBusDxe/UsbBus.h index c1fc0853f..c304d115a 100644 --- a/Drivers/UsbBusDxe/UsbBus.h +++ b/Drivers/UsbBusDxe/UsbBus.h @@ -2,14 +2,8 @@ Usb Bus Driver Binding and Bus IO Protocol. -Copyright (c) 2004 - 2012, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/Drivers/UsbBusDxe/UsbBusDxe.inf b/Drivers/UsbBusDxe/UsbBusDxe.inf index 9db8c004a..5f0f0aa12 100644 --- a/Drivers/UsbBusDxe/UsbBusDxe.inf +++ b/Drivers/UsbBusDxe/UsbBusDxe.inf @@ -1,15 +1,9 @@ ## @file # The Usb Bus Dxe driver is used to enumerate and manage all attached usb devices. -# -# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.
# -# This program and the accompanying materials -# are licensed and made available under the terms and conditions of the BSD License -# which accompanies this distribution. The full text of the license may be found at -# http://opensource.org/licenses/bsd-license.php +# Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
# -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# SPDX-License-Identifier: BSD-2-Clause-Patent # # ## @@ -27,9 +21,9 @@ # # The following information is for reference only and not required by the build tools. # -# VALID_ARCHITECTURES = IA32 X64 IPF EBC +# VALID_ARCHITECTURES = IA32 X64 EBC ARM AARCH64 # -# DRIVER_BINDING = mUsbBusDriverBinding +# DRIVER_BINDING = mUsbBusDriverBinding # COMPONENT_NAME = mUsbBusComponentName # COMPONENT_NAME2 = mUsbBusComponentName2 # @@ -66,7 +60,9 @@ [Protocols] gEfiUsbIoProtocolGuid ## BY_START - gEfiDevicePathProtocolGuid ## BY_START + ## TO_START + ## BY_START + gEfiDevicePathProtocolGuid gEfiUsb2HcProtocolGuid ## TO_START gEfiUsbHcProtocolGuid ## TO_START diff --git a/Drivers/UsbBusDxe/UsbBusDxe.uni b/Drivers/UsbBusDxe/UsbBusDxe.uni index 70f9e62436750e2351486abe9b5cf09ca66710af..7d45a3768ffc6dd1a517bcf03eea6f359003b0e3 100644 GIT binary patch delta 106 zcmeC6vgkeiT}ffzNl%78smd8MvzrEY9X+s^{H9DNeVRVisheIe`jVtfY8(@ zV>Y`pbLVpIx#!*)e*dal-2&ccJb}HpiOucC#`f4AVbxx2GuDCiEwuq-(|#}utYvr3 zKC(5x*)U&Yox44GjBUg^vlZX5E&0{L`6Sqcmtd2}!p#z!=GGhHYd7ObZ0MrPPne27 z!f!*IA!BOiCDUV!d$8SQd}X0S_&1FE=Hoxi_ya24+SVyKCF2a1Pss2o<4b$a^P1UN zzItJ=?38(gg3?lY31JO}zS3^aY>7I7HQ1Mja`xD&-rA|BnyGRlJl~>K*WTTur?2ZR z{wq)vV*yH0!z}L+)oX~y0w&tq5_5^aud=v`MFO9+j3X4W39$OAF3avI@YN$yQN9~q z^=Lvjs8iJ$>LlNP1rr}@0aC?M%;Y&Q_0jH%o>!mxE^kt^7VEEjT&mvsiJw@`9PWO$ zb2tc5SY9v1N?9xG0X%o>66X;o*nNe>`3|2$PW!reEw^|LT=o+(@Cqo?Y)4o1QAQ=+ zxRb07(>Y9?|C$`eR9*ctWq&_Lie-T3h@RWuIR|CNTPae_V*BjQSBE}o+b6ya`v%Vl zO?6*rjIl;^TAx|ylzG|&k3bbh+ePoP5_j1YGsagwit4>S;;ZQ28NaY2<~oUC9>r%7+Es~D zp+{)Zp|2FPb@blS9b9+ZrK#SNvU~g~^7>ta)CQvuT4>iWl3r4_fm$(q?t4zCrq0xq zjwxs5oZ@ Ov+Dor|M)kkwD|+P7%Z;< diff --git a/Drivers/UsbBusDxe/UsbBusDxeExtra.uni b/Drivers/UsbBusDxe/UsbBusDxeExtra.uni index 305ab09c3e2b9cd9814f2e9ffb80fcbe55411315..7655ba3d4de512a29192cd2b3b316951a0543812 100644 GIT binary patch delta 105 zcmdnNwS#5C7DkJSTXX$`83Gtw7$O*S8GINr8Il=N8S)s4fut^jCqoLDR{|7I1L9PM uA_gl41qLUEV4x0N1|uMLX2@YkWGIE|2w+H@m?=HEgC%J49TufYtQG+A3>QHF literal 1336 zcmZXUOK%fF5QO`T#D5q$7eI;4>x2-(#tW=Syq05&aEjJ;;;iIHv^F8;#{*yWzTzNj zXL@>is%xs-^Y>53Iu`g|@C)|Qt}U~rUD;E6f>(PJ+uGE6_LI49_v{5bwT;azB{H+$ zc;@)dZD%>_wJnGY?5^GaiP$xJS3Xv_)f`Owx3>4Q3%emQ*fY?dGrzW%_R8L1oz$zh zc8ndDm`iLSvgOO|&bhbkJ@*^ghx*nHyD^M1zt1i4 z8&H&E1xj_l9TCzbh4YMv6->0ZFSQ7G#7g-xtR-j-eu`J8rQ{52?aZWSg|E}|GQ%CV z>XT9tRVh#vsVwY3j)F;%Yvrsf6fsj|R_h}rHq^U0*Q17g)~5$t8m_-wiy7npx6R-n zL~$teQm!p)-Fgbohjo#vVtaapv#pkYco7?Bqv-3#%EuJaN=k(lR_BJRte3c^A9Bgb~ErQjME=ueRW7p1D$0!=m zRPz{bOrK4#BG-9h1Lg>SgV59n@qZY=A!oRTzn9AF&d5`IK`^lwy>%i26*dPX1v2#*Ucle;Acnid#f>QR6h|F%tNG-n)7ua-tMleg6O}yv$z! diff --git a/Drivers/UsbBusDxe/UsbDesc.c b/Drivers/UsbBusDxe/UsbDesc.c index 326fcb144..bd2555fd9 100644 --- a/Drivers/UsbBusDxe/UsbDesc.c +++ b/Drivers/UsbBusDxe/UsbDesc.c @@ -2,14 +2,8 @@ Manage Usb Descriptor List -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -177,6 +171,18 @@ UsbCreateDesc ( DescLen = sizeof (EFI_USB_ENDPOINT_DESCRIPTOR); CtrlLen = sizeof (USB_ENDPOINT_DESC); break; + + default: + // ASSERT (FALSE); + return NULL; + } + + // + // Total length is too small that cannot hold the single descriptor header plus data. + // + if (Len <= sizeof (USB_DESC_HEAD)) { + DEBUG ((DEBUG_ERROR, "UsbCreateDesc: met mal-format descriptor, total length = %d!\n", Len)); + return NULL; } // @@ -184,24 +190,44 @@ UsbCreateDesc ( // format. Skip the descriptor that isn't of this Type // Offset = 0; - Head = (USB_DESC_HEAD*)DescBuf; + Head = (USB_DESC_HEAD *)DescBuf; + while (Offset < Len - sizeof (USB_DESC_HEAD)) { + // + // Above condition make sure Head->Len and Head->Type are safe to access + // + Head = (USB_DESC_HEAD *)&DescBuf[Offset]; - while ((Offset < Len) && (Head->Type != Type)) { - Offset += Head->Len; - if (Len <= Offset) { - DEBUG (( EFI_D_ERROR, "UsbCreateDesc: met mal-format descriptor, Beyond boundary!\n")); + if (Head->Len == 0) { + DEBUG ((DEBUG_ERROR, "UsbCreateDesc: met mal-format descriptor, Head->Len = 0!\n")); return NULL; } - Head = (USB_DESC_HEAD*)(DescBuf + Offset); - if (Head->Len == 0) { - DEBUG (( EFI_D_ERROR, "UsbCreateDesc: met mal-format descriptor, Head->Len = 0!\n")); + + // + // Make sure no overflow when adding Head->Len to Offset. + // + if (Head->Len > MAX_UINTN - Offset) { + DEBUG ((DEBUG_ERROR, "UsbCreateDesc: met mal-format descriptor, Head->Len = %d!\n", Head->Len)); return NULL; } + + Offset += Head->Len; + + if (Head->Type == Type) { + break; + } } - if ((Len <= Offset) || (Len < Offset + Head->Len) || - (Head->Type != Type) || (Head->Len < DescLen)) { - DEBUG (( EFI_D_ERROR, "UsbCreateDesc: met mal-format descriptor\n")); + // + // Head->Len is invalid resulting data beyond boundary, or + // Descriptor cannot be found: No such type. + // + if (Len < Offset) { + DEBUG ((DEBUG_ERROR, "UsbCreateDesc: met mal-format descriptor, Offset/Len = %d/%d!\n", Offset, Len)); + return NULL; + } + + if ((Head->Type != Type) || (Head->Len < DescLen)) { + DEBUG ((DEBUG_ERROR, "UsbCreateDesc: descriptor cannot be found, Header(T/L) = %d/%d!\n", Head->Type, Head->Len)); return NULL; } @@ -212,7 +238,7 @@ UsbCreateDesc ( CopyMem(Desc, Head, (UINTN) DescLen); - *Consumed = Offset + Head->Len; + *Consumed = Offset; return Desc; } @@ -627,7 +653,13 @@ UsbGetOneString ( // Status = UsbCtrlGetDesc (UsbDev, USB_DESC_TYPE_STRING, Index, LangId, &Desc, 2); - if (EFI_ERROR(Status)) { + // + // Reject if Length even cannot cover itself, or odd because Unicode string byte length should be even. + // + if (EFI_ERROR(Status) || + (Desc.Length < OFFSET_OF (EFI_USB_STRING_DESCRIPTOR, Length) + sizeof (Desc.Length)) || + (Desc.Length % 2 != 0) + ) { return NULL; } @@ -744,6 +776,13 @@ UsbGetOneConfig ( DEBUG (( EFI_D_INFO, "UsbGetOneConfig: total length is %d\n", Desc.TotalLength)); + // + // Reject if TotalLength even cannot cover itself. + // + if (Desc.TotalLength < OFFSET_OF (EFI_USB_CONFIG_DESCRIPTOR, TotalLength) + sizeof (Desc.TotalLength)) { + return NULL; + } + Buf = AllocateZeroPool(Desc.TotalLength); if (Buf == NULL) { diff --git a/Drivers/UsbBusDxe/UsbDesc.h b/Drivers/UsbBusDxe/UsbDesc.h index 482a71f33..7b0c77fdc 100644 --- a/Drivers/UsbBusDxe/UsbDesc.h +++ b/Drivers/UsbBusDxe/UsbDesc.h @@ -3,13 +3,7 @@ Manage Usb Descriptor List Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +SPDX-License-Identifier: BSD-2-Clause-Patent **/ diff --git a/Drivers/UsbBusDxe/UsbEnumer.c b/Drivers/UsbBusDxe/UsbEnumer.c index 3888931c6..5c26a7932 100644 --- a/Drivers/UsbBusDxe/UsbEnumer.c +++ b/Drivers/UsbBusDxe/UsbEnumer.c @@ -2,14 +2,8 @@ Usb bus enumeration support. -Copyright (c) 2007 - 2013, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -71,28 +65,33 @@ UsbGetEndpointDesc ( @param UsbIf The USB interface to free. -**/ -VOID + @retval EFI_ACCESS_DENIED The interface is still occupied. + @retval EFI_SUCCESS The interface is freed. +**/ +EFI_STATUS UsbFreeInterface ( IN USB_INTERFACE *UsbIf ) { + EFI_STATUS Status; + UsbCloseHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle); - gBS->UninstallMultipleProtocolInterfaces ( - UsbIf->Handle, - &gEfiDevicePathProtocolGuid, - UsbIf->DevicePath, - &gEfiUsbIoProtocolGuid, - &UsbIf->UsbIo, - NULL - ); - - if (UsbIf->DevicePath != NULL) { - FreePool(UsbIf->DevicePath); - } - - FreePool(UsbIf); + Status = gBS->UninstallMultipleProtocolInterfaces ( + UsbIf->Handle, + &gEfiDevicePathProtocolGuid, UsbIf->DevicePath, + &gEfiUsbIoProtocolGuid, &UsbIf->UsbIo, + NULL + ); + if (!EFI_ERROR(Status)) { + if (UsbIf->DevicePath != NULL) { + FreePool(UsbIf->DevicePath); + } + FreePool(UsbIf); + } else { + UsbOpenHostProtoByChild (UsbIf->Device->Bus, UsbIf->Handle); + } + return Status; } @@ -185,7 +184,7 @@ UsbCreateInterface ( if (EFI_ERROR(Status)) { gBS->UninstallMultipleProtocolInterfaces ( - &UsbIf->Handle, + UsbIf->Handle, &gEfiDevicePathProtocolGuid, UsbIf->DevicePath, &gEfiUsbIoProtocolGuid, diff --git a/Drivers/UsbBusDxe/UsbHub.h b/Drivers/UsbBusDxe/UsbHub.h index 4e5fcd85e..78d1f9f01 100644 --- a/Drivers/UsbBusDxe/UsbHub.h +++ b/Drivers/UsbBusDxe/UsbHub.h @@ -2,14 +2,8 @@ The definition for USB hub. -Copyright (c) 2007 - 2010, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +Copyright (c) 2007 - 2018, Intel Corporation. All rights reserved.
+SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -96,7 +90,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #define USB_HUB_SUBCLASS_CODE 0x00 // -// Host software return timeout if port status doesn't change +// Host software return timeout if port status doesn't change // after 500ms(LOOP * STALL = 5000 * 0.1ms), set by experience // #define USB_WAIT_PORT_STS_CHANGE_LOOP 5000 diff --git a/Drivers/UsbBusDxe/UsbUtility.c b/Drivers/UsbBusDxe/UsbUtility.c index 07fba6cf8..da98074e6 100644 --- a/Drivers/UsbBusDxe/UsbUtility.c +++ b/Drivers/UsbBusDxe/UsbUtility.c @@ -386,7 +386,7 @@ UsbHcBulkTransfer ( IN UINT8 DevSpeed, IN UINTN MaxPacket, IN UINT8 BufferNum, - IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT VOID **Data, //[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, diff --git a/Drivers/UsbBusDxe/UsbUtility.h b/Drivers/UsbBusDxe/UsbUtility.h index 26709caa3..e8894d5c8 100644 --- a/Drivers/UsbBusDxe/UsbUtility.h +++ b/Drivers/UsbBusDxe/UsbUtility.h @@ -3,13 +3,7 @@ Manage Usb Port/Hc/Etc. Copyright (c) 2007, Intel Corporation. All rights reserved.
-This program and the accompanying materials -are licensed and made available under the terms and conditions of the BSD License -which accompanies this distribution. The full text of the license may be found at -http://opensource.org/licenses/bsd-license.php - -THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, -WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +SPDX-License-Identifier: BSD-2-Clause-Patent **/ @@ -204,7 +198,7 @@ UsbHcBulkTransfer ( IN UINT8 DevSpeed, IN UINTN MaxPacket, IN UINT8 BufferNum, - IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT VOID **Data, //[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, diff --git a/Drivers/XhciDxe/Xhci.c b/Drivers/XhciDxe/Xhci.c index e3f344921..a1786849e 100644 --- a/Drivers/XhciDxe/Xhci.c +++ b/Drivers/XhciDxe/Xhci.c @@ -800,7 +800,10 @@ XhcTransfer ( EFI_STATUS RecoveryStatus; URB *Urb; - ASSERT ((Type == XHC_CTRL_TRANSFER) || (Type == XHC_BULK_TRANSFER) || (Type == XHC_INT_TRANSFER_SYNC)); +// ASSERT ((Type == XHC_CTRL_TRANSFER) || (Type == XHC_BULK_TRANSFER) || (Type == XHC_INT_TRANSFER_SYNC)); + if ((Type != XHC_CTRL_TRANSFER) && (Type != XHC_BULK_TRANSFER) && (Type != XHC_INT_TRANSFER_SYNC)) { + return EFI_INVALID_PARAMETER; + } Urb = XhcCreateUrb ( Xhc, DeviceAddress, @@ -832,7 +835,10 @@ XhcTransfer ( // The URB is finished just before stopping endpoint. // Change returning status from EFI_TIMEOUT to EFI_SUCCESS. // - ASSERT (Urb->Result == EFI_USB_NOERROR); + // ASSERT (Urb->Result == EFI_USB_NOERROR); + if (Urb->Result != EFI_USB_NOERROR) { + return EFI_DEVICE_ERROR; + } Status = EFI_SUCCESS; DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: pending URB is finished, Length = %d.\n", Type, Urb->Completed)); } else if (EFI_ERROR(RecoveryStatus)) { @@ -844,7 +850,7 @@ XhcTransfer ( *DataLength = Urb->Completed; if ((*TransferResult == EFI_USB_ERR_STALL) || (*TransferResult == EFI_USB_ERR_BABBLE)) { - ASSERT (Status == EFI_DEVICE_ERROR); +// ASSERT (Status == EFI_DEVICE_ERROR); RecoveryStatus = XhcRecoverHaltedEndpoint(Xhc, Urb); if (EFI_ERROR(RecoveryStatus)) { DEBUG ((DEBUG_ERROR, "XhcTransfer[Type=%d]: XhcRecoverHaltedEndpoint failed!\n", Type)); @@ -1285,7 +1291,7 @@ XhcBulkTransfer ( IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, - IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT VOID **Data, //[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN Timeout, @@ -1302,7 +1308,7 @@ XhcBulkTransfer ( // Validate the parameters // if ((DataLength == NULL) || (*DataLength == 0) || - (Data == NULL) || (Data[0] == NULL) || (TransferResult == NULL)) { + (Data == NULL) || (*Data == NULL) || (TransferResult == NULL)) { return EFI_INVALID_PARAMETER; } @@ -1350,10 +1356,10 @@ XhcBulkTransfer ( MaximumPacketLength, XHC_BULK_TRANSFER, NULL, - Data[0], - DataLength, - Timeout, - TransferResult + *Data, + DataLength, + Timeout, + TransferResult ); ON_EXIT: diff --git a/Drivers/XhciDxe/Xhci.h b/Drivers/XhciDxe/Xhci.h index 823d5b0c5..790ab23a0 100644 --- a/Drivers/XhciDxe/Xhci.h +++ b/Drivers/XhciDxe/Xhci.h @@ -562,7 +562,7 @@ XhcBulkTransfer ( IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, - IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT VOID **Data, //[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN Timeout, diff --git a/MdePkg/Include/Protocol/Usb2HostController.h b/MdePkg/Include/Protocol/Usb2HostController.h index a2c6767a7..2b12aa743 100644 --- a/MdePkg/Include/Protocol/Usb2HostController.h +++ b/MdePkg/Include/Protocol/Usb2HostController.h @@ -298,7 +298,7 @@ EFI_STATUS IN UINT8 DeviceSpeed, IN UINTN MaximumPacketLength, IN UINT8 DataBuffersNumber, - IN OUT VOID *Data[EFI_USB_MAX_BULK_BUFFER_NUM], + IN OUT VOID **Data, //[EFI_USB_MAX_BULK_BUFFER_NUM], IN OUT UINTN *DataLength, IN OUT UINT8 *DataToggle, IN UINTN TimeOut, diff --git a/rEFIt_UEFI/Settings/ConfigPlist/Config_SystemParameters.h b/rEFIt_UEFI/Settings/ConfigPlist/Config_SystemParameters.h index a21bae8ec..107efb948 100644 --- a/rEFIt_UEFI/Settings/ConfigPlist/Config_SystemParameters.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/Config_SystemParameters.h @@ -76,7 +76,7 @@ public: EFI_GUID dgetCustomUuid() const { if ( !CustomUUID.isDefined() ) return nullGuid; EFI_GUID g; - g.takeValueFrom(CustomUUID.value()); + g.takeValueFromBE(CustomUUID.value()); return g; } UINT8 dget_InjectSystemID() const { return InjectSystemID.isDefined() ? (int)InjectSystemID.value() : 2; } diff --git a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h index 26da7543c..b54bd00b5 100755 --- a/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h +++ b/rEFIt_UEFI/Settings/ConfigPlist/SMBIOSPlist.h @@ -671,7 +671,7 @@ public: EFI_GUID dgetSmUUID() const { if ( !SmUUID.isDefined() ) return nullGuid; EFI_GUID g; - g.takeValueFrom(SmUUID.value()); + g.takeValueFromBE(SmUUID.value()); if ( g.isNull() ) panic("SmUUID is not valid. This could not happen because SmUUID is checked to be valid. Did you comment out the validation ?"); return g; } diff --git a/rEFIt_UEFI/refit/main.cpp b/rEFIt_UEFI/refit/main.cpp index 408d08080..50b54936b 100644 --- a/rEFIt_UEFI/refit/main.cpp +++ b/rEFIt_UEFI/refit/main.cpp @@ -2798,6 +2798,10 @@ RefitMain (IN EFI_HANDLE ImageHandle, // For example, if you do "gCPUStructure.TSCCalibr = GetMemLogTscTicksPerSecond();" before this point, it will be erased by construct_globals_objects() construct_globals_objects(gImageHandle); #endif +#ifdef DEBUG_ERALY_CRASH + SystemTable->ConOut->OutputString(SystemTable->ConOut, L"Step41"); + PauseForKey("press any key\n"_XS8); +#endif gCPUStructure.TSCCalibr = GetMemLogTscTicksPerSecond(); //ticks for 1second