Specifications
Example Code
153
EFI_DRIVER_ENTRY_POINT(InitializeChild)
EFI_STATUS
InitializeChild (
IN EFI_HANDLE ImageHandle,
IN EFI_SYSTEM_TABLE *SystemTable
)
/*++
Routine Description:
Initializes the SMM Handler Driver
Arguments:
ImageHandle -
SystemTable -
Returns:
None
--*/
{
EFI_STATUS Status;
BOOLEAN InSmm;
EFI_HANDLE Handle;
UINT8* Buffer;
UINTN BufferSize;
EFI_SMM_SW_DISPATCH_CONTEXT SwContext = { 0 };
EFI_HANDLE SwHandle = 0;
Status = BufferSize = InSmm = 0;
Handle = Buffer = NULL;
//
// Initialize the EFI Runtime Library
//
EfiInitializeSmmDriverLib (ImageHandle, SystemTable);
Status = gBS->LocateProtocol(&gEfiSmmBaseProtocolGuid, NULL, &mSmmBase);
if (EFI_ERROR(Status)) {
return Status;
}
mSmmBase->InSmm(mSmmBase, &InSmm);
if (!InSmm) {
//
// This driver is dispatched by DXE, so first call to this
// driver will not be in SMM. We need to load this driver
// into SMRAM and then generate an SMI to initialize data
// structures in SMRAM.
//
// Load this driver's image to memory
Status = GetFvImage(&mChildFileGuid, &Buffer, &BufferSize);
if (!EFI_ERROR(Status)) {
// Load the image in memory to SMRAM; it will automatically
// generate the SMI.
mSmmBase->Register(mSmmBase, NULL, Buffer, BufferSize, &Handle,
FALSE);
gBS->FreePool(Buffer);
}
} else {
//
// Great! We're now in SMM!
//
// Initialize global variables










