mirror of
https://github.com/acidanthera/audk.git
synced 2025-07-23 21:54:27 +02:00
Ring3: Refactored out AllocateRing3Copy().
This commit is contained in:
parent
94017d9567
commit
d4f5ae14aa
@ -1171,14 +1171,6 @@ CoreAllocatePages (
|
|||||||
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
IN OUT EFI_PHYSICAL_ADDRESS *Memory
|
||||||
);
|
);
|
||||||
|
|
||||||
VOID *
|
|
||||||
EFIAPI
|
|
||||||
AllocateRing3Copy (
|
|
||||||
IN VOID *Source,
|
|
||||||
IN UINT32 AllocationSize,
|
|
||||||
IN UINT32 CopySize
|
|
||||||
);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Frees previous allocated pages.
|
Frees previous allocated pages.
|
||||||
|
|
||||||
|
@ -1570,30 +1570,6 @@ CoreLoadImage (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
VOID *
|
|
||||||
EFIAPI
|
|
||||||
AllocateRing3Copy (
|
|
||||||
IN VOID *Source,
|
|
||||||
IN UINT32 AllocationSize,
|
|
||||||
IN UINT32 CopySize
|
|
||||||
)
|
|
||||||
{
|
|
||||||
EFI_STATUS Status;
|
|
||||||
VOID *MemoryRing3;
|
|
||||||
|
|
||||||
Status = CoreAllocatePool (EfiRing3MemoryType, AllocationSize, &MemoryRing3);
|
|
||||||
if (EFI_ERROR (Status)) {
|
|
||||||
DEBUG ((DEBUG_ERROR, "Core: Failed to allocate %d bytes for Ring3.\n", AllocationSize));
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
ASSERT (CopySize <= AllocationSize);
|
|
||||||
|
|
||||||
CopyMem (MemoryRing3, Source, CopySize);
|
|
||||||
|
|
||||||
return MemoryRing3;
|
|
||||||
}
|
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
InitializeRing3 (
|
InitializeRing3 (
|
||||||
|
@ -103,10 +103,7 @@ PrepareRing3Interface (
|
|||||||
|
|
||||||
Ring3Limit = (UINTN)gRing3Interfaces + EFI_PAGES_TO_SIZE (RING3_INTERFACES_PAGES);
|
Ring3Limit = (UINTN)gRing3Interfaces + EFI_PAGES_TO_SIZE (RING3_INTERFACES_PAGES);
|
||||||
|
|
||||||
ASSERT ((mRing3InterfacePointer + sizeof (EFI_GUID) + CoreSize) <= Ring3Limit);
|
ASSERT ((mRing3InterfacePointer + CoreSize) <= Ring3Limit);
|
||||||
|
|
||||||
CopyMem ((VOID *)mRing3InterfacePointer, (VOID *)Guid, sizeof (EFI_GUID));
|
|
||||||
mRing3InterfacePointer += sizeof (EFI_GUID);
|
|
||||||
|
|
||||||
Ring3Interface = (VOID *)mRing3InterfacePointer;
|
Ring3Interface = (VOID *)mRing3InterfacePointer;
|
||||||
|
|
||||||
@ -265,7 +262,12 @@ CallBootService (
|
|||||||
Status = FindGuid ((EFI_GUID *)UserArgList[Index], (EFI_GUID **)&CoreArgList[Index], &MemoryCoreSize);
|
Status = FindGuid ((EFI_GUID *)UserArgList[Index], (EFI_GUID **)&CoreArgList[Index], &MemoryCoreSize);
|
||||||
if (EFI_ERROR (Status)) {
|
if (EFI_ERROR (Status)) {
|
||||||
EnableSMAP ();
|
EnableSMAP ();
|
||||||
//TODO: Free CoreArgList.
|
|
||||||
|
while (Index > 0) {
|
||||||
|
FreePool (CoreArgList[Index - 1]);
|
||||||
|
Index -= 2;
|
||||||
|
}
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -77,6 +77,34 @@ GoToRing3 (
|
|||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
STATIC
|
||||||
|
EFIAPI
|
||||||
|
VOID *
|
||||||
|
Ring3Copy (
|
||||||
|
IN VOID *Core,
|
||||||
|
IN UINT32 Size
|
||||||
|
)
|
||||||
|
{
|
||||||
|
EFI_STATUS Status;
|
||||||
|
VOID *Ring3;
|
||||||
|
|
||||||
|
Status = CoreAllocatePages (
|
||||||
|
AllocateAnyPages,
|
||||||
|
EfiRing3MemoryType,
|
||||||
|
1,
|
||||||
|
(EFI_PHYSICAL_ADDRESS *)&Ring3
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (Status)) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
DisableSMAP ();
|
||||||
|
CopyMem (Ring3, Core, Size);
|
||||||
|
EnableSMAP ();
|
||||||
|
|
||||||
|
return Ring3;
|
||||||
|
}
|
||||||
|
|
||||||
EFI_STATUS
|
EFI_STATUS
|
||||||
EFIAPI
|
EFIAPI
|
||||||
CoreDriverBindingSupported (
|
CoreDriverBindingSupported (
|
||||||
@ -87,17 +115,10 @@ CoreDriverBindingSupported (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
DisableSMAP ();
|
This = Ring3Copy (This, sizeof (EFI_DRIVER_BINDING_PROTOCOL));
|
||||||
This = AllocateRing3Copy (
|
|
||||||
This,
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
|
|
||||||
);
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
EnableSMAP ();
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
Status = GoToRing3 (
|
Status = GoToRing3 (
|
||||||
3,
|
3,
|
||||||
@ -107,9 +128,7 @@ CoreDriverBindingSupported (
|
|||||||
RemainingDevicePath
|
RemainingDevicePath
|
||||||
);
|
);
|
||||||
|
|
||||||
DisableSMAP ();
|
CoreFreePages ((EFI_PHYSICAL_ADDRESS)This, 1);
|
||||||
FreePool (This);
|
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -124,17 +143,10 @@ CoreDriverBindingStart (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
DisableSMAP ();
|
This = Ring3Copy (This, sizeof (EFI_DRIVER_BINDING_PROTOCOL));
|
||||||
This = AllocateRing3Copy (
|
|
||||||
This,
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
|
|
||||||
);
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
EnableSMAP ();
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
Status = GoToRing3 (
|
Status = GoToRing3 (
|
||||||
3,
|
3,
|
||||||
@ -144,9 +156,7 @@ CoreDriverBindingStart (
|
|||||||
RemainingDevicePath
|
RemainingDevicePath
|
||||||
);
|
);
|
||||||
|
|
||||||
DisableSMAP ();
|
CoreFreePages ((EFI_PHYSICAL_ADDRESS)This, 1);
|
||||||
FreePool (This);
|
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
@ -162,17 +172,10 @@ CoreDriverBindingStop (
|
|||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
EFI_STATUS Status;
|
||||||
|
|
||||||
DisableSMAP ();
|
This = Ring3Copy (This, sizeof (EFI_DRIVER_BINDING_PROTOCOL));
|
||||||
This = AllocateRing3Copy (
|
|
||||||
This,
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL),
|
|
||||||
sizeof (EFI_DRIVER_BINDING_PROTOCOL)
|
|
||||||
);
|
|
||||||
if (This == NULL) {
|
if (This == NULL) {
|
||||||
EnableSMAP ();
|
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
Status = GoToRing3 (
|
Status = GoToRing3 (
|
||||||
4,
|
4,
|
||||||
@ -183,9 +186,7 @@ CoreDriverBindingStop (
|
|||||||
ChildHandleBuffer
|
ChildHandleBuffer
|
||||||
);
|
);
|
||||||
|
|
||||||
DisableSMAP ();
|
CoreFreePages ((EFI_PHYSICAL_ADDRESS)This, 1);
|
||||||
FreePool (This);
|
|
||||||
EnableSMAP ();
|
|
||||||
|
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user