]> git.proxmox.com Git - mirror_edk2.git/blob - StandaloneMmPkg/Library/StandaloneMmDriverEntryPoint/StandaloneMmDriverEntryPoint.c
StandaloneMmPkg: MM driver entry point library.
[mirror_edk2.git] / StandaloneMmPkg / 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
7 This program and the accompanying materials
8 are licensed and made available under the terms and conditions of the BSD License
9 which accompanies this distribution. The full text of the license may be found at
10 http://opensource.org/licenses/bsd-license.php
11
12 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
13 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
14
15 **/
16
17 #include <PiMm.h>
18
19 #include <Library/BaseLib.h>
20 #include <Library/DebugLib.h>
21
22 VOID
23 EFIAPI
24 ProcessLibraryConstructorList (
25 IN EFI_HANDLE ImageHandle,
26 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
27 );
28
29 EFI_STATUS
30 EFIAPI
31 ProcessModuleEntryPointList (
32 IN EFI_HANDLE ImageHandle,
33 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
34 );
35
36 VOID
37 EFIAPI
38 ProcessLibraryDestructorList (
39 IN EFI_HANDLE ImageHandle,
40 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
41 );
42
43 /**
44 The entry point of PE/COFF Image for a Standalone MM Driver.
45
46 This function is the entry point for a Standalone MM Driver.
47 This function must call ProcessLibraryConstructorList() and
48 ProcessModuleEntryPointList().
49 If the return status from ProcessModuleEntryPointList()
50 is an error status, then ProcessLibraryDestructorList() must be called.
51 The return value from ProcessModuleEntryPointList() is returned.
52 If _gDriverUnloadImageCount is greater than zero, then an unload
53 handler must be registered for this image
54 and the unload handler must invoke ProcessModuleUnloadList().
55 If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less
56 than _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.
57
58
59 @param ImageHandle The image handle of the Standalone MM Driver.
60 @param SystemTable A pointer to the EFI System Table.
61
62 @retval EFI_SUCCESS The Standalone MM Driver exited normally.
63 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than
64 SystemTable->Hdr.Revision.
65 @retval Other Return value from ProcessModuleEntryPointList().
66
67 **/
68 EFI_STATUS
69 EFIAPI
70 _ModuleEntryPoint (
71 IN EFI_HANDLE ImageHandle,
72 IN IN EFI_MM_SYSTEM_TABLE *MmSystemTable
73 )
74 {
75 EFI_STATUS Status;
76
77 //
78 // Call constructor for all libraries
79 //
80 ProcessLibraryConstructorList (ImageHandle, MmSystemTable);
81
82 //
83 // Call the driver entry point
84 //
85 Status = ProcessModuleEntryPointList (ImageHandle, MmSystemTable);
86
87 //
88 // If all of the drivers returned errors, then invoke all of the library destructors
89 //
90 if (EFI_ERROR (Status)) {
91 ProcessLibraryDestructorList (ImageHandle, MmSystemTable);
92 }
93
94 //
95 // Return the cumulative return status code from all of the driver entry points
96 //
97 return Status;
98 }
99