mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-27 23:54:02 +02:00
Ring3: Refactored comparing of GUIDs.
This commit is contained in:
parent
a44e2a5efa
commit
cc50bae593
@ -167,6 +167,8 @@
|
|||||||
gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES
|
gEdkiiPeCoffImageEmulatorProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiDevicePathUtilitiesProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiDevicePathUtilitiesProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiComponentNameProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiComponentNameProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
# Arch Protocols
|
# Arch Protocols
|
||||||
gEfiBdsArchProtocolGuid ## CONSUMES
|
gEfiBdsArchProtocolGuid ## CONSUMES
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiDevicePathUtilitiesProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiDevicePathUtilitiesProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
gEfiLoadedImageProtocolGuid ## SOMETIMES_CONSUMES
|
gEfiLoadedImageProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiDiskIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiBlockIoProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
[Depex]
|
[Depex]
|
||||||
TRUE
|
TRUE
|
||||||
|
@ -398,7 +398,7 @@ Ring3OpenProtocol (
|
|||||||
Attributes
|
Attributes
|
||||||
);
|
);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
DEBUG ((DEBUG_ERROR, "Ring3: Failed to open protocol %g\n", Protocol));
|
DEBUG ((DEBUG_ERROR, "Ring3: Failed to open protocol %g - %r\n", Protocol, Status));
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,9 +8,6 @@
|
|||||||
#include "DxeMain.h"
|
#include "DxeMain.h"
|
||||||
#include "SupportedProtocols.h"
|
#include "SupportedProtocols.h"
|
||||||
|
|
||||||
#include <Protocol/ComponentName.h>
|
|
||||||
#include <Protocol/DevicePathUtilities.h>
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CallInstallMultipleProtocolInterfaces (
|
CallInstallMultipleProtocolInterfaces (
|
||||||
@ -20,6 +17,43 @@ CallInstallMultipleProtocolInterfaces (
|
|||||||
IN VOID *Function
|
IN VOID *Function
|
||||||
);
|
);
|
||||||
|
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
FindGuid (
|
||||||
|
IN EFI_GUID *Ring3,
|
||||||
|
OUT EFI_GUID **Core,
|
||||||
|
OUT UINT32 *CoreSize
|
||||||
|
)
|
||||||
|
{
|
||||||
|
ASSERT (Core != NULL);
|
||||||
|
ASSERT (CoreSize != NULL);
|
||||||
|
|
||||||
|
if (CompareGuid (Ring3, &gEfiDevicePathUtilitiesProtocolGuid)) {
|
||||||
|
*Core = &gEfiDevicePathUtilitiesProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_DEVICE_PATH_UTILITIES_PROTOCOL);
|
||||||
|
} else if (CompareGuid (Ring3, &gEfiLoadedImageProtocolGuid)) {
|
||||||
|
*Core = &gEfiLoadedImageProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_LOADED_IMAGE_PROTOCOL);
|
||||||
|
} else if (CompareGuid (Ring3, &gEfiBlockIoProtocolGuid)) {
|
||||||
|
*Core = &gEfiBlockIoProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_BLOCK_IO_PROTOCOL);
|
||||||
|
} else if (CompareGuid (Ring3, &gEfiDiskIoProtocolGuid)) {
|
||||||
|
*Core = &gEfiDiskIoProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_DISK_IO_PROTOCOL);
|
||||||
|
} else if (CompareGuid (Ring3, &gEfiDriverBindingProtocolGuid)) {
|
||||||
|
*Core = &gEfiDriverBindingProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_DRIVER_BINDING_PROTOCOL);
|
||||||
|
} else if (CompareGuid (Ring3, &gEfiComponentNameProtocolGuid)) {
|
||||||
|
*Core = &gEfiComponentNameProtocolGuid;
|
||||||
|
*CoreSize = sizeof (EFI_COMPONENT_NAME_PROTOCOL);
|
||||||
|
} else {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol.\n"));
|
||||||
|
return EFI_NOT_FOUND;
|
||||||
|
}
|
||||||
|
|
||||||
|
return EFI_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
UINTN Argument1;
|
UINTN Argument1;
|
||||||
UINTN Argument2;
|
UINTN Argument2;
|
||||||
@ -76,15 +110,11 @@ CallBootService (
|
|||||||
// Argument 3: VOID **Interface
|
// Argument 3: VOID **Interface
|
||||||
//
|
//
|
||||||
DisableSMAP ();
|
DisableSMAP ();
|
||||||
if (CompareGuid ((EFI_GUID *)CoreRbp->Argument1, &gEfiDevicePathUtilitiesProtocolGuid)) {
|
Status = FindGuid ((EFI_GUID *)CoreRbp->Argument1, &CoreProtocol, &MemoryCoreSize);
|
||||||
CoreProtocol = &gEfiDevicePathUtilitiesProtocolGuid;
|
|
||||||
MemoryCoreSize = sizeof (EFI_DEVICE_PATH_UTILITIES_PROTOCOL);
|
|
||||||
} else {
|
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol.\n"));
|
|
||||||
EnableSMAP ();
|
|
||||||
return EFI_INVALID_PARAMETER;
|
|
||||||
}
|
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return Status;
|
||||||
|
}
|
||||||
|
|
||||||
Status = gBS->LocateProtocol (
|
Status = gBS->LocateProtocol (
|
||||||
CoreProtocol,
|
CoreProtocol,
|
||||||
@ -114,13 +144,10 @@ CallBootService (
|
|||||||
// Argument 6: UINT32 Attributes
|
// Argument 6: UINT32 Attributes
|
||||||
//
|
//
|
||||||
DisableSMAP ();
|
DisableSMAP ();
|
||||||
if (CompareGuid ((EFI_GUID *)CoreRbp->Argument2, &gEfiLoadedImageProtocolGuid)) {
|
Status = FindGuid ((EFI_GUID *)CoreRbp->Argument2, &CoreProtocol, &MemoryCoreSize);
|
||||||
CoreProtocol = &gEfiLoadedImageProtocolGuid;
|
if (EFI_ERROR (Status)) {
|
||||||
MemoryCoreSize = sizeof (EFI_LOADED_IMAGE_PROTOCOL);
|
|
||||||
} else {
|
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol.\n"));
|
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
return EFI_INVALID_PARAMETER;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Argument4 = (EFI_HANDLE)UserRsp->Arguments[4];
|
Argument4 = (EFI_HANDLE)UserRsp->Arguments[4];
|
||||||
@ -158,22 +185,14 @@ CallBootService (
|
|||||||
CoreHandle = *(EFI_HANDLE *)CoreRbp->Argument1;
|
CoreHandle = *(EFI_HANDLE *)CoreRbp->Argument1;
|
||||||
UserArgList = (VOID **)CoreRbp->Argument2;
|
UserArgList = (VOID **)CoreRbp->Argument2;
|
||||||
|
|
||||||
for (Index = 0; UserArgList[Index] != NULL; ++Index) {
|
for (Index = 0; UserArgList[Index] != NULL; Index += 2) {
|
||||||
if (CompareGuid ((EFI_GUID *)UserArgList[Index], &gEfiDriverBindingProtocolGuid)) {
|
Status = FindGuid ((EFI_GUID *)UserArgList[Index], (EFI_GUID **)&CoreArgList[Index], &MemoryCoreSize);
|
||||||
CoreArgList[Index] = (VOID *)&gEfiDriverBindingProtocolGuid;
|
if (EFI_ERROR (Status)) {
|
||||||
MemoryCoreSize = sizeof (EFI_DRIVER_BINDING_PROTOCOL);
|
|
||||||
continue;
|
|
||||||
} else if (CompareGuid ((EFI_GUID *)UserArgList[Index], &gEfiComponentNameProtocolGuid)) {
|
|
||||||
CoreArgList[Index] = (VOID *)&gEfiComponentNameProtocolGuid;
|
|
||||||
MemoryCoreSize = sizeof (EFI_COMPONENT_NAME_PROTOCOL);
|
|
||||||
continue;
|
|
||||||
} else if ((Index % 2) == 0) {
|
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Unknown protocol.\n"));
|
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
return EFI_INVALID_PARAMETER;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
CoreArgList[Index] = AllocateCopyPool (MemoryCoreSize, (VOID *)UserArgList[Index]);
|
CoreArgList[Index + 1] = AllocateCopyPool (MemoryCoreSize, (VOID *)UserArgList[Index + 1]);
|
||||||
}
|
}
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
|
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
|
#include <Protocol/BlockIo.h>
|
||||||
|
#include <Protocol/ComponentName.h>
|
||||||
|
#include <Protocol/DevicePathUtilities.h>
|
||||||
|
#include <Protocol/DiskIo.h>
|
||||||
|
|
||||||
extern EFI_DRIVER_BINDING_PROTOCOL mRing3DriverBindingProtocol;
|
extern EFI_DRIVER_BINDING_PROTOCOL mRing3DriverBindingProtocol;
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
|
Loading…
x
Reference in New Issue
Block a user