b81631dcf4a504003625253e222911c2d9d69174
[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 typedef
154 EFI_STATUS
155 (EFIAPI *SMI_HANDLER_PROFILE_REGISTER_HANDLER) (
156 IN SMI_HANDLER_PROFILE_PROTOCOL *This,
157 IN EFI_GUID *HandlerGuid,
158 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,
159 IN PHYSICAL_ADDRESS CallerAddress,
160 IN VOID *Context, OPTIONAL
161 IN UINTN ContextSize OPTIONAL
162 );
163
164 typedef
165 EFI_STATUS
166 (EFIAPI *SMI_HANDLER_PROFILE_UNREGISTER_HANDLER) (
167 IN SMI_HANDLER_PROFILE_PROTOCOL *This,
168 IN EFI_GUID *HandlerGuid,
169 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler
170 );
171
172 struct _SMI_HANDLER_PROFILE_PROTOCOL {
173 SMI_HANDLER_PROFILE_REGISTER_HANDLER RegisterHandler;
174 SMI_HANDLER_PROFILE_UNREGISTER_HANDLER UnregisterHandler;
175 };
176
177 #endif