]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
MdePkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / MdePkg / Library / StandaloneMmDriverEntryPoint / StandaloneMmDriverEntryPoint.c
1 /** @file
2 Entry point to a Standalone MM driver.
3
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>
7
8 SPDX-License-Identifier: BSD-2-Clause-Patent
9
10 **/
11
12 #include <PiMm.h>
13
14 #include <Library/BaseLib.h>
15 #include <Library/DebugLib.h>
16 #include <Library/MmServicesTableLib.h>
17 #include <Library/StandaloneMmDriverEntryPoint.h>
18
19 /**
20 The entry point of PE/COFF Image for a Standalone MM Driver.
21
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.
30
31 @param ImageHandle The image handle of the Standalone MM Driver.
32 @param MmSystemTable A pointer to the MM System Table.
33
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().
39
40 **/
41 EFI_STATUS
42 EFIAPI
43 _ModuleEntryPoint (
44 IN EFI_HANDLE ImageHandle,
45 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
46 )
47 {
48 EFI_STATUS Status;
49
50 if (_gMmRevision != 0) {
51 //
52 // Make sure that the MM spec revision of the platform
53 // is >= MM spec revision of the driver
54 //
55 if (MmSystemTable->Hdr.Revision < _gMmRevision) {
56 return EFI_INCOMPATIBLE_VERSION;
57 }
58 }
59
60 //
61 // Call constructor for all libraries
62 //
63 ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
64
65 //
66 // Call the driver entry point
67 //
68 Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
69
70 //
71 // If all of the drivers returned errors, then invoke all of the library destructors
72 //
73 if (EFI_ERROR (Status)) {
74 ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
75 }
76
77 //
78 // Return the cumulative return status code from all of the driver entry points
79 //
80 return Status;
81 }