--- /dev/null
+/** @file\r
+ Entry point library instance to a UEFI application.\r
+\r
+Copyright (c) 2007, Intel Corporation<BR>\r
+All rights reserved. This program and the accompanying materials\r
+are licensed and made available under the terms and conditions of the BSD License\r
+which accompanies this distribution. The full text of the license may be found at\r
+http://opensource.org/licenses/bsd-license.php\r
+\r
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+/**\r
+ Enrty point to UEFI application.\r
+\r
+ @param ImageHandle ImageHandle of the loaded driver.\r
+ @param SystemTable Pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+_ModuleEntryPoint (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+\r
+ if (_gUefiDriverRevision != 0) {\r
+ //\r
+ // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.\r
+ //\r
+ if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r
+ return EFI_INCOMPATIBLE_VERSION;\r
+ }\r
+ }\r
+\r
+ //\r
+ // Call constructor for all libraries.\r
+ //\r
+ ProcessLibraryConstructorList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Call the module's entry point\r
+ //\r
+ Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Process destructor for all libraries.\r
+ //\r
+ ProcessLibraryDestructorList (ImageHandle, SystemTable);\r
+\r
+ //\r
+ // Return the return status code from the driver entry point\r
+ //\r
+ return Status;\r
+}\r
+\r
+/**\r
+ Invoke the destuctors of all libraries and call gBS->Exit\r
+ to return control to firmware core.\r
+\r
+ @param Status Status returned by the application that is exiting.\r
+ \r
+ @retval VOID\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+Exit (\r
+ IN EFI_STATUS Status\r
+ )\r
+\r
+{\r
+ ProcessLibraryDestructorList (gImageHandle, gST);\r
+\r
+ gBS->Exit (gImageHandle, Status, 0, NULL);\r
+}\r
+\r
+/**\r
+ Enrty point wrapper of UEFI Application.\r
+\r
+ @param ImageHandle ImageHandle of the loaded driver.\r
+ @param SystemTable Pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS One or more of the drivers returned a success code.\r
+ @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiMain (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ return _ModuleEntryPoint (ImageHandle, SystemTable);\r
+}\r