2 Entry point to a Standalone MM driver.
4 Copyright (c) 2015, Intel Corporation. All rights reserved.<BR>
5 Copyright (c) 2016 - 2018, ARM Ltd. All rights reserved.<BR>
6 Copyright (c) 2018, Linaro, Limited. All rights reserved.<BR>
8 SPDX-License-Identifier: BSD-2-Clause-Patent
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/MmServicesTableLib.h>
17 #include <Library/StandaloneMmDriverEntryPoint.h>
20 The entry point of PE/COFF Image for a Standalone MM Driver.
22 This function is the entry point for a Standalone MM Driver.
23 This function must call ProcessLibraryConstructorList() and
24 ProcessModuleEntryPointList().
25 If the return status from ProcessModuleEntryPointList()
26 is an error status, then ProcessLibraryDestructorList() must be called.
27 The return value from ProcessModuleEntryPointList() is returned.
28 If _gMmRevision is not zero and SystemTable->Hdr.Revision is
29 less than _gMmRevision, then return EFI_INCOMPATIBLE_VERSION.
31 @param ImageHandle The image handle of the Standalone MM Driver.
32 @param MmSystemTable A pointer to the MM System Table.
34 @retval EFI_SUCCESS The Standalone MM Driver exited normally.
35 @retval EFI_INCOMPATIBLE_VERSION _gMmRevision is greater than
36 MmSystemTable->Hdr.Revision.
37 @retval Other Return value from
38 ProcessModuleEntryPointList().
44 IN EFI_HANDLE ImageHandle
,
45 IN IN EFI_MM_SYSTEM_TABLE
*MmSystemTable
50 if (_gMmRevision
!= 0) {
52 // Make sure that the MM spec revision of the platform
53 // is >= MM spec revision of the driver
55 if (MmSystemTable
->Hdr
.Revision
< _gMmRevision
) {
56 return EFI_INCOMPATIBLE_VERSION
;
61 // Call constructor for all libraries
63 ProcessLibraryConstructorList (ImageHandle
, MmSystemTable
);
66 // Call the driver entry point
68 Status
= ProcessModuleEntryPointList (ImageHandle
, MmSystemTable
);
71 // If all of the drivers returned errors, then invoke all of the library destructors
73 if (EFI_ERROR (Status
)) {
74 ProcessLibraryDestructorList (ImageHandle
, MmSystemTable
);
78 // Return the cumulative return status code from all of the driver entry points