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.
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 Notification Entry of ExitBootService event. In the entry, all notifications in _gDriverExitBootServicesEvent[]
69 @param Event The Event that is being processed.
70 @param Context Event Context.
75 _DriverExitBootServices (
80 EFI_EVENT_NOTIFY ChildNotifyEventHandler
;
83 for (Index
= 0; _gDriverExitBootServicesEvent
[Index
] != NULL
; Index
++) {
84 ChildNotifyEventHandler
= _gDriverExitBootServicesEvent
[Index
];
85 ChildNotifyEventHandler (Event
, NULL
);
90 Enrty point to DXE Driver.
92 @param ImageHandle ImageHandle of the loaded driver.
93 @param SystemTable Pointer to the EFI System Table.
95 @retval EFI_SUCCESS One or more of the drivers returned a success code.
96 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
102 IN EFI_HANDLE ImageHandle
,
103 IN EFI_SYSTEM_TABLE
*SystemTable
107 EFI_LOADED_IMAGE_PROTOCOL
*LoadedImage
;
109 if (_gUefiDriverRevision
!= 0) {
111 // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the driver
113 if (SystemTable
->Hdr
.Revision
< _gUefiDriverRevision
) {
114 return EFI_INCOMPATIBLE_VERSION
;
119 // Call constructor for all libraries
121 ProcessLibraryConstructorList (ImageHandle
, SystemTable
);
124 // Register our ExitBootServices () notify function
126 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
127 Status
= gBS
->CreateEvent (
128 EFI_EVENT_SIGNAL_EXIT_BOOT_SERVICES
,
130 _DriverExitBootServices
,
132 &_mDriverExitBootServicesNotifyEvent
135 ASSERT_EFI_ERROR (Status
);
139 // Install unload handler...
141 if (_gDriverUnloadImageCount
!= 0) {
142 Status
= gBS
->HandleProtocol (
144 &gEfiLoadedImageProtocolGuid
,
145 (VOID
**)&LoadedImage
147 ASSERT_EFI_ERROR (Status
);
148 LoadedImage
->Unload
= _DriverUnloadHandler
;
152 // Call the driver entry point
154 Status
= ProcessModuleEntryPointList (ImageHandle
, SystemTable
);
157 // If all of the drivers returned errors, then invoke all of the library destructors
159 if (EFI_ERROR (Status
)) {
161 // Close our ExitBootServices () notify function
163 if (_gDriverExitBootServicesEvent
[0] != NULL
) {
164 Status
= gBS
->CloseEvent (_mDriverExitBootServicesNotifyEvent
);
165 ASSERT_EFI_ERROR (Status
);
168 ProcessLibraryDestructorList (ImageHandle
, SystemTable
);
172 // Return the cummalative return status code from all of the driver entry points
179 Enrty point wrapper of DXE Driver.
181 @param ImageHandle ImageHandle of the loaded driver.
182 @param SystemTable Pointer to the EFI System Table.
184 @retval EFI_SUCCESS One or more of the drivers returned a success code.
185 @retval !EFI_SUCESS The return status from the last driver entry point in the list.
191 IN EFI_HANDLE ImageHandle
,
192 IN EFI_SYSTEM_TABLE
*SystemTable
195 return _ModuleEntryPoint (ImageHandle
, SystemTable
);