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 | // SMM_CORE dump command
|
---|
110 | //
|
---|
111 | #define SMI_HANDLER_PROFILE_COMMAND_GET_INFO 0x1
|
---|
112 | #define SMI_HANDLER_PROFILE_COMMAND_GET_DATA_BY_OFFSET 0x2
|
---|
113 |
|
---|
114 | typedef struct {
|
---|
115 | UINT32 Command;
|
---|
116 | UINT32 DataLength;
|
---|
117 | UINT64 ReturnStatus;
|
---|
118 | } SMI_HANDLER_PROFILE_PARAMETER_HEADER;
|
---|
119 |
|
---|
120 | typedef struct {
|
---|
121 | SMI_HANDLER_PROFILE_PARAMETER_HEADER Header;
|
---|
122 | UINT64 DataSize;
|
---|
123 | } SMI_HANDLER_PROFILE_PARAMETER_GET_INFO;
|
---|
124 |
|
---|
125 | typedef struct {
|
---|
126 | SMI_HANDLER_PROFILE_PARAMETER_HEADER Header;
|
---|
127 | //
|
---|
128 | // On input, data buffer size.
|
---|
129 | // On output, actual data buffer size copied.
|
---|
130 | //
|
---|
131 | UINT64 DataSize;
|
---|
132 | PHYSICAL_ADDRESS DataBuffer;
|
---|
133 | //
|
---|
134 | // On input, data buffer offset to copy.
|
---|
135 | // On output, next time data buffer offset to copy.
|
---|
136 | //
|
---|
137 | UINT64 DataOffset;
|
---|
138 | } SMI_HANDLER_PROFILE_PARAMETER_GET_DATA_BY_OFFSET;
|
---|
139 |
|
---|
140 | #define SMI_HANDLER_PROFILE_GUID {0x49174342, 0x7108, 0x409b, {0x8b, 0xbe, 0x65, 0xfd, 0xa8, 0x53, 0x89, 0xf5}}
|
---|
141 |
|
---|
142 | extern EFI_GUID gSmiHandlerProfileGuid;
|
---|
143 |
|
---|
144 | typedef struct _SMI_HANDLER_PROFILE_PROTOCOL SMI_HANDLER_PROFILE_PROTOCOL;
|
---|
145 |
|
---|
146 | /**
|
---|
147 | This function is called by SmmChildDispatcher module to report
|
---|
148 | a new SMI handler is registered, to SmmCore.
|
---|
149 |
|
---|
150 | @param This The protocol instance
|
---|
151 | @param HandlerGuid The GUID to identify the type of the handler.
|
---|
152 | For the SmmChildDispatch protocol, the HandlerGuid
|
---|
153 | must be the GUID of SmmChildDispatch protocol.
|
---|
154 | @param Handler The SMI handler.
|
---|
155 | @param CallerAddress The address of the module who registers the SMI handler.
|
---|
156 | @param Context The context of the SMI handler.
|
---|
157 | For the SmmChildDispatch protocol, the Context
|
---|
158 | must match the one defined for SmmChildDispatch protocol.
|
---|
159 | @param ContextSize The size of the context in bytes.
|
---|
160 | For the SmmChildDispatch protocol, the Context
|
---|
161 | must match the one defined for SmmChildDispatch protocol.
|
---|
162 |
|
---|
163 | @retval EFI_SUCCESS The information is recorded.
|
---|
164 | @retval EFI_OUT_OF_RESOURCES There is no enough resource to record the information.
|
---|
165 | **/
|
---|
166 | typedef
|
---|
167 | EFI_STATUS
|
---|
168 | (EFIAPI *SMI_HANDLER_PROFILE_REGISTER_HANDLER)(
|
---|
169 | IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
---|
170 | IN EFI_GUID *HandlerGuid,
|
---|
171 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
---|
172 | IN PHYSICAL_ADDRESS CallerAddress,
|
---|
173 | IN VOID *Context OPTIONAL,
|
---|
174 | IN UINTN ContextSize OPTIONAL
|
---|
175 | );
|
---|
176 |
|
---|
177 | /**
|
---|
178 | This function is called by SmmChildDispatcher module to report
|
---|
179 | an existing SMI handler is unregistered, to SmmCore.
|
---|
180 |
|
---|
181 | @param This The protocol instance
|
---|
182 | @param HandlerGuid The GUID to identify the type of the handler.
|
---|
183 | For the SmmChildDispatch protocol, the HandlerGuid
|
---|
184 | must be the GUID of SmmChildDispatch protocol.
|
---|
185 | @param Handler The SMI handler.
|
---|
186 | @param Context The context of the SMI handler.
|
---|
187 | If it is NOT NULL, it will be used to check what is registered.
|
---|
188 | @param ContextSize The size of the context in bytes.
|
---|
189 | If Context is NOT NULL, it will be used to check what is registered.
|
---|
190 |
|
---|
191 | @retval EFI_SUCCESS The original record is removed.
|
---|
192 | @retval EFI_NOT_FOUND There is no record for the HandlerGuid and handler.
|
---|
193 | **/
|
---|
194 | typedef
|
---|
195 | EFI_STATUS
|
---|
196 | (EFIAPI *SMI_HANDLER_PROFILE_UNREGISTER_HANDLER)(
|
---|
197 | IN SMI_HANDLER_PROFILE_PROTOCOL *This,
|
---|
198 | IN EFI_GUID *HandlerGuid,
|
---|
199 | IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
|
---|
200 | IN VOID *Context OPTIONAL,
|
---|
201 | IN UINTN ContextSize OPTIONAL
|
---|
202 | );
|
---|
203 |
|
---|
204 | struct _SMI_HANDLER_PROFILE_PROTOCOL {
|
---|
205 | SMI_HANDLER_PROFILE_REGISTER_HANDLER RegisterHandler;
|
---|
206 | SMI_HANDLER_PROFILE_UNREGISTER_HANDLER UnregisterHandler;
|
---|
207 | };
|
---|
208 |
|
---|
209 | #endif
|
---|