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