mirror of https://github.com/acidanthera/audk.git
MdeModulePkg/PiSmmCore: Add SmiHandlerProfile support.
1) SmmCore maintains the root SMI handler and NULL SMI handler database. 2) SmmCore consumes PcdSmiHandlerProfilePropertyMask to decide if SmmCore need support SMI handler profile. If SMI handler profile is supported, the SmmCore installs SMI handler profile protocol and SMI handler profile communication handler. 3) SMI handler profile protocol will record the hardware SMI handler profile registered by SmmChildDispatcher. 4) SMI handler profile communication handler will return all SMI handler profile info (NULL SMI handler, GUID SMI handler, and hardware SMI handler) Cc: Feng Tian <feng.tian@intel.com> Cc: Star Zeng <star.zeng@intel.com> Cc: Michael D Kinney <michael.d.kinney@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Star Zeng <star.zeng@intel.com>
This commit is contained in:
parent
e08bfc7d6f
commit
ca41f3f43f
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
SMM Core Main Entry Point
|
SMM Core Main Entry Point
|
||||||
|
|
||||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
distribution. The full text of the license may be found at
|
distribution. The full text of the license may be found at
|
||||||
|
@ -680,5 +680,7 @@ SmmMain (
|
||||||
|
|
||||||
SmmCoreInitializeMemoryAttributesTable ();
|
SmmCoreInitializeMemoryAttributesTable ();
|
||||||
|
|
||||||
|
SmmCoreInitializeSmiHandlerProfile ();
|
||||||
|
|
||||||
return EFI_SUCCESS;
|
return EFI_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
The internal header file includes the common header files, defines
|
The internal header file includes the common header files, defines
|
||||||
internal structure and functions used by SmmCore module.
|
internal structure and functions used by SmmCore module.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
distribution. The full text of the license may be found at
|
distribution. The full text of the license may be found at
|
||||||
|
@ -38,6 +38,7 @@
|
||||||
#include <Guid/EventLegacyBios.h>
|
#include <Guid/EventLegacyBios.h>
|
||||||
#include <Guid/MemoryProfile.h>
|
#include <Guid/MemoryProfile.h>
|
||||||
#include <Guid/LoadModuleAtFixedAddress.h>
|
#include <Guid/LoadModuleAtFixedAddress.h>
|
||||||
|
#include <Guid/SmiHandlerProfile.h>
|
||||||
|
|
||||||
#include <Library/BaseLib.h>
|
#include <Library/BaseLib.h>
|
||||||
#include <Library/BaseMemoryLib.h>
|
#include <Library/BaseMemoryLib.h>
|
||||||
|
@ -69,6 +70,32 @@ typedef struct {
|
||||||
BOOLEAN UnRegister;
|
BOOLEAN UnRegister;
|
||||||
} SMM_CORE_SMI_HANDLERS;
|
} SMM_CORE_SMI_HANDLERS;
|
||||||
|
|
||||||
|
//
|
||||||
|
// SMM_HANDLER - used for each SMM handler
|
||||||
|
//
|
||||||
|
|
||||||
|
#define SMI_ENTRY_SIGNATURE SIGNATURE_32('s','m','i','e')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY AllEntries; // All entries
|
||||||
|
|
||||||
|
EFI_GUID HandlerType; // Type of interrupt
|
||||||
|
LIST_ENTRY SmiHandlers; // All handlers
|
||||||
|
} SMI_ENTRY;
|
||||||
|
|
||||||
|
#define SMI_HANDLER_SIGNATURE SIGNATURE_32('s','m','i','h')
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
UINTN Signature;
|
||||||
|
LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers
|
||||||
|
EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point
|
||||||
|
UINTN CallerAddr; // The address of caller who register the SMI handler.
|
||||||
|
SMI_ENTRY *SmiEntry;
|
||||||
|
VOID *Context; // for profile
|
||||||
|
UINTN ContextSize; // for profile
|
||||||
|
} SMI_HANDLER;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Structure for recording the state of an SMM Driver
|
// Structure for recording the state of an SMM Driver
|
||||||
//
|
//
|
||||||
|
@ -1064,6 +1091,66 @@ SmmCoreGetMemoryMap (
|
||||||
OUT UINT32 *DescriptorVersion
|
OUT UINT32 *DescriptorVersion
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
Initialize SmiHandler profile feature.
|
||||||
|
**/
|
||||||
|
VOID
|
||||||
|
SmmCoreInitializeSmiHandlerProfile (
|
||||||
|
VOID
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called by SmmChildDispatcher module to report
|
||||||
|
a new SMI handler is registered, to SmmCore.
|
||||||
|
|
||||||
|
@param This The protocol instance
|
||||||
|
@param HandlerGuid The GUID to identify the type of the handler.
|
||||||
|
For the SmmChildDispatch protocol, the HandlerGuid
|
||||||
|
must be the GUID of SmmChildDispatch protocol.
|
||||||
|
@param Handler The SMI handler.
|
||||||
|
@param CallerAddress The address of the module who registers the SMI handler.
|
||||||
|
@param Context The context of the SMI handler.
|
||||||
|
For the SmmChildDispatch protocol, the Context
|
||||||
|
must match the one defined for SmmChildDispatch protocol.
|
||||||
|
@param ContextSize The size of the context in bytes.
|
||||||
|
For the SmmChildDispatch protocol, the Context
|
||||||
|
must match the one defined for SmmChildDispatch protocol.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The information is recorded.
|
||||||
|
@retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SmiHandlerProfileRegisterHandler (
|
||||||
|
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||||
|
IN EFI_GUID *HandlerGuid,
|
||||||
|
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
||||||
|
IN PHYSICAL_ADDRESS CallerAddress,
|
||||||
|
IN VOID *Context, OPTIONAL
|
||||||
|
IN UINTN ContextSize OPTIONAL
|
||||||
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
This function is called by SmmChildDispatcher module to report
|
||||||
|
an existing SMI handler is unregistered, to SmmCore.
|
||||||
|
|
||||||
|
@param This The protocol instance
|
||||||
|
@param HandlerGuid The GUID to identify the type of the handler.
|
||||||
|
For the SmmChildDispatch protocol, the HandlerGuid
|
||||||
|
must be the GUID of SmmChildDispatch protocol.
|
||||||
|
@param Handler The SMI handler.
|
||||||
|
|
||||||
|
@retval EFI_SUCCESS The original record is removed.
|
||||||
|
@retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.
|
||||||
|
**/
|
||||||
|
EFI_STATUS
|
||||||
|
EFIAPI
|
||||||
|
SmiHandlerProfileUnregisterHandler (
|
||||||
|
IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
||||||
|
IN EFI_GUID *HandlerGuid,
|
||||||
|
IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler
|
||||||
|
);
|
||||||
|
|
||||||
///
|
///
|
||||||
/// For generic EFI machines make the default allocations 4K aligned
|
/// For generic EFI machines make the default allocations 4K aligned
|
||||||
///
|
///
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
## @file
|
## @file
|
||||||
# This module provide an SMM CIS compliant implementation of SMM Core.
|
# This module provide an SMM CIS compliant implementation of SMM Core.
|
||||||
#
|
#
|
||||||
# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>
|
# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
#
|
#
|
||||||
# This program and the accompanying materials
|
# This program and the accompanying materials
|
||||||
# are licensed and made available under the terms and conditions of the BSD License
|
# are licensed and made available under the terms and conditions of the BSD License
|
||||||
|
@ -39,6 +39,7 @@
|
||||||
InstallConfigurationTable.c
|
InstallConfigurationTable.c
|
||||||
SmramProfileRecord.c
|
SmramProfileRecord.c
|
||||||
MemoryAttributesTable.c
|
MemoryAttributesTable.c
|
||||||
|
SmiHandlerProfile.c
|
||||||
|
|
||||||
[Packages]
|
[Packages]
|
||||||
MdePkg/MdePkg.dec
|
MdePkg/MdePkg.dec
|
||||||
|
@ -63,6 +64,7 @@
|
||||||
TimerLib
|
TimerLib
|
||||||
HobLib
|
HobLib
|
||||||
SmmMemLib
|
SmmMemLib
|
||||||
|
DxeServicesLib
|
||||||
|
|
||||||
[Protocols]
|
[Protocols]
|
||||||
gEfiDxeSmmReadyToLockProtocolGuid ## UNDEFINED # SmiHandlerRegister
|
gEfiDxeSmmReadyToLockProtocolGuid ## UNDEFINED # SmiHandlerRegister
|
||||||
|
@ -78,12 +80,22 @@
|
||||||
gEdkiiSmmLegacyBootProtocolGuid ## SOMETIMES_PRODUCES
|
gEdkiiSmmLegacyBootProtocolGuid ## SOMETIMES_PRODUCES
|
||||||
gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES
|
gEdkiiSmmReadyToBootProtocolGuid ## PRODUCES
|
||||||
|
|
||||||
|
gEfiSmmSwDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmSxDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmPowerButtonDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmStandbyButtonDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmPeriodicTimerDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmGpiDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmIoTrapDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
gEfiSmmUsbDispatch2ProtocolGuid ## SOMETIMES_CONSUMES
|
||||||
|
|
||||||
[Pcd]
|
[Pcd]
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber ## SOMETIMES_CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadFixAddressSmmCodePageNumber ## SOMETIMES_CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdLoadModuleAtFixAddressEnable ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileMemoryType ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfilePropertyMask ## CONSUMES
|
||||||
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath ## CONSUMES
|
gEfiMdeModulePkgTokenSpaceGuid.PcdMemoryProfileDriverPath ## CONSUMES
|
||||||
|
gEfiMdeModulePkgTokenSpaceGuid.PcdSmiHandlerProfilePropertyMask ## CONSUMES
|
||||||
|
|
||||||
[Guids]
|
[Guids]
|
||||||
gAprioriGuid ## SOMETIMES_CONSUMES ## File
|
gAprioriGuid ## SOMETIMES_CONSUMES ## File
|
||||||
|
@ -100,6 +112,9 @@
|
||||||
gEdkiiPiSmmMemoryAttributesTableGuid ## SOMETIMES_PRODUCES ## SystemTable
|
gEdkiiPiSmmMemoryAttributesTableGuid ## SOMETIMES_PRODUCES ## SystemTable
|
||||||
## SOMETIMES_CONSUMES ## SystemTable
|
## SOMETIMES_CONSUMES ## SystemTable
|
||||||
gLoadFixedAddressConfigurationTableGuid
|
gLoadFixedAddressConfigurationTableGuid
|
||||||
|
## SOMETIMES_PRODUCES ## GUID # Install protocol
|
||||||
|
## SOMETIMES_PRODUCES ## GUID # SmiHandlerRegister
|
||||||
|
gSmiHandlerProfileGuid
|
||||||
|
|
||||||
[UserExtensions.TianoCore."ExtraFiles"]
|
[UserExtensions.TianoCore."ExtraFiles"]
|
||||||
PiSmmCoreExtra.uni
|
PiSmmCoreExtra.uni
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
/** @file
|
/** @file
|
||||||
SMI management.
|
SMI management.
|
||||||
|
|
||||||
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>
|
Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>
|
||||||
This program and the accompanying materials are licensed and made available
|
This program and the accompanying materials are licensed and made available
|
||||||
under the terms and conditions of the BSD License which accompanies this
|
under the terms and conditions of the BSD License which accompanies this
|
||||||
distribution. The full text of the license may be found at
|
distribution. The full text of the license may be found at
|
||||||
|
@ -14,32 +14,15 @@
|
||||||
|
|
||||||
#include "PiSmmCore.h"
|
#include "PiSmmCore.h"
|
||||||
|
|
||||||
//
|
|
||||||
// SMM_HANDLER - used for each SMM handler
|
|
||||||
//
|
|
||||||
|
|
||||||
#define SMI_ENTRY_SIGNATURE SIGNATURE_32('s','m','i','e')
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
LIST_ENTRY AllEntries; // All entries
|
|
||||||
|
|
||||||
EFI_GUID HandlerType; // Type of interrupt
|
|
||||||
LIST_ENTRY SmiHandlers; // All handlers
|
|
||||||
} SMI_ENTRY;
|
|
||||||
|
|
||||||
#define SMI_HANDLER_SIGNATURE SIGNATURE_32('s','m','i','h')
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
UINTN Signature;
|
|
||||||
LIST_ENTRY Link; // Link on SMI_ENTRY.SmiHandlers
|
|
||||||
EFI_SMM_HANDLER_ENTRY_POINT2 Handler; // The smm handler's entry point
|
|
||||||
SMI_ENTRY *SmiEntry;
|
|
||||||
} SMI_HANDLER;
|
|
||||||
|
|
||||||
LIST_ENTRY mRootSmiHandlerList = INITIALIZE_LIST_HEAD_VARIABLE (mRootSmiHandlerList);
|
|
||||||
LIST_ENTRY mSmiEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mSmiEntryList);
|
LIST_ENTRY mSmiEntryList = INITIALIZE_LIST_HEAD_VARIABLE (mSmiEntryList);
|
||||||
|
|
||||||
|
SMI_ENTRY mRootSmiEntry = {
|
||||||
|
SMI_ENTRY_SIGNATURE,
|
||||||
|
INITIALIZE_LIST_HEAD_VARIABLE (mRootSmiEntry.AllEntries),
|
||||||
|
{0},
|
||||||
|
INITIALIZE_LIST_HEAD_VARIABLE (mRootSmiEntry.SmiHandlers),
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
Finds the SMI entry for the requested handler type.
|
Finds the SMI entry for the requested handler type.
|
||||||
|
|
||||||
|
@ -137,8 +120,7 @@ SmiManage (
|
||||||
//
|
//
|
||||||
// Root SMI handler
|
// Root SMI handler
|
||||||
//
|
//
|
||||||
|
SmiEntry = &mRootSmiEntry;
|
||||||
Head = &mRootSmiHandlerList;
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// Non-root SMI handler
|
// Non-root SMI handler
|
||||||
|
@ -150,9 +132,8 @@ SmiManage (
|
||||||
//
|
//
|
||||||
return Status;
|
return Status;
|
||||||
}
|
}
|
||||||
|
|
||||||
Head = &SmiEntry->SmiHandlers;
|
|
||||||
}
|
}
|
||||||
|
Head = &SmiEntry->SmiHandlers;
|
||||||
|
|
||||||
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
|
for (Link = Head->ForwardLink; Link != Head; Link = Link->ForwardLink) {
|
||||||
SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
|
SmiHandler = CR (Link, SMI_HANDLER, Link, SMI_HANDLER_SIGNATURE);
|
||||||
|
@ -252,13 +233,13 @@ SmiHandlerRegister (
|
||||||
|
|
||||||
SmiHandler->Signature = SMI_HANDLER_SIGNATURE;
|
SmiHandler->Signature = SMI_HANDLER_SIGNATURE;
|
||||||
SmiHandler->Handler = Handler;
|
SmiHandler->Handler = Handler;
|
||||||
|
SmiHandler->CallerAddr = (UINTN)RETURN_ADDRESS (0);
|
||||||
|
|
||||||
if (HandlerType == NULL) {
|
if (HandlerType == NULL) {
|
||||||
//
|
//
|
||||||
// This is root SMI handler
|
// This is root SMI handler
|
||||||
//
|
//
|
||||||
SmiEntry = NULL;
|
SmiEntry = &mRootSmiEntry;
|
||||||
List = &mRootSmiHandlerList;
|
|
||||||
} else {
|
} else {
|
||||||
//
|
//
|
||||||
// None root SMI handler
|
// None root SMI handler
|
||||||
|
@ -267,9 +248,8 @@ SmiHandlerRegister (
|
||||||
if (SmiEntry == NULL) {
|
if (SmiEntry == NULL) {
|
||||||
return EFI_OUT_OF_RESOURCES;
|
return EFI_OUT_OF_RESOURCES;
|
||||||
}
|
}
|
||||||
|
|
||||||
List = &SmiEntry->SmiHandlers;
|
|
||||||
}
|
}
|
||||||
|
List = &SmiEntry->SmiHandlers;
|
||||||
|
|
||||||
SmiHandler->SmiEntry = SmiEntry;
|
SmiHandler->SmiEntry = SmiEntry;
|
||||||
InsertTailList (List, &SmiHandler->Link);
|
InsertTailList (List, &SmiHandler->Link);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue