]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Core/PiSmmCore/PiSmmCore.h
MdeModulePkg DxeCore/PiSmmCore: Add UEFI memory and SMRAM profile support.
[mirror_edk2.git] / MdeModulePkg / Core / PiSmmCore / PiSmmCore.h
CommitLineData
e42e9404 1/** @file\r
2 The internal header file includes the common header files, defines\r
3 internal structure and functions used by SmmCore module.\r
4\r
84edd20b 5 Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.<BR>\r
e42e9404 6 This program and the accompanying materials are licensed and made available \r
7 under the terms and conditions of the BSD License which accompanies this \r
8 distribution. The full text of the license may be found at \r
9 http://opensource.org/licenses/bsd-license.php \r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
13\r
14**/\r
15\r
16#ifndef _SMM_CORE_H_\r
17#define _SMM_CORE_H_\r
18\r
19#include <PiSmm.h>\r
20\r
21#include <Protocol/DxeSmmReadyToLock.h>\r
22#include <Protocol/SmmReadyToLock.h>\r
46ece1ff 23#include <Protocol/SmmEndOfDxe.h>\r
e42e9404 24#include <Protocol/CpuIo2.h>\r
25#include <Protocol/SmmCommunication.h>\r
26#include <Protocol/SmmAccess2.h>\r
27#include <Protocol/FirmwareVolume2.h> \r
28#include <Protocol/LoadedImage.h> \r
29#include <Protocol/DevicePath.h> \r
30#include <Protocol/Security.h> \r
bc2dfdbc 31#include <Protocol/Security2.h>\r
e42e9404 32\r
33#include <Guid/Apriori.h>\r
34#include <Guid/EventGroup.h>\r
35#include <Guid/EventLegacyBios.h>\r
84edd20b
SZ
36#include <Guid/ZeroGuid.h>\r
37#include <Guid/MemoryProfile.h>\r
e42e9404 38\r
39#include <Library/BaseLib.h>\r
40#include <Library/BaseMemoryLib.h>\r
41#include <Library/PeCoffLib.h>\r
42#include <Library/CacheMaintenanceLib.h>\r
43#include <Library/DebugLib.h>\r
44#include <Library/ReportStatusCodeLib.h>\r
45#include <Library/MemoryAllocationLib.h>\r
46#include <Library/DevicePathLib.h> \r
47#include <Library/UefiLib.h> \r
3c447c27 48#include <Library/UefiBootServicesTableLib.h>\r
49#include <Library/PcdLib.h>\r
495797c5 50#include <Library/SmmCorePlatformHookLib.h>\r
51#include <Library/PerformanceLib.h>\r
c2cb08df 52#include <Library/TimerLib.h>\r
e42e9404 53\r
54#include "PiSmmCorePrivateData.h"\r
55\r
56//\r
57// Used to build a table of SMI Handlers that the SMM Core registers\r
58//\r
59typedef struct {\r
60 EFI_SMM_HANDLER_ENTRY_POINT2 Handler;\r
61 EFI_GUID *HandlerType;\r
62 EFI_HANDLE DispatchHandle;\r
63 BOOLEAN UnRegister;\r
64} SMM_CORE_SMI_HANDLERS;\r
65\r
66//\r
67// Structure for recording the state of an SMM Driver\r
68//\r
69#define EFI_SMM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')\r
70\r
71typedef struct {\r
72 UINTN Signature;\r
73 LIST_ENTRY Link; // mDriverList\r
74\r
75 LIST_ENTRY ScheduledLink; // mScheduledQueue\r
76\r
77 EFI_HANDLE FvHandle;\r
78 EFI_GUID FileName;\r
79 EFI_DEVICE_PATH_PROTOCOL *FvFileDevicePath;\r
80 EFI_FIRMWARE_VOLUME2_PROTOCOL *Fv;\r
81\r
82 VOID *Depex;\r
83 UINTN DepexSize;\r
84\r
85 BOOLEAN Before;\r
86 BOOLEAN After;\r
87 EFI_GUID BeforeAfterGuid;\r
88\r
89 BOOLEAN Dependent;\r
e42e9404 90 BOOLEAN Scheduled;\r
e42e9404 91 BOOLEAN Initialized;\r
92 BOOLEAN DepexProtocolError;\r
93\r
94 EFI_HANDLE ImageHandle;\r
95 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
96 //\r
97 // Image EntryPoint in SMRAM\r
98 //\r
99 PHYSICAL_ADDRESS ImageEntryPoint;\r
100 //\r
101 // Image Buffer in SMRAM \r
102 //\r
103 PHYSICAL_ADDRESS ImageBuffer;\r
104 //\r
105 // Image Page Number\r
106 //\r
107 UINTN NumberOfPage;\r
108} EFI_SMM_DRIVER_ENTRY;\r
109\r
110#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')\r
111\r
112///\r
113/// IHANDLE - contains a list of protocol handles\r
114///\r
115typedef struct {\r
116 UINTN Signature;\r
117 /// All handles list of IHANDLE\r
118 LIST_ENTRY AllHandles;\r
119 /// List of PROTOCOL_INTERFACE's for this handle\r
120 LIST_ENTRY Protocols;\r
121 UINTN LocateRequest;\r
122} IHANDLE;\r
123\r
124#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)\r
125\r
126#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')\r
127\r
128///\r
129/// PROTOCOL_ENTRY - each different protocol has 1 entry in the protocol\r
130/// database. Each handler that supports this protocol is listed, along\r
131/// with a list of registered notifies.\r
132///\r
133typedef struct {\r
134 UINTN Signature;\r
135 /// Link Entry inserted to mProtocolDatabase\r
136 LIST_ENTRY AllEntries;\r
137 /// ID of the protocol\r
138 EFI_GUID ProtocolID;\r
139 /// All protocol interfaces\r
140 LIST_ENTRY Protocols;\r
141 /// Registerd notification handlers\r
142 LIST_ENTRY Notify;\r
143} PROTOCOL_ENTRY;\r
144\r
145#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')\r
146\r
147///\r
148/// PROTOCOL_INTERFACE - each protocol installed on a handle is tracked\r
149/// with a protocol interface structure\r
150///\r
151typedef struct {\r
152 UINTN Signature;\r
153 /// Link on IHANDLE.Protocols\r
154 LIST_ENTRY Link;\r
155 /// Back pointer\r
156 IHANDLE *Handle;\r
157 /// Link on PROTOCOL_ENTRY.Protocols\r
158 LIST_ENTRY ByProtocol;\r
159 /// The protocol ID\r
160 PROTOCOL_ENTRY *Protocol;\r
161 /// The interface value\r
162 VOID *Interface;\r
163} PROTOCOL_INTERFACE;\r
164\r
165#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')\r
166\r
167///\r
168/// PROTOCOL_NOTIFY - used for each register notification for a protocol\r
169///\r
170typedef struct {\r
171 UINTN Signature;\r
172 PROTOCOL_ENTRY *Protocol;\r
173 /// All notifications for this protocol\r
174 LIST_ENTRY Link;\r
175 /// Notification function\r
176 EFI_SMM_NOTIFY_FN Function;\r
177 /// Last position notified\r
178 LIST_ENTRY *Position;\r
179} PROTOCOL_NOTIFY;\r
180\r
181//\r
182// SMM Core Global Variables\r
183//\r
184extern SMM_CORE_PRIVATE_DATA *gSmmCorePrivate;\r
185extern EFI_SMM_SYSTEM_TABLE2 gSmmCoreSmst;\r
186extern LIST_ENTRY gHandleList;\r
3c447c27 187extern EFI_PHYSICAL_ADDRESS gLoadModuleAtFixAddressSmramBase;\r
e42e9404 188\r
189/**\r
190 Called to initialize the memory service.\r
191\r
192 @param SmramRangeCount Number of SMRAM Regions\r
193 @param SmramRanges Pointer to SMRAM Descriptors\r
194\r
195**/\r
196VOID\r
197SmmInitializeMemoryServices (\r
198 IN UINTN SmramRangeCount,\r
199 IN EFI_SMRAM_DESCRIPTOR *SmramRanges\r
200 );\r
201\r
202/**\r
203 The SmmInstallConfigurationTable() function is used to maintain the list\r
204 of configuration tables that are stored in the System Management System\r
205 Table. The list is stored as an array of (GUID, Pointer) pairs. The list\r
206 must be allocated from pool memory with PoolType set to EfiRuntimeServicesData.\r
207\r
208 @param SystemTable A pointer to the SMM System Table (SMST).\r
209 @param Guid A pointer to the GUID for the entry to add, update, or remove.\r
210 @param Table A pointer to the buffer of the table to add.\r
211 @param TableSize The size of the table to install.\r
212\r
213 @retval EFI_SUCCESS The (Guid, Table) pair was added, updated, or removed.\r
214 @retval EFI_INVALID_PARAMETER Guid is not valid.\r
215 @retval EFI_NOT_FOUND An attempt was made to delete a non-existent entry.\r
216 @retval EFI_OUT_OF_RESOURCES There is not enough memory available to complete the operation.\r
217\r
218**/\r
219EFI_STATUS\r
220EFIAPI\r
221SmmInstallConfigurationTable (\r
222 IN CONST EFI_SMM_SYSTEM_TABLE2 *SystemTable,\r
223 IN CONST EFI_GUID *Guid,\r
224 IN VOID *Table,\r
225 IN UINTN TableSize\r
226 );\r
227\r
228/**\r
229 Wrapper function to SmmInstallProtocolInterfaceNotify. This is the public API which\r
230 Calls the private one which contains a BOOLEAN parameter for notifications\r
231\r
232 @param UserHandle The handle to install the protocol handler on,\r
233 or NULL if a new handle is to be allocated\r
234 @param Protocol The protocol to add to the handle\r
235 @param InterfaceType Indicates whether Interface is supplied in\r
236 native form.\r
237 @param Interface The interface for the protocol being added\r
238\r
239 @return Status code\r
240\r
241**/\r
242EFI_STATUS\r
243EFIAPI\r
244SmmInstallProtocolInterface (\r
245 IN OUT EFI_HANDLE *UserHandle,\r
246 IN EFI_GUID *Protocol,\r
247 IN EFI_INTERFACE_TYPE InterfaceType,\r
248 IN VOID *Interface\r
249 );\r
250\r
251/**\r
252 Allocates pages from the memory map.\r
253\r
254 @param Type The type of allocation to perform\r
255 @param MemoryType The type of memory to turn the allocated pages\r
256 into\r
257 @param NumberOfPages The number of pages to allocate\r
258 @param Memory A pointer to receive the base allocated memory\r
259 address\r
260\r
261 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r
262 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r
263 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r
264 @retval EFI_SUCCESS Pages successfully allocated.\r
265\r
266**/\r
267EFI_STATUS\r
268EFIAPI\r
269SmmAllocatePages (\r
270 IN EFI_ALLOCATE_TYPE Type,\r
271 IN EFI_MEMORY_TYPE MemoryType,\r
272 IN UINTN NumberOfPages,\r
273 OUT EFI_PHYSICAL_ADDRESS *Memory\r
274 );\r
275\r
84edd20b
SZ
276/**\r
277 Allocates pages from the memory map.\r
278\r
279 @param Type The type of allocation to perform\r
280 @param MemoryType The type of memory to turn the allocated pages\r
281 into\r
282 @param NumberOfPages The number of pages to allocate\r
283 @param Memory A pointer to receive the base allocated memory\r
284 address\r
285\r
286 @retval EFI_INVALID_PARAMETER Parameters violate checking rules defined in spec.\r
287 @retval EFI_NOT_FOUND Could not allocate pages match the requirement.\r
288 @retval EFI_OUT_OF_RESOURCES No enough pages to allocate.\r
289 @retval EFI_SUCCESS Pages successfully allocated.\r
290\r
291**/\r
292EFI_STATUS\r
293EFIAPI\r
294SmmInternalAllocatePages (\r
295 IN EFI_ALLOCATE_TYPE Type,\r
296 IN EFI_MEMORY_TYPE MemoryType,\r
297 IN UINTN NumberOfPages,\r
298 OUT EFI_PHYSICAL_ADDRESS *Memory\r
299 );\r
300\r
e42e9404 301/**\r
302 Frees previous allocated pages.\r
303\r
304 @param Memory Base address of memory being freed\r
305 @param NumberOfPages The number of pages to free\r
306\r
307 @retval EFI_NOT_FOUND Could not find the entry that covers the range\r
308 @retval EFI_INVALID_PARAMETER Address not aligned\r
309 @return EFI_SUCCESS Pages successfully freed.\r
310\r
311**/\r
312EFI_STATUS\r
313EFIAPI\r
314SmmFreePages (\r
315 IN EFI_PHYSICAL_ADDRESS Memory,\r
316 IN UINTN NumberOfPages\r
317 );\r
318\r
84edd20b
SZ
319/**\r
320 Frees previous allocated pages.\r
321\r
322 @param Memory Base address of memory being freed\r
323 @param NumberOfPages The number of pages to free\r
324\r
325 @retval EFI_NOT_FOUND Could not find the entry that covers the range\r
326 @retval EFI_INVALID_PARAMETER Address not aligned\r
327 @return EFI_SUCCESS Pages successfully freed.\r
328\r
329**/\r
330EFI_STATUS\r
331EFIAPI\r
332SmmInternalFreePages (\r
333 IN EFI_PHYSICAL_ADDRESS Memory,\r
334 IN UINTN NumberOfPages\r
335 );\r
336\r
e42e9404 337/**\r
338 Allocate pool of a particular type.\r
339\r
340 @param PoolType Type of pool to allocate\r
341 @param Size The amount of pool to allocate\r
342 @param Buffer The address to return a pointer to the allocated\r
343 pool\r
344\r
345 @retval EFI_INVALID_PARAMETER PoolType not valid\r
346 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
347 @retval EFI_SUCCESS Pool successfully allocated.\r
348\r
349**/\r
350EFI_STATUS\r
351EFIAPI\r
352SmmAllocatePool (\r
353 IN EFI_MEMORY_TYPE PoolType,\r
354 IN UINTN Size,\r
355 OUT VOID **Buffer\r
356 );\r
357\r
84edd20b
SZ
358/**\r
359 Allocate pool of a particular type.\r
360\r
361 @param PoolType Type of pool to allocate\r
362 @param Size The amount of pool to allocate\r
363 @param Buffer The address to return a pointer to the allocated\r
364 pool\r
365\r
366 @retval EFI_INVALID_PARAMETER PoolType not valid\r
367 @retval EFI_OUT_OF_RESOURCES Size exceeds max pool size or allocation failed.\r
368 @retval EFI_SUCCESS Pool successfully allocated.\r
369\r
370**/\r
371EFI_STATUS\r
372EFIAPI\r
373SmmInternalAllocatePool (\r
374 IN EFI_MEMORY_TYPE PoolType,\r
375 IN UINTN Size,\r
376 OUT VOID **Buffer\r
377 );\r
378\r
e42e9404 379/**\r
380 Frees pool.\r
381\r
382 @param Buffer The allocated pool entry to free\r
383\r
384 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
385 @retval EFI_SUCCESS Pool successfully freed.\r
386\r
387**/\r
388EFI_STATUS\r
389EFIAPI\r
390SmmFreePool (\r
391 IN VOID *Buffer\r
392 );\r
393\r
84edd20b
SZ
394/**\r
395 Frees pool.\r
396\r
397 @param Buffer The allocated pool entry to free\r
398\r
399 @retval EFI_INVALID_PARAMETER Buffer is not a valid value.\r
400 @retval EFI_SUCCESS Pool successfully freed.\r
401\r
402**/\r
403EFI_STATUS\r
404EFIAPI\r
405SmmInternalFreePool (\r
406 IN VOID *Buffer\r
407 );\r
408\r
e42e9404 409/**\r
410 Installs a protocol interface into the boot services environment.\r
411\r
412 @param UserHandle The handle to install the protocol handler on,\r
413 or NULL if a new handle is to be allocated\r
414 @param Protocol The protocol to add to the handle\r
415 @param InterfaceType Indicates whether Interface is supplied in\r
416 native form.\r
417 @param Interface The interface for the protocol being added\r
418 @param Notify indicates whether notify the notification list\r
419 for this protocol\r
420\r
421 @retval EFI_INVALID_PARAMETER Invalid parameter\r
422 @retval EFI_OUT_OF_RESOURCES No enough buffer to allocate\r
423 @retval EFI_SUCCESS Protocol interface successfully installed\r
424\r
425**/\r
426EFI_STATUS\r
427SmmInstallProtocolInterfaceNotify (\r
428 IN OUT EFI_HANDLE *UserHandle,\r
429 IN EFI_GUID *Protocol,\r
430 IN EFI_INTERFACE_TYPE InterfaceType,\r
431 IN VOID *Interface,\r
432 IN BOOLEAN Notify\r
433 );\r
434\r
435/**\r
436 Uninstalls all instances of a protocol:interfacer from a handle.\r
437 If the last protocol interface is remove from the handle, the\r
438 handle is freed.\r
439\r
440 @param UserHandle The handle to remove the protocol handler from\r
441 @param Protocol The protocol, of protocol:interface, to remove\r
442 @param Interface The interface, of protocol:interface, to remove\r
443\r
444 @retval EFI_INVALID_PARAMETER Protocol is NULL.\r
445 @retval EFI_SUCCESS Protocol interface successfully uninstalled.\r
446\r
447**/\r
448EFI_STATUS\r
449EFIAPI\r
450SmmUninstallProtocolInterface (\r
451 IN EFI_HANDLE UserHandle,\r
452 IN EFI_GUID *Protocol,\r
453 IN VOID *Interface\r
454 );\r
455\r
456/**\r
457 Queries a handle to determine if it supports a specified protocol.\r
458\r
459 @param UserHandle The handle being queried.\r
460 @param Protocol The published unique identifier of the protocol.\r
461 @param Interface Supplies the address where a pointer to the\r
462 corresponding Protocol Interface is returned.\r
463\r
464 @return The requested protocol interface for the handle\r
465\r
466**/\r
467EFI_STATUS\r
468EFIAPI\r
469SmmHandleProtocol (\r
470 IN EFI_HANDLE UserHandle,\r
471 IN EFI_GUID *Protocol,\r
472 OUT VOID **Interface\r
473 );\r
474\r
475/**\r
476 Add a new protocol notification record for the request protocol.\r
477\r
478 @param Protocol The requested protocol to add the notify\r
479 registration\r
480 @param Function Points to the notification function\r
481 @param Registration Returns the registration record\r
482\r
483 @retval EFI_INVALID_PARAMETER Invalid parameter\r
484 @retval EFI_SUCCESS Successfully returned the registration record\r
485 that has been added\r
486\r
487**/\r
488EFI_STATUS\r
489EFIAPI\r
490SmmRegisterProtocolNotify (\r
491 IN CONST EFI_GUID *Protocol,\r
492 IN EFI_SMM_NOTIFY_FN Function,\r
493 OUT VOID **Registration\r
494 );\r
495\r
496/**\r
497 Locates the requested handle(s) and returns them in Buffer.\r
498\r
499 @param SearchType The type of search to perform to locate the\r
500 handles\r
501 @param Protocol The protocol to search for\r
502 @param SearchKey Dependant on SearchType\r
503 @param BufferSize On input the size of Buffer. On output the\r
504 size of data returned.\r
505 @param Buffer The buffer to return the results in\r
506\r
507 @retval EFI_BUFFER_TOO_SMALL Buffer too small, required buffer size is\r
508 returned in BufferSize.\r
509 @retval EFI_INVALID_PARAMETER Invalid parameter\r
510 @retval EFI_SUCCESS Successfully found the requested handle(s) and\r
511 returns them in Buffer.\r
512\r
513**/\r
514EFI_STATUS\r
515EFIAPI\r
516SmmLocateHandle (\r
517 IN EFI_LOCATE_SEARCH_TYPE SearchType,\r
518 IN EFI_GUID *Protocol OPTIONAL,\r
519 IN VOID *SearchKey OPTIONAL,\r
520 IN OUT UINTN *BufferSize,\r
521 OUT EFI_HANDLE *Buffer\r
522 );\r
523\r
524/**\r
525 Return the first Protocol Interface that matches the Protocol GUID. If\r
526 Registration is pasased in return a Protocol Instance that was just add\r
527 to the system. If Retistration is NULL return the first Protocol Interface\r
528 you find.\r
529\r
530 @param Protocol The protocol to search for\r
531 @param Registration Optional Registration Key returned from\r
532 RegisterProtocolNotify()\r
533 @param Interface Return the Protocol interface (instance).\r
534\r
535 @retval EFI_SUCCESS If a valid Interface is returned\r
536 @retval EFI_INVALID_PARAMETER Invalid parameter\r
537 @retval EFI_NOT_FOUND Protocol interface not found\r
538\r
539**/\r
540EFI_STATUS\r
541EFIAPI\r
542SmmLocateProtocol (\r
543 IN EFI_GUID *Protocol,\r
544 IN VOID *Registration OPTIONAL,\r
545 OUT VOID **Interface\r
546 );\r
547\r
548/**\r
549 Manage SMI of a particular type.\r
550\r
551 @param HandlerType Points to the handler type or NULL for root SMI handlers.\r
552 @param Context Points to an optional context buffer.\r
553 @param CommBuffer Points to the optional communication buffer.\r
554 @param CommBufferSize Points to the size of the optional communication buffer.\r
555\r
556 @retval EFI_SUCCESS Interrupt source was processed successfully but not quiesced.\r
557 @retval EFI_INTERRUPT_PENDING One or more SMI sources could not be quiesced.\r
558 @retval EFI_WARN_INTERRUPT_SOURCE_PENDING Interrupt source was not handled or quiesced.\r
559 @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED Interrupt source was handled and quiesced.\r
560\r
561**/\r
562EFI_STATUS\r
563EFIAPI\r
564SmiManage (\r
565 IN CONST EFI_GUID *HandlerType,\r
566 IN CONST VOID *Context OPTIONAL,\r
567 IN OUT VOID *CommBuffer OPTIONAL,\r
568 IN OUT UINTN *CommBufferSize OPTIONAL\r
569 );\r
570\r
571/**\r
572 Registers a handler to execute within SMM.\r
573\r
574 @param Handler Handler service funtion pointer.\r
575 @param HandlerType Points to the handler type or NULL for root SMI handlers.\r
576 @param DispatchHandle On return, contains a unique handle which can be used to later unregister the handler function.\r
577\r
578 @retval EFI_SUCCESS Handler register success.\r
579 @retval EFI_INVALID_PARAMETER Handler or DispatchHandle is NULL.\r
580\r
581**/\r
582EFI_STATUS\r
583EFIAPI\r
584SmiHandlerRegister (\r
585 IN EFI_SMM_HANDLER_ENTRY_POINT2 Handler,\r
586 IN CONST EFI_GUID *HandlerType OPTIONAL,\r
587 OUT EFI_HANDLE *DispatchHandle\r
588 );\r
589\r
590/**\r
591 Unregister a handler in SMM.\r
592\r
593 @param DispatchHandle The handle that was specified when the handler was registered.\r
594\r
595 @retval EFI_SUCCESS Handler function was successfully unregistered.\r
596 @retval EFI_INVALID_PARAMETER DispatchHandle does not refer to a valid handle.\r
597\r
598**/\r
599EFI_STATUS\r
600EFIAPI\r
601SmiHandlerUnRegister (\r
602 IN EFI_HANDLE DispatchHandle\r
603 );\r
604\r
605/**\r
606 This function is the main entry point for an SMM handler dispatch\r
607 or communicate-based callback.\r
608\r
609 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
610 @param Context Points to an optional handler context which was specified when the handler was registered.\r
611 @param CommBuffer A pointer to a collection of data in memory that will\r
612 be conveyed from a non-SMM environment into an SMM environment.\r
613 @param CommBufferSize The size of the CommBuffer.\r
614\r
615 @return Status Code\r
616\r
617**/\r
618EFI_STATUS\r
619EFIAPI\r
620SmmDriverDispatchHandler (\r
621 IN EFI_HANDLE DispatchHandle,\r
622 IN CONST VOID *Context, OPTIONAL\r
623 IN OUT VOID *CommBuffer, OPTIONAL\r
624 IN OUT UINTN *CommBufferSize OPTIONAL\r
625 );\r
626\r
627/**\r
628 This function is the main entry point for an SMM handler dispatch\r
629 or communicate-based callback.\r
630\r
631 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
632 @param Context Points to an optional handler context which was specified when the handler was registered.\r
633 @param CommBuffer A pointer to a collection of data in memory that will\r
634 be conveyed from a non-SMM environment into an SMM environment.\r
635 @param CommBufferSize The size of the CommBuffer.\r
636\r
637 @return Status Code\r
638\r
639**/\r
640EFI_STATUS\r
641EFIAPI\r
642SmmLegacyBootHandler (\r
643 IN EFI_HANDLE DispatchHandle,\r
644 IN CONST VOID *Context, OPTIONAL\r
645 IN OUT VOID *CommBuffer, OPTIONAL\r
646 IN OUT UINTN *CommBufferSize OPTIONAL\r
647 );\r
648\r
649/**\r
650 This function is the main entry point for an SMM handler dispatch\r
651 or communicate-based callback.\r
652\r
653 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
654 @param Context Points to an optional handler context which was specified when the handler was registered.\r
655 @param CommBuffer A pointer to a collection of data in memory that will\r
656 be conveyed from a non-SMM environment into an SMM environment.\r
657 @param CommBufferSize The size of the CommBuffer.\r
658\r
659 @return Status Code\r
660\r
661**/\r
662EFI_STATUS\r
663EFIAPI\r
664SmmReadyToLockHandler (\r
665 IN EFI_HANDLE DispatchHandle,\r
666 IN CONST VOID *Context, OPTIONAL\r
667 IN OUT VOID *CommBuffer, OPTIONAL\r
668 IN OUT UINTN *CommBufferSize OPTIONAL\r
669 );\r
670\r
46ece1ff
JY
671/**\r
672 This function is the main entry point for an SMM handler dispatch\r
673 or communicate-based callback.\r
674\r
675 @param DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().\r
676 @param Context Points to an optional handler context which was specified when the handler was registered.\r
677 @param CommBuffer A pointer to a collection of data in memory that will\r
678 be conveyed from a non-SMM environment into an SMM environment.\r
679 @param CommBufferSize The size of the CommBuffer.\r
680\r
681 @return Status Code\r
682\r
683**/\r
684EFI_STATUS\r
685EFIAPI\r
686SmmEndOfDxeHandler (\r
687 IN EFI_HANDLE DispatchHandle,\r
688 IN CONST VOID *Context, OPTIONAL\r
689 IN OUT VOID *CommBuffer, OPTIONAL\r
690 IN OUT UINTN *CommBufferSize OPTIONAL\r
691 );\r
692\r
e42e9404 693/**\r
694 Place holder function until all the SMM System Table Service are available.\r
695\r
696 @param Arg1 Undefined\r
697 @param Arg2 Undefined\r
698 @param Arg3 Undefined\r
699 @param Arg4 Undefined\r
700 @param Arg5 Undefined\r
701\r
702 @return EFI_NOT_AVAILABLE_YET\r
703\r
704**/\r
705EFI_STATUS\r
706EFIAPI\r
707SmmEfiNotAvailableYetArg5 (\r
708 UINTN Arg1,\r
709 UINTN Arg2,\r
710 UINTN Arg3,\r
711 UINTN Arg4,\r
712 UINTN Arg5\r
713 );\r
714\r
715//\r
716//Functions used during debug buils\r
717//\r
718\r
719/**\r
720 Traverse the discovered list for any drivers that were discovered but not loaded\r
721 because the dependency experessions evaluated to false.\r
722\r
723**/\r
724VOID\r
725SmmDisplayDiscoveredNotDispatched (\r
726 VOID\r
727 );\r
728\r
729/**\r
730 Add free SMRAM region for use by memory service.\r
731\r
732 @param MemBase Base address of memory region.\r
733 @param MemLength Length of the memory region.\r
734 @param Type Memory type.\r
735 @param Attributes Memory region state.\r
736\r
737**/\r
738VOID\r
739SmmAddMemoryRegion (\r
740 IN EFI_PHYSICAL_ADDRESS MemBase,\r
741 IN UINT64 MemLength,\r
742 IN EFI_MEMORY_TYPE Type,\r
743 IN UINT64 Attributes\r
744 );\r
745\r
746/**\r
747 Finds the protocol entry for the requested protocol.\r
748\r
749 @param Protocol The ID of the protocol\r
750 @param Create Create a new entry if not found\r
751\r
752 @return Protocol entry\r
753\r
754**/\r
755PROTOCOL_ENTRY *\r
756SmmFindProtocolEntry (\r
757 IN EFI_GUID *Protocol,\r
758 IN BOOLEAN Create\r
759 );\r
760\r
761/**\r
762 Signal event for every protocol in protocol entry.\r
763\r
764 @param Prot Protocol interface\r
765\r
766**/\r
767VOID\r
768SmmNotifyProtocol (\r
769 IN PROTOCOL_INTERFACE *Prot\r
770 );\r
771\r
772/**\r
773 Finds the protocol instance for the requested handle and protocol.\r
774 Note: This function doesn't do parameters checking, it's caller's responsibility\r
775 to pass in valid parameters.\r
776\r
777 @param Handle The handle to search the protocol on\r
778 @param Protocol GUID of the protocol\r
779 @param Interface The interface for the protocol being searched\r
780\r
781 @return Protocol instance (NULL: Not found)\r
782\r
783**/\r
784PROTOCOL_INTERFACE *\r
785SmmFindProtocolInterface (\r
786 IN IHANDLE *Handle,\r
787 IN EFI_GUID *Protocol,\r
788 IN VOID *Interface\r
789 );\r
790\r
791/**\r
792 Removes Protocol from the protocol list (but not the handle list).\r
793\r
794 @param Handle The handle to remove protocol on.\r
795 @param Protocol GUID of the protocol to be moved\r
796 @param Interface The interface of the protocol\r
797\r
798 @return Protocol Entry\r
799\r
800**/\r
801PROTOCOL_INTERFACE *\r
802SmmRemoveInterfaceFromProtocol (\r
803 IN IHANDLE *Handle,\r
804 IN EFI_GUID *Protocol,\r
805 IN VOID *Interface\r
806 );\r
807\r
808/**\r
809 This is the POSTFIX version of the dependency evaluator. This code does\r
810 not need to handle Before or After, as it is not valid to call this\r
fa542a1e 811 routine in this case. POSTFIX means all the math is done on top of the stack.\r
e42e9404 812\r
813 @param DriverEntry DriverEntry element to update.\r
814\r
815 @retval TRUE If driver is ready to run.\r
816 @retval FALSE If driver is not ready to run or some fatal error\r
817 was found.\r
818\r
819**/\r
820BOOLEAN\r
821SmmIsSchedulable (\r
822 IN EFI_SMM_DRIVER_ENTRY *DriverEntry\r
823 );\r
824\r
84edd20b
SZ
825//\r
826// SmramProfile\r
827//\r
828\r
829/**\r
830 Initialize SMRAM profile.\r
831\r
832**/\r
833VOID\r
834SmramProfileInit (\r
835 VOID\r
836 );\r
837\r
838/**\r
839 Register SMM image to SMRAM profile.\r
840\r
841 @param DriverEntry SMM image info.\r
842 @param RegisterToDxe Register image to DXE.\r
843\r
844 @retval TRUE Register success.\r
845 @retval FALSE Register fail.\r
846\r
847**/\r
848BOOLEAN\r
849RegisterSmramProfileImage (\r
850 IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r
851 IN BOOLEAN RegisterToDxe\r
852 );\r
853\r
854/**\r
855 Unregister image from SMRAM profile.\r
856\r
857 @param DriverEntry SMM image info.\r
858 @param UnregisterToDxe Unregister image from DXE.\r
859\r
860 @retval TRUE Unregister success.\r
861 @retval FALSE Unregister fail.\r
862\r
863**/\r
864BOOLEAN\r
865UnregisterSmramProfileImage (\r
866 IN EFI_SMM_DRIVER_ENTRY *DriverEntry,\r
867 IN BOOLEAN UnregisterToDxe\r
868 );\r
869\r
870/**\r
871 Update SMRAM profile information.\r
872\r
873 @param CallerAddress Address of caller who call Allocate or Free.\r
874 @param Action This Allocate or Free action.\r
875 @param MemoryType Memory type.\r
876 @param Size Buffer size.\r
877 @param Buffer Buffer address.\r
878\r
879 @retval TRUE Profile udpate success.\r
880 @retval FALSE Profile update fail.\r
881\r
882**/\r
883BOOLEAN\r
884SmmCoreUpdateProfile (\r
885 IN EFI_PHYSICAL_ADDRESS CallerAddress,\r
886 IN MEMORY_PROFILE_ACTION Action,\r
887 IN EFI_MEMORY_TYPE MemoryType, // Valid for AllocatePages/AllocatePool\r
888 IN UINTN Size, // Valid for AllocatePages/FreePages/AllocatePool\r
889 IN VOID *Buffer\r
890 );\r
891\r
892/**\r
893 Register SMRAM profile handler.\r
894\r
895**/\r
896VOID\r
897RegisterSmramProfileHandler (\r
898 VOID\r
899 );\r
900\r
901/**\r
902 SMRAM profile ready to lock callback function.\r
903\r
904**/\r
905VOID\r
906SmramProfileReadyToLock (\r
907 VOID\r
908 );\r
909\r
910/**\r
911 Dump SMRAM infromation.\r
912\r
913**/\r
914VOID\r
915DumpSmramInfo (\r
916 VOID\r
917 );\r
918\r
919extern UINTN mFullSmramRangeCount;\r
920extern EFI_SMRAM_DESCRIPTOR *mFullSmramRanges;\r
921\r
e42e9404 922#endif\r