]> git.proxmox.com Git - mirror_edk2.git/blame - StdLibPrivateInternalFiles/Include/MainData.h
SecurityPkg: Add TPM PTP support in TPM2 device lib.
[mirror_edk2.git] / StdLibPrivateInternalFiles / Include / MainData.h
CommitLineData
2aa62f2b 1/** @file\r
2 Global data for the program environment.\r
3\r
b00771f5 4 Copyright (c) 2010 - 2011, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials are licensed and made available\r
6 under the terms and conditions of the BSD License which accompanies this\r
7 distribution. The full text of the license may be found at\r
2aa62f2b 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#include <Uefi.h>\r
2aa62f2b 14\r
b00771f5 15#include <stdio.h>\r
16#include <stdlib.h>\r
17#include <sys/types.h>\r
2aa62f2b 18#include <limits.h>\r
19#include <signal.h>\r
2aa62f2b 20#include <time.h>\r
f766dd76 21#include <setjmp.h>\r
b00771f5 22\r
23#include <kfile.h>\r
24#include <Device/Device.h>\r
25\r
26#include "Device/Console.h"\r
2aa62f2b 27\r
28/* ################## Type Declarations ################################# */\r
29\r
30/** The type of an atexit handler function. **/\r
31typedef void __xithandler_t(void);\r
32\r
33/* ################## Global Declarations ############################### */\r
34#ifndef TYPE_BIT\r
35#define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)\r
36#endif /* !defined TYPE_BIT */\r
37\r
38#ifndef TYPE_SIGNED\r
39#define TYPE_SIGNED(type) (((type) -1) < 0)\r
40#endif /* !defined TYPE_SIGNED */\r
41\r
42#ifndef INT_STRLEN_MAXIMUM\r
43/*\r
44** 302 / 1000 is log10(2.0) rounded up.\r
45** Subtract one for the sign bit if the type is signed;\r
46** add one for integer division truncation;\r
47** add one more for a minus sign if the type is signed.\r
48*/\r
49#define INT_STRLEN_MAXIMUM(type) \\r
50((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))\r
51#endif /* !defined INT_STRLEN_MAXIMUM */\r
52\r
53/*\r
54** Big enough for something such as\r
55** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n\r
56** (two three-character abbreviations, five strings denoting integers,\r
57** three explicit spaces, two explicit colons, a newline,\r
58** and a trailing ASCII nul).\r
59*/\r
b00771f5 60#define ASCTIME_BUFLEN ((2 * 3) + (5 * INT_STRLEN_MAXIMUM(int)) + 3 + 2 + 1 + 1)\r
61\r
62struct __filedes; /* Forward Reference */\r
63struct stat; /* Forward Reference so I don't have to include <stat.h> */\r
2aa62f2b 64\r
65struct __MainData {\r
66 // File descriptors\r
67 struct __filedes fdarray[OPEN_MAX];\r
68 // Low-level File abstractions for the stdin, stdout, stderr streams\r
b00771f5 69 ConInstance *StdIo[3];\r
2aa62f2b 70\r
71 // Signal Handlers\r
72 __sighandler_t *sigarray[SIG_LAST]; // Pointers to signal handlers\r
73\r
b00771f5 74 char *NArgV[ARGC_MAX]; // Narrow character argv array\r
75 char *NCmdLine; // Narrow character version of command line arguments.\r
76\r
77 void (*cleanup)(void); // Stdio Cleanup Function Pointer\r
2aa62f2b 78\r
79 __xithandler_t *atexit_handler[ATEXIT_MAX]; // Array of handlers for atexit.\r
80 clock_t AppStartTime; // Set in Main.c and used for time.h\r
81 clock_t ClocksPerSecond; // Set in Main.c and used for time.h\r
82 int num_atexit; ///< Number of registered atexit handlers.\r
83\r
84 CHAR16 UString[UNICODE_STRING_MAX];\r
b00771f5 85 CHAR16 UString2[UNICODE_STRING_MAX];\r
2aa62f2b 86 struct tm BDTime; // Broken-down time structure for localtime.\r
87 EFI_TIME TimeBuffer; // Used by <time.h>mk\r
88 char ASgetenv[ASCII_STRING_MAX]; // Only modified by getenv\r
89 char ASasctime[ASCTIME_BUFLEN]; // Only modified by asctime\r
90\r
f766dd76 91 jmp_buf MainExit; ///< Save environment used for implementing _Exit()\r
92 int ExitValue; ///< Value being returned by _Exit()\r
93\r
2aa62f2b 94 BOOLEAN aborting; // Ensures cleanup function only called once when aborting.\r
95};\r
96\r
97extern struct __MainData *gMD;\r