Ring3: Added SysCallFreePool,

fixed wrappers for EFI_DRIVER_BINDING_PROTOCOL.
This commit is contained in:
Mikhail Krichanov 2024-02-16 15:45:25 +03:00
parent 77bb186c8a
commit 3d8a6585a1
4 changed files with 100 additions and 19 deletions

View File

@ -98,7 +98,17 @@ Ring3FreePool (
IN VOID *Buffer
)
{
return EFI_UNSUPPORTED;
EFI_STATUS Status;
Status = SysCall (
SysCallFreePool,
Buffer
);
if (EFI_ERROR (Status)) {
DEBUG ((DEBUG_ERROR, "Ring3: Failed to free buffer.\n"));
}
return Status;
}
EFI_STATUS

View File

@ -95,7 +95,6 @@ CallBootService (
DisableSMAP ();
Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize);
if (Interface == NULL) {
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
EnableSMAP ();
return EFI_OUT_OF_RESOURCES;
}
@ -141,7 +140,6 @@ CallBootService (
DisableSMAP ();
Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize);
if (Interface == NULL) {
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
EnableSMAP ();
return EFI_OUT_OF_RESOURCES;
}
@ -219,6 +217,18 @@ CallBootService (
);
EnableSMAP ();
return Status;
case SysCallFreePool:
//
// Argument 1: IN VOID *Buffer
//
DisableSMAP ();
Status = gBS->FreePool (
(VOID *)CoreRbp->Argument1
);
EnableSMAP ();
return Status;
default:
break;

View File

@ -55,13 +55,33 @@ CoreDriverBindingSupported (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
return GoToRing3 (
3,
(VOID *)mRing3DriverBindingProtocol.Supported,
EFI_STATUS Status;
DisableSMAP ();
This = AllocateRing3Copy (
This,
ControllerHandle,
RemainingDevicePath
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
);
if (This == NULL) {
EnableSMAP ();
return EFI_OUT_OF_RESOURCES;
}
EnableSMAP ();
Status = GoToRing3 (
3,
(VOID *)mRing3DriverBindingProtocol.Supported,
This,
ControllerHandle,
RemainingDevicePath
);
DisableSMAP ();
FreePool (This);
EnableSMAP ();
return Status;
}
EFI_STATUS
@ -72,13 +92,33 @@ CoreDriverBindingStart (
IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
)
{
return GoToRing3 (
3,
(VOID *)mRing3DriverBindingProtocol.Start,
EFI_STATUS Status;
DisableSMAP ();
This = AllocateRing3Copy (
This,
ControllerHandle,
RemainingDevicePath
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
);
if (This == NULL) {
EnableSMAP ();
return EFI_OUT_OF_RESOURCES;
}
EnableSMAP ();
Status = GoToRing3 (
3,
(VOID *)mRing3DriverBindingProtocol.Start,
This,
ControllerHandle,
RemainingDevicePath
);
DisableSMAP ();
FreePool (This);
EnableSMAP ();
return Status;
}
EFI_STATUS
@ -90,12 +130,32 @@ CoreDriverBindingStop (
IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
)
{
return GoToRing3 (
4,
(VOID *)mRing3DriverBindingProtocol.Stop,
EFI_STATUS Status;
DisableSMAP ();
This = AllocateRing3Copy (
This,
ControllerHandle,
NumberOfChildren,
ChildHandleBuffer
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
);
if (This == NULL) {
EnableSMAP ();
return EFI_OUT_OF_RESOURCES;
}
EnableSMAP ();
Status = GoToRing3 (
4,
(VOID *)mRing3DriverBindingProtocol.Stop,
This,
ControllerHandle,
NumberOfChildren,
ChildHandleBuffer
);
DisableSMAP ();
FreePool (This);
EnableSMAP ();
return Status;
}

View File

@ -2019,6 +2019,7 @@ typedef enum {
SysCallOpenProtocol,
SysCallInstallMultipleProtocolInterfaces,
SysCallAllocatePool,
SysCallFreePool,
SysCallMax
} SYS_CALL_TYPE;