2 Entry point to a EFI/DXE driver.
4 Copyright (c) 2006 - 2007, 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.
17 // Include common header file for this module.
19 #include "CommonHeader.h"
23 Unload function that is registered in the LoadImage protocol. It un-installs
24 protocols produced and deallocates pool used by the driver. Called by the core
25 when unloading the driver.
35 _DriverUnloadHandler (
36 EFI_HANDLE ImageHandle
42 // If an UnloadImage() handler is specified, then call it
44 Status
= ProcessModuleUnloadList (ImageHandle
);
47 // If the driver specific unload handler does not return an error, then call all of the
48 // library destructors. If the unload handler returned an error, then the driver can not be
49 // unloaded, and the library destructors should not be called
51 if (!EFI_ERROR (Status
)) {
53 ProcessLibraryDestructorList (ImageHandle
, gST
);
57 // Return the status from the driver specific unload handler
64 Notification Entry of ExitBootService event. In the entry, all notifications in _gDriverExitBootServicesEvent[]
67 @param Event The Event that is being processed.
68 @param Context Event Context.
74 _DriverExitBootServices (
79 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
82 for (Index
= 0; _gDriverExitBootServicesEvent
[Index
] != NULL
; Index
++) {
83 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
84 ChildNotifyEventHandler (Event
, NULL
);
89 Enrty point to DXE Driver.
91 @param ImageHandle ImageHandle of the loaded driver.
92 @param SystemTable Pointer to the EFI System Table.
94 @retval EFI_SUCCESS One or more of the drivers returned a success code.
95 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
101 IN EFI_HANDLE ImageHandle
,
102 IN EFI_SYSTEM_TABLE
*SystemTable
106 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
108 if (_gUefiDriverRevision
!= 0) {
110 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
112 if (SystemTable
->Hdr
.Revision
< _gUefiDriverRevision
) {
113 return EFI_INCOMPATIBLE_VERSION
;
118 // Install unload handler...
120 if (_gDriverUnloadImageCount
!= 0) {
121 Status
= gBS
->HandleProtocol (
123 &gEfiLoadedImageProtocolGuid
,
124 (VOID
**)&LoadedImage
126 ASSERT_EFI_ERROR (Status
);
127 LoadedImage
->Unload
= _DriverUnloadHandler
;
131 // Call constructor for all libraries
133 ProcessLibraryConstructorList (ImageHandle
, SystemTable
);
136 // Call the driver entry point
138 Status
= ProcessModuleEntryPointList (ImageHandle
, SystemTable
);
141 // If all of the drivers returned errors, then invoke all of the library destructors
143 if (EFI_ERROR (Status
)) {
144 ProcessLibraryDestructorList (ImageHandle
, SystemTable
);
148 // Return the cummalative return status code from all of the driver entry points
155 Enrty point wrapper of DXE Driver.
157 @param ImageHandle ImageHandle of the loaded driver.
158 @param SystemTable Pointer to the EFI System Table.
160 @retval EFI_SUCCESS One or more of the drivers returned a success code.
161 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
167 IN EFI_HANDLE ImageHandle
,
168 IN EFI_SYSTEM_TABLE
*SystemTable
171 return _ModuleEntryPoint (ImageHandle
, SystemTable
);