]>
Commit | Line | Data |
---|---|---|
9e620719 | 1 | /** @file\r |
2 | SMM Base Protocol on SMM Base2 Protocol Thunk driver.\r | |
3 | \r | |
4 | This driver co-operates with SMM Base Helper SMM driver to provide SMM Base Protocol\r | |
5 | based on SMM Base2 Protocol.\r | |
6 | \r | |
7 | This thunk driver is expected to be loaded before PI SMM IPL driver so that\r | |
8 | SMM BASE Protocol can be published immediately after SMM Base2 Protocol is installed to\r | |
9 | make SMM Base Protocol.InSmm() as early as possible.\r | |
10 | \r | |
fb03ca1a | 11 | Copyright (c) 2009 - 2010, Intel Corporation\r |
9e620719 | 12 | All rights reserved. This program and the accompanying materials\r |
13 | are licensed and made available under the terms and conditions of the BSD License\r | |
14 | which accompanies this distribution. The full text of the license may be found at\r | |
15 | http://opensource.org/licenses/bsd-license.php\r | |
16 | \r | |
17 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
18 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
19 | \r | |
20 | **/\r | |
21 | \r | |
f5501a65 | 22 | #include <PiDxe.h>\r |
23 | #include <FrameworkSmm.h>\r | |
9e620719 | 24 | \r |
f5501a65 | 25 | #include <Protocol/SmmBase2.h>\r |
26 | #include <Protocol/SmmCommunication.h>\r | |
27 | #include <Protocol/SmmBaseHelperReady.h>\r | |
28 | \r | |
29 | #include <Guid/SmmBaseThunkCommunication.h>\r | |
30 | #include <Guid/EventGroup.h>\r | |
31 | \r | |
32 | #include <Library/DebugLib.h>\r | |
33 | #include <Library/UefiBootServicesTableLib.h>\r | |
34 | #include <Library/UefiDriverEntryPoint.h>\r | |
35 | #include <Library/UefiLib.h>\r | |
36 | #include <Library/UefiRuntimeLib.h>\r | |
37 | \r | |
38 | //\r | |
39 | // SMM Base Protocol function ptoyotypes\r | |
40 | //\r | |
41 | EFI_STATUS\r | |
42 | EFIAPI\r | |
43 | SmmBaseRegister (\r | |
44 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
45 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
46 | IN VOID *SourceBuffer,\r | |
47 | IN UINTN SourceSize,\r | |
48 | OUT EFI_HANDLE *ImageHandle,\r | |
49 | IN BOOLEAN LegacyIA32Binary\r | |
50 | );\r | |
51 | \r | |
52 | EFI_STATUS\r | |
53 | EFIAPI\r | |
54 | SmmBaseUnregister (\r | |
55 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
56 | IN EFI_HANDLE ImageHandle\r | |
57 | );\r | |
58 | \r | |
59 | EFI_STATUS\r | |
60 | EFIAPI\r | |
61 | SmmBaseCommunicate (\r | |
62 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
63 | IN EFI_HANDLE ImageHandle,\r | |
64 | IN OUT VOID *CommunicationBuffer,\r | |
65 | IN OUT UINTN *BufferSize\r | |
66 | );\r | |
67 | \r | |
68 | EFI_STATUS\r | |
69 | EFIAPI\r | |
70 | SmmBaseRegisterCallback (\r | |
71 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
72 | IN EFI_HANDLE SmmImageHandle,\r | |
73 | IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress,\r | |
74 | IN BOOLEAN MakeLast,\r | |
75 | IN BOOLEAN FloatingPointSave\r | |
76 | );\r | |
77 | \r | |
78 | EFI_STATUS\r | |
79 | EFIAPI\r | |
80 | SmmBaseInSmm (\r | |
81 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
82 | OUT BOOLEAN *InSmm\r | |
83 | );\r | |
84 | \r | |
85 | EFI_STATUS\r | |
86 | EFIAPI\r | |
87 | SmmBaseSmmAllocatePool (\r | |
88 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
89 | IN EFI_MEMORY_TYPE PoolType,\r | |
90 | IN UINTN Size,\r | |
91 | OUT VOID **Buffer\r | |
92 | );\r | |
93 | \r | |
94 | EFI_STATUS\r | |
95 | EFIAPI\r | |
96 | SmmBaseSmmFreePool (\r | |
97 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
98 | IN VOID *Buffer\r | |
99 | );\r | |
100 | \r | |
101 | EFI_STATUS\r | |
102 | EFIAPI\r | |
103 | SmmBaseGetSmstLocation (\r | |
104 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
105 | OUT EFI_SMM_SYSTEM_TABLE **Smst\r | |
106 | );\r | |
107 | \r | |
108 | ///\r | |
109 | /// SMM Base Protocol instance\r | |
110 | ///\r | |
111 | EFI_SMM_BASE_PROTOCOL mSmmBase = {\r | |
9e620719 | 112 | SmmBaseRegister,\r |
113 | SmmBaseUnregister,\r | |
114 | SmmBaseCommunicate,\r | |
115 | SmmBaseRegisterCallback,\r | |
116 | SmmBaseInSmm,\r | |
117 | SmmBaseSmmAllocatePool,\r | |
118 | SmmBaseSmmFreePool,\r | |
119 | SmmBaseGetSmstLocation\r | |
120 | };\r | |
121 | \r | |
f5501a65 | 122 | SMMBASETHUNK_COMMUNICATION_DATA mCommunicationData = {\r |
9e620719 | 123 | EFI_SMM_BASE_THUNK_COMMUNICATION_GUID,\r |
124 | sizeof (SMMBASE_FUNCTION_DATA)\r | |
125 | };\r | |
126 | \r | |
f5501a65 | 127 | EFI_HANDLE mSmmBaseHandle = NULL;\r |
9e620719 | 128 | EFI_SMM_BASE2_PROTOCOL *mSmmBase2 = NULL;\r |
129 | EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL;\r | |
130 | EFI_SMM_BASE_HELPER_READY_PROTOCOL *mSmmBaseHelperReady = NULL;\r | |
131 | \r | |
17d2c9a3 | 132 | /**\r |
133 | Determine if in SMM mode.\r | |
134 | \r | |
135 | @retval TRUE In SMM mode.\r | |
136 | @retval FALSE Not in SMM mode.\r | |
137 | **/\r | |
9e620719 | 138 | BOOLEAN\r |
139 | IsInSmm (\r | |
140 | VOID\r | |
141 | )\r | |
142 | {\r | |
143 | EFI_STATUS Status;\r | |
144 | BOOLEAN InSmm;\r | |
145 | \r | |
146 | Status = mSmmBase2->InSmm (mSmmBase2, &InSmm);\r | |
147 | ASSERT_EFI_ERROR (Status);\r | |
148 | return InSmm;\r | |
149 | }\r | |
150 | \r | |
151 | /**\r | |
152 | Invoke services provided by SMM Base Helper SMM driver.\r | |
153 | **/\r | |
154 | VOID\r | |
155 | SmmBaseHelperService (\r | |
156 | VOID\r | |
157 | )\r | |
158 | {\r | |
159 | UINTN DataSize;\r | |
160 | \r | |
f5501a65 | 161 | mCommunicationData.FunctionData.Status = EFI_UNSUPPORTED;\r |
9e620719 | 162 | \r |
bade9bf5 | 163 | if ((mCommunicationData.FunctionData.Function != SMMBASE_COMMUNICATE) && IsInSmm()) {\r |
9e620719 | 164 | ///\r |
165 | /// If in SMM mode, directly call services in SMM Base Helper.\r | |
166 | ///\r | |
9e620719 | 167 | DataSize = (UINTN)(sizeof (SMMBASE_FUNCTION_DATA));\r |
168 | mSmmBaseHelperReady->ServiceEntry (\r | |
169 | NULL,\r | |
170 | NULL,\r | |
f5501a65 | 171 | &mCommunicationData.FunctionData,\r |
9e620719 | 172 | &DataSize\r |
173 | );\r | |
174 | } else {\r | |
175 | ///\r | |
bade9bf5 | 176 | /// Call services in SMM Base Helper via SMM Communication Protocol.\r |
9e620719 | 177 | ///\r |
f5501a65 | 178 | DataSize = (UINTN)(sizeof (mCommunicationData));\r |
9e620719 | 179 | mSmmCommunication->Communicate (\r |
180 | mSmmCommunication,\r | |
f5501a65 | 181 | &mCommunicationData,\r |
9e620719 | 182 | &DataSize\r |
183 | );\r | |
184 | }\r | |
185 | }\r | |
186 | \r | |
187 | /**\r | |
188 | Register a given driver into SMRAM. This is the equivalent of performing\r | |
189 | the LoadImage/StartImage into System Management Mode.\r | |
190 | \r | |
191 | @param[in] This Protocol instance pointer.\r | |
192 | @param[in] FilePath Location of the image to be installed as the handler.\r | |
193 | @param[in] SourceBuffer Optional source buffer in case the image file\r | |
194 | is in memory.\r | |
195 | @param[in] SourceSize Size of the source image file, if in memory.\r | |
196 | @param[out] ImageHandle The handle that the base driver uses to decode \r | |
197 | the handler. Unique among SMM handlers only, \r | |
198 | not unique across DXE/EFI.\r | |
199 | @param[in] LegacyIA32Binary An optional parameter specifying that the associated \r | |
200 | file is a real-mode IA-32 binary.\r | |
201 | \r | |
202 | @retval EFI_SUCCESS The operation was successful.\r | |
203 | @retval EFI_OUT_OF_RESOURCES There were no additional SMRAM resources to load the handler\r | |
204 | @retval EFI_UNSUPPORTED This platform does not support 16-bit handlers.\r | |
205 | @retval EFI_UNSUPPORTED Platform is in runtime.\r | |
206 | @retval EFI_INVALID_PARAMETER The handlers was not the correct image type\r | |
207 | **/\r | |
208 | EFI_STATUS\r | |
209 | EFIAPI\r | |
210 | SmmBaseRegister (\r | |
211 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
212 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath,\r | |
213 | IN VOID *SourceBuffer,\r | |
214 | IN UINTN SourceSize,\r | |
215 | OUT EFI_HANDLE *ImageHandle,\r | |
216 | IN BOOLEAN LegacyIA32Binary\r | |
217 | )\r | |
218 | {\r | |
219 | if (LegacyIA32Binary) {\r | |
220 | return EFI_UNSUPPORTED;\r | |
221 | }\r | |
222 | \r | |
f5501a65 | 223 | mCommunicationData.FunctionData.Function = SMMBASE_REGISTER;\r |
224 | mCommunicationData.FunctionData.Args.Register.FilePath = FilePath;\r | |
225 | mCommunicationData.FunctionData.Args.Register.SourceBuffer = SourceBuffer;\r | |
226 | mCommunicationData.FunctionData.Args.Register.SourceSize = SourceSize;\r | |
227 | mCommunicationData.FunctionData.Args.Register.ImageHandle = ImageHandle;\r | |
228 | mCommunicationData.FunctionData.Args.Register.LegacyIA32Binary = LegacyIA32Binary;\r | |
9e620719 | 229 | \r |
230 | SmmBaseHelperService ();\r | |
f5501a65 | 231 | return mCommunicationData.FunctionData.Status;\r |
9e620719 | 232 | }\r |
233 | \r | |
234 | /**\r | |
235 | Removes a handler from execution within SMRAM. This is the equivalent of performing\r | |
236 | the UnloadImage in System Management Mode.\r | |
237 | \r | |
238 | @param[in] This Protocol instance pointer.\r | |
239 | @param[in] ImageHandle The handler to be removed.\r | |
240 | \r | |
241 | @retval EFI_SUCCESS The operation was successful\r | |
242 | @retval EFI_INVALID_PARAMETER The handler did not exist\r | |
243 | @retval EFI_UNSUPPORTED Platform is in runtime.\r | |
244 | **/\r | |
245 | EFI_STATUS\r | |
246 | EFIAPI\r | |
247 | SmmBaseUnregister (\r | |
248 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
249 | IN EFI_HANDLE ImageHandle\r | |
250 | )\r | |
251 | {\r | |
f5501a65 | 252 | mCommunicationData.FunctionData.Function = SMMBASE_UNREGISTER;\r |
253 | mCommunicationData.FunctionData.Args.UnRegister.ImageHandle = ImageHandle;\r | |
9e620719 | 254 | \r |
255 | SmmBaseHelperService ();\r | |
f5501a65 | 256 | return mCommunicationData.FunctionData.Status;\r |
9e620719 | 257 | }\r |
258 | \r | |
259 | /**\r | |
260 | The SMM Inter-module Communicate Service Communicate() function\r | |
261 | provides a service to send/receive messages from a registered\r | |
262 | EFI service. The BASE protocol driver is responsible for doing\r | |
263 | any of the copies such that the data lives in boot-service-accessible RAM.\r | |
264 | \r | |
265 | @param[in] This Protocol instance pointer.\r | |
266 | @param[in] ImageHandle The handle of the registered driver.\r | |
267 | @param[in,out] CommunicationBuffer Pointer to the buffer to convey into SMRAM.\r | |
268 | @param[in,out] BufferSize The size of the data buffer being passed in.\r | |
269 | On exit, the size of data being returned.\r | |
270 | Zero if the handler does not wish to reply with any data.\r | |
271 | \r | |
272 | @retval EFI_SUCCESS The message was successfully posted\r | |
273 | @retval EFI_INVALID_PARAMETER The buffer was NULL\r | |
274 | **/\r | |
275 | EFI_STATUS\r | |
276 | EFIAPI\r | |
277 | SmmBaseCommunicate (\r | |
278 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
279 | IN EFI_HANDLE ImageHandle,\r | |
280 | IN OUT VOID *CommunicationBuffer,\r | |
281 | IN OUT UINTN *BufferSize\r | |
282 | )\r | |
283 | {\r | |
bade9bf5 | 284 | ///\r |
285 | /// Note this is a runtime interface\r | |
286 | ///\r | |
287 | \r | |
288 | mCommunicationData.FunctionData.Function = SMMBASE_COMMUNICATE;\r | |
289 | mCommunicationData.FunctionData.Args.Communicate.ImageHandle = ImageHandle;\r | |
290 | mCommunicationData.FunctionData.Args.Communicate.CommunicationBuffer = CommunicationBuffer;\r | |
291 | mCommunicationData.FunctionData.Args.Communicate.SourceSize = BufferSize;\r | |
9e620719 | 292 | \r |
bade9bf5 | 293 | SmmBaseHelperService ();\r |
294 | return mCommunicationData.FunctionData.Status;\r | |
9e620719 | 295 | }\r |
296 | \r | |
297 | /**\r | |
298 | Register a callback to execute within SMM.\r | |
299 | This allows receipt of messages created with EFI_SMM_BASE_PROTOCOL.Communicate().\r | |
300 | \r | |
301 | @param[in] This Protocol instance pointer.\r | |
302 | @param[in] SmmImageHandle Handle of the callback service.\r | |
303 | @param[in] CallbackAddress Address of the callback service.\r | |
304 | @param[in] MakeLast If present, will stipulate that the handler is posted to \r | |
305 | be executed last in the dispatch table.\r | |
306 | @param[in] FloatingPointSave An optional parameter that informs the\r | |
307 | EFI_SMM_ACCESS_PROTOCOL Driver core if it needs to save\r | |
308 | the floating point register state. If any handler\r | |
309 | require this, the state will be saved for all handlers.\r | |
310 | \r | |
311 | @retval EFI_SUCCESS The operation was successful\r | |
312 | @retval EFI_OUT_OF_RESOURCES Not enough space in the dispatch queue\r | |
313 | @retval EFI_UNSUPPORTED Platform is in runtime.\r | |
314 | @retval EFI_UNSUPPORTED The caller is not in SMM.\r | |
315 | **/\r | |
316 | EFI_STATUS\r | |
317 | EFIAPI\r | |
318 | SmmBaseRegisterCallback (\r | |
319 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
320 | IN EFI_HANDLE SmmImageHandle,\r | |
321 | IN EFI_SMM_CALLBACK_ENTRY_POINT CallbackAddress,\r | |
322 | IN BOOLEAN MakeLast,\r | |
323 | IN BOOLEAN FloatingPointSave\r | |
324 | )\r | |
325 | {\r | |
326 | if (!IsInSmm()) {\r | |
327 | return EFI_UNSUPPORTED;\r | |
328 | }\r | |
329 | \r | |
f5501a65 | 330 | mCommunicationData.FunctionData.Function = SMMBASE_REGISTER_CALLBACK;\r |
331 | mCommunicationData.FunctionData.Args.RegisterCallback.SmmImageHandle = SmmImageHandle;\r | |
332 | mCommunicationData.FunctionData.Args.RegisterCallback.CallbackAddress = CallbackAddress;\r | |
333 | mCommunicationData.FunctionData.Args.RegisterCallback.MakeLast = MakeLast;\r | |
334 | mCommunicationData.FunctionData.Args.RegisterCallback.FloatingPointSave = FloatingPointSave;\r | |
9e620719 | 335 | \r |
336 | SmmBaseHelperService();\r | |
f5501a65 | 337 | return mCommunicationData.FunctionData.Status;\r |
9e620719 | 338 | }\r |
339 | \r | |
340 | /**\r | |
341 | This routine tells caller if execution context is SMM or not.\r | |
342 | \r | |
343 | @param[in] This Protocol instance pointer.\r | |
344 | @param[out] InSmm Whether the caller is inside SMM for IA-32\r | |
345 | or servicing a PMI for the Itanium processor\r | |
346 | family.\r | |
347 | \r | |
348 | @retval EFI_SUCCESS The operation was successful\r | |
349 | @retval EFI_INVALID_PARAMETER InSmm was NULL.\r | |
350 | **/\r | |
351 | EFI_STATUS\r | |
352 | EFIAPI\r | |
353 | SmmBaseInSmm (\r | |
354 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
355 | OUT BOOLEAN *InSmm\r | |
356 | )\r | |
357 | {\r | |
358 | return mSmmBase2->InSmm (mSmmBase2, InSmm);\r | |
359 | }\r | |
360 | \r | |
361 | /**\r | |
362 | The SmmAllocatePool() function allocates a memory region of Size bytes from memory of\r | |
363 | type PoolType and returns the address of the allocated memory in the location referenced\r | |
364 | by Buffer. This function allocates pages from EFI SMRAM Memory as needed to grow the\r | |
365 | requested pool type. All allocations are eight-byte aligned.\r | |
366 | \r | |
367 | @param[in] This Protocol instance pointer.\r | |
368 | @param[in] PoolType The type of pool to allocate.\r | |
369 | The only supported type is EfiRuntimeServicesData;\r | |
370 | the interface will internally map this runtime request to \r | |
371 | SMRAM for IA-32 and leave as this type for the Itanium \r | |
372 | processor family. Other types can be ignored.\r | |
373 | @param[in] Size The number of bytes to allocate from the pool.\r | |
374 | @param[out] Buffer A pointer to a pointer to the allocated buffer if the call\r | |
375 | succeeds; undefined otherwise.\r | |
376 | \r | |
377 | @retval EFI_SUCCESS The requested number of bytes was allocated.\r | |
378 | @retval EFI_OUT_OF_RESOURCES The pool requested could not be allocated.\r | |
379 | @retval EFI_UNSUPPORTED Platform is in runtime.\r | |
380 | **/\r | |
381 | EFI_STATUS\r | |
382 | EFIAPI\r | |
383 | SmmBaseSmmAllocatePool (\r | |
384 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
385 | IN EFI_MEMORY_TYPE PoolType,\r | |
386 | IN UINTN Size,\r | |
387 | OUT VOID **Buffer\r | |
388 | )\r | |
389 | {\r | |
f5501a65 | 390 | mCommunicationData.FunctionData.Function = SMMBASE_ALLOCATE_POOL;\r |
391 | mCommunicationData.FunctionData.Args.AllocatePool.PoolType = PoolType;\r | |
392 | mCommunicationData.FunctionData.Args.AllocatePool.Size = Size;\r | |
393 | mCommunicationData.FunctionData.Args.AllocatePool.Buffer = Buffer;\r | |
9e620719 | 394 | \r |
395 | SmmBaseHelperService ();\r | |
f5501a65 | 396 | return mCommunicationData.FunctionData.Status;\r |
9e620719 | 397 | }\r |
398 | \r | |
399 | /**\r | |
400 | The SmmFreePool() function returns the memory specified by Buffer to the system.\r | |
401 | On return, the memory's type is EFI SMRAM Memory. The Buffer that is freed must\r | |
402 | have been allocated by SmmAllocatePool().\r | |
403 | \r | |
404 | @param[in] This Protocol instance pointer.\r | |
405 | @param[in] Buffer Pointer to the buffer allocation.\r | |
406 | \r | |
407 | @retval EFI_SUCCESS The memory was returned to the system.\r | |
408 | @retval EFI_INVALID_PARAMETER Buffer was invalid.\r | |
409 | @retval EFI_UNSUPPORTED Platform is in runtime.\r | |
410 | **/\r | |
411 | EFI_STATUS\r | |
412 | EFIAPI\r | |
413 | SmmBaseSmmFreePool (\r | |
414 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
415 | IN VOID *Buffer\r | |
416 | )\r | |
417 | {\r | |
f5501a65 | 418 | mCommunicationData.FunctionData.Function = SMMBASE_FREE_POOL;\r |
419 | mCommunicationData.FunctionData.Args.FreePool.Buffer = Buffer;\r | |
9e620719 | 420 | \r |
421 | SmmBaseHelperService ();\r | |
f5501a65 | 422 | return mCommunicationData.FunctionData.Status;\r |
9e620719 | 423 | }\r |
424 | \r | |
425 | /**\r | |
426 | The GetSmstLocation() function returns the location of the System Management\r | |
427 | Service Table. The use of the API is such that a driver can discover the\r | |
428 | location of the SMST in its entry point and then cache it in some driver\r | |
429 | global variable so that the SMST can be invoked in subsequent callbacks.\r | |
430 | \r | |
431 | @param[in] This Protocol instance pointer.\r | |
432 | @param[in] Smst Pointer to the SMST.\r | |
433 | \r | |
434 | @retval EFI_SUCCESS The operation was successful\r | |
435 | @retval EFI_INVALID_PARAMETER Smst was invalid.\r | |
436 | @retval EFI_UNSUPPORTED Not in SMM.\r | |
437 | **/\r | |
438 | EFI_STATUS\r | |
439 | EFIAPI\r | |
440 | SmmBaseGetSmstLocation (\r | |
441 | IN EFI_SMM_BASE_PROTOCOL *This,\r | |
442 | OUT EFI_SMM_SYSTEM_TABLE **Smst\r | |
443 | )\r | |
444 | {\r | |
9e620719 | 445 | if (!IsInSmm ()) {\r |
446 | return EFI_UNSUPPORTED;\r | |
447 | }\r | |
448 | \r | |
449 | if (Smst == NULL) {\r | |
450 | return EFI_INVALID_PARAMETER;\r | |
451 | }\r | |
452 | \r | |
453 | *Smst = mSmmBaseHelperReady->FrameworkSmst;\r | |
454 | return EFI_SUCCESS;\r | |
455 | }\r | |
456 | \r | |
fb03ca1a | 457 | /**\r |
458 | Notification function of EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE\r | |
459 | \r | |
460 | This is a notification function registered on EVT_SIGNAL_VIRTUAL_ADDRESS_CHANGE event.\r | |
461 | It convers pointer to new virtual address.\r | |
462 | \r | |
463 | @param Event Event whose notification function is being invoked\r | |
464 | @param Context Pointer to the notification function's context\r | |
465 | **/\r | |
466 | VOID\r | |
467 | EFIAPI\r | |
468 | SmmBaseAddressChangeEvent (\r | |
469 | IN EFI_EVENT Event,\r | |
470 | IN VOID *Context\r | |
471 | )\r | |
472 | {\r | |
bade9bf5 | 473 | EfiConvertPointer (0x0, (VOID **) &mSmmCommunication);\r |
fb03ca1a | 474 | }\r |
475 | \r | |
9e620719 | 476 | /**\r |
477 | Entry Point for SMM Base Protocol on SMM Base2 Protocol Thunk driver.\r | |
478 | \r | |
479 | @param[in] ImageHandle Image handle of this driver.\r | |
480 | @param[in] SystemTable A Pointer to the EFI System Table.\r | |
481 | \r | |
482 | @retval EFI_SUCCESS The entry point is executed successfully.\r | |
483 | **/\r | |
484 | EFI_STATUS\r | |
485 | EFIAPI\r | |
486 | SmmBaseThunkMain (\r | |
487 | IN EFI_HANDLE ImageHandle,\r | |
488 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
489 | )\r | |
490 | {\r | |
f5501a65 | 491 | EFI_STATUS Status;\r |
492 | EFI_EVENT Event;\r | |
9e620719 | 493 | \r |
f5501a65 | 494 | //\r |
495 | // Assume only one instance of SMM Base2 Protocol in the system\r | |
496 | // Locate SMM Base2 Protocol\r | |
497 | //\r | |
498 | Status = gBS->LocateProtocol (&gEfiSmmBase2ProtocolGuid, NULL, (VOID **) &mSmmBase2);\r | |
499 | ASSERT_EFI_ERROR (Status);\r | |
500 | \r | |
501 | //\r | |
502 | // Assume only one instance of SMM Communication Protocol in the system\r | |
503 | // Locate SMM Communication Protocol\r | |
504 | //\r | |
505 | gBS->LocateProtocol (&gEfiSmmCommunicationProtocolGuid, NULL, (VOID **) &mSmmCommunication);\r | |
506 | ASSERT_EFI_ERROR (Status);\r | |
507 | \r | |
508 | //\r | |
509 | // Assume only one instance of SMM Base Helper Ready Protocol in the system\r | |
510 | // Locate SMM Base Helper Ready Protocol\r | |
511 | //\r | |
512 | Status = gBS->LocateProtocol (&gEfiSmmBaseHelperReadyProtocolGuid, NULL, (VOID **) &mSmmBaseHelperReady);\r | |
513 | ASSERT_EFI_ERROR (Status);\r | |
9e620719 | 514 | \r |
f5501a65 | 515 | //\r |
516 | // Create event on SetVirtualAddressMap() to convert mSmmCommunication from a physical address to a virtual address\r | |
517 | //\r | |
fb03ca1a | 518 | Status = gBS->CreateEventEx (\r |
519 | EVT_NOTIFY_SIGNAL,\r | |
520 | TPL_NOTIFY,\r | |
521 | SmmBaseAddressChangeEvent,\r | |
522 | NULL,\r | |
523 | &gEfiEventVirtualAddressChangeGuid,\r | |
f5501a65 | 524 | &Event\r |
fb03ca1a | 525 | );\r |
526 | ASSERT_EFI_ERROR (Status);\r | |
f5501a65 | 527 | \r |
528 | //\r | |
529 | // Publish Framework SMM BASE Protocol immediately after SMM Base2 Protocol is installed to\r | |
530 | // make SMM Base Protocol.InSmm() available as early as possible.\r | |
531 | //\r | |
532 | Status = gBS->InstallMultipleProtocolInterfaces (\r | |
533 | &mSmmBaseHandle,\r | |
534 | &gEfiSmmBaseProtocolGuid, &mSmmBase,\r | |
535 | NULL\r | |
536 | );\r | |
537 | ASSERT_EFI_ERROR (Status);\r | |
538 | \r | |
9e620719 | 539 | return EFI_SUCCESS;\r |
540 | }\r |