]>
Commit | Line | Data |
---|---|---|
30fdf114 | 1 | /** @file\r |
97fa0ee9 | 2 | Common library assistance routines.\r |
30fdf114 | 3 | \r |
1be2ed90 | 4 | Copyright (c) 2004 - 2014, Intel Corporation. All rights reserved.<BR>\r |
40d841f6 | 5 | This program and the accompanying materials\r |
30fdf114 LG |
6 | are licensed and made available under the terms and conditions of the BSD License\r |
7 | which accompanies this distribution. 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 | |
30fdf114 LG |
13 | **/\r |
14 | \r | |
15 | #ifndef _EFI_COMMON_LIB_H\r | |
16 | #define _EFI_COMMON_LIB_H\r | |
17 | \r | |
18 | #include <Common/UefiBaseTypes.h>\r | |
b36d134f | 19 | #include <Common/BuildVersion.h>\r |
30fdf114 | 20 | #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r |
1be2ed90 HC |
21 | \r |
22 | #define MAX_LONG_FILE_PATH 500\r | |
23 | \r | |
24 | #ifdef __cplusplus\r | |
25 | extern "C" {\r | |
26 | #endif\r | |
97fa0ee9 | 27 | \r |
30fdf114 LG |
28 | //\r |
29 | // Function declarations\r | |
30 | //\r | |
31 | VOID\r | |
32 | PeiZeroMem (\r | |
33 | IN VOID *Buffer,\r | |
34 | IN UINTN Size\r | |
35 | )\r | |
36 | ;\r | |
37 | \r | |
38 | VOID\r | |
39 | PeiCopyMem (\r | |
40 | IN VOID *Destination,\r | |
41 | IN VOID *Source,\r | |
42 | IN UINTN Length\r | |
43 | )\r | |
44 | ;\r | |
45 | \r | |
46 | VOID\r | |
47 | ZeroMem (\r | |
48 | IN VOID *Buffer,\r | |
49 | IN UINTN Size\r | |
50 | )\r | |
51 | ;\r | |
52 | \r | |
53 | VOID\r | |
54 | CopyMem (\r | |
55 | IN VOID *Destination,\r | |
56 | IN VOID *Source,\r | |
57 | IN UINTN Length\r | |
58 | )\r | |
59 | ;\r | |
60 | \r | |
61 | INTN\r | |
62 | CompareGuid (\r | |
63 | IN EFI_GUID *Guid1,\r | |
64 | IN EFI_GUID *Guid2\r | |
65 | )\r | |
66 | ;\r | |
67 | \r | |
68 | EFI_STATUS\r | |
69 | GetFileImage (\r | |
70 | IN CHAR8 *InputFileName,\r | |
71 | OUT CHAR8 **InputFileImage,\r | |
72 | OUT UINT32 *BytesRead\r | |
73 | )\r | |
74 | ;\r | |
75 | \r | |
76 | EFI_STATUS\r | |
77 | PutFileImage (\r | |
78 | IN CHAR8 *OutputFileName,\r | |
79 | IN CHAR8 *OutputFileImage,\r | |
80 | IN UINT32 BytesToWrite\r | |
81 | )\r | |
82 | ;\r | |
83 | /*++\r | |
84 | \r | |
85 | Routine Description:\r | |
86 | \r | |
87 | This function opens a file and writes OutputFileImage into the file.\r | |
88 | \r | |
89 | Arguments:\r | |
90 | \r | |
91 | OutputFileName The name of the file to write.\r | |
92 | OutputFileImage A pointer to the memory buffer.\r | |
93 | BytesToWrite The size of the memory buffer.\r | |
94 | \r | |
95 | Returns:\r | |
96 | \r | |
97 | EFI_SUCCESS The function completed successfully.\r | |
98 | EFI_INVALID_PARAMETER One of the input parameters was invalid.\r | |
99 | EFI_ABORTED An error occurred.\r | |
100 | EFI_OUT_OF_RESOURCES No resource to complete operations.\r | |
101 | \r | |
102 | **/\r | |
103 | \r | |
104 | UINT8\r | |
105 | CalculateChecksum8 (\r | |
106 | IN UINT8 *Buffer,\r | |
107 | IN UINTN Size\r | |
108 | )\r | |
109 | ;\r | |
110 | \r | |
111 | UINT8\r | |
112 | CalculateSum8 (\r | |
113 | IN UINT8 *Buffer,\r | |
114 | IN UINTN Size\r | |
115 | )\r | |
116 | ;\r | |
117 | \r | |
118 | UINT16\r | |
119 | CalculateChecksum16 (\r | |
120 | IN UINT16 *Buffer,\r | |
121 | IN UINTN Size\r | |
122 | )\r | |
123 | ;\r | |
124 | \r | |
125 | UINT16\r | |
126 | CalculateSum16 (\r | |
127 | IN UINT16 *Buffer,\r | |
128 | IN UINTN Size\r | |
129 | )\r | |
130 | ;\r | |
131 | \r | |
132 | EFI_STATUS\r | |
133 | PrintGuid (\r | |
134 | IN EFI_GUID *Guid\r | |
135 | )\r | |
136 | ;\r | |
137 | \r | |
138 | #define PRINTED_GUID_BUFFER_SIZE 37 // including null-termination\r | |
139 | EFI_STATUS\r | |
140 | PrintGuidToBuffer (\r | |
141 | IN EFI_GUID *Guid,\r | |
142 | IN OUT UINT8 *Buffer,\r | |
143 | IN UINT32 BufferLen,\r | |
144 | IN BOOLEAN Uppercase\r | |
145 | )\r | |
146 | ;\r | |
147 | \r | |
1be2ed90 HC |
148 | CHAR8 *\r |
149 | LongFilePath (\r | |
150 | IN CHAR8 *FileName\r | |
151 | );\r | |
152 | /*++\r | |
153 | \r | |
154 | Routine Description:\r | |
155 | Convert FileName to the long file path, which can support larger than 260 length. \r | |
156 | \r | |
157 | Arguments:\r | |
158 | FileName - FileName. \r | |
159 | \r | |
160 | Returns:\r | |
161 | LongFilePath A pointer to the converted long file path.\r | |
162 | \r | |
163 | --*/\r | |
164 | \r | |
165 | #ifdef __cplusplus\r | |
166 | }\r | |
167 | #endif\r | |
168 | \r | |
30fdf114 LG |
169 | #define ASSERT(x) assert(x)\r |
170 | \r | |
171 | #ifdef __GNUC__\r | |
172 | #include <stdio.h>\r | |
173 | #include <sys/stat.h>\r | |
174 | #define stricmp strcasecmp\r | |
175 | #define _stricmp strcasecmp\r | |
176 | #define strnicmp strncasecmp\r | |
177 | #define strcmpi strcasecmp\r | |
178 | size_t _filelength(int fd);\r | |
179 | #ifndef __CYGWIN__\r | |
180 | char *strlwr(char *s);\r | |
181 | #endif\r | |
182 | #endif\r | |
183 | \r | |
184 | //\r | |
185 | // On windows, mkdir only has one parameter.\r | |
186 | // On unix, it has two parameters\r | |
187 | //\r | |
188 | #if defined(__GNUC__)\r | |
189 | #define mkdir(dir, perm) mkdir(dir, perm)\r | |
190 | #else\r | |
191 | #define mkdir(dir, perm) mkdir(dir)\r | |
192 | #endif\r | |
193 | \r | |
194 | #endif\r |