]>
Commit | Line | Data |
---|---|---|
2aa62f2b | 1 | /** @file\r |
2 | Global data for the program environment.\r | |
3 | \r | |
4 | Copyright (c) 2010, Intel Corporation. All rights reserved.<BR>\r | |
5 | This program and the accompanying materials are licensed and made available under\r | |
6 | the terms and conditions of the BSD License that accompanies this distribution.\r | |
7 | 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 | #include <Uefi.h>\r | |
14 | #include <Library/ShellLib.h>\r | |
15 | \r | |
16 | #include <limits.h>\r | |
17 | #include <signal.h>\r | |
18 | #include <stdlib.h>\r | |
19 | #include <stdio.h>\r | |
20 | #include <time.h>\r | |
21 | #include "Efi/Console.h"\r | |
22 | \r | |
23 | /* ################## Type Declarations ################################# */\r | |
24 | \r | |
25 | /** The type of an atexit handler function. **/\r | |
26 | typedef void __xithandler_t(void);\r | |
27 | \r | |
28 | /* ################## Global Declarations ############################### */\r | |
29 | #ifndef TYPE_BIT\r | |
30 | #define TYPE_BIT(type) (sizeof (type) * CHAR_BIT)\r | |
31 | #endif /* !defined TYPE_BIT */\r | |
32 | \r | |
33 | #ifndef TYPE_SIGNED\r | |
34 | #define TYPE_SIGNED(type) (((type) -1) < 0)\r | |
35 | #endif /* !defined TYPE_SIGNED */\r | |
36 | \r | |
37 | #ifndef INT_STRLEN_MAXIMUM\r | |
38 | /*\r | |
39 | ** 302 / 1000 is log10(2.0) rounded up.\r | |
40 | ** Subtract one for the sign bit if the type is signed;\r | |
41 | ** add one for integer division truncation;\r | |
42 | ** add one more for a minus sign if the type is signed.\r | |
43 | */\r | |
44 | #define INT_STRLEN_MAXIMUM(type) \\r | |
45 | ((TYPE_BIT(type) - TYPE_SIGNED(type)) * 302 / 1000 + 1 + TYPE_SIGNED(type))\r | |
46 | #endif /* !defined INT_STRLEN_MAXIMUM */\r | |
47 | \r | |
48 | /*\r | |
49 | ** Big enough for something such as\r | |
50 | ** ??? ???-2147483648 -2147483648:-2147483648:-2147483648 -2147483648\n\r | |
51 | ** (two three-character abbreviations, five strings denoting integers,\r | |
52 | ** three explicit spaces, two explicit colons, a newline,\r | |
53 | ** and a trailing ASCII nul).\r | |
54 | */\r | |
55 | #define ASCTIME_BUFLEN (3 * 2 + 5 * INT_STRLEN_MAXIMUM(int) + 3 + 2 + 1 + 1)\r | |
56 | \r | |
57 | struct __filedes {\r | |
58 | EFI_FILE_HANDLE FileHandle;\r | |
59 | UINT32 State; // In use if non-zero\r | |
60 | int Oflags; // From the open call\r | |
61 | int Omode; // From the open call\r | |
62 | int RefCount; // Reference count of opens\r | |
63 | int SocProc; // Placeholder: socket owner process or process group.\r | |
64 | UINT16 MyFD; // Which FD this is.\r | |
65 | };\r | |
66 | \r | |
67 | struct __MainData {\r | |
68 | // File descriptors\r | |
69 | struct __filedes fdarray[OPEN_MAX];\r | |
70 | // Low-level File abstractions for the stdin, stdout, stderr streams\r | |
71 | ConInstance StdIo[3];\r | |
72 | \r | |
73 | // Signal Handlers\r | |
74 | __sighandler_t *sigarray[SIG_LAST]; // Pointers to signal handlers\r | |
75 | \r | |
76 | void (*cleanup)(void); // Cleanup Function Pointer\r | |
77 | \r | |
78 | __xithandler_t *atexit_handler[ATEXIT_MAX]; // Array of handlers for atexit.\r | |
79 | clock_t AppStartTime; // Set in Main.c and used for time.h\r | |
80 | clock_t ClocksPerSecond; // Set in Main.c and used for time.h\r | |
81 | int num_atexit; ///< Number of registered atexit handlers.\r | |
82 | \r | |
83 | CHAR16 UString[UNICODE_STRING_MAX];\r | |
84 | struct tm BDTime; // Broken-down time structure for localtime.\r | |
85 | EFI_TIME TimeBuffer; // Used by <time.h>mk\r | |
86 | char ASgetenv[ASCII_STRING_MAX]; // Only modified by getenv\r | |
87 | char ASasctime[ASCTIME_BUFLEN]; // Only modified by asctime\r | |
88 | \r | |
89 | BOOLEAN aborting; // Ensures cleanup function only called once when aborting.\r | |
90 | };\r | |
91 | \r | |
92 | extern struct __MainData *gMD;\r |