From 9d797a62c1b7d9ed952b90d3d428067ff250c9b6 Mon Sep 17 00:00:00 2001 From: Mikhail Krichanov Date: Thu, 22 Feb 2024 12:42:53 +0300 Subject: [PATCH] Ring3: Added SysCallCloseProtocol. --- .../Core/Dxe/DxeRing3/Ring3UefiBootServices.c | 8 +++++- MdeModulePkg/Core/Dxe/SysCall/BootServices.c | 28 ++++++++++++++++++- MdePkg/Include/Uefi/UefiSpec.h | 1 + 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c index d6950485f5..22acc09f50 100644 --- a/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c +++ b/MdeModulePkg/Core/Dxe/DxeRing3/Ring3UefiBootServices.c @@ -441,7 +441,13 @@ Ring3CloseProtocol ( IN EFI_HANDLE ControllerHandle ) { - return EFI_UNSUPPORTED; + return SysCall ( + SysCallCloseProtocol, + UserHandle, + Protocol, + AgentHandle, + ControllerHandle + ); } EFI_STATUS diff --git a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c index c7566b46d6..b27abfcd92 100644 --- a/MdeModulePkg/Core/Dxe/SysCall/BootServices.c +++ b/MdeModulePkg/Core/Dxe/SysCall/BootServices.c @@ -288,7 +288,7 @@ CallBootService ( case SysCallFreePool: // - // Argument 1: IN VOID *Buffer + // Argument 1: VOID *Buffer // DisableSMAP (); Status = gBS->FreePool ( @@ -298,6 +298,32 @@ CallBootService ( return Status; + case SysCallCloseProtocol: + // + // Argument 1: EFI_HANDLE CoreUserHandle + // Argument 2: EFI_GUID *Protocol + // Argument 3: EFI_HANDLE CoreAgentHandle + // Argument 4: EFI_HANDLE CoreControllerHandle + // + DisableSMAP (); + Status = FindGuid ((EFI_GUID *)CoreRbp->Argument2, &CoreProtocol, &MemoryCoreSize); + if (EFI_ERROR (Status)) { + EnableSMAP (); + return Status; + } + + Argument4 = UserRsp->Arguments[4]; + EnableSMAP (); + + Status = gBS->CloseProtocol ( + (EFI_HANDLE)CoreRbp->Argument1, + CoreProtocol, + (EFI_HANDLE)CoreRbp->Argument3, + (EFI_HANDLE)Argument4 + ); + + return Status; + case SysCallBlockIoReset: // // Argument 1: EFI_BLOCK_IO_PROTOCOL *This diff --git a/MdePkg/Include/Uefi/UefiSpec.h b/MdePkg/Include/Uefi/UefiSpec.h index f8a898590b..c16217a4af 100644 --- a/MdePkg/Include/Uefi/UefiSpec.h +++ b/MdePkg/Include/Uefi/UefiSpec.h @@ -1969,6 +1969,7 @@ typedef enum { SysCallInstallMultipleProtocolInterfaces, SysCallAllocatePool, SysCallFreePool, + SysCallCloseProtocol, // // Protocols //