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 EFI_EVENT _mDriverExitBootServicesNotifyEvent
;
19 Unload function that is registered in the LoadImage protocol. It un-installs
20 protocols produced and deallocates pool used by the driver. Called by the core
21 when unloading the driver.
31 _DriverUnloadHandler (
32 EFI_HANDLE ImageHandle
38 // If an UnloadImage() handler is specified, then call it
40 Status
= ProcessModuleUnloadList (ImageHandle
);
43 // If the driver specific unload handler does not return an error, then call all of the
44 // library destructors. If the unload handler returned an error, then the driver can not be
45 // unloaded, and the library destructors should not be called
47 if (!EFI_ERROR (Status
)) {
49 // Close our ExitBootServices () notify function
51 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
52 Status
= gBS
->CloseEvent (_mDriverExitBootServicesNotifyEvent
);
53 ASSERT_EFI_ERROR (Status
);
56 ProcessLibraryDestructorList (ImageHandle
, gST
);
60 // Return the status from the driver specific unload handler
67 Notification Entry of ExitBootService event. In the entry, all notifications in _gDriverExitBootServicesEvent[]
70 @param Event The Event that is being processed.
71 @param Context Event Context.
77 _DriverExitBootServices (
82 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
85 for (Index
= 0; _gDriverExitBootServicesEvent
[Index
] != NULL
; Index
++) {
86 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
87 ChildNotifyEventHandler (Event
, NULL
);
92 Enrty point to DXE Driver.
94 @param ImageHandle ImageHandle of the loaded driver.
95 @param SystemTable Pointer to the EFI System Table.
97 @retval EFI_SUCCESS One or more of the drivers returned a success code.
98 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
104 IN EFI_HANDLE ImageHandle
,
105 IN EFI_SYSTEM_TABLE
*SystemTable
109 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
111 if (_gUefiDriverRevision
!= 0) {
113 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
115 if (SystemTable
->Hdr
.Revision
< _gUefiDriverRevision
) {
116 return EFI_INCOMPATIBLE_VERSION
;
121 // Call constructor for all libraries
123 ProcessLibraryConstructorList (ImageHandle
, SystemTable
);
126 // Register our ExitBootServices () notify function
128 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
129 Status
= gBS
->CreateEvent (
130 EVT_SIGNAL_EXIT_BOOT_SERVICES
,
132 _DriverExitBootServices
,
134 &_mDriverExitBootServicesNotifyEvent
137 ASSERT_EFI_ERROR (Status
);
141 // Install unload handler...
143 if (_gDriverUnloadImageCount
!= 0) {
144 Status
= gBS
->HandleProtocol (
146 &gEfiLoadedImageProtocolGuid
,
147 (VOID
**)&LoadedImage
149 ASSERT_EFI_ERROR (Status
);
150 LoadedImage
->Unload
= _DriverUnloadHandler
;
154 // Call the driver entry point
156 Status
= ProcessModuleEntryPointList (ImageHandle
, SystemTable
);
159 // If all of the drivers returned errors, then invoke all of the library destructors
161 if (EFI_ERROR (Status
)) {
163 // Close our ExitBootServices () notify function
165 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
166 Status
= gBS
->CloseEvent (_mDriverExitBootServicesNotifyEvent
);
167 ASSERT_EFI_ERROR (Status
);
170 ProcessLibraryDestructorList (ImageHandle
, SystemTable
);
174 // Return the cummalative return status code from all of the driver entry points
181 Enrty point wrapper of DXE Driver.
183 @param ImageHandle ImageHandle of the loaded driver.
184 @param SystemTable Pointer to the EFI System Table.
186 @retval EFI_SUCCESS One or more of the drivers returned a success code.
187 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
193 IN EFI_HANDLE ImageHandle
,
194 IN EFI_SYSTEM_TABLE
*SystemTable
197 return _ModuleEntryPoint (ImageHandle
, SystemTable
);