TianoCore EDK2 master
Loading...
Searching...
No Matches
PiSmmIpl.c File Reference

Go to the source code of this file.

Data Structures

struct  SMM_IPL_EVENT_NOTIFICATION
 

Macros

#define SMRAM_CAPABILITIES   (EFI_MEMORY_WB | EFI_MEMORY_UC)
 

Functions

EFI_STATUS EFIAPI SmmBase2InSmram (IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT BOOLEAN *InSmram)
 
EFI_STATUS EFIAPI SmmBase2GetSmstLocation (IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT EFI_SMM_SYSTEM_TABLE2 **Smst)
 
EFI_STATUS EFIAPI SmmCommunicationCommunicate (IN CONST EFI_SMM_COMMUNICATION_PROTOCOL *This, IN OUT VOID *CommBuffer, IN OUT UINTN *CommSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2 (IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, IN OUT VOID *CommBufferPhysical, IN OUT VOID *CommBufferVirtual, IN OUT UINTN *CommSize OPTIONAL)
 
VOID EFIAPI SmmIplSmmConfigurationEventNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmIplReadyToLockEventNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmIplDxeDispatchEventNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmIplGuidedEventNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmIplEndOfDxeEventNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID EFIAPI SmmIplSetVirtualAddressNotify (IN EFI_EVENT Event, IN VOID *Context)
 
VOID GetSmramCacheRange (IN EFI_SMRAM_DESCRIPTOR *SmramRange, OUT EFI_PHYSICAL_ADDRESS *SmramCacheBase, OUT UINT64 *SmramCacheSize)
 
EFI_STATUS GetPeCoffImageFixLoadingAssignedAddress (IN OUT PE_COFF_LOADER_IMAGE_CONTEXT *ImageContext)
 
EFI_STATUS ExecuteSmmCoreFromSmram (IN OUT EFI_SMRAM_DESCRIPTOR *SmramRange, IN OUT EFI_SMRAM_DESCRIPTOR *SmramRangeSmmCore, IN VOID *Context)
 
VOID SmmSplitSmramEntry (IN OUT EFI_SMRAM_DESCRIPTOR *RangeToCompare, IN OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare, OUT EFI_SMRAM_DESCRIPTOR *Ranges, IN OUT UINTN *RangeCount, OUT EFI_SMM_RESERVED_SMRAM_REGION *ReservedRanges, IN OUT UINTN *ReservedRangeCount, OUT EFI_SMRAM_DESCRIPTOR *FinalRanges, IN OUT UINTN *FinalRangeCount)
 
BOOLEAN SmmIsSmramOverlap (IN EFI_SMRAM_DESCRIPTOR *RangeToCompare, IN EFI_SMM_RESERVED_SMRAM_REGION *ReservedRangeToCompare)
 
EFI_SMRAM_DESCRIPTORGetFullSmramRanges (OUT UINTN *FullSmramRangeCount)
 
EFI_STATUS EFIAPI SmmIplEntry (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

EFI_HANDLE mSmmIplHandle = NULL
 
EFI_SMM_BASE2_PROTOCOL mSmmBase2
 
EFI_SMM_COMMUNICATION_PROTOCOL mSmmCommunication
 
EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2
 
SMM_CORE_PRIVATE_DATA mSmmCorePrivateData
 
SMM_CORE_PRIVATE_DATAgSmmCorePrivate = &mSmmCorePrivateData
 
EFI_SMM_CONTROL2_PROTOCOLmSmmControl2
 
EFI_SMM_ACCESS2_PROTOCOLmSmmAccess
 
EFI_SMRAM_DESCRIPTORmCurrentSmramRange
 
BOOLEAN mSmmLocked = FALSE
 
BOOLEAN mEndOfDxe = FALSE
 
EFI_PHYSICAL_ADDRESS mSmramCacheBase
 
UINT64 mSmramCacheSize
 
EFI_SMM_COMMUNICATE_HEADER mCommunicateHeader
 
EFI_LOAD_FIXED_ADDRESS_CONFIGURATION_TABLEmLMFAConfigurationTable = NULL
 
SMM_IPL_EVENT_NOTIFICATION mSmmIplEvents []
 

Detailed Description

SMM IPL that produces SMM related runtime protocols and load the SMM Core into SMRAM

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file PiSmmIpl.c.

Macro Definition Documentation

◆ SMRAM_CAPABILITIES

#define SMRAM_CAPABILITIES   (EFI_MEMORY_WB | EFI_MEMORY_UC)

Definition at line 40 of file PiSmmIpl.c.

Function Documentation

◆ ExecuteSmmCoreFromSmram()

EFI_STATUS ExecuteSmmCoreFromSmram ( IN OUT EFI_SMRAM_DESCRIPTOR SmramRange,
IN OUT EFI_SMRAM_DESCRIPTOR SmramRangeSmmCore,
IN VOID *  Context 
)

Load the SMM Core image into SMRAM and executes the SMM Core from SMRAM.

Parameters
[in,out]SmramRangeDescriptor for the range of SMRAM to reload the currently executing image, the rang of SMRAM to hold SMM Core will be excluded.
[in,out]SmramRangeSmmCoreDescriptor for the range of SMRAM to hold SMM Core.
[in]ContextContext to pass into SMM Core
Returns
EFI_STATUS

Definition at line 1018 of file PiSmmIpl.c.

◆ GetFullSmramRanges()

EFI_SMRAM_DESCRIPTOR * GetFullSmramRanges ( OUT UINTN FullSmramRangeCount)

Get full SMRAM ranges.

It will get SMRAM ranges from SmmAccess protocol and SMRAM reserved ranges from SmmConfiguration protocol, split the entries if there is overlap between them. It will also reserve one entry for SMM core.

Parameters
[out]FullSmramRangeCountOutput pointer to full SMRAM range count.
Returns
Pointer to full SMRAM ranges.

Definition at line 1417 of file PiSmmIpl.c.

◆ GetPeCoffImageFixLoadingAssignedAddress()

EFI_STATUS GetPeCoffImageFixLoadingAssignedAddress ( IN OUT PE_COFF_LOADER_IMAGE_CONTEXT ImageContext)

Get the fixed loading address from image header assigned by build tool. This function only be called when Loading module at Fixed address feature enabled.

Parameters
ImageContextPointer to the image context structure that describes the PE/COFF image that needs to be examined by this function.
Return values
EFI_SUCCESSAn fixed loading address is assigned to this image by build tools .
EFI_NOT_FOUNDThe image has no assigned fixed loading address.

Definition at line 916 of file PiSmmIpl.c.

◆ GetSmramCacheRange()

VOID GetSmramCacheRange ( IN EFI_SMRAM_DESCRIPTOR SmramRange,
OUT EFI_PHYSICAL_ADDRESS SmramCacheBase,
OUT UINT64 *  SmramCacheSize 
)

Find the maximum SMRAM cache range that covers the range specified by SmramRange.

This function searches and joins all adjacent ranges of SmramRange into a range to be cached.

Parameters
SmramRangeThe SMRAM range to search from.
SmramCacheBaseThe returned cache range base.
SmramCacheSizeThe returned cache range size.

Definition at line 391 of file PiSmmIpl.c.

◆ SmmBase2GetSmstLocation()

EFI_STATUS EFIAPI SmmBase2GetSmstLocation ( IN CONST EFI_SMM_BASE2_PROTOCOL This,
OUT EFI_SMM_SYSTEM_TABLE2 **  Smst 
)

Retrieves the location of the System Management System Table (SMST).

Parameters
ThisThe EFI_SMM_BASE2_PROTOCOL instance.
SmstOn return, points to a pointer to the System Management Service Table (SMST).
Return values
EFI_INVALID_PARAMETERSmst or This was invalid.
EFI_SUCCESSThe memory was returned to the system.
EFI_UNSUPPORTEDNot in SMM.

Definition at line 462 of file PiSmmIpl.c.

◆ SmmBase2InSmram()

EFI_STATUS EFIAPI SmmBase2InSmram ( IN CONST EFI_SMM_BASE2_PROTOCOL This,
OUT BOOLEAN *  InSmram 
)

Indicate whether the driver is currently executing in the SMM Initialization phase.

Parameters
ThisThe EFI_SMM_BASE2_PROTOCOL instance.
InSmramPointer to a Boolean which, on return, indicates that the driver is currently executing inside of SMRAM (TRUE) or outside of SMRAM (FALSE).
Return values
EFI_INVALID_PARAMETERInSmram was NULL.
EFI_SUCCESSThe call returned successfully.

Definition at line 435 of file PiSmmIpl.c.

◆ SmmCommunicationCommunicate()

EFI_STATUS EFIAPI SmmCommunicationCommunicate ( IN CONST EFI_SMM_COMMUNICATION_PROTOCOL This,
IN OUT VOID *  CommBuffer,
IN OUT UINTN *CommSize  OPTIONAL 
)

Communicates with a registered handler.

This function provides a service to send and receive messages from a registered UEFI service. This function is part of the SMM Communication Protocol that may be called in physical mode prior to SetVirtualAddressMap() and in virtual mode after SetVirtualAddressMap().

Parameters
[in]ThisThe EFI_SMM_COMMUNICATION_PROTOCOL instance.
[in,out]CommBufferA pointer to the buffer to convey into SMRAM.
[in,out]CommSizeThe size of the data buffer being passed in. On exit, the size of data being returned. Zero if the handler does not wish to reply with any data. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe message was successfully posted.
EFI_INVALID_PARAMETERThe CommBuffer was NULL.
EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM implementation. If this error is returned, the MessageLength field in the CommBuffer header or the integer pointed by CommSize, are updated to reflect the maximum payload size the implementation can accommodate.
EFI_ACCESS_DENIEDThe CommunicateBuffer parameter or CommSize parameter, if not omitted, are in address range that cannot be accessed by the MM environment.

Definition at line 508 of file PiSmmIpl.c.

◆ SmmCommunicationMmCommunicate2()

EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2 ( IN CONST EFI_MM_COMMUNICATION2_PROTOCOL This,
IN OUT VOID *  CommBufferPhysical,
IN OUT VOID *  CommBufferVirtual,
IN OUT UINTN *CommSize  OPTIONAL 
)

Communicates with a registered handler.

This function provides a service to send and receive messages from a registered UEFI service.

Parameters
[in]ThisThe EFI_MM_COMMUNICATION_PROTOCOL instance.
[in]CommBufferPhysicalPhysical address of the MM communication buffer
[in]CommBufferVirtualVirtual address of the MM communication buffer
[in]CommSizeThe size of the data buffer being passed in. On exit, the size of data being returned. Zero if the handler does not wish to reply with any data. This parameter is optional and may be NULL.
Return values
EFI_SUCCESSThe message was successfully posted.
EFI_INVALID_PARAMETERThe CommBuffer was NULL.
EFI_BAD_BUFFER_SIZEThe buffer is too large for the MM implementation. If this error is returned, the MessageLength field in the CommBuffer header or the integer pointed by CommSize, are updated to reflect the maximum payload size the implementation can accommodate.
EFI_ACCESS_DENIEDThe CommunicateBuffer parameter or CommSize parameter, if not omitted, are in address range that cannot be accessed by the MM environment.

Definition at line 640 of file PiSmmIpl.c.

◆ SmmIplDxeDispatchEventNotify()

VOID EFIAPI SmmIplDxeDispatchEventNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired when DxeDispatch Event Group is signaled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Definition at line 710 of file PiSmmIpl.c.

◆ SmmIplEndOfDxeEventNotify()

VOID EFIAPI SmmIplEndOfDxeEventNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired when EndOfDxe Event Group is signaled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Definition at line 693 of file PiSmmIpl.c.

◆ SmmIplEntry()

EFI_STATUS EFIAPI SmmIplEntry ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

The Entry Point for SMM IPL

Load SMM Core into SMRAM, register SMM Core entry point for SMIs, install SMM Base 2 Protocol and SMM Communication Protocol, and register for the critical events required to coordinate between DXE and SMM environments.

Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe entry point is executed successfully.
OtherSome error occurred when executing this entry point.

Definition at line 1642 of file PiSmmIpl.c.

◆ SmmIplGuidedEventNotify()

VOID EFIAPI SmmIplGuidedEventNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired when a GUIDed Event Group is signaled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Event notification that is fired when GUIDed Event Group is signaled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Definition at line 663 of file PiSmmIpl.c.

◆ SmmIplReadyToLockEventNotify()

VOID EFIAPI SmmIplReadyToLockEventNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired every time a DxeSmmReadyToLock protocol is added or if gEfiEventReadyToBootGuid is signalled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Event notification that is fired every time a DxeSmmReadyToLock protocol is added or if gEfiEventReadyToBootGuid is signaled.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Definition at line 812 of file PiSmmIpl.c.

◆ SmmIplSetVirtualAddressNotify()

VOID EFIAPI SmmIplSetVirtualAddressNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE.

This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event. It convers pointer to new virtual address.

Parameters
EventEvent whose notification function is being invoked.
ContextPointer to the notification function's context.

Definition at line 898 of file PiSmmIpl.c.

◆ SmmIplSmmConfigurationEventNotify()

VOID EFIAPI SmmIplSmmConfigurationEventNotify ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

Event notification that is fired every time a gEfiSmmConfigurationProtocol installs.

Parameters
EventThe Event that is being processed, not used.
ContextEvent Context, not used.

Definition at line 768 of file PiSmmIpl.c.

◆ SmmIsSmramOverlap()

BOOLEAN SmmIsSmramOverlap ( IN EFI_SMRAM_DESCRIPTOR RangeToCompare,
IN EFI_SMM_RESERVED_SMRAM_REGION ReservedRangeToCompare 
)

Returns if SMRAM range and SMRAM reserved range are overlapped.

Parameters
[in]RangeToComparePointer to EFI_SMRAM_DESCRIPTOR to compare.
[in]ReservedRangeToComparePointer to EFI_SMM_RESERVED_SMRAM_REGION to compare.
Return values
TRUEThere is overlap.
TRUEMath error.
FALSEThere is no overlap.

Definition at line 1362 of file PiSmmIpl.c.

◆ SmmSplitSmramEntry()

VOID SmmSplitSmramEntry ( IN OUT EFI_SMRAM_DESCRIPTOR RangeToCompare,
IN OUT EFI_SMM_RESERVED_SMRAM_REGION ReservedRangeToCompare,
OUT EFI_SMRAM_DESCRIPTOR Ranges,
IN OUT UINTN RangeCount,
OUT EFI_SMM_RESERVED_SMRAM_REGION ReservedRanges,
IN OUT UINTN ReservedRangeCount,
OUT EFI_SMRAM_DESCRIPTOR FinalRanges,
IN OUT UINTN FinalRangeCount 
)

SMM split SMRAM entry.

Parameters
[in,out]RangeToComparePointer to EFI_SMRAM_DESCRIPTOR to compare.
[in,out]ReservedRangeToComparePointer to EFI_SMM_RESERVED_SMRAM_REGION to compare.
[out]RangesOutput pointer to hold split EFI_SMRAM_DESCRIPTOR entry.
[in,out]RangeCountPointer to range count.
[out]ReservedRangesOutput pointer to hold split EFI_SMM_RESERVED_SMRAM_REGION entry.
[in,out]ReservedRangeCountPointer to reserved range count.
[out]FinalRangesOutput pointer to hold split final EFI_SMRAM_DESCRIPTOR entry that no need to be split anymore.
[in,out]FinalRangeCountPointer to final range count.

Definition at line 1188 of file PiSmmIpl.c.

Variable Documentation

◆ gSmmCorePrivate

SMM_CORE_PRIVATE_DATA* gSmmCorePrivate = &mSmmCorePrivateData

Definition at line 299 of file PiSmmIpl.c.

◆ mCommunicateHeader

EFI_SMM_COMMUNICATE_HEADER mCommunicateHeader

Definition at line 312 of file PiSmmIpl.c.

◆ mCurrentSmramRange

EFI_SMRAM_DESCRIPTOR* mCurrentSmramRange

Definition at line 306 of file PiSmmIpl.c.

◆ mEndOfDxe

BOOLEAN mEndOfDxe = FALSE

Definition at line 308 of file PiSmmIpl.c.

◆ mLMFAConfigurationTable

Definition at line 313 of file PiSmmIpl.c.

◆ mMmCommunication2

EFI_MM_COMMUNICATION2_PROTOCOL mMmCommunication2
Initial value:
= {
}
EFI_STATUS EFIAPI SmmCommunicationMmCommunicate2(IN CONST EFI_MM_COMMUNICATION2_PROTOCOL *This, IN OUT VOID *CommBufferPhysical, IN OUT VOID *CommBufferVirtual, IN OUT UINTN *CommSize OPTIONAL)
Definition: PiSmmIpl.c:640

Definition at line 274 of file PiSmmIpl.c.

◆ mSmmAccess

Definition at line 305 of file PiSmmIpl.c.

◆ mSmmBase2

Initial value:
= {
}
EFI_STATUS EFIAPI SmmBase2GetSmstLocation(IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT EFI_SMM_SYSTEM_TABLE2 **Smst)
Definition: PiSmmIpl.c:462
EFI_STATUS EFIAPI SmmBase2InSmram(IN CONST EFI_SMM_BASE2_PROTOCOL *This, OUT BOOLEAN *InSmram)
Definition: PiSmmIpl.c:435

Definition at line 259 of file PiSmmIpl.c.

◆ mSmmCommunication

EFI_SMM_COMMUNICATION_PROTOCOL mSmmCommunication
Initial value:
= {
}
EFI_STATUS EFIAPI SmmCommunicationCommunicate(IN CONST EFI_SMM_COMMUNICATION_PROTOCOL *This, IN OUT VOID *CommBuffer, IN OUT UINTN *CommSize OPTIONAL)
Definition: PiSmmIpl.c:508

Definition at line 267 of file PiSmmIpl.c.

◆ mSmmControl2

Definition at line 304 of file PiSmmIpl.c.

◆ mSmmCorePrivateData

SMM_CORE_PRIVATE_DATA mSmmCorePrivateData
Initial value:
= {
NULL,
0,
NULL,
NULL,
NULL,
NULL,
0,
}
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
#define SMM_CORE_PRIVATE_DATA_SIGNATURE
#define EFI_SUCCESS
Definition: UefiBaseType.h:112

Definition at line 282 of file PiSmmIpl.c.

◆ mSmmIplEvents

SMM_IPL_EVENT_NOTIFICATION mSmmIplEvents[]

Definition at line 318 of file PiSmmIpl.c.

◆ mSmmIplHandle

EFI_HANDLE mSmmIplHandle = NULL

Definition at line 254 of file PiSmmIpl.c.

◆ mSmmLocked

BOOLEAN mSmmLocked = FALSE

Definition at line 307 of file PiSmmIpl.c.

◆ mSmramCacheBase

EFI_PHYSICAL_ADDRESS mSmramCacheBase

Definition at line 309 of file PiSmmIpl.c.

◆ mSmramCacheSize

UINT64 mSmramCacheSize

Definition at line 310 of file PiSmmIpl.c.