2 Entry point to a EFI/DXE driver.
4 Copyright (c) 2006, Intel Corporation<BR>
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 Unload function that is registered in the LoadImage protocol. It un-installs
17 protocols produced and deallocates pool used by the driver. Called by the core
18 when unloading the driver.
27 _DriverUnloadHandler (
28 EFI_HANDLE ImageHandle
34 // If an UnloadImage() handler is specified, then call it
36 Status
= ProcessModuleUnloadList (ImageHandle
);
39 // If the driver specific unload handler does not return an error, then call all of the
40 // library destructors. If the unload handler returned an error, then the driver can not be
41 // unloaded, and the library destructors should not be called
43 if (!EFI_ERROR (Status
)) {
44 ProcessLibraryDestructorList (ImageHandle
, gST
);
48 // Return the status from the driver specific unload handler
54 Enrty point to DXE Driver.
56 @param ImageHandle ImageHandle of the loaded driver.
57 @param SystemTable Pointer to the EFI System Table.
59 @retval EFI_SUCCESS One or more of the drivers returned a success code.
60 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
66 IN EFI_HANDLE ImageHandle
,
67 IN EFI_SYSTEM_TABLE
*SystemTable
71 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
73 if (_gUefiDriverRevision
!= 0) {
75 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
77 if (SystemTable
->Hdr
.Revision
< _gUefiDriverRevision
) {
78 return EFI_INCOMPATIBLE_VERSION
;
83 // Call constructor for all libraries
85 ProcessLibraryConstructorList (ImageHandle
, SystemTable
);
88 // Install unload handler...
90 if (_gDriverUnloadImageCount
!= 0) {
91 Status
= gBS
->HandleProtocol (
93 &gEfiLoadedImageProtocolGuid
,
96 ASSERT_EFI_ERROR (Status
);
97 LoadedImage
->Unload
= _DriverUnloadHandler
;
101 // Call the driver entry point
103 Status
= ProcessModuleEntryPointList (ImageHandle
, SystemTable
);
106 // If all of the drivers returned errors, then invoke all of the library destructors
108 if (EFI_ERROR (Status
)) {
109 ProcessLibraryDestructorList (ImageHandle
, SystemTable
);
113 // Return the cummalative return status code from all of the driver entry points
120 Enrty point wrapper of DXE Driver.
122 @param ImageHandle ImageHandle of the loaded driver.
123 @param SystemTable Pointer to the EFI System Table.
125 @retval EFI_SUCCESS One or more of the drivers returned a success code.
126 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
132 IN EFI_HANDLE ImageHandle
,
133 IN EFI_SYSTEM_TABLE
*SystemTable
136 return _ModuleEntryPoint (ImageHandle
, SystemTable
);