darylm503 2aa62f2bc9 Standard Libraries for EDK II.
This set of three packages: AppPkg, StdLib, StdLibPrivateInternalFiles; contains the implementation of libraries based upon non-UEFI standards such as ISO/IEC-9899, the library portion of the C Language Standard, POSIX, etc.

AppPkg contains applications that make use of the standard libraries defined in the StdLib Package.

StdLib contains header (include) files and the implementations of the standard libraries.

StdLibPrivateInternalFiles contains files for the exclusive use of the library implementations in StdLib.  These files should never be directly referenced from applications or other code.


git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11600 6f19259b-4bc3-4df7-8a09-765794883524
2011-04-27 21:42:16 +00:00

103 lines
2.5 KiB
C

/** @file
Establish the program environment and the "main" entry point.
All of the global data in the gMD structure is initialized to 0, NULL, or
SIG_DFL; as appropriate.
Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials are licensed and made available under
the terms and conditions of the BSD License that accompanies this distribution.
The full text of the license may be found at
http://opensource.org/licenses/bsd-license.php.
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Uefi.h>
#include <Library/UefiLib.h>
#include <Library/ShellCEntryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/TimerLib.h>
#include <LibConfig.h>
#include <errno.h>
#include <stdio.h>
#include <string.h>
#include <MainData.h>
extern int main( int, wchar_t**);
extern int __sse2_available;
struct __MainData *gMD;
/* Worker function to keep GCC happy. */
void __main()
{
;
}
INTN
EFIAPI
ShellAppMain (
IN UINTN Argc,
IN CHAR16 **Argv
)
{
INTN ExitVal;
INTN i;
struct __filedes *mfd;
FILE *fp;
ExitVal = (INTN)RETURN_SUCCESS;
gMD = AllocateZeroPool(sizeof(struct __MainData));
if( gMD == NULL ) {
ExitVal = (INTN)RETURN_OUT_OF_RESOURCES;
}
else {
/* Initialize data */
__sse2_available = 0;
_fltused = 1;
errno = 0;
EFIerrno = 0;
#ifdef NT32dvm
gMD->ClocksPerSecond = 0; // For NT32 only
gMD->AppStartTime = 0; // For NT32 only
#else
gMD->ClocksPerSecond = (clock_t)GetPerformanceCounterProperties( NULL, NULL);
gMD->AppStartTime = (clock_t)GetPerformanceCounter();
#endif /* NT32 dvm */
// Initialize file descriptors
mfd = gMD->fdarray;
for(i = 0; i < (FOPEN_MAX); ++i) {
mfd[i].MyFD = (UINT16)i;
}
// Open stdin, stdout, stderr
fp = freopen("stdin:", "r", stdin);
if(fp != NULL) {
fp = freopen("stdout:", "w", stdout);
if(fp != NULL) {
fp = freopen("stderr:", "w", stderr);
}
}
if(fp == NULL) {
Print(L"ERROR Initializing Standard IO: %a.\n %r\n",
strerror(errno), EFIerrno);
}
ExitVal = (INTN)main( (int)Argc, (wchar_t **)Argv);
if (gMD->cleanup != NULL) {
gMD->cleanup();
}
}
if(gMD != NULL) {
FreePool( gMD );
}
return ExitVal;
}