mirror of https://github.com/acidanthera/audk.git
Use Memory Allocation Library instance for modules of type DXE_SMM_DRIVER
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@10015 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
d3308de7f5
commit
27af6f9d0a
|
@ -24,6 +24,7 @@
|
||||||
#include <Library/PeCoffLib.h>
|
#include <Library/PeCoffLib.h>
|
||||||
#include <Library/DevicePathLib.h>
|
#include <Library/DevicePathLib.h>
|
||||||
#include <Library/CacheMaintenanceLib.h>
|
#include <Library/CacheMaintenanceLib.h>
|
||||||
|
#include <Library/MemoryAllocationLib.h>
|
||||||
#include <Guid/SmmBaseThunkCommunication.h>
|
#include <Guid/SmmBaseThunkCommunication.h>
|
||||||
#include <Protocol/SmmBaseHelperReady.h>
|
#include <Protocol/SmmBaseHelperReady.h>
|
||||||
#include <Protocol/SmmCpu.h>
|
#include <Protocol/SmmCpu.h>
|
||||||
|
@ -134,15 +135,10 @@ ConstructFrameworkSmst (
|
||||||
VOID
|
VOID
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
EFI_SMM_SYSTEM_TABLE *FrameworkSmst;
|
EFI_SMM_SYSTEM_TABLE *FrameworkSmst;
|
||||||
|
|
||||||
Status = gSmst->SmmAllocatePool (
|
FrameworkSmst = (EFI_SMM_SYSTEM_TABLE *)AllocatePool (sizeof (EFI_SMM_SYSTEM_TABLE));
|
||||||
EfiRuntimeServicesData,
|
ASSERT (FrameworkSmst != NULL);
|
||||||
sizeof (EFI_SMM_SYSTEM_TABLE),
|
|
||||||
(VOID **)&FrameworkSmst
|
|
||||||
);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Copy same things from PI SMST to Framework SMST
|
/// Copy same things from PI SMST to Framework SMST
|
||||||
|
@ -160,13 +156,8 @@ ConstructFrameworkSmst (
|
||||||
FrameworkSmst->Hdr.Revision = EFI_SMM_SYSTEM_TABLE_REVISION;
|
FrameworkSmst->Hdr.Revision = EFI_SMM_SYSTEM_TABLE_REVISION;
|
||||||
CopyGuid (&FrameworkSmst->EfiSmmCpuIoGuid, &mEfiSmmCpuIoGuid);
|
CopyGuid (&FrameworkSmst->EfiSmmCpuIoGuid, &mEfiSmmCpuIoGuid);
|
||||||
|
|
||||||
Status = gSmst->SmmAllocatePool (
|
FrameworkSmst->CpuSaveState = (EFI_SMM_CPU_SAVE_STATE *)AllocateZeroPool (gSmst->NumberOfCpus * sizeof (EFI_SMM_CPU_SAVE_STATE));
|
||||||
EfiRuntimeServicesData,
|
ASSERT (FrameworkSmst->CpuSaveState != NULL);
|
||||||
gSmst->NumberOfCpus * sizeof (EFI_SMM_CPU_SAVE_STATE),
|
|
||||||
(VOID **)&FrameworkSmst->CpuSaveState
|
|
||||||
);
|
|
||||||
ASSERT_EFI_ERROR (Status);
|
|
||||||
ZeroMem (FrameworkSmst->CpuSaveState, gSmst->NumberOfCpus * sizeof (EFI_SMM_CPU_SAVE_STATE));
|
|
||||||
|
|
||||||
///
|
///
|
||||||
/// Do not support floating point state now
|
/// Do not support floating point state now
|
||||||
|
@ -335,8 +326,8 @@ LoadImage (
|
||||||
}
|
}
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
gSmst->SmmFreePages (Buffer, PageCount);
|
FreePages ((VOID *)(UINTN)Buffer, PageCount);
|
||||||
return Status;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -534,10 +525,9 @@ CallbackThunk (
|
||||||
**/
|
**/
|
||||||
VOID
|
VOID
|
||||||
RegisterCallback (
|
RegisterCallback (
|
||||||
IN OUT SMMBASE_FUNCTION_DATA *FunctionData
|
IN OUT SMMBASE_FUNCTION_DATA *FunctionData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
EFI_STATUS Status;
|
|
||||||
CALLBACK_INFO *Buffer;
|
CALLBACK_INFO *Buffer;
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -547,36 +537,35 @@ RegisterCallback (
|
||||||
///
|
///
|
||||||
/// Allocate buffer for callback thunk information
|
/// Allocate buffer for callback thunk information
|
||||||
///
|
///
|
||||||
Status = gSmst->SmmAllocatePool (
|
Buffer = (CALLBACK_INFO *)AllocatePool (sizeof (CALLBACK_INFO));
|
||||||
EfiRuntimeServicesCode,
|
if (Buffer == NULL) {
|
||||||
sizeof (CALLBACK_INFO),
|
FunctionData->Status = EFI_OUT_OF_RESOURCES;
|
||||||
(VOID **)&Buffer
|
return;
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
///
|
|
||||||
/// Fill SmmImageHandle and CallbackAddress into the thunk
|
|
||||||
///
|
|
||||||
Buffer->SmmImageHandle = FunctionData->Args.RegisterCallback.SmmImageHandle;
|
|
||||||
Buffer->CallbackAddress = FunctionData->Args.RegisterCallback.CallbackAddress;
|
|
||||||
|
|
||||||
///
|
|
||||||
/// Register the thunk code as a root SMI handler
|
|
||||||
///
|
|
||||||
Status = gSmst->SmiHandlerRegister (
|
|
||||||
CallbackThunk,
|
|
||||||
NULL,
|
|
||||||
&Buffer->DispatchHandle
|
|
||||||
);
|
|
||||||
if (!EFI_ERROR (Status)) {
|
|
||||||
///
|
|
||||||
/// Save this callback info
|
|
||||||
///
|
|
||||||
InsertTailList (&mCallbackInfoListHead, &Buffer->Link);
|
|
||||||
} else {
|
|
||||||
gSmst->SmmFreePool (Buffer);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
FunctionData->Status = Status;
|
|
||||||
|
///
|
||||||
|
/// Fill SmmImageHandle and CallbackAddress into the thunk
|
||||||
|
///
|
||||||
|
Buffer->SmmImageHandle = FunctionData->Args.RegisterCallback.SmmImageHandle;
|
||||||
|
Buffer->CallbackAddress = FunctionData->Args.RegisterCallback.CallbackAddress;
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Register the thunk code as a root SMI handler
|
||||||
|
///
|
||||||
|
FunctionData->Status = gSmst->SmiHandlerRegister (
|
||||||
|
CallbackThunk,
|
||||||
|
NULL,
|
||||||
|
&Buffer->DispatchHandle
|
||||||
|
);
|
||||||
|
if (EFI_ERROR (FunctionData->Status)) {
|
||||||
|
FreePool (Buffer);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
///
|
||||||
|
/// Save this callback info
|
||||||
|
///
|
||||||
|
InsertTailList (&mCallbackInfoListHead, &Buffer->Link);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -607,9 +596,8 @@ HelperFreePool (
|
||||||
IN OUT SMMBASE_FUNCTION_DATA *FunctionData
|
IN OUT SMMBASE_FUNCTION_DATA *FunctionData
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
FunctionData->Status = gSmst->SmmFreePool (
|
FreePool (FunctionData->Args.FreePool.Buffer);
|
||||||
FunctionData->Args.FreePool.Buffer
|
FunctionData->Status = EFI_SUCCESS;
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
PeCoffLib
|
PeCoffLib
|
||||||
DevicePathLib
|
DevicePathLib
|
||||||
CacheMaintenanceLib
|
CacheMaintenanceLib
|
||||||
|
MemoryAllocationLib
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gEfiSmmBaseThunkCommunicationGuid
|
gEfiSmmBaseThunkCommunicationGuid
|
||||||
|
|
Loading…
Reference in New Issue