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.
26 EFI_EVENT _mDriverExitBootServicesNotifyEvent
;
30 _DriverUnloadHandler (
31 EFI_HANDLE ImageHandle
37 // If an UnloadImage() handler is specified, then call it
39 Status
= ProcessModuleUnloadList (ImageHandle
);
42 // If the driver specific unload handler does not return an error, then call all of the
43 // library destructors. If the unload handler returned an error, then the driver can not be
44 // unloaded, and the library destructors should not be called
46 if (!EFI_ERROR (Status
)) {
48 // Close our ExitBootServices () notify function
50 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
51 Status
= gBS
->CloseEvent (_mDriverExitBootServicesNotifyEvent
);
52 ASSERT_EFI_ERROR (Status
);
55 ProcessLibraryDestructorList (ImageHandle
, gST
);
59 // Return the status from the driver specific unload handler
66 _DriverExitBootServices (
74 Set AtRuntime flag as TRUE after ExitBootServices
78 Event - The Event that is being processed
80 Context - Event Context
88 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
91 for (Index
= 0; _gDriverExitBootServicesEvent
[Index
] != NULL
; Index
++) {
92 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
93 ChildNotifyEventHandler (Event
, NULL
);
98 Enrty point to DXE Driver.
100 @param ImageHandle ImageHandle of the loaded driver.
101 @param SystemTable Pointer to the EFI System Table.
103 @retval EFI_SUCCESS One or more of the drivers returned a success code.
104 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
110 IN EFI_HANDLE ImageHandle
,
111 IN EFI_SYSTEM_TABLE
*SystemTable
115 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
117 if (_gUefiDriverRevision
!= 0) {
119 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
121 if (SystemTable
->Hdr
.Revision
< _gUefiDriverRevision
) {
122 return EFI_INCOMPATIBLE_VERSION
;
127 // Call constructor for all libraries
129 ProcessLibraryConstructorList (ImageHandle
, SystemTable
);
132 // Register our ExitBootServices () notify function
134 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
135 Status
= gBS
->CreateEvent (
136 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
138 _DriverExitBootServices
,
140 &_mDriverExitBootServicesNotifyEvent
143 ASSERT_EFI_ERROR (Status
);
147 // Install unload handler...
149 if (_gDriverUnloadImageCount
!= 0) {
150 Status
= gBS
->HandleProtocol (
152 &gEfiLoadedImageProtocolGuid
,
153 (VOID
**)&LoadedImage
155 ASSERT_EFI_ERROR (Status
);
156 LoadedImage
->Unload
= _DriverUnloadHandler
;
160 // Call the driver entry point
162 Status
= ProcessModuleEntryPointList (ImageHandle
, SystemTable
);
165 // If all of the drivers returned errors, then invoke all of the library destructors
167 if (EFI_ERROR (Status
)) {
169 // Close our ExitBootServices () notify function
171 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
172 Status
= gBS
->CloseEvent (_mDriverExitBootServicesNotifyEvent
);
173 ASSERT_EFI_ERROR (Status
);
176 ProcessLibraryDestructorList (ImageHandle
, SystemTable
);
180 // Return the cummalative return status code from all of the driver entry points
187 Enrty point wrapper of DXE Driver.
189 @param ImageHandle ImageHandle of the loaded driver.
190 @param SystemTable Pointer to the EFI System Table.
192 @retval EFI_SUCCESS One or more of the drivers returned a success code.
193 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
199 IN EFI_HANDLE ImageHandle
,
200 IN EFI_SYSTEM_TABLE
*SystemTable
203 return _ModuleEntryPoint (ImageHandle
, SystemTable
);