]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Library/SmmSmiHandlerProfileLib/MmSmiHandlerProfileLib.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdeModulePkg / Library / SmmSmiHandlerProfileLib / MmSmiHandlerProfileLib.c
CommitLineData
1f0fa918
KQ
1/** @file\r
2 MM driver instance of SmiHandlerProfile Library.\r
3\r
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>\r
5 Copyright (c) Microsoft Corporation.\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#include <PiMm.h>\r
11#include <Library/SmiHandlerProfileLib.h>\r
12#include <Library/MmServicesTableLib.h>\r
13#include <Guid/SmiHandlerProfile.h>\r
14\r
15SMI_HANDLER_PROFILE_PROTOCOL *mSmiHandlerProfile;\r
16\r
17/**\r
18 This function is called by SmmChildDispatcher module to report\r
19 a new SMI handler is registered, to SmmCore.\r
20\r
21 @param HandlerGuid The GUID to identify the type of the handler.\r
22 For the SmmChildDispatch protocol, the HandlerGuid\r
23 must be the GUID of SmmChildDispatch protocol.\r
24 @param Handler The SMI handler.\r
25 @param CallerAddress The address of the module who registers the SMI handler.\r
26 @param Context The context of the SMI handler.\r
27 For the SmmChildDispatch protocol, the Context\r
28 must match the one defined for SmmChildDispatch protocol.\r
29 @param ContextSize The size of the context in bytes.\r
30 For the SmmChildDispatch protocol, the Context\r
31 must match the one defined for SmmChildDispatch protocol.\r
32\r
33 @retval EFI_SUCCESS The information is recorded.\r
34 @retval EFI_UNSUPPORTED The feature is unsupported.\r
35 @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.\r
36**/\r
37EFI_STATUS\r
38EFIAPI\r
39SmiHandlerProfileRegisterHandler (\r
1436aea4
MK
40 IN EFI_GUID *HandlerGuid,\r
41 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r
42 IN PHYSICAL_ADDRESS CallerAddress,\r
43 IN VOID *Context OPTIONAL,\r
44 IN UINTN ContextSize OPTIONAL\r
1f0fa918
KQ
45 )\r
46{\r
47 if (mSmiHandlerProfile != NULL) {\r
48 return mSmiHandlerProfile->RegisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, CallerAddress, Context, ContextSize);\r
49 }\r
1436aea4 50\r
1f0fa918
KQ
51 return EFI_UNSUPPORTED;\r
52}\r
53\r
54/**\r
55 This function is called by SmmChildDispatcher module to report\r
56 an existing SMI handler is unregistered, to SmmCore.\r
57\r
58 @param HandlerGuid The GUID to identify the type of the handler.\r
59 For the SmmChildDispatch protocol, the HandlerGuid\r
60 must be the GUID of SmmChildDispatch protocol.\r
61 @param Handler The SMI handler.\r
62 @param Context The context of the SMI handler.\r
63 If it is NOT NULL, it will be used to check what is registered.\r
64 @param ContextSize The size of the context in bytes.\r
65 If Context is NOT NULL, it will be used to check what is registered.\r
66\r
67 @retval EFI_SUCCESS The original record is removed.\r
68 @retval EFI_UNSUPPORTED The feature is unsupported.\r
69 @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.\r
70**/\r
71EFI_STATUS\r
72EFIAPI\r
73SmiHandlerProfileUnregisterHandler (\r
1436aea4
MK
74 IN EFI_GUID *HandlerGuid,\r
75 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r
76 IN VOID *Context OPTIONAL,\r
77 IN UINTN ContextSize OPTIONAL\r
1f0fa918
KQ
78 )\r
79{\r
80 if (mSmiHandlerProfile != NULL) {\r
81 return mSmiHandlerProfile->UnregisterHandler (mSmiHandlerProfile, HandlerGuid, Handler, Context, ContextSize);\r
82 }\r
1436aea4 83\r
1f0fa918
KQ
84 return EFI_UNSUPPORTED;\r
85}\r
86\r
87/**\r
88 The common constructor function for SMI handler profile.\r
89\r
90 @retval EFI_SUCCESS The constructor always returns EFI_SUCCESS.\r
91**/\r
92EFI_STATUS\r
93MmSmiHandlerProfileLibInitialization (\r
94 VOID\r
95 )\r
96{\r
97 gMmst->MmLocateProtocol (\r
98 &gSmiHandlerProfileGuid,\r
99 NULL,\r
1436aea4 100 (VOID **)&mSmiHandlerProfile\r
1f0fa918
KQ
101 );\r
102 return EFI_SUCCESS;\r
103}\r