summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJiewen Yao <jiewen.yao@intel.com>2017-10-20 11:28:50 +0800
committerJiewen Yao <jiewen.yao@intel.com>2017-10-24 19:43:10 +0800
commit23926ef8005f9a2cc5795896372d442c6d34f20d (patch)
treee8135a0d55cb9bf84569a9e6455dd61065c00005
parentbb0af376e515f6e6a68fe06a1fadd910db5403dd (diff)
downloadedk2-platforms-23926ef8005f9a2cc5795896372d442c6d34f20d.tar.xz
Enable SmiHandlerProfile in Silicon code.
Make SmiChildDispatch report the SMI handler information. As such, people can know how many SMI child handlers are installed. Cc: Michael A Kubacki <michael.a.kubacki@intel.com> Cc: Amy Chan <amy.chan@intel.com> Cc: Chasel Chiu <chasel.chiu@intel.com> Cc: Brett Wang <brett.wang@intel.com> Cc: Daocheng Bu <daocheng.bu@intel.com> Cc: Isaac W Oram <isaac.w.oram@intel.com> Cc: Rangasai V Chaganty <rangasai.v.chaganty@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jiewen Yao <jiewen.yao@intel.com> Reviewed-by: Amy Chan <amy.chan@intel.com>
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/IoTrap.c4
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatch.c44
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatcher.inf1
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmm.h4
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmCore.c50
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.c13
-rw-r--r--Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.h4
7 files changed, 114 insertions, 6 deletions
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/IoTrap.c b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/IoTrap.c
index 5c3ea07646..ffb2105719 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/IoTrap.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/IoTrap.c
@@ -457,6 +457,8 @@ IoTrapRegister (
DEBUG ((DEBUG_INFO, "RegisterContext->Address:%x! \n", RegisterContext->Address));
DEBUG ((DEBUG_INFO, "RegisterContext->Length:%x! \n", RegisterContext->Length));
+ SmiHandlerProfileRegisterHandler (&gEfiSmmIoTrapDispatch2ProtocolGuid, DispatchFunction, (UINTN)RETURN_ADDRESS (0), RegisterContext, sizeof(*RegisterContext));
+
return EFI_SUCCESS;
}
@@ -584,6 +586,8 @@ IoTrapUnRegister (
}
}
+ SmiHandlerProfileUnregisterHandler (&gEfiSmmIoTrapDispatch2ProtocolGuid, RecordToDelete->Callback, &RecordToDelete->Context, sizeof(RecordToDelete->Context));
+
RemoveEntryList (&RecordToDelete->Link);
Status = gSmst->SmmFreePool (RecordToDelete);
ASSERT_EFI_ERROR (Status);
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatch.c b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatch.c
index 24773560e5..a0bd9aaaa1 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatch.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatch.c
@@ -28,6 +28,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
EFI_STATUS
PchSmiRecordInsert (
+ IN EFI_GUID *ProtocolGuid,
IN PCH_SMM_SOURCE_DESC *SrcDesc,
IN PCH_SMI_CALLBACK_FUNCTIONS DispatchFunction,
IN PCH_SMI_TYPES PchSmiType,
@@ -59,6 +60,7 @@ PchSmiRecordInsert (
Record->Signature = DATABASE_RECORD_SIGNATURE;
Record->PchSmiCallback = DispatchFunction;
Record->ProtocolType = PchSmiDispatchType;
+ Record->ProtocolGuid = ProtocolGuid;
Record->PchSmiType = PchSmiType;
Record->ContextFunctions.GetContext = NULL;
@@ -78,9 +80,20 @@ PchSmiRecordInsert (
//
*DispatchHandle = (EFI_HANDLE) (&Record->Link);
+ if (ProtocolGuid != NULL) {
+ SmiHandlerProfileRegisterHandler (ProtocolGuid, (EFI_SMM_HANDLER_ENTRY_POINT2)DispatchFunction, (UINTN)RETURN_ADDRESS (0), &PchSmiType, sizeof(PchSmiType));
+ }
+
return EFI_SUCCESS;
}
+EFI_STATUS
+PchSmiRecordUnRegister (
+ IN EFI_HANDLE DispatchHandle
+ )
+{
+ return PchSmmCoreUnRegister(NULL, DispatchHandle);
+}
//
// TCO_STS bit that needs to be cleared
@@ -230,6 +243,7 @@ PchTcoSmiMchRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescMch,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiMchType,
@@ -312,6 +326,7 @@ PchTcoSmiTcoTimeoutRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescTcoTimeout,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiTcoTimeoutType,
@@ -394,6 +409,7 @@ PchTcoSmiOsTcoRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescOsTco,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiOsTcoType,
@@ -473,6 +489,7 @@ PchTcoSmiNmiRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescNmi,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiNmiType,
@@ -562,6 +579,7 @@ PchTcoSmiIntruderDetRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescIntruderDet,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiIntruderDetectType,
@@ -721,6 +739,7 @@ PchTcoSmiSpiBiosWpRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescSpiBiosWp,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiSpiBiosWpType,
@@ -816,6 +835,7 @@ PchTcoSmiLpcBiosWpRegister (
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescLpcBiosWp,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiLpcBiosWpType,
@@ -918,6 +938,7 @@ PchTcoSmiNewCenturyRegister (
}
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescNewCentury,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchTcoSmiNewCenturyType,
@@ -974,7 +995,7 @@ PchTcoSmiUnRegister (
//
return EFI_ACCESS_DENIED;
}
- return PchSmmCoreUnRegister (NULL, DispatchHandle);
+ return PchSmiRecordUnRegister (DispatchHandle);
}
@@ -1058,6 +1079,7 @@ PchPcieSmiHotPlugRegister (
PchPcieSmiRpHotPlugTemplate.Sts[0].Reg.Data.pcie.Fields.Fnc = (UINT8) RpFun;
Status = PchSmiRecordInsert (
+ &gPchPcieSmiDispatchProtocolGuid,
&PchPcieSmiRpHotPlugTemplate,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchPcieSmiRpHotplugType,
@@ -1149,6 +1171,7 @@ PchPcieSmiLinkActiveRegister (
PchPcieSmiRpLinkActiveTemplate.Sts[0].Reg.Data.pcie.Fields.Fnc = (UINT8) RpFun;
Status = PchSmiRecordInsert (
+ &gPchPcieSmiDispatchProtocolGuid,
&PchPcieSmiRpLinkActiveTemplate,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchPcieSmiRpLinkActiveType,
@@ -1239,6 +1262,7 @@ PchPcieSmiLinkEqRegister (
PchPcieSmiRpLinkEqTemplate.Sts[0].Reg.Data.pcie.Fields.Fnc = (UINT8) RpFun;
return PchSmiRecordInsert (
+ &gPchPcieSmiDispatchProtocolGuid,
&PchPcieSmiRpLinkEqTemplate,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchPcieSmiRpLinkEqType,
@@ -1266,7 +1290,7 @@ PchPcieSmiUnRegister (
IN EFI_HANDLE DispatchHandle
)
{
- return PchSmmCoreUnRegister (NULL, DispatchHandle);
+ return PchSmiRecordUnRegister (DispatchHandle);
}
//
@@ -1336,6 +1360,7 @@ PchAcpiSmiPmeRegister (
}
Status = PchSmiRecordInsert (
+ &gPchAcpiSmiDispatchProtocolGuid,
&mSrcDescPme,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchAcpiSmiPmeType,
@@ -1414,6 +1439,7 @@ PchAcpiSmiPmeB0Register (
}
Status = PchSmiRecordInsert (
+ &gPchAcpiSmiDispatchProtocolGuid,
&mSrcDescPmeB0,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchAcpiSmiPmeB0Type,
@@ -1492,6 +1518,7 @@ PchAcpiSmiRtcAlarmRegister (
}
Status = PchSmiRecordInsert (
+ &gPchAcpiSmiDispatchProtocolGuid,
&mSrcDescRtcAlarm,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchAcpiSmiRtcAlarmType,
@@ -1570,6 +1597,7 @@ PchAcpiSmiTmrOverflowRegister (
}
Status = PchSmiRecordInsert (
+ &gPchAcpiSmiDispatchProtocolGuid,
&mSrcDescTmrOverflow,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchAcpiSmiTmrOverflowType,
@@ -1601,7 +1629,7 @@ PchAcpiSmiUnRegister (
IN EFI_HANDLE DispatchHandle
)
{
- return PchSmmCoreUnRegister (NULL, DispatchHandle);
+ return PchSmiRecordUnRegister (DispatchHandle);
}
//
@@ -1671,6 +1699,7 @@ PchGpioUnlockSmiRegister (
}
Status = PchSmiRecordInsert (
+ &gPchGpioUnlockSmiDispatchProtocolGuid,
&mSrcDescGpioUnlock,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchGpioUnlockSmiType,
@@ -1702,7 +1731,7 @@ PchGpioUnlockSmiUnRegister (
IN EFI_HANDLE DispatchHandle
)
{
- return PchSmmCoreUnRegister (NULL, DispatchHandle);
+ return PchSmiRecordUnRegister (DispatchHandle);
}
//
@@ -1765,6 +1794,7 @@ PchSmiSerialIrqRegister (
}
Status = PchSmiRecordInsert (
+ &gPchSmiDispatchProtocolGuid,
&mSrcDescSerialIrq,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchSmiSerialIrqType,
@@ -1843,6 +1873,7 @@ PchSmiMcSmiRegister (
}
Status = PchSmiRecordInsert (
+ &gPchSmiDispatchProtocolGuid,
&mSrcDescMcSmi,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchSmiMcSmiType,
@@ -1914,6 +1945,7 @@ PchSmiSmbusRegister (
}
Status = PchSmiRecordInsert (
+ &gPchSmiDispatchProtocolGuid,
&mSrcDescSmbus,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchSmiSmBusType,
@@ -2064,6 +2096,7 @@ PchSmiSpiAsyncRegister (
}
Status = PchSmiRecordInsert (
+ &gPchSmiDispatchProtocolGuid,
&mSrcDescSpiAsyncSmi,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchSmiSpiAsyncType,
@@ -2121,7 +2154,7 @@ PchSmiUnRegister (
}
}
- return PchSmmCoreUnRegister (NULL, DispatchHandle);
+ return PchSmiRecordUnRegister (DispatchHandle);
}
@@ -2466,6 +2499,7 @@ PchInternalIoTrapSmiRegister (
EFI_STATUS Status;
Status = PchSmiRecordInsert (
+ NULL,
&mSrcDescIoTrap[IoTrapIndex],
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchIoTrapSmiType,
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatcher.inf b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatcher.inf
index b6fc2b95fd..a593d631d3 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatcher.inf
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmiDispatcher.inf
@@ -45,6 +45,7 @@ GpioLib
GpioPrivateLib
S3BootScriptLib
ConfigBlockLib
+SmiHandlerProfileLib
[Packages]
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmm.h b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmm.h
index 7e4cce83f3..3eebdc1daf 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmm.h
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmm.h
@@ -53,6 +53,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/PchEspiSmiDispatch.h>
#include "IoTrap.h"
+#include <Library/SmiHandlerProfileLib.h>
+
#define EFI_BAD_POINTER 0xAFAFAFAFAFAFAFAFULL
extern BOOLEAN mReadyToLock;
@@ -450,6 +452,7 @@ struct _DATABASE_RECORD {
/// The protocol that this record dispatches
///
PCH_SMM_PROTOCOL_TYPE ProtocolType;
+ EFI_GUID *ProtocolGuid;
///
/// Misc data for private usage
@@ -915,6 +918,7 @@ PchInternalEspiSmiUnRegister (
**/
EFI_STATUS
PchSmiRecordInsert (
+ IN EFI_GUID *ProtocolGuid,
IN PCH_SMM_SOURCE_DESC *SrcDesc,
IN PCH_SMI_CALLBACK_FUNCTIONS DispatchFunction,
IN PCH_SMI_TYPES PchSmiType,
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmCore.c b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmCore.c
index 977a7ec57c..77f0561ce4 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmCore.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmCore.c
@@ -349,6 +349,7 @@ PchSmmCoreRegister (
UINT32 GpiSmiStsRegAddress;
UINT32 Data32Or;
UINT32 Data32And;
+ UINTN ContextSize;
//
// Initialize NullSourceDesc
@@ -380,6 +381,8 @@ PchSmmCoreRegister (
///
Record->Callback = DispatchFunction;
+ Record->ChildContext = *DispatchContext;
+
Qualified = QUALIFIED_PROTOCOL_FROM_GENERIC (This);
Record->ProtocolType = Qualified->Type;
@@ -389,6 +392,7 @@ PchSmmCoreRegister (
/// Perform linked list housekeeping
///
Record->Signature = DATABASE_RECORD_SIGNATURE;
+ ContextSize = 0;
switch (Qualified->Type) {
///
@@ -406,6 +410,7 @@ PchSmmCoreRegister (
MapUsbToSrcDesc (DispatchContext, &(Record->SrcDesc));
Record->ClearSource = NULL;
+ ContextSize = sizeof(Record->ChildContext.Usb);
///
/// use default clear source function
///
@@ -426,6 +431,7 @@ PchSmmCoreRegister (
CopyMem ((VOID *) &(Record->SrcDesc), (VOID *) (&SX_SOURCE_DESC), sizeof (PCH_SMM_SOURCE_DESC));
Record->ClearSource = NULL;
+ ContextSize = sizeof(Record->ChildContext.Sx);
///
/// use default clear source function
///
@@ -458,6 +464,7 @@ PchSmmCoreRegister (
CopyMem ((VOID *) &(Record->SrcDesc), (VOID *) (&SW_SOURCE_DESC), sizeof (PCH_SMM_SOURCE_DESC));
Record->ClearSource = NULL;
+ ContextSize = sizeof(Record->ChildContext.Sw);
///
/// use default clear source function
///
@@ -490,6 +497,7 @@ PchSmmCoreRegister (
Record->SrcDesc.Sts[0].Reg.Data.raw = GpiSmiStsRegAddress; // GPI SMI Status register
Record->SrcDesc.Sts[0].Bit = GpiSmiBitOffset; // Bit position for selected pad
Record->ClearSource = NULL;
+ ContextSize = sizeof(Record->ChildContext.Gpi);
///
/// use default clear source function
///
@@ -515,6 +523,7 @@ PchSmmCoreRegister (
CopyMem ((VOID *) &(Record->SrcDesc), (VOID *) &POWER_BUTTON_SOURCE_DESC, sizeof (PCH_SMM_SOURCE_DESC));
Record->ClearSource = NULL;
+ ContextSize = sizeof(Record->ChildContext.PowerButton);
///
/// use default clear source function
///
@@ -531,6 +540,7 @@ PchSmmCoreRegister (
MapPeriodicTimerToSrcDesc (DispatchContext, &(Record->SrcDesc));
Record->ClearSource = PchSmmPeriodicTimerClearSource;
+ ContextSize = sizeof(Record->ChildContext.PeriodicTimer);
break;
default:
@@ -565,6 +575,9 @@ PchSmmCoreRegister (
/// Child's handle will be the address linked list link in the record
///
*DispatchHandle = (EFI_HANDLE) (&Record->Link);
+ *DispatchContext = Record->ChildContext;
+
+ SmiHandlerProfileRegisterHandler (Qualified->Guid, DispatchFunction, (UINTN)RETURN_ADDRESS (0), &Record->ChildContext, ContextSize);
return EFI_SUCCESS;
@@ -600,7 +613,7 @@ PchSmmCoreUnRegister (
DATABASE_RECORD *RecordToDelete;
DATABASE_RECORD *RecordInDb;
LIST_ENTRY *LinkInDb;
-
+ PCH_SMM_QUALIFIED_PROTOCOL *Qualified;
if (DispatchHandle == NULL) {
return EFI_INVALID_PARAMETER;
@@ -649,6 +662,41 @@ PchSmmCoreUnRegister (
WriteBitDesc (&RecordToDelete->SrcDesc.En[DescIndex], 0, FALSE);
}
+ if (This != NULL) {
+ UINTN ContextSize;
+
+ Qualified = QUALIFIED_PROTOCOL_FROM_GENERIC (This);
+ switch (Qualified->Type) {
+ case UsbType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.Usb);
+ break;
+ case SxType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.Sx);
+ break;
+ case SwType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.Sw);
+ break;
+ case GpiType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.Gpi);
+ break;
+ case PowerButtonType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.PowerButton);
+ break;
+ case PeriodicTimerType:
+ ContextSize = sizeof(RecordToDelete->ChildContext.PeriodicTimer);
+ break;
+ default:
+ ASSERT(FALSE);
+ ContextSize = 0;
+ break;
+ }
+ SmiHandlerProfileUnregisterHandler (Qualified->Guid, RecordToDelete->Callback, &RecordToDelete->ChildContext, ContextSize);
+ } else {
+ if (RecordToDelete->ProtocolGuid != NULL) {
+ SmiHandlerProfileUnregisterHandler (RecordToDelete->ProtocolGuid, (EFI_SMM_HANDLER_ENTRY_POINT2)RecordToDelete->PchSmiCallback, &RecordToDelete->PchSmiType, sizeof(RecordToDelete->PchSmiType));
+ }
+ }
+
Status = gSmst->SmmFreePool (RecordToDelete);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.c b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.c
index 8484be18ea..a4a7380737 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.c
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.c
@@ -14,6 +14,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "PchSmmEspi.h"
+#define PCH_ESPI_SMI_DISPATCH_GUID \
+ {0xcfde92ca, 0xd104, 0x4f75, {0x85, 0xde, 0xab, 0x56, 0x5e, 0x2f, 0x52, 0xf0}}
+
+EFI_GUID gPchEspiSmiDispatchGuid = PCH_ESPI_SMI_DISPATCH_GUID;
+
GLOBAL_REMOVE_IF_UNREFERENCED ESPI_SMI_INSTANCE mEspiSmiInstance = {
//
// Signature
@@ -545,6 +550,7 @@ InsertEspiRecord (
Record->Callback = DispatchFunction;
Record->Signature = ESPI_SMI_RECORD_SIGNATURE;
+ Record->EspiSmiType = EspiSmiType;
InsertTailList (&mEspiSmiInstance.CallbackDataBase[EspiSmiType], &Record->Link);
EspiSmiClearStatus (EspiSmiType);
@@ -554,6 +560,8 @@ InsertEspiRecord (
*DispatchHandle = (EFI_HANDLE) (&Record->Link);
+ SmiHandlerProfileRegisterHandler (&gPchEspiSmiDispatchGuid, (EFI_SMM_HANDLER_ENTRY_POINT2)DispatchFunction, (UINTN)RETURN_ADDRESS (0), &EspiSmiType, sizeof(EspiSmiType));
+
return EFI_SUCCESS;
}
@@ -699,6 +707,7 @@ RegisterBiosWrProtectIfNull (
if (mEspiSmiInstance.PchSmiEspiHandle[EspiBiosWrProtect] == NULL) {
Status = PchSmiRecordInsert (
+ &gPchTcoSmiDispatchProtocolGuid,
&mSrcDescEspiBiosWp,
(PCH_SMI_CALLBACK_FUNCTIONS) EspiSmiCallback,
PchTcoSmiLpcBiosWpType,
@@ -735,6 +744,7 @@ RegisterSerialIrqIfNull (
if (mEspiSmiInstance.PchSmiEspiHandle[EspiSerialIrq] == NULL) {
Status = PchSmiRecordInsert (
+ &gPchSmiDispatchProtocolGuid,
&mSrcDescSerialIrq,
(PCH_SMI_CALLBACK_FUNCTIONS) EspiSmiCallback,
PchSmiSerialIrqType,
@@ -1244,6 +1254,7 @@ EspiSlaveSmiRegister (
// instead of EspiSmiCallback.
//
Status = PchSmiRecordInsert (
+ &gPchEspiSmiDispatchProtocolGuid,
&mSrcDescEspiSlave,
(PCH_SMI_CALLBACK_FUNCTIONS) DispatchFunction,
PchEspiSmiEspiSlaveType,
@@ -1338,6 +1349,8 @@ EspiSmiUnRegister (
}
}
+ SmiHandlerProfileUnregisterHandler (&gPchEspiSmiDispatchGuid, (EFI_SMM_HANDLER_ENTRY_POINT2)RecordPointer->Callback, &RecordPointer->EspiSmiType, sizeof(RecordPointer->EspiSmiType));
+
Status = gSmst->SmmFreePool (RecordPointer);
if (EFI_ERROR (Status)) {
ASSERT (FALSE);
diff --git a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.h b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.h
index 2e4f407181..da600495c0 100644
--- a/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.h
+++ b/Silicon/Intel/KabylakeSiliconPkg/Pch/PchSmiDispatcher/Smm/PchSmmEspi.h
@@ -100,6 +100,10 @@ typedef struct _ESPI_SMI_RECORD {
UINT32 Signature;
LIST_ENTRY Link;
PCH_ESPI_SMI_DISPATCH_CALLBACK Callback;
+ ///
+ /// Indicate the ESPI SMI types.
+ ///
+ ESPI_SMI_TYPE EspiSmiType;
} ESPI_SMI_RECORD;
/**