TianoCore EDK2 master
Loading...
Searching...
No Matches
StandaloneMmDriverEntryPoint.c
Go to the documentation of this file.
1
12#include <PiMm.h>
13
15#include <Library/BaseLib.h>
16#include <Library/DebugLib.h>
19
32EFIAPI
34 EFI_HANDLE ImageHandle
35 )
36{
37 EFI_STATUS Status;
38
39 //
40 // If an UnloadImage() handler is specified, then call it
41 //
42 Status = ProcessModuleUnloadList (ImageHandle);
43
44 //
45 // If the driver specific unload handler does not return an error, then call all of the
46 // library destructors. If the unload handler returned an error, then the driver can not be
47 // unloaded, and the library destructors should not be called
48 //
49 if (!EFI_ERROR (Status)) {
50 ProcessLibraryDestructorList (ImageHandle, gMmst);
51 }
52
53 //
54 // Return the status from the driver specific unload handler
55 //
56 return Status;
57}
58
82EFIAPI
84 IN EFI_HANDLE ImageHandle,
85 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
86 )
87{
88 EFI_STATUS Status;
89 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
90
91 if (_gMmRevision != 0) {
92 //
93 // Make sure that the MM spec revision of the platform
94 // is >= MM spec revision of the driver
95 //
96 if (MmSystemTable->Hdr.Revision < _gMmRevision) {
97 return EFI_INCOMPATIBLE_VERSION;
98 }
99 }
100
101 //
102 // Call constructor for all libraries
103 //
104 ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
105
106 //
107 // Install unload handler...
108 //
109 if (_gDriverUnloadImageCount != 0) {
110 Status = gMmst->MmHandleProtocol (
111 ImageHandle,
112 &gEfiLoadedImageProtocolGuid,
113 (VOID **)&LoadedImage
114 );
115 ASSERT_EFI_ERROR (Status);
116 LoadedImage->Unload = _DriverUnloadHandler;
117 }
118
119 //
120 // Call the driver entry point
121 //
122 Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
123
124 //
125 // If all of the drivers returned errors, then invoke all of the library destructors
126 //
127 if (EFI_ERROR (Status)) {
128 ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
129 }
130
131 //
132 // Return the cumulative return status code from all of the driver entry points
133 //
134 return Status;
135}
VOID EFIAPI ProcessModuleEntryPointList(IN VOID *HobStart)
#define IN
Definition: Base.h:279
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
EFI_STATUS EFIAPI _DriverUnloadHandler(EFI_HANDLE ImageHandle)
EFI_STATUS EFIAPI _ModuleEntryPoint(IN EFI_HANDLE ImageHandle, IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
CONST UINT8 _gDriverUnloadImageCount
CONST UINT32 _gMmRevision
VOID EFIAPI ProcessLibraryDestructorList(IN EFI_HANDLE ImageHandle, IN EFI_MM_SYSTEM_TABLE *MmSystemTable)
EFI_STATUS EFIAPI ProcessModuleUnloadList(IN EFI_HANDLE ImageHandle)
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33