]>
git.proxmox.com Git - mirror_edk2.git/blob - StdLib/LibC/Main/Main.c
2 Establish the program environment and the "main" entry point.
4 All of the global data in the gMD structure is initialized to 0, NULL, or
5 SIG_DFL; as appropriate.
7 Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/UefiLib.h>
19 #include <Library/ShellCEntryLib.h>
20 #include <Library/MemoryAllocationLib.h>
21 #include <Library/TimerLib.h>
23 #include <LibConfig.h>
30 extern int main( int, wchar_t**);
31 extern int __sse2_available
;
33 struct __MainData
*gMD
;
35 /* Worker function to keep GCC happy. */
50 struct __filedes
*mfd
;
53 ExitVal
= (INTN
)RETURN_SUCCESS
;
54 gMD
= AllocateZeroPool(sizeof(struct __MainData
));
56 ExitVal
= (INTN
)RETURN_OUT_OF_RESOURCES
;
66 gMD
->ClocksPerSecond
= 0; // For NT32 only
67 gMD
->AppStartTime
= 0; // For NT32 only
69 gMD
->ClocksPerSecond
= (clock_t)GetPerformanceCounterProperties( NULL
, NULL
);
70 gMD
->AppStartTime
= (clock_t)GetPerformanceCounter();
73 // Initialize file descriptors
75 for(i
= 0; i
< (FOPEN_MAX
); ++i
) {
76 mfd
[i
].MyFD
= (UINT16
)i
;
79 // Open stdin, stdout, stderr
80 fp
= freopen("stdin:", "r", stdin
);
82 fp
= freopen("stdout:", "w", stdout
);
84 fp
= freopen("stderr:", "w", stderr
);
88 Print(L
"ERROR Initializing Standard IO: %a.\n %r\n",
89 strerror(errno
), EFIerrno
);
92 ExitVal
= (INTN
)main( (int)Argc
, (wchar_t **)Argv
);
94 if (gMD
->cleanup
!= NULL
) {