TianoCore EDK2 master
Loading...
Searching...
No Matches
StandaloneMmCore.h
Go to the documentation of this file.
1
12#ifndef _MM_CORE_H_
13#define _MM_CORE_H_
14
15#include <PiMm.h>
16#include <StandaloneMm.h>
17
20#include <Protocol/MmEndOfDxe.h>
24
25#include <Guid/Apriori.h>
26#include <Guid/EventGroup.h>
28#include <Guid/ZeroGuid.h>
29#include <Guid/MemoryProfile.h>
30#include <Guid/HobList.h>
31#include <Guid/MmFvDispatch.h>
33#include <Guid/MmCommBuffer.h>
35
37#include <Library/BaseLib.h>
39#include <Library/PeCoffLib.h>
41#include <Library/DebugLib.h>
44#include <Library/PcdLib.h>
45#include <Library/HobPrintLib.h>
49#include <Library/HobLib.h>
50
52
53//
54// Used to build a table of MMI Handlers that the MM Core registers
55//
56typedef struct {
58 EFI_GUID *HandlerType;
59 EFI_HANDLE DispatchHandle;
60 BOOLEAN UnRegister;
62
63//
64// Structure for recording the state of an MM Driver
65//
66#define EFI_MM_DRIVER_ENTRY_SIGNATURE SIGNATURE_32('s', 'd','r','v')
67
68typedef struct {
69 UINTN Signature;
70 LIST_ENTRY Link; // mDriverList
71
72 LIST_ENTRY ScheduledLink; // mScheduledQueue
73
74 EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader;
75 EFI_GUID FileName;
76 VOID *Pe32Data;
77 UINTN Pe32DataSize;
78
79 VOID *Depex;
80 UINTN DepexSize;
81
82 BOOLEAN Before;
83 BOOLEAN After;
84 EFI_GUID BeforeAfterGuid;
85
86 BOOLEAN Dependent;
87 BOOLEAN Scheduled;
88 BOOLEAN Initialized;
89 BOOLEAN DepexProtocolError;
90
91 EFI_HANDLE ImageHandle;
92 EFI_LOADED_IMAGE_PROTOCOL LoadedImage;
93 //
94 // Image EntryPoint in MMRAM
95 //
96 PHYSICAL_ADDRESS ImageEntryPoint;
97 //
98 // Image Buffer in MMRAM
99 //
100 PHYSICAL_ADDRESS ImageBuffer;
101 //
102 // Image Page Number
103 //
104 UINTN NumberOfPage;
106
107#define EFI_HANDLE_SIGNATURE SIGNATURE_32('h','n','d','l')
108
112typedef struct {
113 UINTN Signature;
117 LIST_ENTRY Protocols;
118 UINTN LocateRequest;
119} IHANDLE;
120
121#define ASSERT_IS_HANDLE(a) ASSERT((a)->Signature == EFI_HANDLE_SIGNATURE)
122
123#define PROTOCOL_ENTRY_SIGNATURE SIGNATURE_32('p','r','t','e')
124
130typedef struct {
131 UINTN Signature;
133 LIST_ENTRY AllEntries;
135 EFI_GUID ProtocolID;
137 LIST_ENTRY Protocols;
139 LIST_ENTRY Notify;
141
142#define PROTOCOL_INTERFACE_SIGNATURE SIGNATURE_32('p','i','f','c')
143
148typedef struct {
149 UINTN Signature;
151 LIST_ENTRY Link;
153 IHANDLE *Handle;
157 PROTOCOL_ENTRY *Protocol;
159 VOID *Interface;
161
162#define PROTOCOL_NOTIFY_SIGNATURE SIGNATURE_32('p','r','t','n')
163
167typedef struct {
168 UINTN Signature;
169 PROTOCOL_ENTRY *Protocol;
171 LIST_ENTRY Link;
175 LIST_ENTRY *Position;
177
178//
179// MM Core Global Variables
180//
181extern EFI_MM_SYSTEM_TABLE gMmCoreMmst;
182extern LIST_ENTRY gHandleList;
183extern BOOLEAN mMmEntryPointRegistered;
184extern EFI_FIRMWARE_VOLUME_HEADER *mBfv;
185
193VOID
195 IN UINTN MmramRangeCount,
196 IN EFI_MMRAM_DESCRIPTOR *MmramRanges
197 );
198
217EFIAPI
219 IN CONST EFI_MM_SYSTEM_TABLE *SystemTable,
220 IN CONST EFI_GUID *Guid,
221 IN VOID *Table,
222 IN UINTN TableSize
223 );
224
240EFIAPI
242 IN OUT EFI_HANDLE *UserHandle,
243 IN EFI_GUID *Protocol,
244 IN EFI_INTERFACE_TYPE InterfaceType,
245 IN VOID *Interface
246 );
247
265EFIAPI
268 IN EFI_MEMORY_TYPE MemoryType,
269 IN UINTN NumberOfPages,
271 );
272
290EFIAPI
293 IN EFI_MEMORY_TYPE MemoryType,
294 IN UINTN NumberOfPages,
296 );
297
310EFIAPI
313 IN UINTN NumberOfPages
314 );
315
328EFIAPI
331 IN UINTN NumberOfPages
332 );
333
348EFIAPI
350 IN EFI_MEMORY_TYPE PoolType,
351 IN UINTN Size,
352 OUT VOID **Buffer
353 );
354
369EFIAPI
371 IN EFI_MEMORY_TYPE PoolType,
372 IN UINTN Size,
373 OUT VOID **Buffer
374 );
375
386EFIAPI
388 IN VOID *Buffer
389 );
390
401EFIAPI
403 IN VOID *Buffer
404 );
405
425 IN OUT EFI_HANDLE *UserHandle,
426 IN EFI_GUID *Protocol,
427 IN EFI_INTERFACE_TYPE InterfaceType,
428 IN VOID *Interface,
429 IN BOOLEAN Notify
430 );
431
446EFIAPI
448 IN EFI_HANDLE UserHandle,
449 IN EFI_GUID *Protocol,
450 IN VOID *Interface
451 );
452
465EFIAPI
467 IN EFI_HANDLE UserHandle,
468 IN EFI_GUID *Protocol,
469 OUT VOID **Interface
470 );
471
486EFIAPI
488 IN CONST EFI_GUID *Protocol,
489 IN EFI_MM_NOTIFY_FN Function,
490 OUT VOID **Registration
491 );
492
512EFIAPI
514 IN EFI_LOCATE_SEARCH_TYPE SearchType,
515 IN EFI_GUID *Protocol OPTIONAL,
516 IN VOID *SearchKey OPTIONAL,
517 IN OUT UINTN *BufferSize,
518 OUT EFI_HANDLE *Buffer
519 );
520
544EFIAPI
546 IN EFI_LOCATE_SEARCH_TYPE SearchType,
547 IN EFI_GUID *Protocol OPTIONAL,
548 IN VOID *SearchKey OPTIONAL,
549 IN OUT UINTN *NumberHandles,
550 OUT EFI_HANDLE **Buffer
551 );
552
570EFIAPI
572 IN EFI_GUID *Protocol,
573 IN VOID *Registration OPTIONAL,
574 OUT VOID **Interface
575 );
576
592EFIAPI
593MmiManage (
594 IN CONST EFI_GUID *HandlerType,
595 IN CONST VOID *Context OPTIONAL,
596 IN OUT VOID *CommBuffer OPTIONAL,
597 IN OUT UINTN *CommBufferSize OPTIONAL
598 );
599
612EFIAPI
615 IN CONST EFI_GUID *HandlerType OPTIONAL,
616 OUT EFI_HANDLE *DispatchHandle
617 );
618
629EFIAPI
631 IN EFI_HANDLE DispatchHandle
632 );
633
648EFIAPI
650 IN EFI_HANDLE DispatchHandle,
651 IN CONST VOID *Context OPTIONAL,
652 IN OUT VOID *CommBuffer OPTIONAL,
653 IN OUT UINTN *CommBufferSize OPTIONAL
654 );
655
670EFIAPI
672 IN EFI_HANDLE DispatchHandle,
673 IN CONST VOID *Context OPTIONAL,
674 IN OUT VOID *CommBuffer OPTIONAL,
675 IN OUT UINTN *CommBufferSize OPTIONAL
676 );
677
692EFIAPI
694 IN EFI_HANDLE DispatchHandle,
695 IN CONST VOID *Context OPTIONAL,
696 IN OUT VOID *CommBuffer OPTIONAL,
697 IN OUT UINTN *CommBufferSize OPTIONAL
698 );
699
714EFIAPI
716 IN EFI_HANDLE DispatchHandle,
717 IN CONST VOID *Context OPTIONAL,
718 IN OUT VOID *CommBuffer OPTIONAL,
719 IN OUT UINTN *CommBufferSize OPTIONAL
720 );
721
737EFIAPI
739 IN EFI_HANDLE DispatchHandle,
740 IN CONST VOID *Context OPTIONAL,
741 IN OUT VOID *CommBuffer OPTIONAL,
742 IN OUT UINTN *CommBufferSize OPTIONAL
743 );
744
759EFIAPI
761 IN EFI_HANDLE DispatchHandle,
762 IN CONST VOID *Context OPTIONAL,
763 IN OUT VOID *CommBuffer OPTIONAL,
764 IN OUT UINTN *CommBufferSize OPTIONAL
765 );
766
780EFIAPI
782 UINTN Arg1,
783 UINTN Arg2,
784 UINTN Arg3,
785 UINTN Arg4,
786 UINTN Arg5
787 );
788
789//
790// Functions used during debug builds
791//
792
798VOID
800 VOID
801 );
802
812VOID
814 IN EFI_PHYSICAL_ADDRESS MemBase,
815 IN UINT64 MemLength,
816 IN EFI_MEMORY_TYPE Type,
817 IN UINT64 Attributes
818 );
819
831 IN EFI_GUID *Protocol,
832 IN BOOLEAN Create
833 );
834
841VOID
844 );
845
860 IN IHANDLE *Handle,
861 IN EFI_GUID *Protocol,
862 IN VOID *Interface
863 );
864
877 IN IHANDLE *Handle,
878 IN EFI_GUID *Protocol,
879 IN VOID *Interface
880 );
881
894BOOLEAN
897 );
898
903VOID
905 VOID
906 );
907
930 IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader,
931 IN UINT32 Depth
932 );
933
934#define NEXT_MEMORY_DESCRIPTOR(MemoryDescriptor, Size) \
935 ((EFI_MEMORY_DESCRIPTOR *)((UINT8 *)(MemoryDescriptor) + (Size)))
936
940VOID
941EFIAPI
943 VOID
944 );
945
977EFIAPI
979 IN OUT UINTN *MemoryMapSize,
980 IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap,
981 OUT UINTN *MapKey,
982 OUT UINTN *DescriptorSize,
983 OUT UINT32 *DescriptorVersion
984 );
985
986#endif
UINT64 UINTN
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
EFI_STATUS(EFIAPI * EFI_MM_NOTIFY_FN)(IN CONST EFI_GUID *Protocol, IN VOID *Interface, IN EFI_HANDLE Handle)
Definition: PiMmCis.h:88
EFI_STATUS(EFIAPI * EFI_MM_HANDLER_ENTRY_POINT)(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: PiMmCis.h:162
EFI_STATUS EFIAPI MmReadyToBootHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
Definition: Pool.c:253
EFI_STATUS EFIAPI MmInternalAllocatePool(IN EFI_MEMORY_TYPE PoolType, IN UINTN Size, OUT VOID **Buffer)
Definition: Pool.c:191
EFI_STATUS EFIAPI MmHandleProtocol(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, OUT VOID **Interface)
Definition: Handle.c:489
EFI_STATUS EFIAPI MmLocateProtocol(IN EFI_GUID *Protocol, IN VOID *Registration OPTIONAL, OUT VOID **Interface)
Definition: Locate.c:195
EFI_STATUS EFIAPI MmEndOfPeiHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
PROTOCOL_INTERFACE * MmFindProtocolInterface(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface)
Definition: Handle.c:123
EFI_STATUS EFIAPI MmDriverDispatchHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: Dispatcher.c:736
EFI_STATUS EFIAPI MmInternalAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, OUT EFI_PHYSICAL_ADDRESS *Memory)
Definition: Page.c:668
EFI_STATUS EFIAPI MmLocateHandleBuffer(IN EFI_LOCATE_SEARCH_TYPE SearchType, IN EFI_GUID *Protocol OPTIONAL, IN VOID *SearchKey OPTIONAL, IN OUT UINTN *NumberHandles, OUT EFI_HANDLE **Buffer)
Definition: Locate.c:436
EFI_STATUS MmInstallProtocolInterfaceNotify(IN OUT EFI_HANDLE *UserHandle, IN EFI_GUID *Protocol, IN EFI_INTERFACE_TYPE InterfaceType, IN VOID *Interface, IN BOOLEAN Notify)
Definition: Handle.c:209
EFI_STATUS EFIAPI MmiHandlerRegister(IN EFI_MM_HANDLER_ENTRY_POINT Handler, IN CONST EFI_GUID *HandlerType OPTIONAL, OUT EFI_HANDLE *DispatchHandle)
Definition: Mmi.c:356
EFI_STATUS EFIAPI MmAllocatePages(IN EFI_ALLOCATE_TYPE Type, IN EFI_MEMORY_TYPE MemoryType, IN UINTN NumberOfPages, OUT EFI_PHYSICAL_ADDRESS *Memory)
Definition: Page.c:702
VOID MmAddMemoryRegion(IN EFI_PHYSICAL_ADDRESS MemBase, IN UINT64 MemLength, IN EFI_MEMORY_TYPE Type, IN UINT64 Attributes)
Definition: Page.c:874
EFI_STATUS EFIAPI MmReadyToLockHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmRegisterProtocolNotify(IN CONST EFI_GUID *Protocol, IN EFI_MM_NOTIFY_FN Function, OUT VOID **Registration)
Definition: Notify.c:97
EFI_STATUS EFIAPI MmFreePool(IN VOID *Buffer)
Definition: Pool.c:312
VOID DumpMmramInfo(VOID)
EFI_STATUS EFIAPI MmLocateHandle(IN EFI_LOCATE_SEARCH_TYPE SearchType, IN EFI_GUID *Protocol OPTIONAL, IN VOID *SearchKey OPTIONAL, IN OUT UINTN *BufferSize, OUT EFI_HANDLE *Buffer)
Definition: Locate.c:272
EFI_STATUS EFIAPI MmEfiNotAvailableYetArg5(UINTN Arg1, UINTN Arg2, UINTN Arg3, UINTN Arg4, UINTN Arg5)
PROTOCOL_INTERFACE * MmRemoveInterfaceFromProtocol(IN IHANDLE *Handle, IN EFI_GUID *Protocol, IN VOID *Interface)
Definition: Notify.c:45
VOID MmInitializeMemoryServices(IN UINTN MmramRangeCount, IN EFI_MMRAM_DESCRIPTOR *MmramRanges)
Definition: Pool.c:27
VOID MmDisplayDiscoveredNotDispatched(VOID)
Definition: Dispatcher.c:785
EFI_STATUS EFIAPI MmFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
Definition: Page.c:853
EFI_STATUS MmCoreFfsFindMmDriver(IN EFI_FIRMWARE_VOLUME_HEADER *FwVolHeader, IN UINT32 Depth)
Definition: FwVol.c:55
PROTOCOL_ENTRY * MmFindProtocolEntry(IN EFI_GUID *Protocol, IN BOOLEAN Create)
Definition: Handle.c:57
EFI_STATUS EFIAPI MmInstallProtocolInterface(IN OUT EFI_HANDLE *UserHandle, IN EFI_GUID *Protocol, IN EFI_INTERFACE_TYPE InterfaceType, IN VOID *Interface)
Definition: Handle.c:175
VOID EFIAPI MmCoreInitializeMemoryAttributesTable(VOID)
EFI_STATUS EFIAPI MmInternalFreePages(IN EFI_PHYSICAL_ADDRESS Memory, IN UINTN NumberOfPages)
Definition: Page.c:832
BOOLEAN MmIsSchedulable(IN EFI_MM_DRIVER_ENTRY *DriverEntry)
Definition: Dependency.c:159
EFI_STATUS EFIAPI MmInternalFreePool(IN VOID *Buffer)
Definition: Pool.c:276
EFI_STATUS EFIAPI MmiManage(IN CONST EFI_GUID *HandlerType, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
Definition: Mmi.c:160
VOID MmNotifyProtocol(IN PROTOCOL_INTERFACE *Prot)
Definition: Notify.c:19
EFI_STATUS EFIAPI MmInstallConfigurationTable(IN CONST EFI_MM_SYSTEM_TABLE *SystemTable, IN CONST EFI_GUID *Guid, IN VOID *Table, IN UINTN TableSize)
EFI_STATUS EFIAPI MmCoreGetMemoryMap(IN OUT UINTN *MemoryMapSize, IN OUT EFI_MEMORY_DESCRIPTOR *MemoryMap, OUT UINTN *MapKey, OUT UINTN *DescriptorSize, OUT UINT32 *DescriptorVersion)
Definition: Page.c:938
EFI_STATUS EFIAPI MmUninstallProtocolInterface(IN EFI_HANDLE UserHandle, IN EFI_GUID *Protocol, IN VOID *Interface)
Definition: Handle.c:364
EFI_STATUS EFIAPI MmExitBootServiceHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI MmiHandlerUnRegister(IN EFI_HANDLE DispatchHandle)
Definition: Mmi.c:416
EFI_STATUS EFIAPI MmEndOfDxeHandler(IN EFI_HANDLE DispatchHandle, IN CONST VOID *Context OPTIONAL, IN OUT VOID *CommBuffer OPTIONAL, IN OUT UINTN *CommBufferSize OPTIONAL)
EFI_STATUS EFIAPI DriverEntry(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: TdTcg2Dxe.c:2427
UINT64 EFI_PHYSICAL_ADDRESS
Definition: UefiBaseType.h:50
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
EFI_MEMORY_TYPE
EFI_INTERFACE_TYPE
Definition: UefiSpec.h:1189
EFI_LOCATE_SEARCH_TYPE
Definition: UefiSpec.h:1505
@ ByProtocol
Definition: UefiSpec.h:1518
@ AllHandles
Definition: UefiSpec.h:1509
EFI_ALLOCATE_TYPE
Definition: UefiSpec.h:29
Definition: Base.h:213
Definition: Handle.h:17
EFI_MM_NOTIFY_FN Function
Notification function.