]> git.proxmox.com Git - mirror_edk2.git/blob - MdeModulePkg/Include/Guid/SmiHandlerProfile.h
MdeModulePkg/SmiHandlerProfile: Add Context support in Unregister
[mirror_edk2.git] / MdeModulePkg / Include / Guid / SmiHandlerProfile.h
1 /** @file
2 Header file for SMI handler profile definition.
3
4 Copyright (c) 2017, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef _SMI_HANDLER_PROFILE_H_
16 #define _SMI_HANDLER_PROFILE_H_
17
18 #include <PiSmm.h>
19 #include <Protocol/SmmGpiDispatch2.h>
20 #include <Protocol/SmmIoTrapDispatch2.h>
21 #include <Protocol/SmmPeriodicTimerDispatch2.h>
22 #include <Protocol/SmmPowerButtonDispatch2.h>
23 #include <Protocol/SmmStandbyButtonDispatch2.h>
24 #include <Protocol/SmmSwDispatch2.h>
25 #include <Protocol/SmmSxDispatch2.h>
26 #include <Protocol/SmmUsbDispatch2.h>
27
28 #pragma pack(1)
29
30 typedef struct {
31 UINT32 Signature;
32 UINT32 Length;
33 UINT32 Revision;
34 } SMM_CORE_DATABASE_COMMON_HEADER;
35
36 #define SMM_CORE_IMAGE_DATABASE_SIGNATURE SIGNATURE_32 ('S','C','I','D')
37 #define SMM_CORE_IMAGE_DATABASE_REVISION 0x0001
38
39 typedef struct {
40 SMM_CORE_DATABASE_COMMON_HEADER Header;
41 EFI_GUID FileGuid;
42 UINTN ImageRef;
43 UINTN EntryPoint;
44 UINTN ImageBase;
45 UINTN ImageSize;
46 UINT16 PdbStringOffset;
47 UINT8 Reserved2[6];
48 //CHAR8 PdbString[];
49 } SMM_CORE_IMAGE_DATABASE_STRUCTURE;
50
51 #define SMM_CORE_SMI_DATABASE_SIGNATURE SIGNATURE_32 ('S','C','S','D')
52 #define SMM_CORE_SMI_DATABASE_REVISION 0x0001
53
54 typedef enum {
55 SmmCoreSmiHandlerCategoryRootHandler,
56 SmmCoreSmiHandlerCategoryGuidHandler,
57 SmmCoreSmiHandlerCategoryHardwareHandler,
58 } SMM_CORE_SMI_HANDLER_CATEGORY;
59
60 //
61 // Context for SmmCoreSmiHandlerCategoryRootHandler:
62 // NULL
63 // Context for SmmCoreSmiHandlerCategoryGuidHandler:
64 // NULL
65 // Context for SmmCoreSmiHandlerCategoryHardwareHandler:
66 // (NOTE: The context field should NOT include any data pointer.)
67 // gEfiSmmSwDispatch2ProtocolGuid: EFI_SMM_SW_REGISTER_CONTEXT
68 // gEfiSmmSxDispatch2ProtocolGuid: EFI_SMM_SX_REGISTER_CONTEXT
69 // gEfiSmmPowerButtonDispatch2ProtocolGuid: EFI_SMM_POWER_BUTTON_REGISTER_CONTEXT
70 // gEfiSmmStandbyButtonDispatch2ProtocolGuid: EFI_SMM_STANDBY_BUTTON_REGISTER_CONTEXT
71 // gEfiSmmPeriodicTimerDispatch2ProtocolGuid: EFI_SMM_PERIODIC_TIMER_CONTEXT
72 // gEfiSmmGpiDispatch2ProtocolGuid: EFI_SMM_GPI_REGISTER_CONTEXT
73 // gEfiSmmIoTrapDispatch2ProtocolGuid: EFI_SMM_IO_TRAP_REGISTER_CONTEXT
74 // gEfiSmmUsbDispatch2ProtocolGuid: (EFI_SMM_USB_REGISTER_CONTEXT => SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT)
75 // Other: GUID specific
76
77 typedef struct {
78 EFI_USB_SMI_TYPE Type;
79 UINT32 DevicePathSize;
80 //UINT8 DevicePath[DevicePathSize];
81 } SMI_HANDLER_PROFILE_USB_REGISTER_CONTEXT;
82
83 typedef struct {
84 UINT32 Length;
85 UINTN CallerAddr;
86 UINTN Handler;
87 UINTN ImageRef;
88 UINT16 ContextBufferOffset;
89 UINT8 Reserved2[2];
90 UINT32 ContextBufferSize;
91 //UINT8 ContextBuffer[];
92 } SMM_CORE_SMI_HANDLER_STRUCTURE;
93
94 typedef struct {
95 SMM_CORE_DATABASE_COMMON_HEADER Header;
96 UINT32 HandlerCategory;
97 EFI_GUID HandlerType;
98 UINTN HandlerCount;
99 //SMM_CORE_SMI_HANDLER_STRUCTURE Handler[HandlerCount];
100 } SMM_CORE_SMI_DATABASE_STRUCTURE;
101
102 //
103 // Layout:
104 // +-------------------------------------+
105 // | SMM_CORE_IMAGE_DATABASE_STRUCTURE |
106 // +-------------------------------------+
107 // | SMM_CORE_SMI_DATABASE_STRUCTURE |
108 // +-------------------------------------+
109 //
110
111
112
113 //
114 // SMM_CORE dump command
115 //
116 #define SMI_HANDLER_PROFILE_COMMAND_GET_INFO 0x1
117 #define SMI_HANDLER_PROFILE_COMMAND_GET_DATA_BY_OFFSET 0x2
118
119 typedef struct {
120 UINT32 Command;
121 UINT32 DataLength;
122 UINT64 ReturnStatus;
123 } SMI_HANDLER_PROFILE_PARAMETER_HEADER;
124
125 typedef struct {
126 SMI_HANDLER_PROFILE_PARAMETER_HEADER Header;
127 UINT64 DataSize;
128 } SMI_HANDLER_PROFILE_PARAMETER_GET_INFO;
129
130 typedef struct {
131 SMI_HANDLER_PROFILE_PARAMETER_HEADER Header;
132 //
133 // On input, data buffer size.
134 // On output, actual data buffer size copied.
135 //
136 UINT64 DataSize;
137 PHYSICAL_ADDRESS DataBuffer;
138 //
139 // On input, data buffer offset to copy.
140 // On output, next time data buffer offset to copy.
141 //
142 UINT64 DataOffset;
143 } SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET;
144
145 #define SMI_HANDLER_PROFILE_GUID {0x49174342, 0x7108, 0x409b, {0x8b, 0xbe, 0x65, 0xfd, 0xa8, 0x53, 0x89, 0xf5}}
146
147 #pragma pack()
148
149 extern EFI_GUID gSmiHandlerProfileGuid;
150
151 typedef struct _SMI_HANDLER_PROFILE_PROTOCOL SMI_HANDLER_PROFILE_PROTOCOL;
152
153 /**
154 This function is called by SmmChildDispatcher module to report
155 a new SMI handler is registered, to SmmCore.
156
157 @param This The protocol instance
158 @param HandlerGuid The GUID to identify the type of the handler.
159 For the SmmChildDispatch protocol, the HandlerGuid
160 must be the GUID of SmmChildDispatch protocol.
161 @param Handler The SMI handler.
162 @param CallerAddress The address of the module who registers the SMI handler.
163 @param Context The context of the SMI handler.
164 For the SmmChildDispatch protocol, the Context
165 must match the one defined for SmmChildDispatch protocol.
166 @param ContextSize The size of the context in bytes.
167 For the SmmChildDispatch protocol, the Context
168 must match the one defined for SmmChildDispatch protocol.
169
170 @retval EFI_SUCCESS The information is recorded.
171 @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.
172 **/
173 typedef
174 EFI_STATUS
175 (EFIAPI *SMI_HANDLER_PROFILE_REGISTER_HANDLER) (
176 IN SMI_HANDLER_PROFILE_PROTOCOL *This,
177 IN EFI_GUID *HandlerGuid,
178 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
179 IN PHYSICAL_ADDRESS CallerAddress,
180 IN VOID *Context, OPTIONAL
181 IN UINTN ContextSize OPTIONAL
182 );
183
184 /**
185 This function is called by SmmChildDispatcher module to report
186 an existing SMI handler is unregistered, to SmmCore.
187
188 @param This The protocol instance
189 @param HandlerGuid The GUID to identify the type of the handler.
190 For the SmmChildDispatch protocol, the HandlerGuid
191 must be the GUID of SmmChildDispatch protocol.
192 @param Handler The SMI handler.
193 @param Context The context of the SMI handler.
194 If it is NOT NULL, it will be used to check what is registered.
195 @param ContextSize The size of the context in bytes.
196 If Context is NOT NULL, it will be used to check what is registered.
197
198 @retval EFI_SUCCESS The original record is removed.
199 @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.
200 **/
201 typedef
202 EFI_STATUS
203 (EFIAPI *SMI_HANDLER_PROFILE_UNREGISTER_HANDLER) (
204 IN SMI_HANDLER_PROFILE_PROTOCOL *This,
205 IN EFI_GUID *HandlerGuid,
206 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
207 IN VOID *Context, OPTIONAL
208 IN UINTN ContextSize OPTIONAL
209 );
210
211 struct _SMI_HANDLER_PROFILE_PROTOCOL {
212 SMI_HANDLER_PROFILE_REGISTER_HANDLER RegisterHandler;
213 SMI_HANDLER_PROFILE_UNREGISTER_HANDLER UnregisterHandler;
214 };
215
216 #endif