TianoCore EDK2 master
Loading...
Searching...
No Matches
PiSmmCore.c File Reference
#include "PiSmmCore.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI SmmEfiNotAvailableYetArg5 (UINTN Arg1, UINTN Arg2, UINTN Arg3, UINTN Arg4, UINTN Arg5)
 
EFI_STATUS EFIAPI SmmLegacyBootHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmExitBootServicesHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmS3EntryCallBack (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmReadyToBootHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmReadyToLockHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmEndOfDxeHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmS3SmmInitDoneHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
EFI_STATUS EFIAPI SmmEndOfS3ResumeHandler (IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
 
BOOLEAN InternalIsBufferOverlapped (IN UINT8 *Buff1, IN UINTN Size1, IN UINT8 *Buff2, IN UINTN Size2)
 
VOID EFIAPI SmmEntryPoint (IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext)
 
VOID SmmCoreInstallLoadedImage (VOID)
 
EFI_STATUS EFIAPI SmmMain (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 

Variables

SMM_CORE_PRIVATE_DATAgSmmCorePrivate
 
EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst
 
BOOLEAN mInLegacyBoot = FALSE
 
BOOLEAN mDuringS3Resume = FALSE
 
BOOLEAN mAcpiS3Enable = FALSE
 
SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers []
 
SMM_CORE_SMI_HANDLERS mSmmCoreS3SmiHandlers []
 
UINTN mFullSmramRangeCount
 
EFI_SMRAM_DESCRIPTORmFullSmramRanges
 
EFI_SMM_DRIVER_ENTRYmSmmCoreDriverEntry
 
EFI_LOADED_IMAGE_PROTOCOLmSmmCoreLoadedImage
 

Detailed Description

SMM Core Main Entry Point

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

Definition in file PiSmmCore.c.

Function Documentation

◆ InternalIsBufferOverlapped()

BOOLEAN InternalIsBufferOverlapped ( IN UINT8 *  Buff1,
IN UINTN  Size1,
IN UINT8 *  Buff2,
IN UINTN  Size2 
)

Determine if two buffers overlap in memory.

Parameters
[in]Buff1Pointer to first buffer
[in]Size1Size of Buff1
[in]Buff2Pointer to second buffer
[in]Size2Size of Buff2
Return values
TRUEBuffers overlap in memory.
TRUEMath error. Prevents potential math over and underflows.
FALSEBuffer doesn't overlap.

Definition at line 627 of file PiSmmCore.c.

◆ SmmCoreInstallLoadedImage()

VOID SmmCoreInstallLoadedImage ( VOID  )

Install LoadedImage protocol for SMM Core.

Definition at line 795 of file PiSmmCore.c.

◆ SmmEfiNotAvailableYetArg5()

EFI_STATUS EFIAPI SmmEfiNotAvailableYetArg5 ( UINTN  Arg1,
UINTN  Arg2,
UINTN  Arg3,
UINTN  Arg4,
UINTN  Arg5 
)

Place holder function until all the SMM System Table Service are available.

Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.

Parameters
Arg1Undefined
Arg2Undefined
Arg3Undefined
Arg4Undefined
Arg5Undefined
Returns
EFI_NOT_AVAILABLE_YET

Definition at line 125 of file PiSmmCore.c.

◆ SmmEndOfDxeHandler()

EFI_STATUS EFIAPI SmmEndOfDxeHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when the EndOfDxe event is signalled. This function installs the SMM EndOfDxe Protocol so SMM Drivers are informed that platform code will invoke 3rd part code.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 436 of file PiSmmCore.c.

◆ SmmEndOfS3ResumeHandler()

EFI_STATUS EFIAPI SmmEndOfS3ResumeHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when the EndOfS3Resume signal is triggered. This function installs the SMM EndOfS3Resume Protocol so SMM Drivers are informed that S3 resume has finished.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 569 of file PiSmmCore.c.

◆ SmmEntryPoint()

VOID EFIAPI SmmEntryPoint ( IN CONST EFI_SMM_ENTRY_CONTEXT SmmEntryContext)

The main entry point to SMM Foundation.

Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.

Parameters
SmmEntryContextProcessor information and functionality needed by SMM Foundation.

Definition at line 669 of file PiSmmCore.c.

◆ SmmExitBootServicesHandler()

EFI_STATUS EFIAPI SmmExitBootServicesHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when an Exit Boot Services event is signalled. Then the SMM Core also install SMM Exit Boot Services protocol to notify SMM driver that system enter exit boot services.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 214 of file PiSmmCore.c.

◆ SmmLegacyBootHandler()

EFI_STATUS EFIAPI SmmLegacyBootHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when a Legacy Boot event is signalled. The SMM Core uses this signal to know that a Legacy Boot has been performed and that gSmmCorePrivate that is shared between the UEFI and SMM execution environments can not be accessed from SMM anymore since that structure is considered free memory by a legacy OS. Then the SMM Core also install SMM Legacy Boot protocol to notify SMM driver that system enter legacy boot.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 159 of file PiSmmCore.c.

◆ SmmMain()

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

The Entry Point for SMM Core

Install DXE Protocols and reload SMM Core into SMRAM and register SMM Core EntryPoint on the SMI vector.

Note: This function is called for both DXE invocation and SMRAM invocation.

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 890 of file PiSmmCore.c.

◆ SmmReadyToBootHandler()

EFI_STATUS EFIAPI SmmReadyToBootHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when an Ready To Boot event is signalled. Then the SMM Core also install SMM Ready To Boot protocol to notify SMM driver that system enter ready to boot.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 298 of file PiSmmCore.c.

◆ SmmReadyToLockHandler()

EFI_STATUS EFIAPI SmmReadyToLockHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when the DxeSmmReadyToLock protocol is added or if gEfiEventReadyToBootGuid is signalled. This function unregisters the Software SMIs that are nor required after SMRAM is locked and installs the SMM Ready To Lock Protocol so SMM Drivers are informed that SMRAM is about to be locked. It also verifies the SMM CPU I/O 2 Protocol has been installed and NULLs gBS and gST because they can not longer be used after SMRAM is locked.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 346 of file PiSmmCore.c.

◆ SmmS3EntryCallBack()

EFI_STATUS EFIAPI SmmS3EntryCallBack ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Main entry point for an SMM handler dispatch or communicate-based callback.

Parameters
[in]DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
[in]ContextPoints to an optional handler context which was specified when the handler was registered.
[in,out]CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
[in,out]CommBufferSizeThe size of the CommBuffer.
Return values
EFI_SUCCESSThe interrupt was handled and quiesced. No other handlers should still be called.
EFI_WARN_INTERRUPT_SOURCE_QUIESCEDThe interrupt has been quiesced but other handlers should still be called.
EFI_WARN_INTERRUPT_SOURCE_PENDINGThe interrupt is still pending and other handlers should still be called.
EFI_INTERRUPT_PENDINGThe interrupt could not be quiesced.

Definition at line 271 of file PiSmmCore.c.

◆ SmmS3SmmInitDoneHandler()

EFI_STATUS EFIAPI SmmS3SmmInitDoneHandler ( IN EFI_HANDLE  DispatchHandle,
IN CONST VOID *Context  OPTIONAL,
IN OUT VOID *CommBuffer  OPTIONAL,
IN OUT UINTN *CommBufferSize  OPTIONAL 
)

Software SMI handler that is called when the S3SmmInitDone signal is triggered. This function installs the SMM S3SmmInitDone Protocol so SMM Drivers are informed that S3 SMM initialization has been done.

Parameters
DispatchHandleThe unique handle assigned to this handler by SmiHandlerRegister().
ContextPoints to an optional handler context which was specified when the handler was registered.
CommBufferA pointer to a collection of data in memory that will be conveyed from a non-SMM environment into an SMM environment.
CommBufferSizeThe size of the CommBuffer.
Returns
Status Code

Definition at line 510 of file PiSmmCore.c.

Variable Documentation

◆ gSmmCorePrivate

SMM_CORE_PRIVATE_DATA* gSmmCorePrivate

Definition at line 14 of file PiSmmCore.c.

◆ gSmmCoreSmst

EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst

Definition at line 19 of file PiSmmCore.c.

◆ mAcpiS3Enable

BOOLEAN mAcpiS3Enable = FALSE

Definition at line 78 of file PiSmmCore.c.

◆ mDuringS3Resume

BOOLEAN mDuringS3Resume = FALSE

Definition at line 72 of file PiSmmCore.c.

◆ mFullSmramRangeCount

UINTN mFullSmramRangeCount

Definition at line 102 of file PiSmmCore.c.

◆ mFullSmramRanges

EFI_SMRAM_DESCRIPTOR* mFullSmramRanges

Definition at line 103 of file PiSmmCore.c.

◆ mInLegacyBoot

BOOLEAN mInLegacyBoot = FALSE

Definition at line 66 of file PiSmmCore.c.

◆ mSmmCoreDriverEntry

EFI_SMM_DRIVER_ENTRY* mSmmCoreDriverEntry

Definition at line 105 of file PiSmmCore.c.

◆ mSmmCoreLoadedImage

EFI_LOADED_IMAGE_PROTOCOL* mSmmCoreLoadedImage

Definition at line 107 of file PiSmmCore.c.

◆ mSmmCoreS3SmiHandlers

SMM_CORE_SMI_HANDLERS mSmmCoreS3SmiHandlers[]
Initial value:
= {
{ SmmS3SmmInitDoneHandler, &gEdkiiS3SmmInitDoneGuid, NULL, FALSE },
{ SmmEndOfS3ResumeHandler, &gEdkiiEndOfS3ResumeGuid, NULL, FALSE },
}
#define NULL
Definition: Base.h:319
#define FALSE
Definition: Base.h:307
EFI_STATUS EFIAPI SmmS3SmmInitDoneHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:510
EFI_STATUS EFIAPI SmmEndOfS3ResumeHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:569

Definition at line 96 of file PiSmmCore.c.

◆ mSmmCoreSmiHandlers

SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[]
Initial value:
= {
{ SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE },
{ SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE },
{ SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },
{ SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },
{ SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },
{ SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE },
}
EFI_STATUS EFIAPI SmmDriverDispatchHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: Dispatcher.c:1284
#define TRUE
Definition: Base.h:301
EFI_STATUS EFIAPI SmmReadyToLockHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:346
EFI_STATUS EFIAPI SmmEndOfDxeHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:436
EFI_STATUS EFIAPI SmmExitBootServicesHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:214
EFI_STATUS EFIAPI SmmReadyToBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:298
EFI_STATUS EFIAPI SmmLegacyBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiSmmCore.c:159

Definition at line 83 of file PiSmmCore.c.