]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/UefiDriverEntryPoint/DriverEntryPoint.c
Minor grammatical work--mostly adding periods. Items with ONLY period added did...
[mirror_edk2.git] / MdePkg / Library / UefiDriverEntryPoint / DriverEntryPoint.c
CommitLineData
e386b444 1/** @file\r
2 Entry point to a EFI/DXE driver.\r
3\r
19388d29
HT
4Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
5This program and the accompanying materials\r
e386b444 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
58380e9c 66 The entry point of PE/COFF Image for a DXE Driver, DXE Runtime Driver, DXE SMM \r
67 Driver, or UEFI Driver. \r
66770ccb 68\r
69 This function is the entry point for a DXE Driver, DXE Runtime Driver, DXE SMM Driver,\r
70 or UEFI Driver. This function must call ProcessLibraryConstructorList() and\r
71 ProcessModuleEntryPointList(). If the return status from ProcessModuleEntryPointList()\r
58380e9c 72 is an error status, then ProcessLibraryDestructorList() must be called. The return \r
73 value from ProcessModuleEntryPointList() is returned. If _gDriverUnloadImageCount \r
74 is greater than zero, then an unload handler must be registered for this image \r
75 and the unload handler must invoke ProcessModuleUnloadList().\r
76 If _gUefiDriverRevision is not zero and SystemTable->Hdr.Revision is less than \r
77 _gUefiDriverRevison, then return EFI_INCOMPATIBLE_VERSION.\r
e386b444 78\r
e386b444 79\r
58380e9c 80 @param ImageHandle The image handle of the DXE Driver, DXE Runtime Driver, \r
81 DXE SMM Driver, or UEFI Driver.\r
f6d2bcc6 82 @param SystemTable A pointer to the EFI System Table.\r
66770ccb 83\r
58380e9c 84 @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM \r
85 Driver, or UEFI Driver exited normally.\r
86 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than \r
87 SystemTable->Hdr.Revision.\r
66770ccb 88 @retval Other Return value from ProcessModuleEntryPointList().\r
e386b444 89\r
90**/\r
91EFI_STATUS\r
92EFIAPI\r
93_ModuleEntryPoint (\r
94 IN EFI_HANDLE ImageHandle,\r
95 IN EFI_SYSTEM_TABLE *SystemTable\r
96 )\r
97{\r
98 EFI_STATUS Status;\r
99 EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;\r
100\r
101 if (_gUefiDriverRevision != 0) {\r
102 //\r
103 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver\r
104 //\r
105 if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
106 return EFI_INCOMPATIBLE_VERSION;\r
107 }\r
108 }\r
109\r
c7d265a9 110 //\r
111 // Call constructor for all libraries\r
112 //\r
113 ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
114\r
e386b444 115 //\r
116 // Install unload handler...\r
117 //\r
118 if (_gDriverUnloadImageCount != 0) {\r
119 Status = gBS->HandleProtocol (\r
120 ImageHandle,\r
121 &gEfiLoadedImageProtocolGuid,\r
122 (VOID **)&LoadedImage\r
123 );\r
124 ASSERT_EFI_ERROR (Status);\r
125 LoadedImage->Unload = _DriverUnloadHandler;\r
126 }\r
127\r
e386b444 128 //\r
129 // Call the driver entry point\r
130 //\r
131 Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r
132\r
133 //\r
134 // If all of the drivers returned errors, then invoke all of the library destructors\r
135 //\r
136 if (EFI_ERROR (Status)) {\r
137 ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
138 }\r
139\r
140 //\r
141 // Return the cummalative return status code from all of the driver entry points\r
142 //\r
143 return Status;\r
144}\r
145\r
146\r
147/**\r
66770ccb 148 Required by the EBC compiler and identical in functionality to _ModuleEntryPoint(). \r
149\r
58380e9c 150 This function is required to call _ModuleEntryPoint() passing in ImageHandle,\r
151 and SystemTable.\r
e386b444 152\r
58380e9c 153 @param ImageHandle The image handle of the DXE Driver, DXE Runtime Driver, DXE \r
154 SMM Driver, or UEFI Driver.\r
f6d2bcc6 155 @param SystemTable A pointer to the EFI System Table.\r
e386b444 156\r
58380e9c 157 @retval EFI_SUCCESS The DXE Driver, DXE Runtime Driver, DXE SMM \r
158 Driver, or UEFI Driver exited normally.\r
159 @retval EFI_INCOMPATIBLE_VERSION _gUefiDriverRevision is greater than \r
160 SystemTable->Hdr.Revision.\r
66770ccb 161 @retval Other Return value from ProcessModuleEntryPointList().\r
e386b444 162**/\r
163EFI_STATUS\r
164EFIAPI\r
165EfiMain (\r
166 IN EFI_HANDLE ImageHandle,\r
167 IN EFI_SYSTEM_TABLE *SystemTable\r
168 )\r
169{\r
170 return _ModuleEntryPoint (ImageHandle, SystemTable);\r
171}\r