Skip to content

Commit

Permalink
some workaround from Tianocore
Browse files Browse the repository at this point in the history
Signed-off-by: Slice <[email protected]>
  • Loading branch information
SergeySlice committed Dec 21, 2024
1 parent 286a4f3 commit 015206b
Show file tree
Hide file tree
Showing 17 changed files with 100 additions and 21 deletions.
9 changes: 7 additions & 2 deletions CloverEFI/OsxDxeCore/DxeMain/DxeMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,7 @@ EFI_SYSTEM_TABLE *gDxeCoreST = NULL;
EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;
EFI_HANDLE gDxeCoreImageHandle = NULL;

static BOOLEAN mExitBootServicesCalled = FALSE;

//
// EFI Decompress Protocol
Expand Down Expand Up @@ -778,9 +779,13 @@ CoreExitBootServices (
Status = CoreTerminateMemoryMap (MapKey);
if (EFI_ERROR(Status)) {
//
// Notify other drivers that ExitBootServices fail
// Notify other drivers that ExitBootServices fail. Do this ones
//
CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
//CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
if (!mExitBootServicesCalled) {
CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
mExitBootServicesCalled = TRUE;
}
return Status;
}

Expand Down
25 changes: 25 additions & 0 deletions Drivers/SataControllerDxe/SataController.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,6 +355,31 @@ SataControllerSupported (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 PciData;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
//
// Attempt to open DevicePath Protocol
//
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
(VOID *)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
///
/// Close the protocol because we don't use it here
///
gBS->CloseProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);


//
// Attempt to open PCI I/O Protocol
Expand Down
1 change: 1 addition & 0 deletions Drivers/SataControllerDxe/SataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include <Uefi.h>
#include <Protocol/ComponentName.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/PciIo.h>
#include <Protocol/IdeControllerInit.h>
Expand Down
1 change: 1 addition & 0 deletions Drivers/SataControllerDxe/SataControllerDxe.inf
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,5 @@
[Protocols]
gEfiPciIoProtocolGuid
gEfiIdeControllerInitProtocolGuid
gEfiDevicePathProtocolGuid

12 changes: 6 additions & 6 deletions Drivers/XhciDxe/XhciSched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2762,7 +2762,7 @@ XhcInitializeEndpointContext (

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
Expand Down Expand Up @@ -2954,7 +2954,7 @@ XhcInitializeEndpointContext64 (

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
Expand Down Expand Up @@ -3155,7 +3155,7 @@ XhcSetConfigCmd (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
Expand Down Expand Up @@ -3248,7 +3248,7 @@ XhcSetConfigCmd64 (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
Expand Down Expand Up @@ -3532,7 +3532,7 @@ XhcSetInterface (
IfDescActive = NULL;
IfDescSet = NULL;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
while ((UINTN) IfDesc < ((UINTN) ConfigDesc + ConfigDesc->TotalLength)) {
if ((IfDesc->DescriptorType == USB_DESC_TYPE_INTERFACE) && (IfDesc->Length >= sizeof (USB_INTERFACE_DESCRIPTOR))) {
if (IfDesc->InterfaceNumber == (UINT8) Request->Index) {
Expand Down Expand Up @@ -3734,7 +3734,7 @@ XhcSetInterface64 (
IfDescActive = NULL;
IfDescSet = NULL;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
while ((UINTN) IfDesc < ((UINTN) ConfigDesc + ConfigDesc->TotalLength)) {
if ((IfDesc->DescriptorType == USB_DESC_TYPE_INTERFACE) && (IfDesc->Length >= sizeof (USB_INTERFACE_DESCRIPTOR))) {
if (IfDesc->InterfaceNumber == (UINT8) Request->Index) {
Expand Down
2 changes: 1 addition & 1 deletion FileSystems/FatPkg/EnhancedFatDxe/DirectoryManage.c
Original file line number Diff line number Diff line change
Expand Up @@ -979,7 +979,7 @@ Routine Description:
{
EFI_STATUS Status;
FAT_ODIR *ODir;
FAT_DIRENT *TempDirEnt;
FAT_DIRENT *TempDirEnt = NULL;
UINT32 NewEndPos;

ODir = OFile->ODir;
Expand Down
2 changes: 1 addition & 1 deletion FileSystems/FatPkg/EnhancedFatDxe/Info.c
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,7 @@ Routine Description:
CHAR16 NewFileName[EFI_PATH_STRING_LENGTH];
EFI_TIME ZeroTime;
FAT_DIRENT *DirEnt;
FAT_DIRENT *TempDirEnt;
FAT_DIRENT *TempDirEnt = NULL;
UINT8 NewAttribute;
BOOLEAN ReadOnly;

Expand Down
24 changes: 24 additions & 0 deletions MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.c
Original file line number Diff line number Diff line change
Expand Up @@ -293,6 +293,30 @@ SataControllerSupported (
EFI_STATUS Status;
EFI_PCI_IO_PROTOCOL *PciIo;
PCI_TYPE00 PciData;
EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath;
//
// Attempt to open DevicePath Protocol
//
Status = gBS->OpenProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
(VOID *)&ParentDevicePath,
This->DriverBindingHandle,
Controller,
EFI_OPEN_PROTOCOL_BY_DRIVER
);
if (EFI_ERROR (Status)) {
return Status;
}
///
/// Close the protocol because we don't use it here
///
gBS->CloseProtocol (
Controller,
&gEfiDevicePathProtocolGuid,
This->DriverBindingHandle,
Controller
);

//
// Attempt to open PCI I/O Protocol
Expand Down
1 change: 1 addition & 0 deletions MdeModulePkg/Bus/Pci/SataControllerDxe/SataController.h
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <IndustryStandard/Pci.h>

#include <Protocol/ComponentName.h>
#include <Protocol/DevicePath.h>
#include <Protocol/DriverBinding.h>
#include <Protocol/PciIo.h>
#include <Protocol/IdeControllerInit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
[Protocols]
gEfiPciIoProtocolGuid ## TO_START
gEfiIdeControllerInitProtocolGuid ## BY_START
gEfiDevicePathProtocolGuid

[UserExtensions.TianoCore."ExtraFiles"]
SataControllerDxeExtra.uni
Expand Down
12 changes: 6 additions & 6 deletions MdeModulePkg/Bus/Pci/XhciDxe/XhciSched.c
Original file line number Diff line number Diff line change
Expand Up @@ -2808,7 +2808,7 @@ XhcInitializeEndpointContext (

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
Expand Down Expand Up @@ -3007,7 +3007,7 @@ XhcInitializeEndpointContext64 (

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *)(IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *)((UINTN)EpDesc + EpDesc->Length);
Expand Down Expand Up @@ -3213,7 +3213,7 @@ XhcSetConfigCmd (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
Expand Down Expand Up @@ -3304,7 +3304,7 @@ XhcSetConfigCmd64 (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)IfDesc + IfDesc->Length);
Expand Down Expand Up @@ -3588,7 +3588,7 @@ XhcSetInterface (
IfDescActive = NULL;
IfDescSet = NULL;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
while ((UINTN)IfDesc < ((UINTN)ConfigDesc + ConfigDesc->TotalLength)) {
if ((IfDesc->DescriptorType == USB_DESC_TYPE_INTERFACE) && (IfDesc->Length >= sizeof (USB_INTERFACE_DESCRIPTOR))) {
if (IfDesc->InterfaceNumber == (UINT8)Request->Index) {
Expand Down Expand Up @@ -3794,7 +3794,7 @@ XhcSetInterface64 (
IfDescActive = NULL;
IfDescSet = NULL;

IfDesc = (USB_INTERFACE_DESCRIPTOR *)(ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *)((UINTN)ConfigDesc + ConfigDesc->Length);
while ((UINTN)IfDesc < ((UINTN)ConfigDesc + ConfigDesc->TotalLength)) {
if ((IfDesc->DescriptorType == USB_DESC_TYPE_INTERFACE) && (IfDesc->Length >= sizeof (USB_INTERFACE_DESCRIPTOR))) {
if (IfDesc->InterfaceNumber == (UINT8)Request->Index) {
Expand Down
8 changes: 4 additions & 4 deletions MdeModulePkg/Bus/Pci/XhciPei/XhciSched.c
Original file line number Diff line number Diff line change
Expand Up @@ -1708,15 +1708,15 @@ XhcPeiSetConfigCmd (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *) (ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *) ((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *) ((UINTN) IfDesc + IfDesc->Length);
}

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *) (IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *) ((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *) ((UINTN) EpDesc + EpDesc->Length);
Expand Down Expand Up @@ -1924,15 +1924,15 @@ XhcPeiSetConfigCmd64 (

MaxDci = 0;

IfDesc = (USB_INTERFACE_DESCRIPTOR *) (ConfigDesc + 1);
IfDesc = (USB_INTERFACE_DESCRIPTOR *) ((UINTN)ConfigDesc + ConfigDesc->Length);
for (Index = 0; Index < ConfigDesc->NumInterfaces; Index++) {
while ((IfDesc->DescriptorType != USB_DESC_TYPE_INTERFACE) || (IfDesc->AlternateSetting != 0)) {
IfDesc = (USB_INTERFACE_DESCRIPTOR *) ((UINTN) IfDesc + IfDesc->Length);
}

NumEp = IfDesc->NumEndpoints;

EpDesc = (USB_ENDPOINT_DESCRIPTOR *) (IfDesc + 1);
EpDesc = (USB_ENDPOINT_DESCRIPTOR *) ((UINTN)IfDesc + IfDesc->Length);
for (EpIndex = 0; EpIndex < NumEp; EpIndex++) {
while (EpDesc->DescriptorType != USB_DESC_TYPE_ENDPOINT) {
EpDesc = (USB_ENDPOINT_DESCRIPTOR *) ((UINTN) EpDesc + EpDesc->Length);
Expand Down
5 changes: 5 additions & 0 deletions MdeModulePkg/Core/Dxe/DxeMain/DxeMain.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ EFI_RUNTIME_SERVICES *gDxeCoreRT = &mEfiRuntimeServicesTableTemplate;
EFI_HANDLE gDxeCoreImageHandle = NULL;

BOOLEAN gMemoryMapTerminated = FALSE;
static BOOLEAN mExitBootServicesCalled = FALSE;

//
// EFI Decompress Protocol
Expand Down Expand Up @@ -755,6 +756,10 @@ CoreExitBootServices (
// Notify other drivers that ExitBootServices fail
//
CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
if (!mExitBootServicesCalled) {
CoreNotifySignalList (&gEventExitBootServicesFailedGuid);
mExitBootServicesCalled = TRUE;
}
return Status;
}

Expand Down
13 changes: 13 additions & 0 deletions MdePkg/Include/Protocol/BootManagerPolicy.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
to connect devices using platform policy.
Copyright (c) 2015 - 2018, Intel Corporation. All rights reserved.<BR>
Copyright (c) Microsoft Corporation.<BR>
SPDX-License-Identifier: BSD-2-Clause-Patent
**/

Expand All @@ -31,6 +32,11 @@
0x113B2126, 0xFC8A, 0x11E3, { 0xBD, 0x6C, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA } \
}

#define EFI_BOOT_MANAGER_POLICY_STORAGE_GUID \
{ \
0xCD68FE79, 0xD3CB, 0x436E, { 0xA8, 0x50, 0xF4, 0x43, 0xC8, 0x8C, 0xFB, 0x49 } \
}

typedef struct _EFI_BOOT_MANAGER_POLICY_PROTOCOL EFI_BOOT_MANAGER_POLICY_PROTOCOL;

#define EFI_BOOT_MANAGER_POLICY_PROTOCOL_REVISION 0x00010000
Expand Down Expand Up @@ -98,6 +104,12 @@ EFI_STATUS
EFI_BOOT_SERVICES.ConnectController(). If the Boot Manager has policy
associated with connect all UEFI drivers this policy will be used.
If Class is EFI_BOOT_MANAGER_POLICY_STORAGE_GUID then the Boot Manager will
connect the protocols associated with the discoverable storage disks. This may include
EFI_BLOCK_IO_PROTOCOL, EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, or other storage protocols
appropriate to the device. Some platforms may choose to restrict the connected
devices to exclude USB or other peripherals.
A platform can also define platform specific Class values as a properly generated
EFI_GUID would never conflict with this specification.
Expand Down Expand Up @@ -128,5 +140,6 @@ extern EFI_GUID gEfiBootManagerPolicyProtocolGuid;
extern EFI_GUID gEfiBootManagerPolicyConsoleGuid;
extern EFI_GUID gEfiBootManagerPolicyNetworkGuid;
extern EFI_GUID gEfiBootManagerPolicyConnectAllGuid;
extern EFI_GUID gEfiBootManagerPolicyStorageGuid;

#endif
3 changes: 2 additions & 1 deletion MdePkg/Include/Register/Amd/Msr.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@
#ifndef __AMD_MSR_H__
#define __AMD_MSR_H__

#include <Register/Intel/ArchitecturalMsr.h>
#include <Register/Intel/ArchitecturalMsr.h>
#include <Register/Amd/ArchitecturalMsr.h>
#include <Register/Amd/Fam17Msr.h>

#endif
1 change: 1 addition & 0 deletions MdePkg/Library/SmmPciExpressLib/SmmPciExpressLib.inf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
PcdLib
DebugLib
IoLib
UefiBootServicesTableLib

[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPciExpressBaseAddress ## CONSUMES
1 change: 1 addition & 0 deletions MdePkg/MdePkg.dec
Original file line number Diff line number Diff line change
Expand Up @@ -629,6 +629,7 @@
gEfiBootManagerPolicyConsoleGuid = { 0xCAB0E94C, 0xE15F, 0x11E3, { 0x91, 0x8D, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA }}
gEfiBootManagerPolicyNetworkGuid = { 0xD04159DC, 0xE15F, 0x11E3, { 0xB2, 0x61, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA }}
gEfiBootManagerPolicyConnectAllGuid = { 0x113B2126, 0xFC8A, 0x11E3, { 0xBD, 0x6C, 0xB8, 0xE8, 0x56, 0x2C, 0xBA, 0xFA }}
gEfiBootManagerPolicyStorageGuid = { 0xCD68FE79, 0xD3CB, 0x436E, { 0xA8, 0x50, 0xF4, 0x43, 0xC8, 0x8C, 0xFB, 0x49 }}

## Include/Protocol/DevicePath.h
gEfiVirtualDiskGuid = { 0x77AB535A, 0x45FC, 0x624B, {0x55, 0x60, 0xF7, 0xB2, 0x81, 0xD1, 0xF9, 0x6E }}
Expand Down

0 comments on commit 015206b

Please sign in to comment.