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