b244c7dc |
1 | /** @file\r |
2 | Entry point library instance to a UEFI application.\r |
3 | \r |
4 | Copyright (c) 2007, Intel Corporation<BR>\r |
5 | All rights reserved. This program and the accompanying materials\r |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. The full text of the license may be found at\r |
8 | http://opensource.org/licenses/bsd-license.php\r |
9 | \r |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r |
12 | \r |
13 | **/\r |
14 | \r |
15 | /**\r |
16 | Enrty point to UEFI application.\r |
17 | \r |
18 | @param ImageHandle ImageHandle of the loaded driver.\r |
19 | @param SystemTable Pointer to the EFI System Table.\r |
20 | \r |
21 | @retval EFI_SUCCESS One or more of the drivers returned a success code.\r |
22 | @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r |
23 | \r |
24 | **/\r |
25 | EFI_STATUS\r |
26 | EFIAPI\r |
27 | _ModuleEntryPoint (\r |
28 | IN EFI_HANDLE ImageHandle,\r |
29 | IN EFI_SYSTEM_TABLE *SystemTable\r |
30 | )\r |
31 | {\r |
32 | EFI_STATUS Status;\r |
33 | \r |
34 | if (_gUefiDriverRevision != 0) {\r |
35 | //\r |
36 | // Make sure that the EFI/UEFI spec revision of the platform is >= EFI/UEFI spec revision of the application.\r |
37 | //\r |
38 | if (SystemTable->Hdr.Revision < _gUefiDriverRevision) {\r |
39 | return EFI_INCOMPATIBLE_VERSION;\r |
40 | }\r |
41 | }\r |
42 | \r |
43 | //\r |
44 | // Call constructor for all libraries.\r |
45 | //\r |
46 | ProcessLibraryConstructorList (ImageHandle, SystemTable);\r |
47 | \r |
48 | //\r |
49 | // Call the module's entry point\r |
50 | //\r |
51 | Status = ProcessModuleEntryPointList (ImageHandle, SystemTable);\r |
52 | \r |
53 | //\r |
54 | // Process destructor for all libraries.\r |
55 | //\r |
56 | ProcessLibraryDestructorList (ImageHandle, SystemTable);\r |
57 | \r |
58 | //\r |
59 | // Return the return status code from the driver entry point\r |
60 | //\r |
61 | return Status;\r |
62 | }\r |
63 | \r |
64 | /**\r |
65 | Invoke the destuctors of all libraries and call gBS->Exit\r |
66 | to return control to firmware core.\r |
67 | \r |
68 | @param Status Status returned by the application that is exiting.\r |
69 | \r |
70 | @retval VOID\r |
71 | \r |
72 | **/\r |
73 | VOID\r |
74 | EFIAPI\r |
75 | Exit (\r |
76 | IN EFI_STATUS Status\r |
77 | )\r |
78 | \r |
79 | {\r |
80 | ProcessLibraryDestructorList (gImageHandle, gST);\r |
81 | \r |
82 | gBS->Exit (gImageHandle, Status, 0, NULL);\r |
83 | }\r |
84 | \r |
85 | /**\r |
86 | Enrty point wrapper of UEFI Application.\r |
87 | \r |
88 | @param ImageHandle ImageHandle of the loaded driver.\r |
89 | @param SystemTable Pointer to the EFI System Table.\r |
90 | \r |
91 | @retval EFI_SUCCESS One or more of the drivers returned a success code.\r |
92 | @retval !EFI_SUCESS The return status from the last driver entry point in the list.\r |
93 | \r |
94 | **/\r |
95 | EFI_STATUS\r |
96 | EFIAPI\r |
97 | EfiMain (\r |
98 | IN EFI_HANDLE ImageHandle,\r |
99 | IN EFI_SYSTEM_TABLE *SystemTable\r |
100 | )\r |
101 | {\r |
102 | return _ModuleEntryPoint (ImageHandle, SystemTable);\r |
103 | }\r |