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