]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
2 | Establish the program environment and the "main" entry point.\r | |
3 | \r | |
4 | All of the global data in the gMD structure is initialized to 0, NULL, or\r | |
5 | SIG_DFL; as appropriate.\r | |
6 | \r | |
7 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
8 | This program and the accompanying materials are licensed and made available under\r | |
9 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
10 | The full text of the license may be found at\r | |
11 | http://opensource.org/licenses/bsd-license.php.\r | |
12 | \r | |
13 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
14 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
15 | **/\r | |
16 | #include <Uefi.h>\r | |
17 | #include <Library/UefiLib.h>\r | |
18 | \r | |
19 | #include <Library/ShellCEntryLib.h>\r | |
20 | #include <Library/MemoryAllocationLib.h>\r | |
21 | #include <Library/TimerLib.h>\r | |
22 | \r | |
23 | #include <LibConfig.h>\r | |
24 | \r | |
25 | #include <errno.h>\r | |
26 | #include <stdio.h>\r | |
27 | #include <string.h>\r | |
28 | #include <MainData.h>\r | |
29 | \r | |
30 | extern int main( int, wchar_t**);\r | |
31 | extern int __sse2_available;\r | |
32 | \r | |
33 | struct __MainData *gMD;\r | |
34 | \r | |
35 | /* Worker function to keep GCC happy. */\r | |
36 | void __main()\r | |
37 | {\r | |
38 | ;\r | |
39 | }\r | |
40 | \r | |
41 | INTN\r | |
42 | EFIAPI\r | |
43 | ShellAppMain (\r | |
44 | IN UINTN Argc,\r | |
45 | IN CHAR16 **Argv\r | |
46 | )\r | |
47 | {\r | |
48 | INTN ExitVal;\r | |
49 | INTN i;\r | |
50 | struct __filedes *mfd;\r | |
51 | FILE *fp;\r | |
52 | \r | |
53 | ExitVal = (INTN)RETURN_SUCCESS;\r | |
54 | gMD = AllocateZeroPool(sizeof(struct __MainData));\r | |
55 | if( gMD == NULL ) {\r | |
56 | ExitVal = (INTN)RETURN_OUT_OF_RESOURCES;\r | |
57 | }\r | |
58 | else {\r | |
59 | /* Initialize data */\r | |
60 | __sse2_available = 0;\r | |
61 | _fltused = 1;\r | |
62 | errno = 0;\r | |
63 | EFIerrno = 0;\r | |
64 | \r | |
65 | #ifdef NT32dvm\r | |
66 | gMD->ClocksPerSecond = 0; // For NT32 only\r | |
67 | gMD->AppStartTime = 0; // For NT32 only\r | |
68 | #else\r | |
69 | gMD->ClocksPerSecond = (clock_t)GetPerformanceCounterProperties( NULL, NULL);\r | |
70 | gMD->AppStartTime = (clock_t)GetPerformanceCounter();\r | |
71 | #endif /* NT32 dvm */\r | |
72 | \r | |
73 | // Initialize file descriptors\r | |
74 | mfd = gMD->fdarray;\r | |
75 | for(i = 0; i < (FOPEN_MAX); ++i) {\r | |
76 | mfd[i].MyFD = (UINT16)i;\r | |
77 | }\r | |
78 | \r | |
79 | // Open stdin, stdout, stderr\r | |
80 | fp = freopen("stdin:", "r", stdin);\r | |
81 | if(fp != NULL) {\r | |
82 | fp = freopen("stdout:", "w", stdout);\r | |
83 | if(fp != NULL) {\r | |
84 | fp = freopen("stderr:", "w", stderr);\r | |
85 | }\r | |
86 | }\r | |
87 | if(fp == NULL) {\r | |
88 | Print(L"ERROR Initializing Standard IO: %a.\n %r\n",\r | |
89 | strerror(errno), EFIerrno);\r | |
90 | }\r | |
91 | \r | |
92 | ExitVal = (INTN)main( (int)Argc, (wchar_t **)Argv);\r | |
93 | \r | |
94 | if (gMD->cleanup != NULL) {\r | |
95 | gMD->cleanup();\r | |
96 | }\r | |
97 | }\r | |
98 | if(gMD != NULL) {\r | |
99 | FreePool( gMD );\r | |
100 | }\r | |
101 | return ExitVal;\r | |
102 | }\r |