]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/PiSmmCore/PiSmmCore.c
[CryptoPkg] Correct one typo in the API comments.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.c
CommitLineData
e42e9404 1/** @file\r
2 SMM Core Main Entry Point\r
3\r
53ec4d7f 4 Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
e42e9404 5 This program and the accompanying materials are licensed and made available \r
6 under the terms and conditions of the BSD License which accompanies this \r
7 distribution. The full text of the license may be found at \r
8 http://opensource.org/licenses/bsd-license.php \r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
12\r
13**/\r
14\r
15#include "PiSmmCore.h"\r
16\r
17//\r
18// Physical pointer to private structure shared between SMM IPL and the SMM Core\r
19//\r
20SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;\r
21\r
22//\r
23// SMM Core global variable for SMM System Table. Only accessed as a physical structure in SMRAM.\r
24//\r
25EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst = {\r
26 {\r
27 SMM_SMST_SIGNATURE,\r
28 EFI_SMM_SYSTEM_TABLE2_REVISION,\r
29 sizeof (gSmmCoreSmst.Hdr)\r
30 },\r
31 NULL, // SmmFirmwareVendor\r
32 0, // SmmFirmwareRevision\r
33 SmmInstallConfigurationTable,\r
34 {\r
35 {\r
36 (EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5, // SmmMemRead\r
37 (EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5 // SmmMemWrite\r
38 },\r
39 {\r
40 (EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5, // SmmIoRead\r
41 (EFI_SMM_CPU_IO2) SmmEfiNotAvailableYetArg5 // SmmIoWrite\r
42 }\r
43 },\r
44 SmmAllocatePool,\r
45 SmmFreePool,\r
46 SmmAllocatePages,\r
47 SmmFreePages,\r
48 NULL, // SmmStartupThisAp\r
49 0, // CurrentlyExecutingCpu\r
50 0, // NumberOfCpus\r
51 NULL, // CpuSaveStateSize\r
52 NULL, // CpuSaveState\r
53 0, // NumberOfTableEntries\r
54 NULL, // SmmConfigurationTable\r
55 SmmInstallProtocolInterface,\r
56 SmmUninstallProtocolInterface,\r
57 SmmHandleProtocol,\r
58 SmmRegisterProtocolNotify,\r
59 SmmLocateHandle,\r
60 SmmLocateProtocol,\r
61 SmiManage,\r
62 SmiHandlerRegister,\r
63 SmiHandlerUnRegister\r
64};\r
65\r
66//\r
67// Flag to determine if the platform has performed a legacy boot.\r
68// If this flag is TRUE, then the runtime code and runtime data associated with the \r
53ec4d7f 69// SMM IPL are converted to free memory, so the SMM Core must guarantee that is\r
e42e9404 70// does not touch of the code/data associated with the SMM IPL if this flag is TRUE.\r
71//\r
72BOOLEAN mInLegacyBoot = FALSE;\r
73\r
74//\r
75// Table of SMI Handlers that are registered by the SMM Core when it is initialized\r
76//\r
77SMM_CORE_SMI_HANDLERS mSmmCoreSmiHandlers[] = {\r
53ec4d7f
SZ
78 { SmmDriverDispatchHandler, &gEfiEventDxeDispatchGuid, NULL, TRUE },\r
79 { SmmReadyToLockHandler, &gEfiDxeSmmReadyToLockProtocolGuid, NULL, TRUE }, \r
80 { SmmLegacyBootHandler, &gEfiEventLegacyBootGuid, NULL, FALSE },\r
81 { SmmExitBootServicesHandler, &gEfiEventExitBootServicesGuid, NULL, FALSE },\r
82 { SmmReadyToBootHandler, &gEfiEventReadyToBootGuid, NULL, FALSE },\r
dc157845 83 { SmmEndOfDxeHandler, &gEfiEndOfDxeEventGroupGuid, NULL, TRUE },\r
53ec4d7f 84 { NULL, NULL, NULL, FALSE }\r
e42e9404 85};\r
86\r
84edd20b
SZ
87UINTN mFullSmramRangeCount;\r
88EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r
89\r
e42e9404 90/**\r
91 Place holder function until all the SMM System Table Service are available.\r
92\r
93 Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.\r
94\r
95 @param Arg1 Undefined\r
96 @param Arg2 Undefined\r
97 @param Arg3 Undefined\r
98 @param Arg4 Undefined\r
99 @param Arg5 Undefined\r
100\r
101 @return EFI_NOT_AVAILABLE_YET\r
102\r
103**/\r
104EFI_STATUS\r
105EFIAPI\r
106SmmEfiNotAvailableYetArg5 (\r
107 UINTN Arg1,\r
108 UINTN Arg2,\r
109 UINTN Arg3,\r
110 UINTN Arg4,\r
111 UINTN Arg5\r
112 )\r
113{\r
114 //\r
115 // This function should never be executed. If it does, then the architectural protocols\r
116 // have not been designed correctly.\r
117 //\r
118 return EFI_NOT_AVAILABLE_YET;\r
119}\r
120\r
121/**\r
122 Software SMI handler that is called when a Legacy Boot event is signalled. The SMM\r
123 Core uses this signal to know that a Legacy Boot has been performed and that \r
124 gSmmCorePrivate that is shared between the UEFI and SMM execution environments can\r
125 not be accessed from SMM anymore since that structure is considered free memory by\r
53ec4d7f
SZ
126 a legacy OS. Then the SMM Core also install SMM Legacy Boot protocol to notify SMM\r
127 driver that system enter legacy boot.\r
e42e9404 128\r
129 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
130 @param Context Points to an optional handler context which was specified when the handler was registered.\r
131 @param CommBuffer A pointer to a collection of data in memory that will\r
132 be conveyed from a non-SMM environment into an SMM environment.\r
133 @param CommBufferSize The size of the CommBuffer.\r
134\r
135 @return Status Code\r
136\r
137**/\r
138EFI_STATUS\r
139EFIAPI\r
140SmmLegacyBootHandler (\r
141 IN EFI_HANDLE DispatchHandle,\r
142 IN CONST VOID *Context, OPTIONAL\r
143 IN OUT VOID *CommBuffer, OPTIONAL\r
144 IN OUT UINTN *CommBufferSize OPTIONAL\r
145 )\r
146{\r
53ec4d7f
SZ
147 EFI_STATUS Status;\r
148 EFI_HANDLE SmmHandle;\r
149\r
150 //\r
151 // Install SMM Legacy Boot protocol.\r
152 //\r
153 SmmHandle = NULL;\r
154 Status = SmmInstallProtocolInterface (\r
155 &SmmHandle,\r
156 &gEdkiiSmmLegacyBootProtocolGuid,\r
157 EFI_NATIVE_INTERFACE,\r
158 NULL\r
159 );\r
160\r
e42e9404 161 mInLegacyBoot = TRUE;\r
53ec4d7f
SZ
162\r
163 SmiHandlerUnRegister (DispatchHandle);\r
164\r
165 return Status;\r
166}\r
167\r
168/**\r
169 Software SMI handler that is called when an Exit Boot Services event is signalled.\r
170 Then the SMM Core also install SMM Exit Boot Services protocol to notify SMM driver\r
171 that system enter exit boot services.\r
172\r
173 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
174 @param Context Points to an optional handler context which was specified when the handler was registered.\r
175 @param CommBuffer A pointer to a collection of data in memory that will\r
176 be conveyed from a non-SMM environment into an SMM environment.\r
177 @param CommBufferSize The size of the CommBuffer.\r
178\r
179 @return Status Code\r
180\r
181**/\r
182EFI_STATUS\r
183EFIAPI\r
184SmmExitBootServicesHandler (\r
185 IN EFI_HANDLE DispatchHandle,\r
186 IN CONST VOID *Context, OPTIONAL\r
187 IN OUT VOID *CommBuffer, OPTIONAL\r
188 IN OUT UINTN *CommBufferSize OPTIONAL\r
189 )\r
190{\r
191 EFI_STATUS Status;\r
192 EFI_HANDLE SmmHandle;\r
193\r
194 //\r
195 // Install SMM Exit Boot Services protocol.\r
196 //\r
197 SmmHandle = NULL;\r
198 Status = SmmInstallProtocolInterface (\r
199 &SmmHandle,\r
200 &gEdkiiSmmExitBootServicesProtocolGuid,\r
201 EFI_NATIVE_INTERFACE,\r
202 NULL\r
203 );\r
204\r
205 SmiHandlerUnRegister (DispatchHandle);\r
206\r
207 return Status;\r
208}\r
209\r
210/**\r
211 Software SMI handler that is called when an Ready To Boot event is signalled.\r
212 Then the SMM Core also install SMM Ready To Boot protocol to notify SMM driver\r
213 that system enter ready to boot.\r
214\r
215 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
216 @param Context Points to an optional handler context which was specified when the handler was registered.\r
217 @param CommBuffer A pointer to a collection of data in memory that will\r
218 be conveyed from a non-SMM environment into an SMM environment.\r
219 @param CommBufferSize The size of the CommBuffer.\r
220\r
221 @return Status Code\r
222\r
223**/\r
224EFI_STATUS\r
225EFIAPI\r
226SmmReadyToBootHandler (\r
227 IN EFI_HANDLE DispatchHandle,\r
228 IN CONST VOID *Context, OPTIONAL\r
229 IN OUT VOID *CommBuffer, OPTIONAL\r
230 IN OUT UINTN *CommBufferSize OPTIONAL\r
231 )\r
232{\r
233 EFI_STATUS Status;\r
234 EFI_HANDLE SmmHandle;\r
235\r
236 //\r
237 // Install SMM Ready To Boot protocol.\r
238 //\r
239 SmmHandle = NULL;\r
240 Status = SmmInstallProtocolInterface (\r
241 &SmmHandle,\r
242 &gEdkiiSmmReadyToBootProtocolGuid,\r
243 EFI_NATIVE_INTERFACE,\r
244 NULL\r
245 );\r
246\r
247 SmiHandlerUnRegister (DispatchHandle);\r
248\r
249 return Status;\r
e42e9404 250}\r
251\r
252/**\r
253 Software SMI handler that is called when the DxeSmmReadyToLock protocol is added\r
254 or if gEfiEventReadyToBootGuid is signalled. This function unregisters the \r
255 Software SMIs that are nor required after SMRAM is locked and installs the \r
256 SMM Ready To Lock Protocol so SMM Drivers are informed that SMRAM is about \r
257 to be locked. It also verifies the the SMM CPU I/O 2 Protocol has been installed\r
258 and NULLs gBS and gST because they can not longer be used after SMRAM is locked.\r
259\r
260 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
261 @param Context Points to an optional handler context which was specified when the handler was registered.\r
262 @param CommBuffer A pointer to a collection of data in memory that will\r
263 be conveyed from a non-SMM environment into an SMM environment.\r
264 @param CommBufferSize The size of the CommBuffer.\r
265\r
266 @return Status Code\r
267\r
268**/\r
269EFI_STATUS\r
270EFIAPI\r
271SmmReadyToLockHandler (\r
272 IN EFI_HANDLE DispatchHandle,\r
273 IN CONST VOID *Context, OPTIONAL\r
274 IN OUT VOID *CommBuffer, OPTIONAL\r
275 IN OUT UINTN *CommBufferSize OPTIONAL\r
276 )\r
277{\r
278 EFI_STATUS Status;\r
279 UINTN Index;\r
280 EFI_HANDLE SmmHandle;\r
281 VOID *Interface;\r
282\r
283 //\r
284 // Unregister SMI Handlers that are no required after the SMM driver dispatch is stopped\r
285 //\r
286 for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {\r
287 if (mSmmCoreSmiHandlers[Index].UnRegister) {\r
288 SmiHandlerUnRegister (mSmmCoreSmiHandlers[Index].DispatchHandle);\r
289 }\r
290 }\r
291\r
292 //\r
293 // Install SMM Ready to lock protocol\r
294 //\r
295 SmmHandle = NULL;\r
296 Status = SmmInstallProtocolInterface (\r
297 &SmmHandle,\r
298 &gEfiSmmReadyToLockProtocolGuid,\r
299 EFI_NATIVE_INTERFACE,\r
300 NULL\r
301 );\r
302\r
303 //\r
304 // Make sure SMM CPU I/O 2 Procol has been installed into the handle database\r
305 //\r
306 Status = SmmLocateProtocol (&gEfiSmmCpuIo2ProtocolGuid, NULL, &Interface);\r
307\r
308 //\r
309 // Print a message on a debug build if the SMM CPU I/O 2 Protocol is not installed\r
310 //\r
311 DEBUG_CODE_BEGIN ();\r
312 if (EFI_ERROR (Status)) {\r
313 DEBUG ((DEBUG_ERROR, "\nSMM: SmmCpuIo Arch Protocol not present!!\n"));\r
314 }\r
315 DEBUG_CODE_END ();\r
316\r
317 //\r
318 // Assert if the CPU I/O 2 Protocol is not installed\r
319 //\r
320 ASSERT_EFI_ERROR (Status);\r
321\r
322 //\r
323 // Display any drivers that were not dispatched because dependency expression\r
324 // evaluated to false if this is a debug build\r
325 //\r
326 DEBUG_CODE_BEGIN ();\r
327 SmmDisplayDiscoveredNotDispatched ();\r
328 DEBUG_CODE_END ();\r
329\r
330 //\r
331 // Not allowed to use gST or gBS after lock\r
332 //\r
333 gST = NULL;\r
334 gBS = NULL;\r
335\r
84edd20b
SZ
336 SmramProfileReadyToLock ();\r
337\r
e42e9404 338 return Status;\r
339}\r
340\r
46ece1ff
JY
341/**\r
342 Software SMI handler that is called when the EndOfDxe event is signalled.\r
343 This function installs the SMM EndOfDxe Protocol so SMM Drivers are informed that\r
344 platform code will invoke 3rd part code.\r
345\r
346 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
347 @param Context Points to an optional handler context which was specified when the handler was registered.\r
348 @param CommBuffer A pointer to a collection of data in memory that will\r
349 be conveyed from a non-SMM environment into an SMM environment.\r
350 @param CommBufferSize The size of the CommBuffer.\r
351\r
352 @return Status Code\r
353\r
354**/\r
355EFI_STATUS\r
356EFIAPI\r
357SmmEndOfDxeHandler (\r
358 IN EFI_HANDLE DispatchHandle,\r
359 IN CONST VOID *Context, OPTIONAL\r
360 IN OUT VOID *CommBuffer, OPTIONAL\r
361 IN OUT UINTN *CommBufferSize OPTIONAL\r
362 )\r
363{\r
364 EFI_STATUS Status;\r
365 EFI_HANDLE SmmHandle;\r
366\r
367 DEBUG ((EFI_D_INFO, "SmmEndOfDxeHandler\n"));\r
368 //\r
369 // Install SMM EndOfDxe protocol\r
370 //\r
371 SmmHandle = NULL;\r
372 Status = SmmInstallProtocolInterface (\r
373 &SmmHandle,\r
374 &gEfiSmmEndOfDxeProtocolGuid,\r
375 EFI_NATIVE_INTERFACE,\r
376 NULL\r
377 );\r
42e2ff2e 378 return Status;\r
46ece1ff
JY
379}\r
380\r
3b657538
SZ
381/**\r
382 Determine if two buffers overlap in memory.\r
383\r
384 @param[in] Buff1 Pointer to first buffer\r
385 @param[in] Size1 Size of Buff1\r
386 @param[in] Buff2 Pointer to second buffer\r
387 @param[in] Size2 Size of Buff2\r
388\r
389 @retval TRUE Buffers overlap in memory.\r
390 @retval FALSE Buffer doesn't overlap.\r
391\r
392**/\r
393BOOLEAN\r
394InternalIsBufferOverlapped (\r
395 IN UINT8 *Buff1,\r
396 IN UINTN Size1,\r
397 IN UINT8 *Buff2,\r
398 IN UINTN Size2\r
399 )\r
400{\r
401 //\r
402 // If buff1's end is less than the start of buff2, then it's ok.\r
403 // Also, if buff1's start is beyond buff2's end, then it's ok.\r
404 //\r
405 if (((Buff1 + Size1) <= Buff2) || (Buff1 >= (Buff2 + Size2))) {\r
406 return FALSE;\r
407 }\r
408\r
409 return TRUE;\r
410}\r
411\r
e42e9404 412/**\r
413 The main entry point to SMM Foundation.\r
414\r
415 Note: This function is only used by SMRAM invocation. It is never used by DXE invocation.\r
416\r
417 @param SmmEntryContext Processor information and functionality\r
418 needed by SMM Foundation.\r
419\r
420**/\r
421VOID\r
422EFIAPI\r
423SmmEntryPoint (\r
424 IN CONST EFI_SMM_ENTRY_CONTEXT *SmmEntryContext\r
425)\r
426{\r
427 EFI_STATUS Status;\r
428 EFI_SMM_COMMUNICATE_HEADER *CommunicateHeader;\r
a25cb9f6 429 BOOLEAN InLegacyBoot;\r
3b657538 430 BOOLEAN IsOverlapped;\r
e42e9404 431\r
495797c5 432 PERF_START (NULL, "SMM", NULL, 0) ;\r
433\r
e42e9404 434 //\r
229fd9e7 435 // Update SMST with contents of the SmmEntryContext structure\r
e42e9404 436 //\r
229fd9e7
MK
437 gSmmCoreSmst.SmmStartupThisAp = SmmEntryContext->SmmStartupThisAp;\r
438 gSmmCoreSmst.CurrentlyExecutingCpu = SmmEntryContext->CurrentlyExecutingCpu;\r
439 gSmmCoreSmst.NumberOfCpus = SmmEntryContext->NumberOfCpus;\r
440 gSmmCoreSmst.CpuSaveStateSize = SmmEntryContext->CpuSaveStateSize;\r
441 gSmmCoreSmst.CpuSaveState = SmmEntryContext->CpuSaveState;\r
e42e9404 442\r
495797c5 443 //\r
444 // Call platform hook before Smm Dispatch\r
445 //\r
446 PlatformHookBeforeSmmDispatch ();\r
447\r
e42e9404 448 //\r
449 // If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed\r
450 //\r
a25cb9f6 451 InLegacyBoot = mInLegacyBoot;\r
452 if (!InLegacyBoot) {\r
e42e9404 453 //\r
9fa90bb4 454 // Mark the InSmm flag as TRUE, it will be used by SmmBase2 protocol\r
e42e9404 455 //\r
9fa90bb4 456 gSmmCorePrivate->InSmm = TRUE;\r
e42e9404 457\r
458 //\r
9fa90bb4 459 // Check to see if this is a Synchronous SMI sent through the SMM Communication \r
460 // Protocol or an Asynchronous SMI\r
e42e9404 461 //\r
9fa90bb4 462 if (gSmmCorePrivate->CommunicationBuffer != NULL) {\r
463 //\r
464 // Synchronous SMI for SMM Core or request from Communicate protocol\r
465 //\r
3b657538
SZ
466 IsOverlapped = InternalIsBufferOverlapped (\r
467 (UINT8 *) gSmmCorePrivate->CommunicationBuffer,\r
468 gSmmCorePrivate->BufferSize,\r
469 (UINT8 *) gSmmCorePrivate,\r
470 sizeof (*gSmmCorePrivate)\r
471 );\r
472 if (!SmmIsBufferOutsideSmmValid ((UINTN)gSmmCorePrivate->CommunicationBuffer, gSmmCorePrivate->BufferSize) || IsOverlapped) {\r
3720ee6d 473 //\r
3b657538
SZ
474 // If CommunicationBuffer is not in valid address scope,\r
475 // or there is overlap between gSmmCorePrivate and CommunicationBuffer,\r
476 // return EFI_INVALID_PARAMETER\r
3720ee6d
JF
477 //\r
478 gSmmCorePrivate->CommunicationBuffer = NULL;\r
479 gSmmCorePrivate->ReturnStatus = EFI_INVALID_PARAMETER;\r
480 } else {\r
481 CommunicateHeader = (EFI_SMM_COMMUNICATE_HEADER *)gSmmCorePrivate->CommunicationBuffer;\r
482 gSmmCorePrivate->BufferSize -= OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
483 Status = SmiManage (\r
484 &CommunicateHeader->HeaderGuid, \r
485 NULL, \r
486 CommunicateHeader->Data, \r
487 &gSmmCorePrivate->BufferSize\r
488 );\r
489 //\r
490 // Update CommunicationBuffer, BufferSize and ReturnStatus\r
491 // Communicate service finished, reset the pointer to CommBuffer to NULL\r
492 //\r
493 gSmmCorePrivate->BufferSize += OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data);\r
494 gSmmCorePrivate->CommunicationBuffer = NULL;\r
495 gSmmCorePrivate->ReturnStatus = (Status == EFI_SUCCESS) ? EFI_SUCCESS : EFI_NOT_FOUND;\r
496 }\r
9fa90bb4 497 }\r
e42e9404 498 }\r
9fa90bb4 499\r
500 //\r
501 // Process Asynchronous SMI sources\r
502 //\r
503 SmiManage (NULL, NULL, NULL, NULL);\r
495797c5 504 \r
505 //\r
506 // Call platform hook after Smm Dispatch\r
507 //\r
508 PlatformHookAfterSmmDispatch ();\r
e42e9404 509\r
510 //\r
9fa90bb4 511 // If a legacy boot has occured, then make sure gSmmCorePrivate is not accessed\r
e42e9404 512 //\r
a25cb9f6 513 if (!InLegacyBoot) {\r
9fa90bb4 514 //\r
515 // Clear the InSmm flag as we are going to leave SMM\r
516 //\r
517 gSmmCorePrivate->InSmm = FALSE;\r
518 }\r
495797c5 519\r
520 PERF_END (NULL, "SMM", NULL, 0) ;\r
e42e9404 521}\r
522\r
523/**\r
524 The Entry Point for SMM Core\r
525\r
526 Install DXE Protocols and reload SMM Core into SMRAM and register SMM Core \r
527 EntryPoint on the SMI vector.\r
528\r
529 Note: This function is called for both DXE invocation and SMRAM invocation.\r
530\r
531 @param ImageHandle The firmware allocated handle for the EFI image.\r
532 @param SystemTable A pointer to the EFI System Table.\r
533\r
534 @retval EFI_SUCCESS The entry point is executed successfully.\r
535 @retval Other Some error occurred when executing this entry point.\r
536\r
537**/\r
538EFI_STATUS\r
539EFIAPI\r
540SmmMain (\r
541 IN EFI_HANDLE ImageHandle,\r
542 IN EFI_SYSTEM_TABLE *SystemTable\r
543 )\r
544{\r
545 EFI_STATUS Status;\r
546 UINTN Index;\r
547\r
548 //\r
549 // Get SMM Core Private context passed in from SMM IPL in ImageHandle.\r
550 //\r
551 gSmmCorePrivate = (SMM_CORE_PRIVATE_DATA *)ImageHandle;\r
552\r
553 //\r
554 // Fill in SMRAM physical address for the SMM Services Table and the SMM Entry Point.\r
555 //\r
556 gSmmCorePrivate->Smst = &gSmmCoreSmst;\r
557 gSmmCorePrivate->SmmEntryPoint = SmmEntryPoint;\r
558 \r
559 //\r
842b1242
JY
560 // No need to initialize memory service.\r
561 // It is done in constructor of PiSmmCoreMemoryAllocationLib(),\r
562 // so that the library linked with PiSmmCore can use AllocatePool() in constuctor.\r
e42e9404 563 //\r
e42e9404 564\r
84edd20b
SZ
565 SmramProfileInit ();\r
566\r
567 //\r
568 // Copy FullSmramRanges to SMRAM\r
569 //\r
c03beb76 570 mFullSmramRangeCount = gSmmCorePrivate->SmramRangeCount;\r
84edd20b
SZ
571 mFullSmramRanges = AllocatePool (mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));\r
572 ASSERT (mFullSmramRanges != NULL);\r
c03beb76 573 CopyMem (mFullSmramRanges, gSmmCorePrivate->SmramRanges, mFullSmramRangeCount * sizeof (EFI_SMRAM_DESCRIPTOR));\r
84edd20b 574\r
e42e9404 575 //\r
576 // Register all SMI Handlers required by the SMM Core\r
577 //\r
578 for (Index = 0; mSmmCoreSmiHandlers[Index].HandlerType != NULL; Index++) {\r
579 Status = SmiHandlerRegister (\r
580 mSmmCoreSmiHandlers[Index].Handler,\r
581 mSmmCoreSmiHandlers[Index].HandlerType,\r
582 &mSmmCoreSmiHandlers[Index].DispatchHandle\r
583 );\r
584 ASSERT_EFI_ERROR (Status);\r
585 }\r
84edd20b
SZ
586\r
587 RegisterSmramProfileHandler ();\r
588\r
e42e9404 589 return EFI_SUCCESS;\r
590}\r