/** @file\r
SMM Core Main Entry Point\r
\r
- Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
This program and the accompanying materials are licensed and made available \r
under the terms and conditions of the BSD License which accompanies this \r
distribution. The full text of the license may be found at \r
UINTN mFullSmramRangeCount;\r
EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r
\r
+EFI_LOADED_IMAGE_PROTOCOL *mSmmCoreLoadedImage;\r
+\r
/**\r
Place holder function until all the SMM System Table Service are available.\r
\r
PERF_START (NULL, "SMM", NULL, 0) ;\r
\r
//\r
- // Update SMST using the context\r
+ // Update SMST with contents of the SmmEntryContext structure\r
//\r
- CopyMem (&gSmmCoreSmst.SmmStartupThisAp, SmmEntryContext, sizeof (EFI_SMM_ENTRY_CONTEXT));\r
+ gSmmCoreSmst.SmmStartupThisAp = SmmEntryContext->SmmStartupThisAp;\r
+ gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext->CurrentlyExecutingCpu;\r
+ gSmmCoreSmst.NumberOfCpus = SmmEntryContext->NumberOfCpus;\r
+ gSmmCoreSmst.CpuSaveStateSize = SmmEntryContext->CpuSaveStateSize;\r
+ gSmmCoreSmst.CpuSaveState = SmmEntryContext->CpuSaveState;\r
\r
//\r
// Call platform hook before Smm Dispatch\r
PERF_END (NULL, "SMM", NULL, 0) ;\r
}\r
\r
+/**\r
+ Install LoadedImage protocol for SMM Core.\r
+**/\r
+VOID\r
+SmmCoreInstallLoadedImage (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_HANDLE Handle;\r
+\r
+ //\r
+ // Allocate a Loaded Image Protocol in EfiBootServicesData\r
+ //\r
+ Status = gBS->AllocatePool (EfiBootServicesData, sizeof(EFI_LOADED_IMAGE_PROTOCOL), (VOID **)&mSmmCoreLoadedImage);\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ ZeroMem (mSmmCoreLoadedImage, sizeof (EFI_LOADED_IMAGE_PROTOCOL));\r
+ //\r
+ // Fill in the remaining fields of the Loaded Image Protocol instance.\r
+ // Note: ImageBase is an SMRAM address that can not be accessed outside of SMRAM if SMRAM window is closed.\r
+ //\r
+ mSmmCoreLoadedImage->Revision = EFI_LOADED_IMAGE_PROTOCOL_REVISION;\r
+ mSmmCoreLoadedImage->ParentHandle = gSmmCorePrivate->SmmIplImageHandle;\r
+ mSmmCoreLoadedImage->SystemTable = gST;\r
+\r
+ mSmmCoreLoadedImage->ImageBase = (VOID *)(UINTN)gSmmCorePrivate->PiSmmCoreImageBase;\r
+ mSmmCoreLoadedImage->ImageSize = gSmmCorePrivate->PiSmmCoreImageSize;\r
+ mSmmCoreLoadedImage->ImageCodeType = EfiRuntimeServicesCode;\r
+ mSmmCoreLoadedImage->ImageDataType = EfiRuntimeServicesData;\r
+\r
+ //\r
+ // Create a new image handle in the UEFI handle database for the SMM Driver\r
+ //\r
+ Handle = NULL;\r
+ Status = gBS->InstallMultipleProtocolInterfaces (\r
+ &Handle,\r
+ &gEfiLoadedImageProtocolGuid, mSmmCoreLoadedImage,\r
+ NULL\r
+ );\r
+ ASSERT_EFI_ERROR (Status);\r
+\r
+ return ;\r
+}\r
+\r
/**\r
The Entry Point for SMM Core\r
\r
}\r
\r
RegisterSmramProfileHandler ();\r
+ SmramProfileInstallProtocol ();\r
+\r
+ SmmCoreInstallLoadedImage ();\r
\r
return EFI_SUCCESS;\r
}\r