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