]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
Function headers in .h and .c files synchronized with spec
[mirror_edk2.git] / MdePkg / Library / UefiDriverEntryPoint / DriverEntryPoint.c
CommitLineData
e386b444 1/** @file\r
2 Entry point to a EFI/DXE driver.\r
3\r
4Copyright (c) 2006 - 2007, Intel Corporation<BR>\r
5All rights reserved. This program and the accompanying materials\r
6are licensed and made available under the terms and conditions of the BSD License\r
7which accompanies this distribution. The full text of the license may be found at\r
8http://opensource.org/licenses/bsd-license.php\r
9\r
10THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15\r
c892d846 16\r
c7d265a9 17#include <Uefi.h>\r
c892d846 18\r
c7d265a9 19#include <Protocol/LoadedImage.h>\r
c892d846 20\r
c7d265a9 21#include <Library/UefiDriverEntryPoint.h>\r
22#include <Library/DebugLib.h>\r
23#include <Library/UefiBootServicesTableLib.h>\r
e386b444 24\r
25\r
26/**\r
27 Unload function that is registered in the LoadImage protocol. It un-installs\r
28 protocols produced and deallocates pool used by the driver. Called by the core\r
29 when unloading the driver.\r
30\r
373b5cf9 31 @param ImageHandle ImageHandle of the loaded driver.\r
e386b444 32\r
373b5cf9 33 @return Status returned by all unload().\r
e386b444 34\r
35**/\r
e386b444 36EFI_STATUS\r
37EFIAPI\r
38_DriverUnloadHandler (\r
39 EFI_HANDLE ImageHandle\r
40 )\r
41{\r
42 EFI_STATUS Status;\r
43\r
44 //\r
45 // If an UnloadImage() handler is specified, then call it\r
46 //\r
47 Status = ProcessModuleUnloadList (ImageHandle);\r
48\r
49 //\r
50 // If the driver specific unload handler does not return an error, then call all of the\r
51 // library destructors. If the unload handler returned an error, then the driver can not be\r
52 // unloaded, and the library destructors should not be called\r
53 //\r
54 if (!EFI_ERROR (Status)) {\r
e386b444 55 ProcessLibraryDestructorList (ImageHandle, gST);\r
56 }\r
57\r
58 //\r
59 // Return the status from the driver specific unload handler\r
60 //\r
61 return Status;\r
62}\r
63\r
64\r
e386b444 65/**\r
66 Enrty point to DXE Driver.\r
67\r
68 @param ImageHandle ImageHandle of the loaded driver.\r
69 @param SystemTable Pointer to the EFI System Table.\r
70\r
71 @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
72 @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
73\r
74**/\r
75EFI_STATUS\r
76EFIAPI\r
77_ModuleEntryPoint (\r
78 IN EFI_HANDLE ImageHandle,\r
79 IN EFI_SYSTEM_TABLE *SystemTable\r
80 )\r
81{\r
82 EFI_STATUS Status;\r
83 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
84\r
85 if (_gUefiDriverRevision != 0) {\r
86 //\r
87 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver\r
88 //\r
89 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
90 return EFI_INCOMPATIBLE_VERSION;\r
91 }\r
92 }\r
93\r
c7d265a9 94 //\r
95 // Call constructor for all libraries\r
96 //\r
97 ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
98\r
e386b444 99 //\r
100 // Install unload handler...\r
101 //\r
102 if (_gDriverUnloadImageCount != 0) {\r
103 Status = gBS->HandleProtocol (\r
104 ImageHandle,\r
105 &gEfiLoadedImageProtocolGuid,\r
106 (VOID **)&LoadedImage\r
107 );\r
108 ASSERT_EFI_ERROR (Status);\r
109 LoadedImage->Unload = _DriverUnloadHandler;\r
110 }\r
111\r
e386b444 112 //\r
113 // Call the driver entry point\r
114 //\r
115 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r
116\r
117 //\r
118 // If all of the drivers returned errors, then invoke all of the library destructors\r
119 //\r
120 if (EFI_ERROR (Status)) {\r
121 ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
122 }\r
123\r
124 //\r
125 // Return the cummalative return status code from all of the driver entry points\r
126 //\r
127 return Status;\r
128}\r
129\r
130\r
131/**\r
132 Enrty point wrapper of DXE Driver.\r
133\r
134 @param ImageHandle ImageHandle of the loaded driver.\r
135 @param SystemTable Pointer to the EFI System Table.\r
136\r
137 @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
138 @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
139\r
140**/\r
141EFI_STATUS\r
142EFIAPI\r
143EfiMain (\r
144 IN EFI_HANDLE ImageHandle,\r
145 IN EFI_SYSTEM_TABLE *SystemTable\r
146 )\r
147{\r
148 return _ModuleEntryPoint (ImageHandle, SystemTable);\r
149}\r