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