mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 13:44:33 +02:00
Ring3: Refactored AllocateRing3CopyPages() and mUserDriverBinding.
This commit is contained in:
parent
fa60f3ab00
commit
77bb186c8a
@ -1176,9 +1176,10 @@ CoreAllocatePages (
|
|||||||
|
|
||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
AllocateRing3CopyPages (
|
AllocateRing3Copy (
|
||||||
IN VOID *MemoryCore,
|
IN VOID *Source,
|
||||||
IN UINT32 MemoryCoreSize
|
IN UINT32 AllocationSize,
|
||||||
|
IN UINT32 CopySize
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1571,21 +1571,24 @@ CoreLoadImage (
|
|||||||
|
|
||||||
VOID *
|
VOID *
|
||||||
EFIAPI
|
EFIAPI
|
||||||
AllocateRing3CopyPages (
|
AllocateRing3Copy (
|
||||||
IN VOID *MemoryCore,
|
IN VOID *Source,
|
||||||
IN UINT32 MemoryCoreSize
|
IN UINT32 AllocationSize,
|
||||||
|
IN UINT32 CopySize
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
VOID *MemoryRing3;
|
EFI_STATUS Status;
|
||||||
|
VOID *MemoryRing3;
|
||||||
|
|
||||||
MemoryRing3 = AllocatePages (EFI_SIZE_TO_PAGES (MemoryCoreSize));
|
Status = CoreAllocatePool (EfiRing3MemoryType, AllocationSize, &MemoryRing3);
|
||||||
if (MemoryRing3 == NULL) {
|
if (EFI_ERROR (Status)) {
|
||||||
|
DEBUG ((DEBUG_ERROR, "Core: Failed to allocate %d bytes for Ring3.\n", AllocationSize));
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
CopyMem (MemoryRing3, MemoryCore, MemoryCoreSize);
|
ASSERT (CopySize <= AllocationSize);
|
||||||
|
|
||||||
SetUefiImageMemoryAttributes ((UINTN)MemoryRing3, EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (MemoryCoreSize)), EFI_MEMORY_USER);
|
CopyMem (MemoryRing3, Source, CopySize);
|
||||||
|
|
||||||
return MemoryRing3;
|
return MemoryRing3;
|
||||||
}
|
}
|
||||||
@ -1613,8 +1616,13 @@ InitializeRing3 (
|
|||||||
//
|
//
|
||||||
// Set Ring3 EntryPoint and BootServices.
|
// Set Ring3 EntryPoint and BootServices.
|
||||||
//
|
//
|
||||||
mRing3Data = AllocateRing3CopyPages ((VOID *)Image->Info.SystemTable, sizeof (RING3_DATA));
|
mRing3Data = AllocateRing3Copy (
|
||||||
|
(VOID *)Image->Info.SystemTable,
|
||||||
|
sizeof (RING3_DATA),
|
||||||
|
sizeof (EFI_SYSTEM_TABLE)
|
||||||
|
);
|
||||||
|
ASSERT (mRing3Data != NULL);
|
||||||
|
|
||||||
Image->Status = Image->EntryPoint (ImageHandle, (EFI_SYSTEM_TABLE *)mRing3Data);
|
Image->Status = Image->EntryPoint (ImageHandle, (EFI_SYSTEM_TABLE *)mRing3Data);
|
||||||
|
|
||||||
gRing3EntryPoint = mRing3Data->EntryPoint;
|
gRing3EntryPoint = mRing3Data->EntryPoint;
|
||||||
|
@ -92,13 +92,14 @@ CallBootService (
|
|||||||
&Interface
|
&Interface
|
||||||
);
|
);
|
||||||
|
|
||||||
Interface = AllocateRing3CopyPages (Interface, MemoryCoreSize);
|
DisableSMAP ();
|
||||||
|
Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize);
|
||||||
if (Interface == NULL) {
|
if (Interface == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
|
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
|
||||||
|
EnableSMAP ();
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableSMAP ();
|
|
||||||
*(VOID **)CoreRbp->Argument3 = Interface;
|
*(VOID **)CoreRbp->Argument3 = Interface;
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
|
|
||||||
@ -137,13 +138,14 @@ CallBootService (
|
|||||||
Argument6
|
Argument6
|
||||||
);
|
);
|
||||||
|
|
||||||
Interface = AllocateRing3CopyPages (Interface, MemoryCoreSize);
|
DisableSMAP ();
|
||||||
|
Interface = AllocateRing3Copy (Interface, MemoryCoreSize, MemoryCoreSize);
|
||||||
if (Interface == NULL) {
|
if (Interface == NULL) {
|
||||||
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
|
DEBUG ((DEBUG_ERROR, "Ring0: Failed to allocate pages for Ring3 PROTOCOL structure.\n"));
|
||||||
|
EnableSMAP ();
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
DisableSMAP ();
|
|
||||||
*(VOID **)CoreRbp->Argument3 = Interface;
|
*(VOID **)CoreRbp->Argument3 = Interface;
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
|
|
||||||
@ -184,9 +186,9 @@ CallBootService (
|
|||||||
if (CompareGuid ((EFI_GUID *)CoreArgList[Index], &gEfiDriverBindingProtocolGuid)) {
|
if (CompareGuid ((EFI_GUID *)CoreArgList[Index], &gEfiDriverBindingProtocolGuid)) {
|
||||||
CoreDriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)CoreArgList[Index + 1];
|
CoreDriverBinding = (EFI_DRIVER_BINDING_PROTOCOL *)CoreArgList[Index + 1];
|
||||||
|
|
||||||
mUserDriverBindingSupported = CoreDriverBinding->Supported;
|
mRing3DriverBindingProtocol.Supported = CoreDriverBinding->Supported;
|
||||||
mUserDriverBindingStart = CoreDriverBinding->Start;
|
mRing3DriverBindingProtocol.Start = CoreDriverBinding->Start;
|
||||||
mUserDriverBindingStop = CoreDriverBinding->Stop;
|
mRing3DriverBindingProtocol.Stop = CoreDriverBinding->Stop;
|
||||||
|
|
||||||
CoreDriverBinding->Supported = CoreDriverBindingSupported;
|
CoreDriverBinding->Supported = CoreDriverBindingSupported;
|
||||||
CoreDriverBinding->Start = CoreDriverBindingStart;
|
CoreDriverBinding->Start = CoreDriverBindingStart;
|
||||||
|
@ -7,9 +7,7 @@
|
|||||||
|
|
||||||
#include "DxeMain.h"
|
#include "DxeMain.h"
|
||||||
|
|
||||||
EFI_DRIVER_BINDING_SUPPORTED mUserDriverBindingSupported;
|
EFI_DRIVER_BINDING_PROTOCOL mRing3DriverBindingProtocol;
|
||||||
EFI_DRIVER_BINDING_START mUserDriverBindingStart;
|
|
||||||
EFI_DRIVER_BINDING_STOP mUserDriverBindingStop;
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
@ -59,7 +57,7 @@ CoreDriverBindingSupported (
|
|||||||
{
|
{
|
||||||
return GoToRing3 (
|
return GoToRing3 (
|
||||||
3,
|
3,
|
||||||
(VOID *)mUserDriverBindingSupported,
|
(VOID *)mRing3DriverBindingProtocol.Supported,
|
||||||
This,
|
This,
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
RemainingDevicePath
|
RemainingDevicePath
|
||||||
@ -76,7 +74,7 @@ CoreDriverBindingStart (
|
|||||||
{
|
{
|
||||||
return GoToRing3 (
|
return GoToRing3 (
|
||||||
3,
|
3,
|
||||||
(VOID *)mUserDriverBindingStart,
|
(VOID *)mRing3DriverBindingProtocol.Start,
|
||||||
This,
|
This,
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
RemainingDevicePath
|
RemainingDevicePath
|
||||||
@ -94,7 +92,7 @@ CoreDriverBindingStop (
|
|||||||
{
|
{
|
||||||
return GoToRing3 (
|
return GoToRing3 (
|
||||||
4,
|
4,
|
||||||
(VOID *)mUserDriverBindingStop,
|
(VOID *)mRing3DriverBindingProtocol.Stop,
|
||||||
This,
|
This,
|
||||||
ControllerHandle,
|
ControllerHandle,
|
||||||
NumberOfChildren,
|
NumberOfChildren,
|
||||||
|
@ -5,9 +5,7 @@
|
|||||||
|
|
||||||
**/
|
**/
|
||||||
|
|
||||||
extern EFI_DRIVER_BINDING_SUPPORTED mUserDriverBindingSupported;
|
extern EFI_DRIVER_BINDING_PROTOCOL mRing3DriverBindingProtocol;
|
||||||
extern EFI_DRIVER_BINDING_START mUserDriverBindingStart;
|
|
||||||
extern EFI_DRIVER_BINDING_STOP mUserDriverBindingStop;
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
|
Loading…
x
Reference in New Issue
Block a user