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