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