]>
Commit | Line | Data |
---|---|---|
ac644614 | 1 | /** @file\r |
50a64e5b | 2 | Provides string functions, linked list functions, math functions, synchronization\r |
ae591c14 | 3 | functions, file path functions, and CPU architecture-specific functions.\r |
ac644614 | 4 | \r |
5dbfa01e | 5 | Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>\r |
9df063a0 HT |
6 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
7 | This program and the accompanying materials\r | |
50a64e5b | 8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
af2dc6a7 | 10 | http://opensource.org/licenses/bsd-license.php.\r |
ac644614 | 11 | \r |
50a64e5b | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
ac644614 | 14 | \r |
15 | **/\r | |
16 | \r | |
17 | #ifndef __BASE_LIB__\r | |
18 | #define __BASE_LIB__\r | |
19 | \r | |
1106ffe1 | 20 | //\r |
1a2f870c | 21 | // Definitions for architecture-specific types\r |
1106ffe1 | 22 | //\r |
ac644614 | 23 | #if defined (MDE_CPU_IA32)\r |
fc30687f | 24 | ///\r |
af2dc6a7 | 25 | /// The IA-32 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 26 | ///\r |
ac644614 | 27 | typedef struct {\r |
28 | UINT32 Ebx;\r | |
29 | UINT32 Esi;\r | |
30 | UINT32 Edi;\r | |
31 | UINT32 Ebp;\r | |
32 | UINT32 Esp;\r | |
33 | UINT32 Eip;\r | |
34 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
35 | \r | |
36 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
37 | \r | |
aa4df547 | 38 | #endif // defined (MDE_CPU_IA32)\r |
39 | \r | |
aa4df547 | 40 | #if defined (MDE_CPU_X64)\r |
fc30687f | 41 | ///\r |
af2dc6a7 | 42 | /// The x64 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 43 | ///\r |
ac644614 | 44 | typedef struct {\r |
45 | UINT64 Rbx;\r | |
46 | UINT64 Rsp;\r | |
47 | UINT64 Rbp;\r | |
48 | UINT64 Rdi;\r | |
49 | UINT64 Rsi;\r | |
50 | UINT64 R12;\r | |
51 | UINT64 R13;\r | |
52 | UINT64 R14;\r | |
53 | UINT64 R15;\r | |
54 | UINT64 Rip;\r | |
9b9641c6 | 55 | UINT64 MxCsr;\r |
af2dc6a7 | 56 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r |
ac644614 | 57 | } BASE_LIBRARY_JUMP_BUFFER;\r |
58 | \r | |
59 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
60 | \r | |
aa4df547 | 61 | #endif // defined (MDE_CPU_X64)\r |
62 | \r | |
63 | #if defined (MDE_CPU_EBC)\r | |
fc30687f | 64 | ///\r |
af2dc6a7 | 65 | /// The EBC context buffer used by SetJump() and LongJump().\r |
fc30687f | 66 | ///\r |
ac644614 | 67 | typedef struct {\r |
68 | UINT64 R0;\r | |
69 | UINT64 R1;\r | |
70 | UINT64 R2;\r | |
71 | UINT64 R3;\r | |
72 | UINT64 IP;\r | |
73 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
74 | \r | |
75 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
76 | \r | |
aa4df547 | 77 | #endif // defined (MDE_CPU_EBC)\r |
ac644614 | 78 | \r |
ebd04fc2 | 79 | #if defined (MDE_CPU_ARM)\r |
80 | \r | |
81 | typedef struct {\r | |
af2dc6a7 | 82 | UINT32 R3; ///< A copy of R13.\r |
01a54966 | 83 | UINT32 R4;\r |
84 | UINT32 R5;\r | |
85 | UINT32 R6;\r | |
86 | UINT32 R7;\r | |
87 | UINT32 R8;\r | |
88 | UINT32 R9;\r | |
89 | UINT32 R10;\r | |
90 | UINT32 R11;\r | |
91 | UINT32 R12;\r | |
92 | UINT32 R14;\r | |
ebd04fc2 | 93 | } BASE_LIBRARY_JUMP_BUFFER;\r |
94 | \r | |
95 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
96 | \r | |
97 | #endif // defined (MDE_CPU_ARM)\r | |
98 | \r | |
807e2604 HL |
99 | #if defined (MDE_CPU_AARCH64)\r |
100 | typedef struct {\r | |
101 | // GP regs\r | |
102 | UINT64 X19;\r | |
103 | UINT64 X20;\r | |
104 | UINT64 X21;\r | |
105 | UINT64 X22;\r | |
106 | UINT64 X23;\r | |
107 | UINT64 X24;\r | |
108 | UINT64 X25;\r | |
109 | UINT64 X26;\r | |
110 | UINT64 X27;\r | |
111 | UINT64 X28;\r | |
112 | UINT64 FP;\r | |
113 | UINT64 LR;\r | |
114 | UINT64 IP0;\r | |
115 | \r | |
116 | // FP regs\r | |
117 | UINT64 D8;\r | |
118 | UINT64 D9;\r | |
119 | UINT64 D10;\r | |
120 | UINT64 D11;\r | |
121 | UINT64 D12;\r | |
122 | UINT64 D13;\r | |
123 | UINT64 D14;\r | |
124 | UINT64 D15;\r | |
125 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
126 | \r | |
127 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
128 | \r | |
129 | #endif // defined (MDE_CPU_AARCH64)\r | |
130 | \r | |
131 | \r | |
ac644614 | 132 | //\r |
133 | // String Services\r | |
134 | //\r | |
135 | \r | |
c058d59f JY |
136 | \r |
137 | /**\r | |
138 | Returns the length of a Null-terminated Unicode string.\r | |
139 | \r | |
328f84b1 JY |
140 | This function is similar as strlen_s defined in C11.\r |
141 | \r | |
c058d59f JY |
142 | If String is not aligned on a 16-bit boundary, then ASSERT().\r |
143 | \r | |
144 | @param String A pointer to a Null-terminated Unicode string.\r | |
145 | @param MaxSize The maximum number of Destination Unicode\r | |
146 | char, including terminating null char.\r | |
147 | \r | |
148 | @retval 0 If String is NULL.\r | |
149 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
150 | @return The number of characters that percede the terminating null character.\r | |
151 | \r | |
152 | **/\r | |
153 | UINTN\r | |
154 | EFIAPI\r | |
155 | StrnLenS (\r | |
156 | IN CONST CHAR16 *String,\r | |
157 | IN UINTN MaxSize\r | |
158 | );\r | |
159 | \r | |
b590e43a HW |
160 | /**\r |
161 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
162 | Null terminator.\r | |
163 | \r | |
164 | This function returns the size of the Null-terminated Unicode string\r | |
165 | specified by String in bytes, including the Null terminator.\r | |
166 | \r | |
167 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
168 | \r | |
169 | @param String A pointer to a Null-terminated Unicode string.\r | |
170 | @param MaxSize The maximum number of Destination Unicode\r | |
171 | char, including the Null terminator.\r | |
172 | \r | |
173 | @retval 0 If String is NULL.\r | |
174 | @retval (sizeof (CHAR16) * (MaxSize + 1))\r | |
175 | If there is no Null terminator in the first MaxSize characters of\r | |
176 | String.\r | |
177 | @return The size of the Null-terminated Unicode string in bytes, including\r | |
178 | the Null terminator.\r | |
179 | \r | |
180 | **/\r | |
181 | UINTN\r | |
182 | EFIAPI\r | |
183 | StrnSizeS (\r | |
184 | IN CONST CHAR16 *String,\r | |
185 | IN UINTN MaxSize\r | |
186 | );\r | |
187 | \r | |
c058d59f JY |
188 | /**\r |
189 | Copies the string pointed to by Source (including the terminating null char)\r | |
190 | to the array pointed to by Destination.\r | |
191 | \r | |
328f84b1 JY |
192 | This function is similar as strcpy_s defined in C11.\r |
193 | \r | |
c058d59f JY |
194 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
195 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 196 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 197 | \r |
328f84b1 JY |
198 | If an error is returned, then the Destination is unmodified.\r |
199 | \r | |
c058d59f JY |
200 | @param Destination A pointer to a Null-terminated Unicode string.\r |
201 | @param DestMax The maximum number of Destination Unicode\r | |
202 | char, including terminating null char.\r | |
203 | @param Source A pointer to a Null-terminated Unicode string.\r | |
204 | \r | |
205 | @retval RETURN_SUCCESS String is copied.\r | |
206 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
207 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
208 | If Source is NULL.\r | |
209 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 210 | and DestMax is greater than\r |
c058d59f JY |
211 | PcdMaximumUnicodeStringLength.\r |
212 | If DestMax is 0.\r | |
213 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
214 | **/\r | |
215 | RETURN_STATUS\r | |
216 | EFIAPI\r | |
217 | StrCpyS (\r | |
218 | OUT CHAR16 *Destination,\r | |
219 | IN UINTN DestMax,\r | |
220 | IN CONST CHAR16 *Source\r | |
221 | );\r | |
222 | \r | |
223 | /**\r | |
224 | Copies not more than Length successive char from the string pointed to by\r | |
225 | Source to the array pointed to by Destination. If no null char is copied from\r | |
226 | Source, then Destination[Length] is always set to null.\r | |
227 | \r | |
328f84b1 JY |
228 | This function is similar as strncpy_s defined in C11.\r |
229 | \r | |
c058d59f JY |
230 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
231 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 232 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 233 | \r |
328f84b1 JY |
234 | If an error is returned, then the Destination is unmodified.\r |
235 | \r | |
c058d59f JY |
236 | @param Destination A pointer to a Null-terminated Unicode string.\r |
237 | @param DestMax The maximum number of Destination Unicode\r | |
238 | char, including terminating null char.\r | |
239 | @param Source A pointer to a Null-terminated Unicode string.\r | |
240 | @param Length The maximum number of Unicode characters to copy.\r | |
241 | \r | |
242 | @retval RETURN_SUCCESS String is copied.\r | |
9095d37b | 243 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r |
c058d59f JY |
244 | MIN(StrLen(Source), Length).\r |
245 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
246 | If Source is NULL.\r | |
247 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 248 | and DestMax is greater than\r |
c058d59f JY |
249 | PcdMaximumUnicodeStringLength.\r |
250 | If DestMax is 0.\r | |
251 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
252 | **/\r | |
253 | RETURN_STATUS\r | |
254 | EFIAPI\r | |
255 | StrnCpyS (\r | |
256 | OUT CHAR16 *Destination,\r | |
257 | IN UINTN DestMax,\r | |
258 | IN CONST CHAR16 *Source,\r | |
259 | IN UINTN Length\r | |
260 | );\r | |
261 | \r | |
262 | /**\r | |
263 | Appends a copy of the string pointed to by Source (including the terminating\r | |
264 | null char) to the end of the string pointed to by Destination.\r | |
265 | \r | |
328f84b1 JY |
266 | This function is similar as strcat_s defined in C11.\r |
267 | \r | |
c058d59f JY |
268 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
269 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 270 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 271 | \r |
328f84b1 JY |
272 | If an error is returned, then the Destination is unmodified.\r |
273 | \r | |
c058d59f JY |
274 | @param Destination A pointer to a Null-terminated Unicode string.\r |
275 | @param DestMax The maximum number of Destination Unicode\r | |
276 | char, including terminating null char.\r | |
277 | @param Source A pointer to a Null-terminated Unicode string.\r | |
278 | \r | |
279 | @retval RETURN_SUCCESS String is appended.\r | |
9095d37b | 280 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r |
c058d59f JY |
281 | StrLen(Destination).\r |
282 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
283 | greater than StrLen(Source).\r | |
284 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
285 | If Source is NULL.\r | |
286 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 287 | and DestMax is greater than\r |
c058d59f JY |
288 | PcdMaximumUnicodeStringLength.\r |
289 | If DestMax is 0.\r | |
290 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
291 | **/\r | |
292 | RETURN_STATUS\r | |
293 | EFIAPI\r | |
294 | StrCatS (\r | |
295 | IN OUT CHAR16 *Destination,\r | |
296 | IN UINTN DestMax,\r | |
297 | IN CONST CHAR16 *Source\r | |
298 | );\r | |
299 | \r | |
300 | /**\r | |
301 | Appends not more than Length successive char from the string pointed to by\r | |
302 | Source to the end of the string pointed to by Destination. If no null char is\r | |
303 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
304 | set to null.\r | |
305 | \r | |
328f84b1 JY |
306 | This function is similar as strncat_s defined in C11.\r |
307 | \r | |
c058d59f | 308 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
0e93edbb JY |
309 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
310 | If an error would be returned, then the function will also ASSERT().\r | |
c058d59f | 311 | \r |
328f84b1 JY |
312 | If an error is returned, then the Destination is unmodified.\r |
313 | \r | |
c058d59f JY |
314 | @param Destination A pointer to a Null-terminated Unicode string.\r |
315 | @param DestMax The maximum number of Destination Unicode\r | |
316 | char, including terminating null char.\r | |
317 | @param Source A pointer to a Null-terminated Unicode string.\r | |
318 | @param Length The maximum number of Unicode characters to copy.\r | |
319 | \r | |
320 | @retval RETURN_SUCCESS String is appended.\r | |
321 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
322 | StrLen(Destination).\r | |
323 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
324 | greater than MIN(StrLen(Source), Length).\r | |
325 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
326 | If Source is NULL.\r | |
327 | If PcdMaximumUnicodeStringLength is not zero,\r | |
9095d37b | 328 | and DestMax is greater than\r |
c058d59f JY |
329 | PcdMaximumUnicodeStringLength.\r |
330 | If DestMax is 0.\r | |
331 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
332 | **/\r | |
333 | RETURN_STATUS\r | |
334 | EFIAPI\r | |
335 | StrnCatS (\r | |
336 | IN OUT CHAR16 *Destination,\r | |
337 | IN UINTN DestMax,\r | |
338 | IN CONST CHAR16 *Source,\r | |
339 | IN UINTN Length\r | |
340 | );\r | |
341 | \r | |
d8af3301 HW |
342 | /**\r |
343 | Convert a Null-terminated Unicode decimal string to a value of type UINTN.\r | |
344 | \r | |
345 | This function outputs a value of type UINTN by interpreting the contents of\r | |
346 | the Unicode string specified by String as a decimal number. The format of the\r | |
347 | input Unicode string String is:\r | |
348 | \r | |
349 | [spaces] [decimal digits].\r | |
350 | \r | |
351 | The valid decimal digit character is in the range [0-9]. The function will\r | |
352 | ignore the pad space, which includes spaces or tab characters, before\r | |
353 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
354 | be ignored. Then, the function stops at the first character that is a not a\r | |
355 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
356 | \r | |
357 | If String is NULL, then ASSERT().\r | |
358 | If Data is NULL, then ASSERT().\r | |
359 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
360 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
361 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
362 | Null-terminator, then ASSERT().\r | |
363 | \r | |
364 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
365 | at the location pointed to by Data.\r | |
366 | If the number represented by String exceeds the range defined by UINTN, then\r | |
367 | MAX_UINTN is stored at the location pointed to by Data.\r | |
368 | \r | |
369 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
370 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
371 | decimal digits right after the optional pad spaces, the value of String is\r | |
372 | stored at the location pointed to by EndPointer.\r | |
373 | \r | |
374 | @param String Pointer to a Null-terminated Unicode string.\r | |
375 | @param EndPointer Pointer to character that stops scan.\r | |
376 | @param Data Pointer to the converted value.\r | |
377 | \r | |
378 | @retval RETURN_SUCCESS Value is translated from String.\r | |
379 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
380 | If Data is NULL.\r | |
381 | If PcdMaximumUnicodeStringLength is not\r | |
382 | zero, and String contains more than\r | |
383 | PcdMaximumUnicodeStringLength Unicode\r | |
384 | characters, not including the\r | |
385 | Null-terminator.\r | |
386 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
387 | the range defined by UINTN.\r | |
388 | \r | |
389 | **/\r | |
390 | RETURN_STATUS\r | |
391 | EFIAPI\r | |
392 | StrDecimalToUintnS (\r | |
393 | IN CONST CHAR16 *String,\r | |
394 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
395 | OUT UINTN *Data\r | |
396 | );\r | |
397 | \r | |
398 | /**\r | |
399 | Convert a Null-terminated Unicode decimal string to a value of type UINT64.\r | |
400 | \r | |
401 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
402 | the Unicode string specified by String as a decimal number. The format of the\r | |
403 | input Unicode string String is:\r | |
404 | \r | |
405 | [spaces] [decimal digits].\r | |
406 | \r | |
407 | The valid decimal digit character is in the range [0-9]. The function will\r | |
408 | ignore the pad space, which includes spaces or tab characters, before\r | |
409 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
410 | be ignored. Then, the function stops at the first character that is a not a\r | |
411 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
412 | \r | |
413 | If String is NULL, then ASSERT().\r | |
414 | If Data is NULL, then ASSERT().\r | |
415 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
416 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
417 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
418 | Null-terminator, then ASSERT().\r | |
419 | \r | |
420 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
421 | at the location pointed to by Data.\r | |
422 | If the number represented by String exceeds the range defined by UINT64, then\r | |
423 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
424 | \r | |
425 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
426 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
427 | decimal digits right after the optional pad spaces, the value of String is\r | |
428 | stored at the location pointed to by EndPointer.\r | |
429 | \r | |
430 | @param String Pointer to a Null-terminated Unicode string.\r | |
431 | @param EndPointer Pointer to character that stops scan.\r | |
432 | @param Data Pointer to the converted value.\r | |
433 | \r | |
434 | @retval RETURN_SUCCESS Value is translated from String.\r | |
435 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
436 | If Data is NULL.\r | |
437 | If PcdMaximumUnicodeStringLength is not\r | |
438 | zero, and String contains more than\r | |
439 | PcdMaximumUnicodeStringLength Unicode\r | |
440 | characters, not including the\r | |
441 | Null-terminator.\r | |
442 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
443 | the range defined by UINT64.\r | |
444 | \r | |
445 | **/\r | |
446 | RETURN_STATUS\r | |
447 | EFIAPI\r | |
448 | StrDecimalToUint64S (\r | |
449 | IN CONST CHAR16 *String,\r | |
450 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
451 | OUT UINT64 *Data\r | |
452 | );\r | |
453 | \r | |
454 | /**\r | |
455 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
456 | UINTN.\r | |
457 | \r | |
458 | This function outputs a value of type UINTN by interpreting the contents of\r | |
459 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
460 | the input Unicode string String is:\r | |
461 | \r | |
462 | [spaces][zeros][x][hexadecimal digits].\r | |
463 | \r | |
464 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
465 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
466 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
467 | The function will ignore the pad space, which includes spaces or tab\r | |
468 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
469 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
470 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
471 | the first character that is a not a valid hexadecimal character or NULL,\r | |
472 | whichever one comes first.\r | |
473 | \r | |
474 | If String is NULL, then ASSERT().\r | |
475 | If Data is NULL, then ASSERT().\r | |
476 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
477 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
478 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
479 | Null-terminator, then ASSERT().\r | |
480 | \r | |
481 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
482 | stored at the location pointed to by Data.\r | |
483 | If the number represented by String exceeds the range defined by UINTN, then\r | |
484 | MAX_UINTN is stored at the location pointed to by Data.\r | |
485 | \r | |
486 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
487 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
488 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
489 | is stored at the location pointed to by EndPointer.\r | |
490 | \r | |
491 | @param String Pointer to a Null-terminated Unicode string.\r | |
492 | @param EndPointer Pointer to character that stops scan.\r | |
493 | @param Data Pointer to the converted value.\r | |
494 | \r | |
495 | @retval RETURN_SUCCESS Value is translated from String.\r | |
496 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
497 | If Data is NULL.\r | |
498 | If PcdMaximumUnicodeStringLength is not\r | |
499 | zero, and String contains more than\r | |
500 | PcdMaximumUnicodeStringLength Unicode\r | |
501 | characters, not including the\r | |
502 | Null-terminator.\r | |
503 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
504 | the range defined by UINTN.\r | |
505 | \r | |
506 | **/\r | |
507 | RETURN_STATUS\r | |
508 | EFIAPI\r | |
509 | StrHexToUintnS (\r | |
510 | IN CONST CHAR16 *String,\r | |
511 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
512 | OUT UINTN *Data\r | |
513 | );\r | |
514 | \r | |
515 | /**\r | |
516 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
517 | UINT64.\r | |
518 | \r | |
519 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
520 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
521 | the input Unicode string String is:\r | |
522 | \r | |
523 | [spaces][zeros][x][hexadecimal digits].\r | |
524 | \r | |
525 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
526 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
527 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
528 | The function will ignore the pad space, which includes spaces or tab\r | |
529 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
530 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
531 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
532 | the first character that is a not a valid hexadecimal character or NULL,\r | |
533 | whichever one comes first.\r | |
534 | \r | |
535 | If String is NULL, then ASSERT().\r | |
536 | If Data is NULL, then ASSERT().\r | |
537 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
538 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
539 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
540 | Null-terminator, then ASSERT().\r | |
541 | \r | |
542 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
543 | stored at the location pointed to by Data.\r | |
544 | If the number represented by String exceeds the range defined by UINT64, then\r | |
545 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
546 | \r | |
547 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
548 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
549 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
550 | is stored at the location pointed to by EndPointer.\r | |
551 | \r | |
552 | @param String Pointer to a Null-terminated Unicode string.\r | |
553 | @param EndPointer Pointer to character that stops scan.\r | |
554 | @param Data Pointer to the converted value.\r | |
555 | \r | |
556 | @retval RETURN_SUCCESS Value is translated from String.\r | |
557 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
558 | If Data is NULL.\r | |
559 | If PcdMaximumUnicodeStringLength is not\r | |
560 | zero, and String contains more than\r | |
561 | PcdMaximumUnicodeStringLength Unicode\r | |
562 | characters, not including the\r | |
563 | Null-terminator.\r | |
564 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
565 | the range defined by UINT64.\r | |
566 | \r | |
567 | **/\r | |
568 | RETURN_STATUS\r | |
569 | EFIAPI\r | |
570 | StrHexToUint64S (\r | |
571 | IN CONST CHAR16 *String,\r | |
572 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
573 | OUT UINT64 *Data\r | |
574 | );\r | |
575 | \r | |
c058d59f JY |
576 | /**\r |
577 | Returns the length of a Null-terminated Ascii string.\r | |
578 | \r | |
328f84b1 JY |
579 | This function is similar as strlen_s defined in C11.\r |
580 | \r | |
c058d59f JY |
581 | @param String A pointer to a Null-terminated Ascii string.\r |
582 | @param MaxSize The maximum number of Destination Ascii\r | |
583 | char, including terminating null char.\r | |
584 | \r | |
585 | @retval 0 If String is NULL.\r | |
586 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
587 | @return The number of characters that percede the terminating null character.\r | |
588 | \r | |
589 | **/\r | |
590 | UINTN\r | |
591 | EFIAPI\r | |
592 | AsciiStrnLenS (\r | |
593 | IN CONST CHAR8 *String,\r | |
594 | IN UINTN MaxSize\r | |
595 | );\r | |
596 | \r | |
b590e43a HW |
597 | /**\r |
598 | Returns the size of a Null-terminated Ascii string in bytes, including the\r | |
599 | Null terminator.\r | |
600 | \r | |
601 | This function returns the size of the Null-terminated Ascii string specified\r | |
602 | by String in bytes, including the Null terminator.\r | |
603 | \r | |
604 | @param String A pointer to a Null-terminated Ascii string.\r | |
605 | @param MaxSize The maximum number of Destination Ascii\r | |
606 | char, including the Null terminator.\r | |
607 | \r | |
608 | @retval 0 If String is NULL.\r | |
609 | @retval (sizeof (CHAR8) * (MaxSize + 1))\r | |
610 | If there is no Null terminator in the first MaxSize characters of\r | |
611 | String.\r | |
612 | @return The size of the Null-terminated Ascii string in bytes, including the\r | |
613 | Null terminator.\r | |
614 | \r | |
615 | **/\r | |
616 | UINTN\r | |
617 | EFIAPI\r | |
618 | AsciiStrnSizeS (\r | |
619 | IN CONST CHAR8 *String,\r | |
620 | IN UINTN MaxSize\r | |
621 | );\r | |
622 | \r | |
c058d59f JY |
623 | /**\r |
624 | Copies the string pointed to by Source (including the terminating null char)\r | |
625 | to the array pointed to by Destination.\r | |
626 | \r | |
328f84b1 JY |
627 | This function is similar as strcpy_s defined in C11.\r |
628 | \r | |
0e93edbb JY |
629 | If an error would be returned, then the function will also ASSERT().\r |
630 | \r | |
328f84b1 JY |
631 | If an error is returned, then the Destination is unmodified.\r |
632 | \r | |
c058d59f JY |
633 | @param Destination A pointer to a Null-terminated Ascii string.\r |
634 | @param DestMax The maximum number of Destination Ascii\r | |
635 | char, including terminating null char.\r | |
636 | @param Source A pointer to a Null-terminated Ascii string.\r | |
637 | \r | |
638 | @retval RETURN_SUCCESS String is copied.\r | |
639 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
640 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
641 | If Source is NULL.\r | |
642 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 643 | and DestMax is greater than\r |
c058d59f JY |
644 | PcdMaximumAsciiStringLength.\r |
645 | If DestMax is 0.\r | |
646 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
647 | **/\r | |
648 | RETURN_STATUS\r | |
649 | EFIAPI\r | |
650 | AsciiStrCpyS (\r | |
651 | OUT CHAR8 *Destination,\r | |
652 | IN UINTN DestMax,\r | |
653 | IN CONST CHAR8 *Source\r | |
654 | );\r | |
655 | \r | |
656 | /**\r | |
657 | Copies not more than Length successive char from the string pointed to by\r | |
658 | Source to the array pointed to by Destination. If no null char is copied from\r | |
659 | Source, then Destination[Length] is always set to null.\r | |
660 | \r | |
328f84b1 JY |
661 | This function is similar as strncpy_s defined in C11.\r |
662 | \r | |
0e93edbb JY |
663 | If an error would be returned, then the function will also ASSERT().\r |
664 | \r | |
328f84b1 JY |
665 | If an error is returned, then the Destination is unmodified.\r |
666 | \r | |
c058d59f JY |
667 | @param Destination A pointer to a Null-terminated Ascii string.\r |
668 | @param DestMax The maximum number of Destination Ascii\r | |
669 | char, including terminating null char.\r | |
670 | @param Source A pointer to a Null-terminated Ascii string.\r | |
671 | @param Length The maximum number of Ascii characters to copy.\r | |
672 | \r | |
673 | @retval RETURN_SUCCESS String is copied.\r | |
9095d37b | 674 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r |
c058d59f JY |
675 | MIN(StrLen(Source), Length).\r |
676 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
677 | If Source is NULL.\r | |
678 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 679 | and DestMax is greater than\r |
c058d59f JY |
680 | PcdMaximumAsciiStringLength.\r |
681 | If DestMax is 0.\r | |
682 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
683 | **/\r | |
684 | RETURN_STATUS\r | |
685 | EFIAPI\r | |
686 | AsciiStrnCpyS (\r | |
687 | OUT CHAR8 *Destination,\r | |
688 | IN UINTN DestMax,\r | |
689 | IN CONST CHAR8 *Source,\r | |
690 | IN UINTN Length\r | |
691 | );\r | |
692 | \r | |
693 | /**\r | |
694 | Appends a copy of the string pointed to by Source (including the terminating\r | |
695 | null char) to the end of the string pointed to by Destination.\r | |
696 | \r | |
328f84b1 JY |
697 | This function is similar as strcat_s defined in C11.\r |
698 | \r | |
0e93edbb JY |
699 | If an error would be returned, then the function will also ASSERT().\r |
700 | \r | |
328f84b1 JY |
701 | If an error is returned, then the Destination is unmodified.\r |
702 | \r | |
c058d59f JY |
703 | @param Destination A pointer to a Null-terminated Ascii string.\r |
704 | @param DestMax The maximum number of Destination Ascii\r | |
705 | char, including terminating null char.\r | |
706 | @param Source A pointer to a Null-terminated Ascii string.\r | |
707 | \r | |
708 | @retval RETURN_SUCCESS String is appended.\r | |
9095d37b | 709 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r |
c058d59f JY |
710 | StrLen(Destination).\r |
711 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
712 | greater than StrLen(Source).\r | |
713 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
714 | If Source is NULL.\r | |
715 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 716 | and DestMax is greater than\r |
c058d59f JY |
717 | PcdMaximumAsciiStringLength.\r |
718 | If DestMax is 0.\r | |
719 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
720 | **/\r | |
721 | RETURN_STATUS\r | |
722 | EFIAPI\r | |
723 | AsciiStrCatS (\r | |
724 | IN OUT CHAR8 *Destination,\r | |
725 | IN UINTN DestMax,\r | |
726 | IN CONST CHAR8 *Source\r | |
727 | );\r | |
728 | \r | |
729 | /**\r | |
730 | Appends not more than Length successive char from the string pointed to by\r | |
731 | Source to the end of the string pointed to by Destination. If no null char is\r | |
732 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
733 | set to null.\r | |
734 | \r | |
328f84b1 JY |
735 | This function is similar as strncat_s defined in C11.\r |
736 | \r | |
0e93edbb JY |
737 | If an error would be returned, then the function will also ASSERT().\r |
738 | \r | |
328f84b1 JY |
739 | If an error is returned, then the Destination is unmodified.\r |
740 | \r | |
c058d59f JY |
741 | @param Destination A pointer to a Null-terminated Ascii string.\r |
742 | @param DestMax The maximum number of Destination Ascii\r | |
743 | char, including terminating null char.\r | |
744 | @param Source A pointer to a Null-terminated Ascii string.\r | |
745 | @param Length The maximum number of Ascii characters to copy.\r | |
746 | \r | |
747 | @retval RETURN_SUCCESS String is appended.\r | |
748 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
749 | StrLen(Destination).\r | |
750 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
751 | greater than MIN(StrLen(Source), Length).\r | |
752 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
753 | If Source is NULL.\r | |
754 | If PcdMaximumAsciiStringLength is not zero,\r | |
9095d37b | 755 | and DestMax is greater than\r |
c058d59f JY |
756 | PcdMaximumAsciiStringLength.\r |
757 | If DestMax is 0.\r | |
758 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
759 | **/\r | |
760 | RETURN_STATUS\r | |
761 | EFIAPI\r | |
762 | AsciiStrnCatS (\r | |
763 | IN OUT CHAR8 *Destination,\r | |
764 | IN UINTN DestMax,\r | |
765 | IN CONST CHAR8 *Source,\r | |
766 | IN UINTN Length\r | |
767 | );\r | |
768 | \r | |
d8af3301 HW |
769 | /**\r |
770 | Convert a Null-terminated Ascii decimal string to a value of type UINTN.\r | |
771 | \r | |
772 | This function outputs a value of type UINTN by interpreting the contents of\r | |
773 | the Ascii string specified by String as a decimal number. The format of the\r | |
774 | input Ascii string String is:\r | |
775 | \r | |
776 | [spaces] [decimal digits].\r | |
777 | \r | |
778 | The valid decimal digit character is in the range [0-9]. The function will\r | |
779 | ignore the pad space, which includes spaces or tab characters, before\r | |
780 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
781 | be ignored. Then, the function stops at the first character that is a not a\r | |
782 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
783 | \r | |
784 | If String is NULL, then ASSERT().\r | |
785 | If Data is NULL, then ASSERT().\r | |
786 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
787 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
788 | Null-terminator, then ASSERT().\r | |
789 | \r | |
790 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
791 | at the location pointed to by Data.\r | |
792 | If the number represented by String exceeds the range defined by UINTN, then\r | |
793 | MAX_UINTN is stored at the location pointed to by Data.\r | |
794 | \r | |
795 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
796 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
797 | decimal digits right after the optional pad spaces, the value of String is\r | |
798 | stored at the location pointed to by EndPointer.\r | |
799 | \r | |
800 | @param String Pointer to a Null-terminated Ascii string.\r | |
801 | @param EndPointer Pointer to character that stops scan.\r | |
802 | @param Data Pointer to the converted value.\r | |
803 | \r | |
804 | @retval RETURN_SUCCESS Value is translated from String.\r | |
805 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
806 | If Data is NULL.\r | |
807 | If PcdMaximumAsciiStringLength is not zero,\r | |
808 | and String contains more than\r | |
809 | PcdMaximumAsciiStringLength Ascii\r | |
810 | characters, not including the\r | |
811 | Null-terminator.\r | |
812 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
813 | the range defined by UINTN.\r | |
814 | \r | |
815 | **/\r | |
816 | RETURN_STATUS\r | |
817 | EFIAPI\r | |
818 | AsciiStrDecimalToUintnS (\r | |
819 | IN CONST CHAR8 *String,\r | |
820 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
821 | OUT UINTN *Data\r | |
822 | );\r | |
823 | \r | |
824 | /**\r | |
825 | Convert a Null-terminated Ascii decimal string to a value of type UINT64.\r | |
826 | \r | |
827 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
828 | the Ascii string specified by String as a decimal number. The format of the\r | |
829 | input Ascii string String is:\r | |
830 | \r | |
831 | [spaces] [decimal digits].\r | |
832 | \r | |
833 | The valid decimal digit character is in the range [0-9]. The function will\r | |
834 | ignore the pad space, which includes spaces or tab characters, before\r | |
835 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
836 | be ignored. Then, the function stops at the first character that is a not a\r | |
837 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
838 | \r | |
839 | If String is NULL, then ASSERT().\r | |
840 | If Data is NULL, then ASSERT().\r | |
841 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
842 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
843 | Null-terminator, then ASSERT().\r | |
844 | \r | |
845 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
846 | at the location pointed to by Data.\r | |
847 | If the number represented by String exceeds the range defined by UINT64, then\r | |
848 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
849 | \r | |
850 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
851 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
852 | decimal digits right after the optional pad spaces, the value of String is\r | |
853 | stored at the location pointed to by EndPointer.\r | |
854 | \r | |
855 | @param String Pointer to a Null-terminated Ascii string.\r | |
856 | @param EndPointer Pointer to character that stops scan.\r | |
857 | @param Data Pointer to the converted value.\r | |
858 | \r | |
859 | @retval RETURN_SUCCESS Value is translated from String.\r | |
860 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
861 | If Data is NULL.\r | |
862 | If PcdMaximumAsciiStringLength is not zero,\r | |
863 | and String contains more than\r | |
864 | PcdMaximumAsciiStringLength Ascii\r | |
865 | characters, not including the\r | |
866 | Null-terminator.\r | |
867 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
868 | the range defined by UINT64.\r | |
869 | \r | |
870 | **/\r | |
871 | RETURN_STATUS\r | |
872 | EFIAPI\r | |
873 | AsciiStrDecimalToUint64S (\r | |
874 | IN CONST CHAR8 *String,\r | |
875 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
876 | OUT UINT64 *Data\r | |
877 | );\r | |
878 | \r | |
879 | /**\r | |
880 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.\r | |
881 | \r | |
882 | This function outputs a value of type UINTN by interpreting the contents of\r | |
883 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
884 | the input Ascii string String is:\r | |
885 | \r | |
886 | [spaces][zeros][x][hexadecimal digits].\r | |
887 | \r | |
888 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
889 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
890 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
891 | function will ignore the pad space, which includes spaces or tab characters,\r | |
892 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
893 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
894 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
895 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
896 | whichever on comes first.\r | |
897 | \r | |
898 | If String is NULL, then ASSERT().\r | |
899 | If Data is NULL, then ASSERT().\r | |
900 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
901 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
902 | Null-terminator, then ASSERT().\r | |
903 | \r | |
904 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
905 | stored at the location pointed to by Data.\r | |
906 | If the number represented by String exceeds the range defined by UINTN, then\r | |
907 | MAX_UINTN is stored at the location pointed to by Data.\r | |
908 | \r | |
909 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
910 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
911 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
912 | is stored at the location pointed to by EndPointer.\r | |
913 | \r | |
914 | @param String Pointer to a Null-terminated Ascii string.\r | |
915 | @param EndPointer Pointer to character that stops scan.\r | |
916 | @param Data Pointer to the converted value.\r | |
917 | \r | |
918 | @retval RETURN_SUCCESS Value is translated from String.\r | |
919 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
920 | If Data is NULL.\r | |
921 | If PcdMaximumAsciiStringLength is not zero,\r | |
922 | and String contains more than\r | |
923 | PcdMaximumAsciiStringLength Ascii\r | |
924 | characters, not including the\r | |
925 | Null-terminator.\r | |
926 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
927 | the range defined by UINTN.\r | |
928 | \r | |
929 | **/\r | |
930 | RETURN_STATUS\r | |
931 | EFIAPI\r | |
932 | AsciiStrHexToUintnS (\r | |
933 | IN CONST CHAR8 *String,\r | |
934 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
935 | OUT UINTN *Data\r | |
936 | );\r | |
937 | \r | |
938 | /**\r | |
939 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.\r | |
940 | \r | |
941 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
942 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
943 | the input Ascii string String is:\r | |
944 | \r | |
945 | [spaces][zeros][x][hexadecimal digits].\r | |
946 | \r | |
947 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
948 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
949 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
950 | function will ignore the pad space, which includes spaces or tab characters,\r | |
951 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
952 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
953 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
954 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
955 | whichever on comes first.\r | |
956 | \r | |
957 | If String is NULL, then ASSERT().\r | |
958 | If Data is NULL, then ASSERT().\r | |
959 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
960 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
961 | Null-terminator, then ASSERT().\r | |
962 | \r | |
963 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
964 | stored at the location pointed to by Data.\r | |
965 | If the number represented by String exceeds the range defined by UINT64, then\r | |
966 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
967 | \r | |
968 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
969 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
970 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
971 | is stored at the location pointed to by EndPointer.\r | |
972 | \r | |
973 | @param String Pointer to a Null-terminated Ascii string.\r | |
974 | @param EndPointer Pointer to character that stops scan.\r | |
975 | @param Data Pointer to the converted value.\r | |
976 | \r | |
977 | @retval RETURN_SUCCESS Value is translated from String.\r | |
978 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
979 | If Data is NULL.\r | |
980 | If PcdMaximumAsciiStringLength is not zero,\r | |
981 | and String contains more than\r | |
982 | PcdMaximumAsciiStringLength Ascii\r | |
983 | characters, not including the\r | |
984 | Null-terminator.\r | |
985 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
986 | the range defined by UINT64.\r | |
987 | \r | |
988 | **/\r | |
989 | RETURN_STATUS\r | |
990 | EFIAPI\r | |
991 | AsciiStrHexToUint64S (\r | |
992 | IN CONST CHAR8 *String,\r | |
993 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
994 | OUT UINT64 *Data\r | |
995 | );\r | |
996 | \r | |
c058d59f | 997 | \r |
1bb390f1 ED |
998 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
999 | \r | |
ac644614 | 1000 | /**\r |
ae591c14 | 1001 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1002 | \r |
ac644614 | 1003 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r |
1004 | string and returns the new Unicode string.\r | |
1005 | \r | |
1006 | This function copies the contents of the Unicode string Source to the Unicode\r | |
1007 | string Destination, and returns Destination. If Source and Destination\r | |
1008 | overlap, then the results are undefined.\r | |
1009 | \r | |
1010 | If Destination is NULL, then ASSERT().\r | |
1011 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1012 | If Source is NULL, then ASSERT().\r | |
1013 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1014 | If Source and Destination overlap, then ASSERT().\r | |
1015 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
1016 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1017 | Null-terminator, then ASSERT().\r | |
1018 | \r | |
af2dc6a7 | 1019 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1020 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1021 | \r |
9aa049d9 | 1022 | @return Destination.\r |
ac644614 | 1023 | \r |
1024 | **/\r | |
1025 | CHAR16 *\r | |
1026 | EFIAPI\r | |
1027 | StrCpy (\r | |
1028 | OUT CHAR16 *Destination,\r | |
1029 | IN CONST CHAR16 *Source\r | |
1030 | );\r | |
1031 | \r | |
1032 | \r | |
1033 | /**\r | |
ae591c14 | 1034 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1035 | \r |
9095d37b | 1036 | Copies up to a specified length from one Null-terminated Unicode string to\r |
17f695ed | 1037 | another Null-terminated Unicode string and returns the new Unicode string.\r |
ac644614 | 1038 | \r |
1039 | This function copies the contents of the Unicode string Source to the Unicode\r | |
1040 | string Destination, and returns Destination. At most, Length Unicode\r | |
1041 | characters are copied from Source to Destination. If Length is 0, then\r | |
1042 | Destination is returned unmodified. If Length is greater that the number of\r | |
1043 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
1044 | characters. If Source and Destination overlap, then the results are\r | |
1045 | undefined.\r | |
1046 | \r | |
1047 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1048 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1049 | If Length > 0 and Source is NULL, then ASSERT().\r | |
77f863ee | 1050 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1051 | If Source and Destination overlap, then ASSERT().\r |
9095d37b | 1052 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
50c247fd | 1053 | PcdMaximumUnicodeStringLength, then ASSERT().\r |
ac644614 | 1054 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
50c247fd | 1055 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
1056 | then ASSERT().\r | |
ac644614 | 1057 | \r |
af2dc6a7 | 1058 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1059 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1060 | @param Length The maximum number of Unicode characters to copy.\r | |
ac644614 | 1061 | \r |
9aa049d9 | 1062 | @return Destination.\r |
ac644614 | 1063 | \r |
1064 | **/\r | |
1065 | CHAR16 *\r | |
1066 | EFIAPI\r | |
1067 | StrnCpy (\r | |
1068 | OUT CHAR16 *Destination,\r | |
1069 | IN CONST CHAR16 *Source,\r | |
1070 | IN UINTN Length\r | |
1071 | );\r | |
de4f7f52 | 1072 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
ac644614 | 1073 | \r |
1074 | /**\r | |
1075 | Returns the length of a Null-terminated Unicode string.\r | |
1076 | \r | |
1077 | This function returns the number of Unicode characters in the Null-terminated\r | |
1078 | Unicode string specified by String.\r | |
1079 | \r | |
1080 | If String is NULL, then ASSERT().\r | |
1081 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1082 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1083 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1084 | Null-terminator, then ASSERT().\r | |
1085 | \r | |
1086 | @param String Pointer to a Null-terminated Unicode string.\r | |
1087 | \r | |
1088 | @return The length of String.\r | |
1089 | \r | |
1090 | **/\r | |
1091 | UINTN\r | |
1092 | EFIAPI\r | |
1093 | StrLen (\r | |
1094 | IN CONST CHAR16 *String\r | |
1095 | );\r | |
1096 | \r | |
1097 | \r | |
1098 | /**\r | |
1099 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
1100 | Null terminator.\r | |
1101 | \r | |
9095d37b | 1102 | This function returns the size, in bytes, of the Null-terminated Unicode string\r |
17f695ed | 1103 | specified by String.\r |
ac644614 | 1104 | \r |
1105 | If String is NULL, then ASSERT().\r | |
1106 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1107 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1108 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1109 | Null-terminator, then ASSERT().\r | |
1110 | \r | |
af2dc6a7 | 1111 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1112 | \r |
1113 | @return The size of String.\r | |
1114 | \r | |
1115 | **/\r | |
1116 | UINTN\r | |
1117 | EFIAPI\r | |
1118 | StrSize (\r | |
1119 | IN CONST CHAR16 *String\r | |
1120 | );\r | |
1121 | \r | |
1122 | \r | |
1123 | /**\r | |
1124 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
1125 | between the first mismatched Unicode characters.\r | |
1126 | \r | |
1127 | This function compares the Null-terminated Unicode string FirstString to the\r | |
1128 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
1129 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1130 | mismatched Unicode character in SecondString subtracted from the first\r | |
1131 | mismatched Unicode character in FirstString.\r | |
1132 | \r | |
1133 | If FirstString is NULL, then ASSERT().\r | |
1134 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1135 | If SecondString is NULL, then ASSERT().\r | |
1136 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1137 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
1138 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1139 | Null-terminator, then ASSERT().\r | |
1140 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
af2dc6a7 | 1141 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1142 | Null-terminator, then ASSERT().\r |
1143 | \r | |
af2dc6a7 | 1144 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1145 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1146 | \r |
1106ffe1 | 1147 | @retval 0 FirstString is identical to SecondString.\r |
1148 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1149 | \r |
1150 | **/\r | |
1151 | INTN\r | |
1152 | EFIAPI\r | |
1153 | StrCmp (\r | |
1154 | IN CONST CHAR16 *FirstString,\r | |
1155 | IN CONST CHAR16 *SecondString\r | |
1156 | );\r | |
1157 | \r | |
1158 | \r | |
1159 | /**\r | |
17f695ed | 1160 | Compares up to a specified length the contents of two Null-terminated Unicode strings,\r |
1161 | and returns the difference between the first mismatched Unicode characters.\r | |
9095d37b | 1162 | \r |
ac644614 | 1163 | This function compares the Null-terminated Unicode string FirstString to the\r |
1164 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
1165 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
1166 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1167 | value returned is the first mismatched Unicode character in SecondString\r | |
1168 | subtracted from the first mismatched Unicode character in FirstString.\r | |
1169 | \r | |
1170 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
77f863ee | 1171 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1172 | If Length > 0 and SecondString is NULL, then ASSERT().\r |
77f863ee | 1173 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r |
50c247fd | 1174 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
1175 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
1176 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
1177 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1178 | then ASSERT().\r | |
1179 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
1180 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1181 | then ASSERT().\r | |
ac644614 | 1182 | \r |
af2dc6a7 | 1183 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1184 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
1185 | @param Length The maximum number of Unicode characters to compare.\r | |
ac644614 | 1186 | \r |
1106ffe1 | 1187 | @retval 0 FirstString is identical to SecondString.\r |
1188 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1189 | \r |
1190 | **/\r | |
1191 | INTN\r | |
1192 | EFIAPI\r | |
1193 | StrnCmp (\r | |
1194 | IN CONST CHAR16 *FirstString,\r | |
1195 | IN CONST CHAR16 *SecondString,\r | |
1196 | IN UINTN Length\r | |
1197 | );\r | |
1198 | \r | |
1199 | \r | |
1bb390f1 ED |
1200 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1201 | \r | |
ac644614 | 1202 | /**\r |
ae591c14 | 1203 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1204 | \r |
ac644614 | 1205 | Concatenates one Null-terminated Unicode string to another Null-terminated\r |
1206 | Unicode string, and returns the concatenated Unicode string.\r | |
1207 | \r | |
1208 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
1209 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
1210 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
1211 | Unicode String is returned. If Source and Destination overlap, then the\r | |
1212 | results are undefined.\r | |
1213 | \r | |
1214 | If Destination is NULL, then ASSERT().\r | |
77f863ee | 1215 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1216 | If Source is NULL, then ASSERT().\r |
77f863ee | 1217 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1218 | If Source and Destination overlap, then ASSERT().\r |
1219 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
af2dc6a7 | 1220 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1221 | Null-terminator, then ASSERT().\r |
1222 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
af2dc6a7 | 1223 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1224 | Null-terminator, then ASSERT().\r |
1225 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
1226 | and Source results in a Unicode string with more than\r | |
af2dc6a7 | 1227 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1228 | Null-terminator, then ASSERT().\r |
1229 | \r | |
af2dc6a7 | 1230 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1231 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1232 | \r |
9aa049d9 | 1233 | @return Destination.\r |
ac644614 | 1234 | \r |
1235 | **/\r | |
1236 | CHAR16 *\r | |
1237 | EFIAPI\r | |
1238 | StrCat (\r | |
1239 | IN OUT CHAR16 *Destination,\r | |
1240 | IN CONST CHAR16 *Source\r | |
1241 | );\r | |
1242 | \r | |
1243 | \r | |
1244 | /**\r | |
ae591c14 | 1245 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1246 | \r |
9095d37b LG |
1247 | Concatenates up to a specified length one Null-terminated Unicode to the end\r |
1248 | of another Null-terminated Unicode string, and returns the concatenated\r | |
ac644614 | 1249 | Unicode string.\r |
1250 | \r | |
1251 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
1252 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
1253 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
1254 | most, Length Unicode characters are concatenated from Source to the end of\r | |
1255 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
1256 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
1257 | the results are undefined.\r | |
1258 | \r | |
1259 | If Destination is NULL, then ASSERT().\r | |
1260 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1261 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1262 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1263 | If Source and Destination overlap, then ASSERT().\r | |
9095d37b | 1264 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
50c247fd | 1265 | PcdMaximumUnicodeStringLength, then ASSERT().\r |
ac644614 | 1266 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r |
50c247fd | 1267 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1268 | Null-terminator, then ASSERT().\r |
1269 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
50c247fd | 1270 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1271 | Null-terminator, then ASSERT().\r |
1272 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
50c247fd | 1273 | and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r |
1274 | Unicode characters, not including the Null-terminator, then ASSERT().\r | |
ac644614 | 1275 | \r |
af2dc6a7 | 1276 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1277 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1278 | @param Length The maximum number of Unicode characters to concatenate from\r | |
ac644614 | 1279 | Source.\r |
1280 | \r | |
9aa049d9 | 1281 | @return Destination.\r |
ac644614 | 1282 | \r |
1283 | **/\r | |
1284 | CHAR16 *\r | |
1285 | EFIAPI\r | |
1286 | StrnCat (\r | |
1287 | IN OUT CHAR16 *Destination,\r | |
1288 | IN CONST CHAR16 *Source,\r | |
1289 | IN UINTN Length\r | |
1290 | );\r | |
de4f7f52 | 1291 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
ac644614 | 1292 | \r |
1293 | /**\r | |
9aa049d9 | 1294 | Returns the first occurrence of a Null-terminated Unicode sub-string\r |
ac644614 | 1295 | in a Null-terminated Unicode string.\r |
1296 | \r | |
1297 | This function scans the contents of the Null-terminated Unicode string\r | |
1298 | specified by String and returns the first occurrence of SearchString.\r | |
1299 | If SearchString is not found in String, then NULL is returned. If\r | |
af2dc6a7 | 1300 | the length of SearchString is zero, then String is returned.\r |
ac644614 | 1301 | \r |
1302 | If String is NULL, then ASSERT().\r | |
1303 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1304 | If SearchString is NULL, then ASSERT().\r | |
1305 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1306 | \r | |
1307 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r | |
1308 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
af2dc6a7 | 1309 | characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 1310 | \r |
af2dc6a7 | 1311 | @param String The pointer to a Null-terminated Unicode string.\r |
1312 | @param SearchString The pointer to a Null-terminated Unicode string to search for.\r | |
ac644614 | 1313 | \r |
1314 | @retval NULL If the SearchString does not appear in String.\r | |
1106ffe1 | 1315 | @return others If there is a match.\r |
ac644614 | 1316 | \r |
1317 | **/\r | |
1318 | CHAR16 *\r | |
1319 | EFIAPI\r | |
1320 | StrStr (\r | |
17f695ed | 1321 | IN CONST CHAR16 *String,\r |
1322 | IN CONST CHAR16 *SearchString\r | |
ac644614 | 1323 | );\r |
1324 | \r | |
1325 | /**\r | |
1326 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1327 | type UINTN.\r | |
1328 | \r | |
1329 | This function returns a value of type UINTN by interpreting the contents\r | |
1330 | of the Unicode string specified by String as a decimal number. The format\r | |
1331 | of the input Unicode string String is:\r | |
1332 | \r | |
1333 | [spaces] [decimal digits].\r | |
1334 | \r | |
1335 | The valid decimal digit character is in the range [0-9]. The\r | |
1336 | function will ignore the pad space, which includes spaces or\r | |
1337 | tab characters, before [decimal digits]. The running zero in the\r | |
1338 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1339 | stops at the first character that is a not a valid decimal character\r | |
1340 | or a Null-terminator, whichever one comes first.\r | |
1341 | \r | |
1342 | If String is NULL, then ASSERT().\r | |
1343 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1344 | If String has only pad spaces, then 0 is returned.\r | |
1345 | If String has no pad spaces or valid decimal digits,\r | |
1346 | then 0 is returned.\r | |
1347 | If the number represented by String overflows according\r | |
ea2e0921 | 1348 | to the range defined by UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1349 | \r |
1350 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1351 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1352 | the Null-terminator, then ASSERT().\r | |
1353 | \r | |
af2dc6a7 | 1354 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1355 | \r |
38bbd3d9 | 1356 | @retval Value translated from String.\r |
ac644614 | 1357 | \r |
1358 | **/\r | |
1359 | UINTN\r | |
1360 | EFIAPI\r | |
1361 | StrDecimalToUintn (\r | |
17f695ed | 1362 | IN CONST CHAR16 *String\r |
ac644614 | 1363 | );\r |
1364 | \r | |
1365 | /**\r | |
1366 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1367 | type UINT64.\r | |
1368 | \r | |
1369 | This function returns a value of type UINT64 by interpreting the contents\r | |
1370 | of the Unicode string specified by String as a decimal number. The format\r | |
1371 | of the input Unicode string String is:\r | |
1372 | \r | |
1373 | [spaces] [decimal digits].\r | |
1374 | \r | |
1375 | The valid decimal digit character is in the range [0-9]. The\r | |
1376 | function will ignore the pad space, which includes spaces or\r | |
1377 | tab characters, before [decimal digits]. The running zero in the\r | |
1378 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1379 | stops at the first character that is a not a valid decimal character\r | |
1380 | or a Null-terminator, whichever one comes first.\r | |
1381 | \r | |
1382 | If String is NULL, then ASSERT().\r | |
1383 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1384 | If String has only pad spaces, then 0 is returned.\r | |
1385 | If String has no pad spaces or valid decimal digits,\r | |
1386 | then 0 is returned.\r | |
1387 | If the number represented by String overflows according\r | |
ea2e0921 | 1388 | to the range defined by UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1389 | \r |
1390 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1391 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1392 | the Null-terminator, then ASSERT().\r | |
1393 | \r | |
af2dc6a7 | 1394 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1395 | \r |
38bbd3d9 | 1396 | @retval Value translated from String.\r |
ac644614 | 1397 | \r |
1398 | **/\r | |
1399 | UINT64\r | |
1400 | EFIAPI\r | |
1401 | StrDecimalToUint64 (\r | |
17f695ed | 1402 | IN CONST CHAR16 *String\r |
ac644614 | 1403 | );\r |
9095d37b | 1404 | \r |
ac644614 | 1405 | \r |
1406 | /**\r | |
1407 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
1408 | \r | |
1409 | This function returns a value of type UINTN by interpreting the contents\r | |
1410 | of the Unicode string specified by String as a hexadecimal number.\r | |
1411 | The format of the input Unicode string String is:\r | |
1412 | \r | |
1413 | [spaces][zeros][x][hexadecimal digits].\r | |
1414 | \r | |
1415 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1416 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1417 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1418 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1419 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1420 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
9095d37b | 1421 | first valid hexadecimal digit. Then, the function stops at the first character\r |
af2dc6a7 | 1422 | that is a not a valid hexadecimal character or NULL, whichever one comes first.\r |
ac644614 | 1423 | \r |
1424 | If String is NULL, then ASSERT().\r | |
1425 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1426 | If String has only pad spaces, then zero is returned.\r | |
1427 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1428 | then zero is returned.\r | |
1429 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1430 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1431 | \r |
1432 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1433 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1434 | then ASSERT().\r | |
1435 | \r | |
af2dc6a7 | 1436 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1437 | \r |
38bbd3d9 | 1438 | @retval Value translated from String.\r |
ac644614 | 1439 | \r |
1440 | **/\r | |
1441 | UINTN\r | |
1442 | EFIAPI\r | |
1443 | StrHexToUintn (\r | |
17f695ed | 1444 | IN CONST CHAR16 *String\r |
ac644614 | 1445 | );\r |
1446 | \r | |
1447 | \r | |
1448 | /**\r | |
1449 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
1450 | \r | |
1451 | This function returns a value of type UINT64 by interpreting the contents\r | |
1452 | of the Unicode string specified by String as a hexadecimal number.\r | |
1453 | The format of the input Unicode string String is\r | |
1454 | \r | |
1455 | [spaces][zeros][x][hexadecimal digits].\r | |
1456 | \r | |
1457 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1458 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1459 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1460 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1461 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1462 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
1463 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
1464 | a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
1465 | \r | |
1466 | If String is NULL, then ASSERT().\r | |
1467 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1468 | If String has only pad spaces, then zero is returned.\r | |
1469 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1470 | then zero is returned.\r | |
1471 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1472 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1473 | \r |
1474 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1475 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1476 | then ASSERT().\r | |
1477 | \r | |
af2dc6a7 | 1478 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1479 | \r |
38bbd3d9 | 1480 | @retval Value translated from String.\r |
ac644614 | 1481 | \r |
1482 | **/\r | |
1483 | UINT64\r | |
1484 | EFIAPI\r | |
1485 | StrHexToUint64 (\r | |
17f695ed | 1486 | IN CONST CHAR16 *String\r |
ac644614 | 1487 | );\r |
1488 | \r | |
36396ea2 RN |
1489 | /**\r |
1490 | Convert a Null-terminated Unicode string to IPv6 address and prefix length.\r | |
1491 | \r | |
1492 | This function outputs a value of type IPv6_ADDRESS and may output a value\r | |
1493 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1494 | by String. The format of the input Unicode string String is as follows:\r | |
1495 | \r | |
1496 | X:X:X:X:X:X:X:X[/P]\r | |
1497 | \r | |
1498 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r | |
1499 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r | |
1500 | memory address and high byte is stored in high memory address. P contains decimal\r | |
1501 | digit characters in the range [0-9]. The running zero in the beginning of P will\r | |
1502 | be ignored. /P is optional.\r | |
1503 | \r | |
1504 | When /P is not in the String, the function stops at the first character that is\r | |
1505 | not a valid hexadecimal digit character after eight X's are converted.\r | |
1506 | \r | |
1507 | When /P is in the String, the function stops at the first character that is not\r | |
1508 | a valid decimal digit character after P is converted.\r | |
1509 | \r | |
1510 | "::" can be used to compress one or more groups of X when X contains only 0.\r | |
1511 | The "::" can only appear once in the String.\r | |
1512 | \r | |
1513 | If String is NULL, then ASSERT().\r | |
1514 | \r | |
1515 | If Address is NULL, then ASSERT().\r | |
1516 | \r | |
1517 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1518 | \r | |
1519 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1520 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
1521 | Null-terminator, then ASSERT().\r | |
1522 | \r | |
1523 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
1524 | to the character that stopped the scan is stored at the location pointed to\r | |
1525 | by EndPointer.\r | |
1526 | \r | |
1527 | @param String Pointer to a Null-terminated Unicode string.\r | |
1528 | @param EndPointer Pointer to character that stops scan.\r | |
1529 | @param Address Pointer to the converted IPv6 address.\r | |
1530 | @param PrefixLength Pointer to the converted IPv6 address prefix\r | |
1531 | length. MAX_UINT8 is returned when /P is\r | |
1532 | not in the String.\r | |
1533 | \r | |
1534 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1535 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1536 | If Data is NULL.\r | |
1537 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r | |
1538 | digit characters.\r | |
1539 | If String contains "::" and number of X\r | |
1540 | is not less than 8.\r | |
1541 | If P starts with character that is not a\r | |
1542 | valid decimal digit character.\r | |
1543 | If the decimal number converted from P\r | |
1544 | exceeds 128.\r | |
1545 | \r | |
1546 | **/\r | |
1547 | RETURN_STATUS\r | |
1548 | EFIAPI\r | |
1549 | StrToIpv6Address (\r | |
1550 | IN CONST CHAR16 *String,\r | |
1551 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
1552 | OUT IPv6_ADDRESS *Address,\r | |
1553 | OUT UINT8 *PrefixLength OPTIONAL\r | |
1554 | );\r | |
1555 | \r | |
1556 | /**\r | |
1557 | Convert a Null-terminated Unicode string to IPv4 address and prefix length.\r | |
1558 | \r | |
1559 | This function outputs a value of type IPv4_ADDRESS and may output a value\r | |
1560 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1561 | by String. The format of the input Unicode string String is as follows:\r | |
1562 | \r | |
1563 | D.D.D.D[/P]\r | |
1564 | \r | |
1565 | D and P are decimal digit characters in the range [0-9]. The running zero in\r | |
1566 | the beginning of D and P will be ignored. /P is optional.\r | |
1567 | \r | |
1568 | When /P is not in the String, the function stops at the first character that is\r | |
1569 | not a valid decimal digit character after four D's are converted.\r | |
1570 | \r | |
1571 | When /P is in the String, the function stops at the first character that is not\r | |
1572 | a valid decimal digit character after P is converted.\r | |
1573 | \r | |
1574 | If String is NULL, then ASSERT().\r | |
1575 | \r | |
1576 | If Address is NULL, then ASSERT().\r | |
1577 | \r | |
1578 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1579 | \r | |
1580 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1581 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
1582 | Null-terminator, then ASSERT().\r | |
1583 | \r | |
1584 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
1585 | to the character that stopped the scan is stored at the location pointed to\r | |
1586 | by EndPointer.\r | |
1587 | \r | |
1588 | @param String Pointer to a Null-terminated Unicode string.\r | |
1589 | @param EndPointer Pointer to character that stops scan.\r | |
1590 | @param Address Pointer to the converted IPv4 address.\r | |
1591 | @param PrefixLength Pointer to the converted IPv4 address prefix\r | |
1592 | length. MAX_UINT8 is returned when /P is\r | |
1593 | not in the String.\r | |
1594 | \r | |
1595 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1596 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1597 | If Data is NULL.\r | |
1598 | @retval RETURN_UNSUPPORTED If String is not in the correct format.\r | |
1599 | If any decimal number converted from D\r | |
1600 | exceeds 255.\r | |
1601 | If the decimal number converted from P\r | |
1602 | exceeds 32.\r | |
1603 | \r | |
1604 | **/\r | |
1605 | RETURN_STATUS\r | |
1606 | EFIAPI\r | |
1607 | StrToIpv4Address (\r | |
1608 | IN CONST CHAR16 *String,\r | |
1609 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
1610 | OUT IPv4_ADDRESS *Address,\r | |
1611 | OUT UINT8 *PrefixLength OPTIONAL\r | |
1612 | );\r | |
1613 | \r | |
1614 | #define GUID_STRING_LENGTH 36\r | |
1615 | \r | |
1616 | /**\r | |
1617 | Convert a Null-terminated Unicode GUID string to a value of type\r | |
1618 | EFI_GUID.\r | |
1619 | \r | |
1620 | This function outputs a GUID value by interpreting the contents of\r | |
1621 | the Unicode string specified by String. The format of the input\r | |
1622 | Unicode string String consists of 36 characters, as follows:\r | |
1623 | \r | |
1624 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r | |
1625 | \r | |
1626 | The pairs aa - pp are two characters in the range [0-9], [a-f] and\r | |
1627 | [A-F], with each pair representing a single byte hexadecimal value.\r | |
1628 | \r | |
1629 | The mapping between String and the EFI_GUID structure is as follows:\r | |
1630 | aa Data1[24:31]\r | |
1631 | bb Data1[16:23]\r | |
1632 | cc Data1[8:15]\r | |
1633 | dd Data1[0:7]\r | |
1634 | ee Data2[8:15]\r | |
1635 | ff Data2[0:7]\r | |
1636 | gg Data3[8:15]\r | |
1637 | hh Data3[0:7]\r | |
1638 | ii Data4[0:7]\r | |
1639 | jj Data4[8:15]\r | |
1640 | kk Data4[16:23]\r | |
1641 | ll Data4[24:31]\r | |
1642 | mm Data4[32:39]\r | |
1643 | nn Data4[40:47]\r | |
1644 | oo Data4[48:55]\r | |
1645 | pp Data4[56:63]\r | |
1646 | \r | |
1647 | If String is NULL, then ASSERT().\r | |
1648 | If Guid is NULL, then ASSERT().\r | |
1649 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1650 | \r | |
1651 | @param String Pointer to a Null-terminated Unicode string.\r | |
1652 | @param Guid Pointer to the converted GUID.\r | |
1653 | \r | |
1654 | @retval RETURN_SUCCESS Guid is translated from String.\r | |
1655 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1656 | If Data is NULL.\r | |
1657 | @retval RETURN_UNSUPPORTED If String is not as the above format.\r | |
1658 | \r | |
1659 | **/\r | |
1660 | RETURN_STATUS\r | |
1661 | EFIAPI\r | |
1662 | StrToGuid (\r | |
1663 | IN CONST CHAR16 *String,\r | |
1664 | OUT GUID *Guid\r | |
1665 | );\r | |
1666 | \r | |
1667 | /**\r | |
1668 | Convert a Null-terminated Unicode hexadecimal string to a byte array.\r | |
1669 | \r | |
1670 | This function outputs a byte array by interpreting the contents of\r | |
1671 | the Unicode string specified by String in hexadecimal format. The format of\r | |
1672 | the input Unicode string String is:\r | |
1673 | \r | |
1674 | [XX]*\r | |
1675 | \r | |
1676 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r | |
1677 | The function decodes every two hexadecimal digit characters as one byte. The\r | |
1678 | decoding stops after Length of characters and outputs Buffer containing\r | |
1679 | (Length / 2) bytes.\r | |
1680 | \r | |
1681 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1682 | \r | |
1683 | If String is NULL, then ASSERT().\r | |
1684 | \r | |
1685 | If Buffer is NULL, then ASSERT().\r | |
1686 | \r | |
1687 | If Length is not multiple of 2, then ASSERT().\r | |
1688 | \r | |
1689 | If PcdMaximumUnicodeStringLength is not zero and Length is greater than\r | |
1690 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
1691 | \r | |
1692 | If MaxBufferSize is less than (Length / 2), then ASSERT().\r | |
1693 | \r | |
1694 | @param String Pointer to a Null-terminated Unicode string.\r | |
1695 | @param Length The number of Unicode characters to decode.\r | |
1696 | @param Buffer Pointer to the converted bytes array.\r | |
1697 | @param MaxBufferSize The maximum size of Buffer.\r | |
1698 | \r | |
1699 | @retval RETURN_SUCCESS Buffer is translated from String.\r | |
1700 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1701 | If Data is NULL.\r | |
1702 | If Length is not multiple of 2.\r | |
1703 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1704 | and Length is greater than\r | |
1705 | PcdMaximumUnicodeStringLength.\r | |
1706 | @retval RETURN_UNSUPPORTED If Length of characters from String contain\r | |
1707 | a character that is not valid hexadecimal\r | |
1708 | digit characters, or a Null-terminator.\r | |
1709 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r | |
1710 | **/\r | |
1711 | RETURN_STATUS\r | |
1712 | EFIAPI\r | |
1713 | StrHexToBytes (\r | |
1714 | IN CONST CHAR16 *String,\r | |
1715 | IN UINTN Length,\r | |
1716 | OUT UINT8 *Buffer,\r | |
1717 | IN UINTN MaxBufferSize\r | |
1718 | );\r | |
1719 | \r | |
415aa2f1 SZ |
1720 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1721 | \r | |
ac644614 | 1722 | /**\r |
415aa2f1 SZ |
1723 | [ATTENTION] This function is deprecated for security reason.\r |
1724 | \r | |
17f695ed | 1725 | Convert a Null-terminated Unicode string to a Null-terminated\r |
ac644614 | 1726 | ASCII string and returns the ASCII string.\r |
1727 | \r | |
1728 | This function converts the content of the Unicode string Source\r | |
1729 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1730 | each Unicode character. It returns Destination.\r | |
1731 | \r | |
d3e0289c | 1732 | The caller is responsible to make sure Destination points to a buffer with size\r |
1733 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1734 | \r | |
ac644614 | 1735 | If any Unicode characters in Source contain non-zero value in\r |
1736 | the upper 8 bits, then ASSERT().\r | |
1737 | \r | |
1738 | If Destination is NULL, then ASSERT().\r | |
1739 | If Source is NULL, then ASSERT().\r | |
1740 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1741 | If Source and Destination overlap, then ASSERT().\r | |
1742 | \r | |
1743 | If PcdMaximumUnicodeStringLength is not zero, and Source contains\r | |
1744 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1745 | the Null-terminator, then ASSERT().\r | |
1746 | \r | |
1747 | If PcdMaximumAsciiStringLength is not zero, and Source contains more\r | |
1748 | than PcdMaximumAsciiStringLength Unicode characters not including the\r | |
1749 | Null-terminator, then ASSERT().\r | |
1750 | \r | |
af2dc6a7 | 1751 | @param Source The pointer to a Null-terminated Unicode string.\r |
1752 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1753 | \r |
9aa049d9 | 1754 | @return Destination.\r |
ac644614 | 1755 | \r |
1756 | **/\r | |
1757 | CHAR8 *\r | |
1758 | EFIAPI\r | |
1759 | UnicodeStrToAsciiStr (\r | |
17f695ed | 1760 | IN CONST CHAR16 *Source,\r |
1761 | OUT CHAR8 *Destination\r | |
ac644614 | 1762 | );\r |
1763 | \r | |
de4f7f52 | 1764 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
415aa2f1 | 1765 | \r |
3ab41b7a JY |
1766 | /**\r |
1767 | Convert a Null-terminated Unicode string to a Null-terminated\r | |
1768 | ASCII string.\r | |
1769 | \r | |
1770 | This function is similar to AsciiStrCpyS.\r | |
1771 | \r | |
1772 | This function converts the content of the Unicode string Source\r | |
1773 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1774 | each Unicode character. The function terminates the ASCII string\r | |
1775 | Destination by appending a Null-terminator character at the end.\r | |
1776 | \r | |
1777 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1778 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1779 | \r | |
1780 | If any Unicode characters in Source contain non-zero value in\r | |
1781 | the upper 8 bits, then ASSERT().\r | |
1782 | \r | |
1783 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1784 | If an error would be returned, then the function will also ASSERT().\r | |
1785 | \r | |
1786 | If an error is returned, then the Destination is unmodified.\r | |
1787 | \r | |
1788 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1789 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
1790 | @param DestMax The maximum number of Destination Ascii\r | |
1791 | char, including terminating null char.\r | |
1792 | \r | |
1793 | @retval RETURN_SUCCESS String is converted.\r | |
1794 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
1795 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1796 | If Source is NULL.\r | |
1797 | If PcdMaximumAsciiStringLength is not zero,\r | |
1798 | and DestMax is greater than\r | |
1799 | PcdMaximumAsciiStringLength.\r | |
1800 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1801 | and DestMax is greater than\r | |
1802 | PcdMaximumUnicodeStringLength.\r | |
1803 | If DestMax is 0.\r | |
1804 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1805 | \r | |
1806 | **/\r | |
1807 | RETURN_STATUS\r | |
1808 | EFIAPI\r | |
1809 | UnicodeStrToAsciiStrS (\r | |
1810 | IN CONST CHAR16 *Source,\r | |
1811 | OUT CHAR8 *Destination,\r | |
1812 | IN UINTN DestMax\r | |
1813 | );\r | |
ac644614 | 1814 | \r |
02263214 HW |
1815 | /**\r |
1816 | Convert not more than Length successive characters from a Null-terminated\r | |
1817 | Unicode string to a Null-terminated Ascii string. If no null char is copied\r | |
1818 | from Source, then Destination[Length] is always set to null.\r | |
1819 | \r | |
1820 | This function converts not more than Length successive characters from the\r | |
1821 | Unicode string Source to the Ascii string Destination by copying the lower 8\r | |
1822 | bits of each Unicode character. The function terminates the Ascii string\r | |
1823 | Destination by appending a Null-terminator character at the end.\r | |
1824 | \r | |
1825 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1826 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1827 | \r | |
1828 | If any Unicode characters in Source contain non-zero value in the upper 8\r | |
1829 | bits, then ASSERT().\r | |
1830 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1831 | If an error would be returned, then the function will also ASSERT().\r | |
1832 | \r | |
1833 | If an error is returned, then the Destination is unmodified.\r | |
1834 | \r | |
1835 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1836 | @param Length The maximum number of Unicode characters to\r | |
1837 | convert.\r | |
1838 | @param Destination The pointer to a Null-terminated Ascii string.\r | |
1839 | @param DestMax The maximum number of Destination Ascii\r | |
1840 | char, including terminating null char.\r | |
1841 | @param DestinationLength The number of Unicode characters converted.\r | |
1842 | \r | |
1843 | @retval RETURN_SUCCESS String is converted.\r | |
1844 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1845 | If Source is NULL.\r | |
1846 | If DestinationLength is NULL.\r | |
1847 | If PcdMaximumAsciiStringLength is not zero,\r | |
1848 | and Length or DestMax is greater than\r | |
1849 | PcdMaximumAsciiStringLength.\r | |
1850 | If PcdMaximumUnicodeStringLength is not\r | |
1851 | zero, and Length or DestMax is greater than\r | |
1852 | PcdMaximumUnicodeStringLength.\r | |
1853 | If DestMax is 0.\r | |
1854 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
1855 | MIN(StrLen(Source), Length).\r | |
1856 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1857 | \r | |
1858 | **/\r | |
1859 | RETURN_STATUS\r | |
1860 | EFIAPI\r | |
1861 | UnicodeStrnToAsciiStrS (\r | |
1862 | IN CONST CHAR16 *Source,\r | |
1863 | IN UINTN Length,\r | |
1864 | OUT CHAR8 *Destination,\r | |
1865 | IN UINTN DestMax,\r | |
1866 | OUT UINTN *DestinationLength\r | |
1867 | );\r | |
1868 | \r | |
1bb390f1 ED |
1869 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1870 | \r | |
ac644614 | 1871 | /**\r |
ae591c14 | 1872 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1873 | \r |
ac644614 | 1874 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r |
1875 | string and returns the new ASCII string.\r | |
1876 | \r | |
1877 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1878 | string Destination, and returns Destination. If Source and Destination\r | |
1879 | overlap, then the results are undefined.\r | |
1880 | \r | |
1881 | If Destination is NULL, then ASSERT().\r | |
1882 | If Source is NULL, then ASSERT().\r | |
1883 | If Source and Destination overlap, then ASSERT().\r | |
1884 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
1885 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1886 | then ASSERT().\r | |
1887 | \r | |
af2dc6a7 | 1888 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1889 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1890 | \r |
1891 | @return Destination\r | |
1892 | \r | |
1893 | **/\r | |
1894 | CHAR8 *\r | |
1895 | EFIAPI\r | |
1896 | AsciiStrCpy (\r | |
1897 | OUT CHAR8 *Destination,\r | |
1898 | IN CONST CHAR8 *Source\r | |
1899 | );\r | |
1900 | \r | |
1901 | \r | |
1902 | /**\r | |
ae591c14 | 1903 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1904 | \r |
9095d37b | 1905 | Copies up to a specified length one Null-terminated ASCII string to another\r |
17f695ed | 1906 | Null-terminated ASCII string and returns the new ASCII string.\r |
ac644614 | 1907 | \r |
1908 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1909 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
1910 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
1911 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
1912 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
1913 | and Destination overlap, then the results are undefined.\r | |
1914 | \r | |
1915 | If Destination is NULL, then ASSERT().\r | |
1916 | If Source is NULL, then ASSERT().\r | |
1917 | If Source and Destination overlap, then ASSERT().\r | |
9095d37b | 1918 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
50c247fd | 1919 | PcdMaximumAsciiStringLength, then ASSERT().\r |
ac644614 | 1920 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
50c247fd | 1921 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 1922 | then ASSERT().\r |
1923 | \r | |
af2dc6a7 | 1924 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1925 | @param Source The pointer to a Null-terminated ASCII string.\r | |
1926 | @param Length The maximum number of ASCII characters to copy.\r | |
ac644614 | 1927 | \r |
1928 | @return Destination\r | |
1929 | \r | |
1930 | **/\r | |
1931 | CHAR8 *\r | |
1932 | EFIAPI\r | |
1933 | AsciiStrnCpy (\r | |
1934 | OUT CHAR8 *Destination,\r | |
1935 | IN CONST CHAR8 *Source,\r | |
1936 | IN UINTN Length\r | |
1937 | );\r | |
de4f7f52 | 1938 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
ac644614 | 1939 | \r |
1940 | /**\r | |
1941 | Returns the length of a Null-terminated ASCII string.\r | |
1942 | \r | |
1943 | This function returns the number of ASCII characters in the Null-terminated\r | |
1944 | ASCII string specified by String.\r | |
1945 | \r | |
1946 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1947 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1948 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1949 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1950 | then ASSERT().\r | |
1951 | \r | |
af2dc6a7 | 1952 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1953 | \r |
1954 | @return The length of String.\r | |
1955 | \r | |
1956 | **/\r | |
1957 | UINTN\r | |
1958 | EFIAPI\r | |
1959 | AsciiStrLen (\r | |
1960 | IN CONST CHAR8 *String\r | |
1961 | );\r | |
1962 | \r | |
1963 | \r | |
1964 | /**\r | |
1965 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
1966 | Null terminator.\r | |
1967 | \r | |
1968 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
1969 | specified by String.\r | |
1970 | \r | |
1971 | If String is NULL, then ASSERT().\r | |
1972 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1973 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1974 | then ASSERT().\r | |
1975 | \r | |
af2dc6a7 | 1976 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 1977 | \r |
1978 | @return The size of String.\r | |
1979 | \r | |
1980 | **/\r | |
1981 | UINTN\r | |
1982 | EFIAPI\r | |
1983 | AsciiStrSize (\r | |
1984 | IN CONST CHAR8 *String\r | |
1985 | );\r | |
1986 | \r | |
1987 | \r | |
1988 | /**\r | |
1989 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
1990 | between the first mismatched ASCII characters.\r | |
1991 | \r | |
1992 | This function compares the Null-terminated ASCII string FirstString to the\r | |
1993 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
1994 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1995 | mismatched ASCII character in SecondString subtracted from the first\r | |
1996 | mismatched ASCII character in FirstString.\r | |
1997 | \r | |
1998 | If FirstString is NULL, then ASSERT().\r | |
1999 | If SecondString is NULL, then ASSERT().\r | |
2000 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
2001 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2002 | then ASSERT().\r | |
2003 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
2004 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
2005 | Null-terminator, then ASSERT().\r | |
2006 | \r | |
af2dc6a7 | 2007 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2008 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2009 | \r |
17f695ed | 2010 | @retval ==0 FirstString is identical to SecondString.\r |
2011 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 2012 | \r |
2013 | **/\r | |
2014 | INTN\r | |
2015 | EFIAPI\r | |
2016 | AsciiStrCmp (\r | |
2017 | IN CONST CHAR8 *FirstString,\r | |
2018 | IN CONST CHAR8 *SecondString\r | |
2019 | );\r | |
2020 | \r | |
2021 | \r | |
2022 | /**\r | |
2023 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
2024 | and returns the difference between the first mismatched ASCII characters.\r | |
2025 | \r | |
2026 | This function performs a case insensitive comparison of the Null-terminated\r | |
2027 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
2028 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
2029 | value returned is the first mismatched lower case ASCII character in\r | |
2030 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
2031 | in FirstString.\r | |
2032 | \r | |
2033 | If FirstString is NULL, then ASSERT().\r | |
2034 | If SecondString is NULL, then ASSERT().\r | |
2035 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
2036 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2037 | then ASSERT().\r | |
2038 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
2039 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
2040 | Null-terminator, then ASSERT().\r | |
2041 | \r | |
af2dc6a7 | 2042 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2043 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2044 | \r |
17f695ed | 2045 | @retval ==0 FirstString is identical to SecondString using case insensitive\r |
1106ffe1 | 2046 | comparisons.\r |
17f695ed | 2047 | @retval !=0 FirstString is not identical to SecondString using case\r |
1106ffe1 | 2048 | insensitive comparisons.\r |
ac644614 | 2049 | \r |
2050 | **/\r | |
2051 | INTN\r | |
2052 | EFIAPI\r | |
2053 | AsciiStriCmp (\r | |
2054 | IN CONST CHAR8 *FirstString,\r | |
2055 | IN CONST CHAR8 *SecondString\r | |
2056 | );\r | |
2057 | \r | |
2058 | \r | |
2059 | /**\r | |
2060 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
2061 | the difference between the first mismatched ASCII characters.\r | |
2062 | \r | |
2063 | This function compares the Null-terminated ASCII string FirstString to the\r | |
2064 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
2065 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
2066 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
2067 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
2068 | first mismatched ASCII character in FirstString.\r | |
2069 | \r | |
2070 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
2071 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
9095d37b | 2072 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
50c247fd | 2073 | PcdMaximumAsciiStringLength, then ASSERT().\r |
2074 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
2075 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 2076 | then ASSERT().\r |
50c247fd | 2077 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
2078 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 2079 | then ASSERT().\r |
2080 | \r | |
af2dc6a7 | 2081 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2082 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
2083 | @param Length The maximum number of ASCII characters for compare.\r | |
9095d37b | 2084 | \r |
17f695ed | 2085 | @retval ==0 FirstString is identical to SecondString.\r |
2086 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 2087 | \r |
2088 | **/\r | |
2089 | INTN\r | |
2090 | EFIAPI\r | |
2091 | AsciiStrnCmp (\r | |
2092 | IN CONST CHAR8 *FirstString,\r | |
2093 | IN CONST CHAR8 *SecondString,\r | |
2094 | IN UINTN Length\r | |
2095 | );\r | |
2096 | \r | |
2097 | \r | |
1bb390f1 ED |
2098 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
2099 | \r | |
ac644614 | 2100 | /**\r |
ae591c14 | 2101 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 2102 | \r |
ac644614 | 2103 | Concatenates one Null-terminated ASCII string to another Null-terminated\r |
2104 | ASCII string, and returns the concatenated ASCII string.\r | |
2105 | \r | |
2106 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
2107 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
2108 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
2109 | String is returned.\r | |
2110 | \r | |
2111 | If Destination is NULL, then ASSERT().\r | |
2112 | If Source is NULL, then ASSERT().\r | |
2113 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
2114 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2115 | then ASSERT().\r | |
2116 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
2117 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2118 | then ASSERT().\r | |
2119 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
2120 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
2121 | ASCII characters, then ASSERT().\r | |
2122 | \r | |
af2dc6a7 | 2123 | @param Destination The pointer to a Null-terminated ASCII string.\r |
2124 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2125 | \r |
2126 | @return Destination\r | |
2127 | \r | |
2128 | **/\r | |
2129 | CHAR8 *\r | |
2130 | EFIAPI\r | |
2131 | AsciiStrCat (\r | |
2132 | IN OUT CHAR8 *Destination,\r | |
2133 | IN CONST CHAR8 *Source\r | |
2134 | );\r | |
2135 | \r | |
2136 | \r | |
2137 | /**\r | |
ae591c14 | 2138 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 2139 | \r |
9095d37b LG |
2140 | Concatenates up to a specified length one Null-terminated ASCII string to\r |
2141 | the end of another Null-terminated ASCII string, and returns the\r | |
17f695ed | 2142 | concatenated ASCII string.\r |
ac644614 | 2143 | \r |
2144 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
2145 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
2146 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
2147 | Length ASCII characters are concatenated from Source to the end of\r | |
2148 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
2149 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
2150 | the results are undefined.\r | |
2151 | \r | |
2152 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
2153 | If Length > 0 and Source is NULL, then ASSERT().\r | |
2154 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 2155 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
2156 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
ac644614 | 2157 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r |
50c247fd | 2158 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 2159 | then ASSERT().\r |
2160 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
50c247fd | 2161 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 2162 | then ASSERT().\r |
2163 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
2164 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
50c247fd | 2165 | ASCII characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 2166 | \r |
af2dc6a7 | 2167 | @param Destination The pointer to a Null-terminated ASCII string.\r |
2168 | @param Source The pointer to a Null-terminated ASCII string.\r | |
2169 | @param Length The maximum number of ASCII characters to concatenate from\r | |
ac644614 | 2170 | Source.\r |
2171 | \r | |
2172 | @return Destination\r | |
2173 | \r | |
2174 | **/\r | |
2175 | CHAR8 *\r | |
2176 | EFIAPI\r | |
2177 | AsciiStrnCat (\r | |
2178 | IN OUT CHAR8 *Destination,\r | |
2179 | IN CONST CHAR8 *Source,\r | |
2180 | IN UINTN Length\r | |
2181 | );\r | |
de4f7f52 | 2182 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
ac644614 | 2183 | \r |
2184 | /**\r | |
9aa049d9 | 2185 | Returns the first occurrence of a Null-terminated ASCII sub-string\r |
ac644614 | 2186 | in a Null-terminated ASCII string.\r |
2187 | \r | |
2188 | This function scans the contents of the ASCII string specified by String\r | |
2189 | and returns the first occurrence of SearchString. If SearchString is not\r | |
2190 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
2191 | then String is returned.\r | |
2192 | \r | |
2193 | If String is NULL, then ASSERT().\r | |
2194 | If SearchString is NULL, then ASSERT().\r | |
2195 | \r | |
2196 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r | |
2197 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
2198 | not including the Null-terminator, then ASSERT().\r | |
2199 | \r | |
af2dc6a7 | 2200 | @param String The pointer to a Null-terminated ASCII string.\r |
2201 | @param SearchString The pointer to a Null-terminated ASCII string to search for.\r | |
ac644614 | 2202 | \r |
2203 | @retval NULL If the SearchString does not appear in String.\r | |
17f695ed | 2204 | @retval others If there is a match return the first occurrence of SearchingString.\r |
9aa049d9 | 2205 | If the length of SearchString is zero,return String.\r |
ac644614 | 2206 | \r |
2207 | **/\r | |
2208 | CHAR8 *\r | |
2209 | EFIAPI\r | |
2210 | AsciiStrStr (\r | |
17f695ed | 2211 | IN CONST CHAR8 *String,\r |
2212 | IN CONST CHAR8 *SearchString\r | |
ac644614 | 2213 | );\r |
2214 | \r | |
2215 | \r | |
2216 | /**\r | |
2217 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
2218 | UINTN.\r | |
2219 | \r | |
2220 | This function returns a value of type UINTN by interpreting the contents\r | |
2221 | of the ASCII string String as a decimal number. The format of the input\r | |
2222 | ASCII string String is:\r | |
2223 | \r | |
2224 | [spaces] [decimal digits].\r | |
2225 | \r | |
2226 | The valid decimal digit character is in the range [0-9]. The function will\r | |
2227 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
2228 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
2229 | function stops at the first character that is a not a valid decimal character or\r | |
2230 | Null-terminator, whichever on comes first.\r | |
2231 | \r | |
2232 | If String has only pad spaces, then 0 is returned.\r | |
2233 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
2234 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 2235 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 2236 | If String is NULL, then ASSERT().\r |
2237 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
2238 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2239 | then ASSERT().\r | |
2240 | \r | |
af2dc6a7 | 2241 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2242 | \r |
af2dc6a7 | 2243 | @retval The value translated from String.\r |
ac644614 | 2244 | \r |
2245 | **/\r | |
2246 | UINTN\r | |
2247 | EFIAPI\r | |
2248 | AsciiStrDecimalToUintn (\r | |
2249 | IN CONST CHAR8 *String\r | |
2250 | );\r | |
2251 | \r | |
2252 | \r | |
2253 | /**\r | |
2254 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
2255 | UINT64.\r | |
2256 | \r | |
2257 | This function returns a value of type UINT64 by interpreting the contents\r | |
2258 | of the ASCII string String as a decimal number. The format of the input\r | |
2259 | ASCII string String is:\r | |
2260 | \r | |
2261 | [spaces] [decimal digits].\r | |
2262 | \r | |
2263 | The valid decimal digit character is in the range [0-9]. The function will\r | |
2264 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
2265 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
2266 | function stops at the first character that is a not a valid decimal character or\r | |
2267 | Null-terminator, whichever on comes first.\r | |
2268 | \r | |
2269 | If String has only pad spaces, then 0 is returned.\r | |
2270 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
2271 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 2272 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 2273 | If String is NULL, then ASSERT().\r |
2274 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
2275 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2276 | then ASSERT().\r | |
2277 | \r | |
af2dc6a7 | 2278 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2279 | \r |
38bbd3d9 | 2280 | @retval Value translated from String.\r |
ac644614 | 2281 | \r |
2282 | **/\r | |
2283 | UINT64\r | |
2284 | EFIAPI\r | |
2285 | AsciiStrDecimalToUint64 (\r | |
17f695ed | 2286 | IN CONST CHAR8 *String\r |
ac644614 | 2287 | );\r |
2288 | \r | |
2289 | \r | |
2290 | /**\r | |
2291 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
2292 | \r | |
2293 | This function returns a value of type UINTN by interpreting the contents of\r | |
2294 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
2295 | string String is:\r | |
2296 | \r | |
2297 | [spaces][zeros][x][hexadecimal digits].\r | |
2298 | \r | |
2299 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
2300 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
2301 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
2302 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
2303 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
2304 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
2305 | digit. Then, the function stops at the first character that is a not a valid\r | |
2306 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
2307 | \r | |
2308 | If String has only pad spaces, then 0 is returned.\r | |
2309 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
2310 | 0 is returned.\r | |
2311 | \r | |
2312 | If the number represented by String overflows according to the range defined by UINTN,\r | |
ea2e0921 | 2313 | then MAX_UINTN is returned.\r |
ac644614 | 2314 | If String is NULL, then ASSERT().\r |
2315 | If PcdMaximumAsciiStringLength is not zero,\r | |
2316 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
2317 | the Null-terminator, then ASSERT().\r | |
2318 | \r | |
af2dc6a7 | 2319 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2320 | \r |
38bbd3d9 | 2321 | @retval Value translated from String.\r |
ac644614 | 2322 | \r |
2323 | **/\r | |
2324 | UINTN\r | |
2325 | EFIAPI\r | |
2326 | AsciiStrHexToUintn (\r | |
17f695ed | 2327 | IN CONST CHAR8 *String\r |
ac644614 | 2328 | );\r |
2329 | \r | |
2330 | \r | |
2331 | /**\r | |
2332 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
2333 | \r | |
2334 | This function returns a value of type UINT64 by interpreting the contents of\r | |
2335 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
2336 | string String is:\r | |
2337 | \r | |
2338 | [spaces][zeros][x][hexadecimal digits].\r | |
2339 | \r | |
2340 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
2341 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
2342 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
2343 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
2344 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
2345 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
2346 | digit. Then, the function stops at the first character that is a not a valid\r | |
2347 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
2348 | \r | |
2349 | If String has only pad spaces, then 0 is returned.\r | |
2350 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
2351 | 0 is returned.\r | |
2352 | \r | |
2353 | If the number represented by String overflows according to the range defined by UINT64,\r | |
ea2e0921 | 2354 | then MAX_UINT64 is returned.\r |
ac644614 | 2355 | If String is NULL, then ASSERT().\r |
2356 | If PcdMaximumAsciiStringLength is not zero,\r | |
2357 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
2358 | the Null-terminator, then ASSERT().\r | |
2359 | \r | |
af2dc6a7 | 2360 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2361 | \r |
38bbd3d9 | 2362 | @retval Value translated from String.\r |
ac644614 | 2363 | \r |
2364 | **/\r | |
2365 | UINT64\r | |
2366 | EFIAPI\r | |
2367 | AsciiStrHexToUint64 (\r | |
17f695ed | 2368 | IN CONST CHAR8 *String\r |
ac644614 | 2369 | );\r |
2370 | \r | |
fb4dd857 RN |
2371 | /**\r |
2372 | Convert a Null-terminated ASCII string to IPv6 address and prefix length.\r | |
2373 | \r | |
2374 | This function outputs a value of type IPv6_ADDRESS and may output a value\r | |
2375 | of type UINT8 by interpreting the contents of the ASCII string specified\r | |
2376 | by String. The format of the input ASCII string String is as follows:\r | |
2377 | \r | |
2378 | X:X:X:X:X:X:X:X[/P]\r | |
2379 | \r | |
2380 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r | |
2381 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r | |
2382 | memory address and high byte is stored in high memory address. P contains decimal\r | |
2383 | digit characters in the range [0-9]. The running zero in the beginning of P will\r | |
2384 | be ignored. /P is optional.\r | |
2385 | \r | |
2386 | When /P is not in the String, the function stops at the first character that is\r | |
2387 | not a valid hexadecimal digit character after eight X's are converted.\r | |
2388 | \r | |
2389 | When /P is in the String, the function stops at the first character that is not\r | |
2390 | a valid decimal digit character after P is converted.\r | |
2391 | \r | |
2392 | "::" can be used to compress one or more groups of X when X contains only 0.\r | |
2393 | The "::" can only appear once in the String.\r | |
2394 | \r | |
2395 | If String is NULL, then ASSERT().\r | |
2396 | \r | |
2397 | If Address is NULL, then ASSERT().\r | |
2398 | \r | |
2399 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
2400 | to the character that stopped the scan is stored at the location pointed to\r | |
2401 | by EndPointer.\r | |
2402 | \r | |
2403 | @param String Pointer to a Null-terminated ASCII string.\r | |
2404 | @param EndPointer Pointer to character that stops scan.\r | |
2405 | @param Address Pointer to the converted IPv6 address.\r | |
2406 | @param PrefixLength Pointer to the converted IPv6 address prefix\r | |
2407 | length. MAX_UINT8 is returned when /P is\r | |
2408 | not in the String.\r | |
2409 | \r | |
2410 | @retval RETURN_SUCCESS Address is translated from String.\r | |
2411 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2412 | If Data is NULL.\r | |
2413 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r | |
2414 | digit characters.\r | |
2415 | If String contains "::" and number of X\r | |
2416 | is not less than 8.\r | |
2417 | If P starts with character that is not a\r | |
2418 | valid decimal digit character.\r | |
2419 | If the decimal number converted from P\r | |
2420 | exceeds 128.\r | |
2421 | \r | |
2422 | **/\r | |
2423 | RETURN_STATUS\r | |
2424 | EFIAPI\r | |
2425 | AsciiStrToIpv6Address (\r | |
2426 | IN CONST CHAR8 *String,\r | |
2427 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
2428 | OUT IPv6_ADDRESS *Address,\r | |
2429 | OUT UINT8 *PrefixLength OPTIONAL\r | |
2430 | );\r | |
2431 | \r | |
2432 | /**\r | |
2433 | Convert a Null-terminated ASCII string to IPv4 address and prefix length.\r | |
2434 | \r | |
2435 | This function outputs a value of type IPv4_ADDRESS and may output a value\r | |
2436 | of type UINT8 by interpreting the contents of the ASCII string specified\r | |
2437 | by String. The format of the input ASCII string String is as follows:\r | |
2438 | \r | |
2439 | D.D.D.D[/P]\r | |
2440 | \r | |
2441 | D and P are decimal digit characters in the range [0-9]. The running zero in\r | |
2442 | the beginning of D and P will be ignored. /P is optional.\r | |
2443 | \r | |
2444 | When /P is not in the String, the function stops at the first character that is\r | |
2445 | not a valid decimal digit character after four D's are converted.\r | |
2446 | \r | |
2447 | When /P is in the String, the function stops at the first character that is not\r | |
2448 | a valid decimal digit character after P is converted.\r | |
2449 | \r | |
2450 | If String is NULL, then ASSERT().\r | |
2451 | \r | |
2452 | If Address is NULL, then ASSERT().\r | |
2453 | \r | |
2454 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
2455 | to the character that stopped the scan is stored at the location pointed to\r | |
2456 | by EndPointer.\r | |
2457 | \r | |
2458 | @param String Pointer to a Null-terminated ASCII string.\r | |
2459 | @param EndPointer Pointer to character that stops scan.\r | |
2460 | @param Address Pointer to the converted IPv4 address.\r | |
2461 | @param PrefixLength Pointer to the converted IPv4 address prefix\r | |
2462 | length. MAX_UINT8 is returned when /P is\r | |
2463 | not in the String.\r | |
2464 | \r | |
2465 | @retval RETURN_SUCCESS Address is translated from String.\r | |
2466 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2467 | If Data is NULL.\r | |
2468 | @retval RETURN_UNSUPPORTED If String is not in the correct format.\r | |
2469 | If any decimal number converted from D\r | |
2470 | exceeds 255.\r | |
2471 | If the decimal number converted from P\r | |
2472 | exceeds 32.\r | |
2473 | \r | |
2474 | **/\r | |
2475 | RETURN_STATUS\r | |
2476 | EFIAPI\r | |
2477 | AsciiStrToIpv4Address (\r | |
2478 | IN CONST CHAR8 *String,\r | |
2479 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
2480 | OUT IPv4_ADDRESS *Address,\r | |
2481 | OUT UINT8 *PrefixLength OPTIONAL\r | |
2482 | );\r | |
2483 | \r | |
2484 | /**\r | |
2485 | Convert a Null-terminated ASCII GUID string to a value of type\r | |
2486 | EFI_GUID.\r | |
2487 | \r | |
2488 | This function outputs a GUID value by interpreting the contents of\r | |
2489 | the ASCII string specified by String. The format of the input\r | |
2490 | ASCII string String consists of 36 characters, as follows:\r | |
2491 | \r | |
2492 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r | |
2493 | \r | |
2494 | The pairs aa - pp are two characters in the range [0-9], [a-f] and\r | |
2495 | [A-F], with each pair representing a single byte hexadecimal value.\r | |
2496 | \r | |
2497 | The mapping between String and the EFI_GUID structure is as follows:\r | |
2498 | aa Data1[24:31]\r | |
2499 | bb Data1[16:23]\r | |
2500 | cc Data1[8:15]\r | |
2501 | dd Data1[0:7]\r | |
2502 | ee Data2[8:15]\r | |
2503 | ff Data2[0:7]\r | |
2504 | gg Data3[8:15]\r | |
2505 | hh Data3[0:7]\r | |
2506 | ii Data4[0:7]\r | |
2507 | jj Data4[8:15]\r | |
2508 | kk Data4[16:23]\r | |
2509 | ll Data4[24:31]\r | |
2510 | mm Data4[32:39]\r | |
2511 | nn Data4[40:47]\r | |
2512 | oo Data4[48:55]\r | |
2513 | pp Data4[56:63]\r | |
2514 | \r | |
2515 | If String is NULL, then ASSERT().\r | |
2516 | If Guid is NULL, then ASSERT().\r | |
2517 | \r | |
2518 | @param String Pointer to a Null-terminated ASCII string.\r | |
2519 | @param Guid Pointer to the converted GUID.\r | |
2520 | \r | |
2521 | @retval RETURN_SUCCESS Guid is translated from String.\r | |
2522 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2523 | If Data is NULL.\r | |
2524 | @retval RETURN_UNSUPPORTED If String is not as the above format.\r | |
2525 | \r | |
2526 | **/\r | |
2527 | RETURN_STATUS\r | |
2528 | EFIAPI\r | |
2529 | AsciiStrToGuid (\r | |
2530 | IN CONST CHAR8 *String,\r | |
2531 | OUT GUID *Guid\r | |
2532 | );\r | |
2533 | \r | |
2534 | /**\r | |
2535 | Convert a Null-terminated ASCII hexadecimal string to a byte array.\r | |
2536 | \r | |
2537 | This function outputs a byte array by interpreting the contents of\r | |
2538 | the ASCII string specified by String in hexadecimal format. The format of\r | |
2539 | the input ASCII string String is:\r | |
2540 | \r | |
2541 | [XX]*\r | |
2542 | \r | |
2543 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r | |
2544 | The function decodes every two hexadecimal digit characters as one byte. The\r | |
2545 | decoding stops after Length of characters and outputs Buffer containing\r | |
2546 | (Length / 2) bytes.\r | |
2547 | \r | |
2548 | If String is NULL, then ASSERT().\r | |
2549 | \r | |
2550 | If Buffer is NULL, then ASSERT().\r | |
2551 | \r | |
2552 | If Length is not multiple of 2, then ASSERT().\r | |
2553 | \r | |
2554 | If PcdMaximumAsciiStringLength is not zero and Length is greater than\r | |
2555 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
2556 | \r | |
2557 | If MaxBufferSize is less than (Length / 2), then ASSERT().\r | |
2558 | \r | |
2559 | @param String Pointer to a Null-terminated ASCII string.\r | |
2560 | @param Length The number of ASCII characters to decode.\r | |
2561 | @param Buffer Pointer to the converted bytes array.\r | |
2562 | @param MaxBufferSize The maximum size of Buffer.\r | |
2563 | \r | |
2564 | @retval RETURN_SUCCESS Buffer is translated from String.\r | |
2565 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
2566 | If Data is NULL.\r | |
2567 | If Length is not multiple of 2.\r | |
2568 | If PcdMaximumAsciiStringLength is not zero,\r | |
2569 | and Length is greater than\r | |
2570 | PcdMaximumAsciiStringLength.\r | |
2571 | @retval RETURN_UNSUPPORTED If Length of characters from String contain\r | |
2572 | a character that is not valid hexadecimal\r | |
2573 | digit characters, or a Null-terminator.\r | |
2574 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r | |
2575 | **/\r | |
2576 | RETURN_STATUS\r | |
2577 | EFIAPI\r | |
2578 | AsciiStrHexToBytes (\r | |
2579 | IN CONST CHAR8 *String,\r | |
2580 | IN UINTN Length,\r | |
2581 | OUT UINT8 *Buffer,\r | |
2582 | IN UINTN MaxBufferSize\r | |
2583 | );\r | |
2584 | \r | |
415aa2f1 | 2585 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
ac644614 | 2586 | \r |
2587 | /**\r | |
415aa2f1 SZ |
2588 | [ATTENTION] This function is deprecated for security reason.\r |
2589 | \r | |
ac644614 | 2590 | Convert one Null-terminated ASCII string to a Null-terminated\r |
2591 | Unicode string and returns the Unicode string.\r | |
2592 | \r | |
2593 | This function converts the contents of the ASCII string Source to the Unicode\r | |
2594 | string Destination, and returns Destination. The function terminates the\r | |
2595 | Unicode string Destination by appending a Null-terminator character at the end.\r | |
2596 | The caller is responsible to make sure Destination points to a buffer with size\r | |
2597 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
2598 | \r | |
2599 | If Destination is NULL, then ASSERT().\r | |
2600 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2601 | If Source is NULL, then ASSERT().\r | |
2602 | If Source and Destination overlap, then ASSERT().\r | |
2603 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
2604 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2605 | then ASSERT().\r | |
2606 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
2607 | PcdMaximumUnicodeStringLength ASCII characters not including the\r | |
2608 | Null-terminator, then ASSERT().\r | |
2609 | \r | |
af2dc6a7 | 2610 | @param Source The pointer to a Null-terminated ASCII string.\r |
2611 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 2612 | \r |
9aa049d9 | 2613 | @return Destination.\r |
ac644614 | 2614 | \r |
2615 | **/\r | |
2616 | CHAR16 *\r | |
2617 | EFIAPI\r | |
2618 | AsciiStrToUnicodeStr (\r | |
17f695ed | 2619 | IN CONST CHAR8 *Source,\r |
2620 | OUT CHAR16 *Destination\r | |
ac644614 | 2621 | );\r |
2622 | \r | |
de4f7f52 | 2623 | #endif // !defined (DISABLE_NEW_DEPRECATED_INTERFACES)\r |
415aa2f1 | 2624 | \r |
3ab41b7a JY |
2625 | /**\r |
2626 | Convert one Null-terminated ASCII string to a Null-terminated\r | |
2627 | Unicode string.\r | |
2628 | \r | |
2629 | This function is similar to StrCpyS.\r | |
2630 | \r | |
2631 | This function converts the contents of the ASCII string Source to the Unicode\r | |
2632 | string Destination. The function terminates the Unicode string Destination by\r | |
2633 | appending a Null-terminator character at the end.\r | |
2634 | \r | |
2635 | The caller is responsible to make sure Destination points to a buffer with size\r | |
2636 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
2637 | \r | |
2638 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2639 | If an error would be returned, then the function will also ASSERT().\r | |
2640 | \r | |
2641 | If an error is returned, then the Destination is unmodified.\r | |
2642 | \r | |
2643 | @param Source The pointer to a Null-terminated ASCII string.\r | |
2644 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2645 | @param DestMax The maximum number of Destination Unicode\r | |
2646 | char, including terminating null char.\r | |
2647 | \r | |
2648 | @retval RETURN_SUCCESS String is converted.\r | |
2649 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
2650 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2651 | If Source is NULL.\r | |
2652 | If PcdMaximumUnicodeStringLength is not zero,\r | |
2653 | and DestMax is greater than\r | |
2654 | PcdMaximumUnicodeStringLength.\r | |
2655 | If PcdMaximumAsciiStringLength is not zero,\r | |
2656 | and DestMax is greater than\r | |
2657 | PcdMaximumAsciiStringLength.\r | |
2658 | If DestMax is 0.\r | |
2659 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2660 | \r | |
2661 | **/\r | |
2662 | RETURN_STATUS\r | |
2663 | EFIAPI\r | |
2664 | AsciiStrToUnicodeStrS (\r | |
2665 | IN CONST CHAR8 *Source,\r | |
2666 | OUT CHAR16 *Destination,\r | |
2667 | IN UINTN DestMax\r | |
2668 | );\r | |
ac644614 | 2669 | \r |
02263214 HW |
2670 | /**\r |
2671 | Convert not more than Length successive characters from a Null-terminated\r | |
2672 | Ascii string to a Null-terminated Unicode string. If no null char is copied\r | |
2673 | from Source, then Destination[Length] is always set to null.\r | |
2674 | \r | |
2675 | This function converts not more than Length successive characters from the\r | |
2676 | Ascii string Source to the Unicode string Destination. The function\r | |
2677 | terminates the Unicode string Destination by appending a Null-terminator\r | |
2678 | character at the end.\r | |
2679 | \r | |
2680 | The caller is responsible to make sure Destination points to a buffer with\r | |
2681 | size not smaller than\r | |
2682 | ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r | |
2683 | \r | |
2684 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2685 | If an error would be returned, then the function will also ASSERT().\r | |
2686 | \r | |
2687 | If an error is returned, then Destination and DestinationLength are\r | |
2688 | unmodified.\r | |
2689 | \r | |
2690 | @param Source The pointer to a Null-terminated Ascii string.\r | |
2691 | @param Length The maximum number of Ascii characters to convert.\r | |
2692 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2693 | @param DestMax The maximum number of Destination Unicode char,\r | |
2694 | including terminating null char.\r | |
2695 | @param DestinationLength The number of Ascii characters converted.\r | |
2696 | \r | |
2697 | @retval RETURN_SUCCESS String is converted.\r | |
2698 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2699 | If Source is NULL.\r | |
2700 | If DestinationLength is NULL.\r | |
2701 | If PcdMaximumUnicodeStringLength is not\r | |
2702 | zero, and Length or DestMax is greater than\r | |
2703 | PcdMaximumUnicodeStringLength.\r | |
2704 | If PcdMaximumAsciiStringLength is not zero,\r | |
2705 | and Length or DestMax is greater than\r | |
2706 | PcdMaximumAsciiStringLength.\r | |
2707 | If DestMax is 0.\r | |
2708 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
2709 | MIN(AsciiStrLen(Source), Length).\r | |
2710 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2711 | \r | |
2712 | **/\r | |
2713 | RETURN_STATUS\r | |
2714 | EFIAPI\r | |
2715 | AsciiStrnToUnicodeStrS (\r | |
2716 | IN CONST CHAR8 *Source,\r | |
2717 | IN UINTN Length,\r | |
2718 | OUT CHAR16 *Destination,\r | |
2719 | IN UINTN DestMax,\r | |
2720 | OUT UINTN *DestinationLength\r | |
2721 | );\r | |
2722 | \r | |
5dbfa01e MT |
2723 | /**\r |
2724 | Convert a Unicode character to upper case only if\r | |
2725 | it maps to a valid small-case ASCII character.\r | |
2726 | \r | |
2727 | This internal function only deal with Unicode character\r | |
2728 | which maps to a valid small-case ASCII character, i.e.\r | |
2729 | L'a' to L'z'. For other Unicode character, the input character\r | |
2730 | is returned directly.\r | |
2731 | \r | |
2732 | @param Char The character to convert.\r | |
2733 | \r | |
2734 | @retval LowerCharacter If the Char is with range L'a' to L'z'.\r | |
2735 | @retval Unchanged Otherwise.\r | |
2736 | \r | |
2737 | **/\r | |
2738 | CHAR16\r | |
2739 | EFIAPI\r | |
2740 | CharToUpper (\r | |
2741 | IN CHAR16 Char\r | |
2742 | );\r | |
2743 | \r | |
2744 | /**\r | |
2745 | Converts a lowercase Ascii character to upper one.\r | |
2746 | \r | |
2747 | If Chr is lowercase Ascii character, then converts it to upper one.\r | |
2748 | \r | |
2749 | If Value >= 0xA0, then ASSERT().\r | |
2750 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2751 | \r | |
2752 | @param Chr one Ascii character\r | |
2753 | \r | |
2754 | @return The uppercase value of Ascii character\r | |
2755 | \r | |
2756 | **/\r | |
2757 | CHAR8\r | |
2758 | EFIAPI\r | |
2759 | AsciiCharToUpper (\r | |
2760 | IN CHAR8 Chr\r | |
2761 | );\r | |
2762 | \r | |
1f7af69d MT |
2763 | /**\r |
2764 | Convert binary data to a Base64 encoded ascii string based on RFC4648.\r | |
2765 | \r | |
2766 | Produce a Null-terminated Ascii string in the output buffer specified by Destination and DestinationSize.\r | |
2767 | The Ascii string is produced by converting the data string specified by Source and SourceLength.\r | |
2768 | \r | |
2769 | @param Source Input UINT8 data\r | |
2770 | @param SourceLength Number of UINT8 bytes of data\r | |
2771 | @param Destination Pointer to output string buffer\r | |
2772 | @param DestinationSize Size of ascii buffer. Set to 0 to get the size needed.\r | |
2773 | Caller is responsible for passing in buffer of DestinationSize\r | |
2774 | \r | |
2775 | @retval RETURN_SUCCESS When ascii buffer is filled in.\r | |
2776 | @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.\r | |
2777 | @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS - (UINTN)Destination).\r | |
2778 | @retval RETURN_BUFFER_TOO_SMALL If SourceLength is 0 and DestinationSize is <1.\r | |
2779 | @retval RETURN_BUFFER_TOO_SMALL If Destination is NULL or DestinationSize is smaller than required buffersize.\r | |
2780 | \r | |
2781 | **/\r | |
2782 | RETURN_STATUS\r | |
2783 | EFIAPI\r | |
2784 | Base64Encode (\r | |
2785 | IN CONST UINT8 *Source,\r | |
2786 | IN UINTN SourceLength,\r | |
2787 | OUT CHAR8 *Destination OPTIONAL,\r | |
2788 | IN OUT UINTN *DestinationSize\r | |
2789 | );\r | |
2790 | \r | |
2791 | /**\r | |
2792 | Convert Base64 ascii string to binary data based on RFC4648.\r | |
2793 | \r | |
2794 | Produce Null-terminated binary data in the output buffer specified by Destination and DestinationSize.\r | |
2795 | The binary data is produced by converting the Base64 ascii string specified by Source and SourceLength.\r | |
2796 | \r | |
2797 | @param Source Input ASCII characters\r | |
2798 | @param SourceLength Number of ASCII characters\r | |
2799 | @param Destination Pointer to output buffer\r | |
2800 | @param DestinationSize Caller is responsible for passing in buffer of at least DestinationSize.\r | |
2801 | Set 0 to get the size needed. Set to bytes stored on return.\r | |
2802 | \r | |
2803 | @retval RETURN_SUCCESS When binary buffer is filled in.\r | |
2804 | @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize is NULL.\r | |
2805 | @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is bigger than (MAX_ADDRESS -(UINTN)Destination ).\r | |
2806 | @retval RETURN_INVALID_PARAMETER If there is any invalid character in input stream.\r | |
2807 | @retval RETURN_BUFFER_TOO_SMALL If buffer length is smaller than required buffer size.\r | |
2808 | \r | |
2809 | **/\r | |
2810 | RETURN_STATUS\r | |
2811 | EFIAPI\r | |
2812 | Base64Decode (\r | |
2813 | IN CONST CHAR8 *Source,\r | |
2814 | IN UINTN SourceLength,\r | |
2815 | OUT UINT8 *Destination OPTIONAL,\r | |
2816 | IN OUT UINTN *DestinationSize\r | |
2817 | );\r | |
2818 | \r | |
ac644614 | 2819 | /**\r |
2820 | Converts an 8-bit value to an 8-bit BCD value.\r | |
2821 | \r | |
2822 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
2823 | returned.\r | |
2824 | \r | |
2825 | If Value >= 100, then ASSERT().\r | |
2826 | \r | |
2827 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
2828 | \r | |
9aa049d9 | 2829 | @return The BCD value.\r |
ac644614 | 2830 | \r |
2831 | **/\r | |
2832 | UINT8\r | |
2833 | EFIAPI\r | |
2834 | DecimalToBcd8 (\r | |
2835 | IN UINT8 Value\r | |
2836 | );\r | |
2837 | \r | |
2838 | \r | |
2839 | /**\r | |
2840 | Converts an 8-bit BCD value to an 8-bit value.\r | |
2841 | \r | |
2842 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
2843 | value is returned.\r | |
2844 | \r | |
2845 | If Value >= 0xA0, then ASSERT().\r | |
2846 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2847 | \r | |
2848 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
2849 | \r | |
2850 | @return The 8-bit value is returned.\r | |
2851 | \r | |
2852 | **/\r | |
2853 | UINT8\r | |
2854 | EFIAPI\r | |
2855 | BcdToDecimal8 (\r | |
2856 | IN UINT8 Value\r | |
2857 | );\r | |
2858 | \r | |
ae591c14 DM |
2859 | //\r |
2860 | // File Path Manipulation Functions\r | |
2861 | //\r | |
2862 | \r | |
2863 | /**\r | |
6a623094 | 2864 | Removes the last directory or file entry in a path.\r |
ae591c14 DM |
2865 | \r |
2866 | @param[in, out] Path The pointer to the path to modify.\r | |
2867 | \r | |
2868 | @retval FALSE Nothing was found to remove.\r | |
2869 | @retval TRUE A directory or file was removed.\r | |
2870 | **/\r | |
2871 | BOOLEAN\r | |
2872 | EFIAPI\r | |
2873 | PathRemoveLastItem(\r | |
2874 | IN OUT CHAR16 *Path\r | |
2875 | );\r | |
2876 | \r | |
2877 | /**\r | |
2878 | Function to clean up paths.\r | |
2879 | - Single periods in the path are removed.\r | |
2880 | - Double periods in the path are removed along with a single parent directory.\r | |
2881 | - Forward slashes L'/' are converted to backward slashes L'\'.\r | |
2882 | \r | |
2883 | This will be done inline and the existing buffer may be larger than required\r | |
2884 | upon completion.\r | |
2885 | \r | |
2886 | @param[in] Path The pointer to the string containing the path.\r | |
2887 | \r | |
00b7cc0f | 2888 | @return Returns Path, otherwise returns NULL to indicate that an error has occurred.\r |
ae591c14 DM |
2889 | **/\r |
2890 | CHAR16*\r | |
2891 | EFIAPI\r | |
2892 | PathCleanUpDirectories(\r | |
2893 | IN CHAR16 *Path\r | |
909ac47b | 2894 | );\r |
ac644614 | 2895 | \r |
2896 | //\r | |
2897 | // Linked List Functions and Macros\r | |
2898 | //\r | |
2899 | \r | |
2900 | /**\r | |
2901 | Initializes the head node of a doubly linked list that is declared as a\r | |
2902 | global variable in a module.\r | |
2903 | \r | |
2904 | Initializes the forward and backward links of a new linked list. After\r | |
2905 | initializing a linked list with this macro, the other linked list functions\r | |
2906 | may be used to add and remove nodes from the linked list. This macro results\r | |
2907 | in smaller executables by initializing the linked list in the data section,\r | |
2908 | instead if calling the InitializeListHead() function to perform the\r | |
2909 | equivalent operation.\r | |
2910 | \r | |
77f863ee | 2911 | @param ListHead The head note of a list to initialize.\r |
ac644614 | 2912 | \r |
2913 | **/\r | |
17f695ed | 2914 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r |
ac644614 | 2915 | \r |
2916 | \r | |
d0aef615 MH |
2917 | /**\r |
2918 | Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r | |
2919 | list.\r | |
2920 | \r | |
2921 | If FirstEntry is NULL, then ASSERT().\r | |
2922 | If FirstEntry->ForwardLink is NULL, then ASSERT().\r | |
2923 | If FirstEntry->BackLink is NULL, then ASSERT().\r | |
2924 | If SecondEntry is NULL, then ASSERT();\r | |
2925 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r | |
2926 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
2927 | \r | |
2928 | @param FirstEntry A pointer to a node in a linked list.\r | |
2929 | @param SecondEntry A pointer to the node to locate.\r | |
2930 | \r | |
2931 | @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.\r | |
2932 | @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,\r | |
2933 | or FirstEntry is invalid.\r | |
2934 | \r | |
2935 | **/\r | |
2936 | BOOLEAN\r | |
2937 | EFIAPI\r | |
2938 | IsNodeInList (\r | |
2939 | IN CONST LIST_ENTRY *FirstEntry,\r | |
2940 | IN CONST LIST_ENTRY *SecondEntry\r | |
2941 | );\r | |
2942 | \r | |
2943 | \r | |
ac644614 | 2944 | /**\r |
2945 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
2946 | the head node of the doubly linked list.\r | |
2947 | \r | |
2948 | Initializes the forward and backward links of a new linked list. After\r | |
2949 | initializing a linked list with this function, the other linked list\r | |
2950 | functions may be used to add and remove nodes from the linked list. It is up\r | |
2951 | to the caller of this function to allocate the memory for ListHead.\r | |
2952 | \r | |
2953 | If ListHead is NULL, then ASSERT().\r | |
2954 | \r | |
2955 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
2956 | \r | |
2957 | @return ListHead\r | |
2958 | \r | |
2959 | **/\r | |
2960 | LIST_ENTRY *\r | |
2961 | EFIAPI\r | |
2962 | InitializeListHead (\r | |
aa0583c7 | 2963 | IN OUT LIST_ENTRY *ListHead\r |
ac644614 | 2964 | );\r |
2965 | \r | |
2966 | \r | |
2967 | /**\r | |
2968 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
2969 | to the head node of the doubly linked list.\r | |
2970 | \r | |
2971 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
2972 | ListHead, and returns ListHead.\r | |
2973 | \r | |
2974 | If ListHead is NULL, then ASSERT().\r | |
2975 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 2976 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
2977 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2978 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 2979 | of nodes in ListHead, including the ListHead node, is greater than or\r |
2980 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2981 | \r | |
2982 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2983 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
2984 | of a doubly linked list.\r | |
2985 | \r | |
2986 | @return ListHead\r | |
2987 | \r | |
2988 | **/\r | |
2989 | LIST_ENTRY *\r | |
2990 | EFIAPI\r | |
2991 | InsertHeadList (\r | |
aa0583c7 | 2992 | IN OUT LIST_ENTRY *ListHead,\r |
2993 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 2994 | );\r |
2995 | \r | |
2996 | \r | |
2997 | /**\r | |
2998 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
2999 | the head node of the doubly linked list.\r | |
3000 | \r | |
3001 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
3002 | and returns ListHead.\r | |
3003 | \r | |
3004 | If ListHead is NULL, then ASSERT().\r | |
3005 | If Entry is NULL, then ASSERT().\r | |
9095d37b | 3006 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3007 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3008 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 3009 | of nodes in ListHead, including the ListHead node, is greater than or\r |
3010 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
3011 | \r | |
3012 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
3013 | @param Entry A pointer to a node that is to be added at the end of the\r | |
3014 | doubly linked list.\r | |
3015 | \r | |
3016 | @return ListHead\r | |
3017 | \r | |
3018 | **/\r | |
3019 | LIST_ENTRY *\r | |
3020 | EFIAPI\r | |
3021 | InsertTailList (\r | |
aa0583c7 | 3022 | IN OUT LIST_ENTRY *ListHead,\r |
3023 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 3024 | );\r |
3025 | \r | |
3026 | \r | |
3027 | /**\r | |
3028 | Retrieves the first node of a doubly linked list.\r | |
3029 | \r | |
9095d37b | 3030 | Returns the first node of a doubly linked list. List must have been\r |
17f695ed | 3031 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
3032 | If List is empty, then List is returned.\r | |
ac644614 | 3033 | \r |
3034 | If List is NULL, then ASSERT().\r | |
9095d37b | 3035 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3036 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3037 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3038 | in List, including the List node, is greater than or equal to\r |
3039 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3040 | \r | |
3041 | @param List A pointer to the head node of a doubly linked list.\r | |
3042 | \r | |
3043 | @return The first node of a doubly linked list.\r | |
e01a125f | 3044 | @retval List The list is empty.\r |
ac644614 | 3045 | \r |
3046 | **/\r | |
3047 | LIST_ENTRY *\r | |
3048 | EFIAPI\r | |
3049 | GetFirstNode (\r | |
3050 | IN CONST LIST_ENTRY *List\r | |
3051 | );\r | |
3052 | \r | |
3053 | \r | |
3054 | /**\r | |
3055 | Retrieves the next node of a doubly linked list.\r | |
3056 | \r | |
9095d37b | 3057 | Returns the node of a doubly linked list that follows Node.\r |
17f695ed | 3058 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
3059 | or InitializeListHead(). If List is empty, then List is returned.\r | |
ac644614 | 3060 | \r |
3061 | If List is NULL, then ASSERT().\r | |
3062 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3063 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3064 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
3065 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
3066 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
1081f624 | 3067 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 3068 | \r |
3069 | @param List A pointer to the head node of a doubly linked list.\r | |
3070 | @param Node A pointer to a node in the doubly linked list.\r | |
3071 | \r | |
af2dc6a7 | 3072 | @return The pointer to the next node if one exists. Otherwise List is returned.\r |
ac644614 | 3073 | \r |
3074 | **/\r | |
3075 | LIST_ENTRY *\r | |
3076 | EFIAPI\r | |
3077 | GetNextNode (\r | |
3078 | IN CONST LIST_ENTRY *List,\r | |
3079 | IN CONST LIST_ENTRY *Node\r | |
3080 | );\r | |
3081 | \r | |
9095d37b | 3082 | \r |
cbca8de5 | 3083 | /**\r |
3084 | Retrieves the previous node of a doubly linked list.\r | |
9095d37b LG |
3085 | \r |
3086 | Returns the node of a doubly linked list that precedes Node.\r | |
cbca8de5 | 3087 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
3088 | or InitializeListHead(). If List is empty, then List is returned.\r | |
9095d37b | 3089 | \r |
cbca8de5 | 3090 | If List is NULL, then ASSERT().\r |
3091 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3092 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
cbca8de5 | 3093 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
3094 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
3095 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
cbca8de5 | 3096 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
9095d37b | 3097 | \r |
cbca8de5 | 3098 | @param List A pointer to the head node of a doubly linked list.\r |
3099 | @param Node A pointer to a node in the doubly linked list.\r | |
9095d37b | 3100 | \r |
af2dc6a7 | 3101 | @return The pointer to the previous node if one exists. Otherwise List is returned.\r |
9095d37b | 3102 | \r |
cbca8de5 | 3103 | **/\r |
3104 | LIST_ENTRY *\r | |
3105 | EFIAPI\r | |
3106 | GetPreviousNode (\r | |
3107 | IN CONST LIST_ENTRY *List,\r | |
3108 | IN CONST LIST_ENTRY *Node\r | |
3109 | );\r | |
ac644614 | 3110 | \r |
9095d37b | 3111 | \r |
ac644614 | 3112 | /**\r |
3113 | Checks to see if a doubly linked list is empty or not.\r | |
3114 | \r | |
3115 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
3116 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
3117 | \r | |
3118 | If ListHead is NULL, then ASSERT().\r | |
9095d37b | 3119 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3120 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3121 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3122 | in List, including the List node, is greater than or equal to\r |
3123 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3124 | \r | |
3125 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
3126 | \r | |
3127 | @retval TRUE The linked list is empty.\r | |
3128 | @retval FALSE The linked list is not empty.\r | |
3129 | \r | |
3130 | **/\r | |
3131 | BOOLEAN\r | |
3132 | EFIAPI\r | |
3133 | IsListEmpty (\r | |
3134 | IN CONST LIST_ENTRY *ListHead\r | |
3135 | );\r | |
3136 | \r | |
3137 | \r | |
3138 | /**\r | |
aa0583c7 | 3139 | Determines if a node in a doubly linked list is the head node of a the same\r |
3140 | doubly linked list. This function is typically used to terminate a loop that\r | |
3141 | traverses all the nodes in a doubly linked list starting with the head node.\r | |
ac644614 | 3142 | \r |
aa0583c7 | 3143 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r |
3144 | nodes in the doubly linked list specified by List. List must have been\r | |
17f695ed | 3145 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 3146 | \r |
3147 | If List is NULL, then ASSERT().\r | |
3148 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3149 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),\r |
17f695ed | 3150 | then ASSERT().\r |
a71865b1 | 3151 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3152 | in List, including the List node, is greater than or equal to\r |
3153 | PcdMaximumLinkedListLength, then ASSERT().\r | |
9095d37b | 3154 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal\r |
1081f624 | 3155 | to List, then ASSERT().\r |
ac644614 | 3156 | \r |
3157 | @param List A pointer to the head node of a doubly linked list.\r | |
3158 | @param Node A pointer to a node in the doubly linked list.\r | |
3159 | \r | |
1955808d LG |
3160 | @retval TRUE Node is the head of the doubly-linked list pointed by List.\r |
3161 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r | |
ac644614 | 3162 | \r |
3163 | **/\r | |
3164 | BOOLEAN\r | |
3165 | EFIAPI\r | |
3166 | IsNull (\r | |
3167 | IN CONST LIST_ENTRY *List,\r | |
3168 | IN CONST LIST_ENTRY *Node\r | |
3169 | );\r | |
3170 | \r | |
3171 | \r | |
3172 | /**\r | |
3173 | Determines if a node the last node in a doubly linked list.\r | |
3174 | \r | |
3175 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
3176 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
17f695ed | 3177 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 3178 | \r |
3179 | If List is NULL, then ASSERT().\r | |
3180 | If Node is NULL, then ASSERT().\r | |
17f695ed | 3181 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
3182 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 3183 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3184 | in List, including the List node, is greater than or equal to\r |
3185 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 3186 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 3187 | \r |
3188 | @param List A pointer to the head node of a doubly linked list.\r | |
3189 | @param Node A pointer to a node in the doubly linked list.\r | |
3190 | \r | |
3191 | @retval TRUE Node is the last node in the linked list.\r | |
3192 | @retval FALSE Node is not the last node in the linked list.\r | |
3193 | \r | |
3194 | **/\r | |
3195 | BOOLEAN\r | |
3196 | EFIAPI\r | |
3197 | IsNodeAtEnd (\r | |
3198 | IN CONST LIST_ENTRY *List,\r | |
3199 | IN CONST LIST_ENTRY *Node\r | |
3200 | );\r | |
3201 | \r | |
3202 | \r | |
3203 | /**\r | |
3204 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
3205 | first node after the swap.\r | |
3206 | \r | |
3207 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
3208 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
3209 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
3210 | same double linked list as FirstEntry and that double linked list must have\r | |
9095d37b | 3211 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
17f695ed | 3212 | SecondEntry is returned after the nodes are swapped.\r |
ac644614 | 3213 | \r |
3214 | If FirstEntry is NULL, then ASSERT().\r | |
3215 | If SecondEntry is NULL, then ASSERT().\r | |
9095d37b | 3216 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the\r |
1081f624 | 3217 | same linked list, then ASSERT().\r |
ac644614 | 3218 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r |
3219 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
3220 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
3221 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3222 | \r | |
3223 | @param FirstEntry A pointer to a node in a linked list.\r | |
3224 | @param SecondEntry A pointer to another node in the same linked list.\r | |
9095d37b | 3225 | \r |
9aa049d9 | 3226 | @return SecondEntry.\r |
ac644614 | 3227 | \r |
3228 | **/\r | |
3229 | LIST_ENTRY *\r | |
3230 | EFIAPI\r | |
3231 | SwapListEntries (\r | |
aa0583c7 | 3232 | IN OUT LIST_ENTRY *FirstEntry,\r |
3233 | IN OUT LIST_ENTRY *SecondEntry\r | |
ac644614 | 3234 | );\r |
3235 | \r | |
3236 | \r | |
3237 | /**\r | |
3238 | Removes a node from a doubly linked list, and returns the node that follows\r | |
3239 | the removed node.\r | |
3240 | \r | |
3241 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
3242 | this function to release the memory used by this node if that is required. On\r | |
3243 | exit, the node following Entry in the doubly linked list is returned. If\r | |
3244 | Entry is the only node in the linked list, then the head node of the linked\r | |
3245 | list is returned.\r | |
3246 | \r | |
3247 | If Entry is NULL, then ASSERT().\r | |
3248 | If Entry is the head node of an empty list, then ASSERT().\r | |
3249 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
3250 | linked list containing Entry, including the Entry node, is greater than\r | |
3251 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
3252 | \r | |
9aa049d9 | 3253 | @param Entry A pointer to a node in a linked list.\r |
ac644614 | 3254 | \r |
9aa049d9 | 3255 | @return Entry.\r |
ac644614 | 3256 | \r |
3257 | **/\r | |
3258 | LIST_ENTRY *\r | |
3259 | EFIAPI\r | |
3260 | RemoveEntryList (\r | |
3261 | IN CONST LIST_ENTRY *Entry\r | |
3262 | );\r | |
3263 | \r | |
3264 | //\r | |
3265 | // Math Services\r | |
3266 | //\r | |
3267 | \r | |
3268 | /**\r | |
3269 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
3270 | with zeros. The shifted value is returned.\r | |
3271 | \r | |
3272 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
3273 | low Count bits are set to zero. The shifted value is returned.\r | |
3274 | \r | |
3275 | If Count is greater than 63, then ASSERT().\r | |
3276 | \r | |
3277 | @param Operand The 64-bit operand to shift left.\r | |
3278 | @param Count The number of bits to shift left.\r | |
3279 | \r | |
9aa049d9 | 3280 | @return Operand << Count.\r |
ac644614 | 3281 | \r |
3282 | **/\r | |
3283 | UINT64\r | |
3284 | EFIAPI\r | |
3285 | LShiftU64 (\r | |
3286 | IN UINT64 Operand,\r | |
3287 | IN UINTN Count\r | |
3288 | );\r | |
3289 | \r | |
3290 | \r | |
3291 | /**\r | |
3292 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
3293 | filled with zeros. The shifted value is returned.\r | |
3294 | \r | |
3295 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3296 | high Count bits are set to zero. The shifted value is returned.\r | |
3297 | \r | |
3298 | If Count is greater than 63, then ASSERT().\r | |
3299 | \r | |
3300 | @param Operand The 64-bit operand to shift right.\r | |
3301 | @param Count The number of bits to shift right.\r | |
3302 | \r | |
3303 | @return Operand >> Count\r | |
3304 | \r | |
3305 | **/\r | |
3306 | UINT64\r | |
3307 | EFIAPI\r | |
3308 | RShiftU64 (\r | |
3309 | IN UINT64 Operand,\r | |
3310 | IN UINTN Count\r | |
3311 | );\r | |
3312 | \r | |
3313 | \r | |
3314 | /**\r | |
3315 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
3316 | with original integer's bit 63. The shifted value is returned.\r | |
3317 | \r | |
3318 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3319 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
3320 | \r | |
3321 | If Count is greater than 63, then ASSERT().\r | |
3322 | \r | |
3323 | @param Operand The 64-bit operand to shift right.\r | |
3324 | @param Count The number of bits to shift right.\r | |
3325 | \r | |
3326 | @return Operand >> Count\r | |
3327 | \r | |
3328 | **/\r | |
3329 | UINT64\r | |
3330 | EFIAPI\r | |
3331 | ARShiftU64 (\r | |
3332 | IN UINT64 Operand,\r | |
3333 | IN UINTN Count\r | |
3334 | );\r | |
3335 | \r | |
3336 | \r | |
3337 | /**\r | |
3338 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
3339 | with the high bits that were rotated.\r | |
3340 | \r | |
3341 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
3342 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3343 | value is returned.\r | |
3344 | \r | |
3345 | If Count is greater than 31, then ASSERT().\r | |
3346 | \r | |
3347 | @param Operand The 32-bit operand to rotate left.\r | |
3348 | @param Count The number of bits to rotate left.\r | |
3349 | \r | |
17f695ed | 3350 | @return Operand << Count\r |
ac644614 | 3351 | \r |
3352 | **/\r | |
3353 | UINT32\r | |
3354 | EFIAPI\r | |
3355 | LRotU32 (\r | |
3356 | IN UINT32 Operand,\r | |
3357 | IN UINTN Count\r | |
3358 | );\r | |
3359 | \r | |
3360 | \r | |
3361 | /**\r | |
3362 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
3363 | with the low bits that were rotated.\r | |
3364 | \r | |
3365 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
3366 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3367 | value is returned.\r | |
3368 | \r | |
3369 | If Count is greater than 31, then ASSERT().\r | |
3370 | \r | |
3371 | @param Operand The 32-bit operand to rotate right.\r | |
3372 | @param Count The number of bits to rotate right.\r | |
3373 | \r | |
2fe241a2 | 3374 | @return Operand >> Count\r |
ac644614 | 3375 | \r |
3376 | **/\r | |
3377 | UINT32\r | |
3378 | EFIAPI\r | |
3379 | RRotU32 (\r | |
3380 | IN UINT32 Operand,\r | |
3381 | IN UINTN Count\r | |
3382 | );\r | |
3383 | \r | |
3384 | \r | |
3385 | /**\r | |
3386 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
3387 | with the high bits that were rotated.\r | |
3388 | \r | |
3389 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
3390 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3391 | value is returned.\r | |
3392 | \r | |
3393 | If Count is greater than 63, then ASSERT().\r | |
3394 | \r | |
3395 | @param Operand The 64-bit operand to rotate left.\r | |
3396 | @param Count The number of bits to rotate left.\r | |
3397 | \r | |
17f695ed | 3398 | @return Operand << Count\r |
ac644614 | 3399 | \r |
3400 | **/\r | |
3401 | UINT64\r | |
3402 | EFIAPI\r | |
3403 | LRotU64 (\r | |
3404 | IN UINT64 Operand,\r | |
3405 | IN UINTN Count\r | |
3406 | );\r | |
3407 | \r | |
3408 | \r | |
3409 | /**\r | |
3410 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
3411 | with the high low bits that were rotated.\r | |
3412 | \r | |
3413 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
3414 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3415 | value is returned.\r | |
3416 | \r | |
3417 | If Count is greater than 63, then ASSERT().\r | |
3418 | \r | |
3419 | @param Operand The 64-bit operand to rotate right.\r | |
3420 | @param Count The number of bits to rotate right.\r | |
3421 | \r | |
17f695ed | 3422 | @return Operand >> Count\r |
ac644614 | 3423 | \r |
3424 | **/\r | |
3425 | UINT64\r | |
3426 | EFIAPI\r | |
3427 | RRotU64 (\r | |
3428 | IN UINT64 Operand,\r | |
3429 | IN UINTN Count\r | |
3430 | );\r | |
3431 | \r | |
3432 | \r | |
3433 | /**\r | |
3434 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
3435 | \r | |
3436 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
3437 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3438 | Otherwise, a value between 0 and 31 is returned.\r | |
3439 | \r | |
3440 | @param Operand The 32-bit operand to evaluate.\r | |
3441 | \r | |
9aa049d9 | 3442 | @retval 0..31 The lowest bit set in Operand was found.\r |
17f695ed | 3443 | @retval -1 Operand is zero.\r |
ac644614 | 3444 | \r |
3445 | **/\r | |
3446 | INTN\r | |
3447 | EFIAPI\r | |
3448 | LowBitSet32 (\r | |
3449 | IN UINT32 Operand\r | |
3450 | );\r | |
3451 | \r | |
3452 | \r | |
3453 | /**\r | |
3454 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
3455 | \r | |
3456 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
3457 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3458 | Otherwise, a value between 0 and 63 is returned.\r | |
3459 | \r | |
3460 | @param Operand The 64-bit operand to evaluate.\r | |
3461 | \r | |
9aa049d9 | 3462 | @retval 0..63 The lowest bit set in Operand was found.\r |
17f695ed | 3463 | @retval -1 Operand is zero.\r |
3464 | \r | |
ac644614 | 3465 | \r |
3466 | **/\r | |
3467 | INTN\r | |
3468 | EFIAPI\r | |
3469 | LowBitSet64 (\r | |
3470 | IN UINT64 Operand\r | |
3471 | );\r | |
3472 | \r | |
3473 | \r | |
3474 | /**\r | |
3475 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
3476 | to log2(x).\r | |
3477 | \r | |
3478 | This function computes the bit position of the highest bit set in the 32-bit\r | |
3479 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3480 | Otherwise, a value between 0 and 31 is returned.\r | |
3481 | \r | |
3482 | @param Operand The 32-bit operand to evaluate.\r | |
3483 | \r | |
9aa049d9 | 3484 | @retval 0..31 Position of the highest bit set in Operand if found.\r |
17f695ed | 3485 | @retval -1 Operand is zero.\r |
ac644614 | 3486 | \r |
3487 | **/\r | |
3488 | INTN\r | |
3489 | EFIAPI\r | |
3490 | HighBitSet32 (\r | |
3491 | IN UINT32 Operand\r | |
3492 | );\r | |
3493 | \r | |
3494 | \r | |
3495 | /**\r | |
3496 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
3497 | to log2(x).\r | |
3498 | \r | |
3499 | This function computes the bit position of the highest bit set in the 64-bit\r | |
3500 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3501 | Otherwise, a value between 0 and 63 is returned.\r | |
3502 | \r | |
3503 | @param Operand The 64-bit operand to evaluate.\r | |
3504 | \r | |
9aa049d9 | 3505 | @retval 0..63 Position of the highest bit set in Operand if found.\r |
17f695ed | 3506 | @retval -1 Operand is zero.\r |
ac644614 | 3507 | \r |
3508 | **/\r | |
3509 | INTN\r | |
3510 | EFIAPI\r | |
3511 | HighBitSet64 (\r | |
3512 | IN UINT64 Operand\r | |
3513 | );\r | |
3514 | \r | |
3515 | \r | |
3516 | /**\r | |
3517 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
17f695ed | 3518 | 1 << log2(x).\r |
ac644614 | 3519 | \r |
3520 | This function computes the value of the highest bit set in the 32-bit value\r | |
3521 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3522 | \r | |
3523 | @param Operand The 32-bit operand to evaluate.\r | |
3524 | \r | |
3525 | @return 1 << HighBitSet32(Operand)\r | |
3526 | @retval 0 Operand is zero.\r | |
3527 | \r | |
3528 | **/\r | |
3529 | UINT32\r | |
3530 | EFIAPI\r | |
3531 | GetPowerOfTwo32 (\r | |
3532 | IN UINT32 Operand\r | |
3533 | );\r | |
3534 | \r | |
3535 | \r | |
3536 | /**\r | |
3537 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
17f695ed | 3538 | 1 << log2(x).\r |
ac644614 | 3539 | \r |
3540 | This function computes the value of the highest bit set in the 64-bit value\r | |
3541 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3542 | \r | |
3543 | @param Operand The 64-bit operand to evaluate.\r | |
3544 | \r | |
3545 | @return 1 << HighBitSet64(Operand)\r | |
3546 | @retval 0 Operand is zero.\r | |
3547 | \r | |
3548 | **/\r | |
3549 | UINT64\r | |
3550 | EFIAPI\r | |
3551 | GetPowerOfTwo64 (\r | |
3552 | IN UINT64 Operand\r | |
3553 | );\r | |
3554 | \r | |
3555 | \r | |
3556 | /**\r | |
af2dc6a7 | 3557 | Switches the endianness of a 16-bit integer.\r |
ac644614 | 3558 | \r |
3559 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
3560 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3561 | returned.\r | |
3562 | \r | |
2a53dabf | 3563 | @param Value A 16-bit unsigned value.\r |
ac644614 | 3564 | \r |
efb23117 | 3565 | @return The byte swapped Value.\r |
ac644614 | 3566 | \r |
3567 | **/\r | |
3568 | UINT16\r | |
3569 | EFIAPI\r | |
3570 | SwapBytes16 (\r | |
3571 | IN UINT16 Value\r | |
3572 | );\r | |
3573 | \r | |
3574 | \r | |
3575 | /**\r | |
af2dc6a7 | 3576 | Switches the endianness of a 32-bit integer.\r |
ac644614 | 3577 | \r |
3578 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
3579 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3580 | returned.\r | |
3581 | \r | |
2a53dabf | 3582 | @param Value A 32-bit unsigned value.\r |
ac644614 | 3583 | \r |
efb23117 | 3584 | @return The byte swapped Value.\r |
ac644614 | 3585 | \r |
3586 | **/\r | |
3587 | UINT32\r | |
3588 | EFIAPI\r | |
3589 | SwapBytes32 (\r | |
3590 | IN UINT32 Value\r | |
3591 | );\r | |
3592 | \r | |
3593 | \r | |
3594 | /**\r | |
af2dc6a7 | 3595 | Switches the endianness of a 64-bit integer.\r |
ac644614 | 3596 | \r |
3597 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
3598 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3599 | returned.\r | |
3600 | \r | |
2a53dabf | 3601 | @param Value A 64-bit unsigned value.\r |
ac644614 | 3602 | \r |
efb23117 | 3603 | @return The byte swapped Value.\r |
ac644614 | 3604 | \r |
3605 | **/\r | |
3606 | UINT64\r | |
3607 | EFIAPI\r | |
3608 | SwapBytes64 (\r | |
3609 | IN UINT64 Value\r | |
3610 | );\r | |
3611 | \r | |
3612 | \r | |
3613 | /**\r | |
3614 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
3615 | generates a 64-bit unsigned result.\r | |
3616 | \r | |
3617 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
3618 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3619 | bit unsigned result is returned.\r | |
3620 | \r | |
ac644614 | 3621 | @param Multiplicand A 64-bit unsigned value.\r |
3622 | @param Multiplier A 32-bit unsigned value.\r | |
3623 | \r | |
3624 | @return Multiplicand * Multiplier\r | |
3625 | \r | |
3626 | **/\r | |
3627 | UINT64\r | |
3628 | EFIAPI\r | |
3629 | MultU64x32 (\r | |
3630 | IN UINT64 Multiplicand,\r | |
3631 | IN UINT32 Multiplier\r | |
3632 | );\r | |
3633 | \r | |
3634 | \r | |
3635 | /**\r | |
3636 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
3637 | generates a 64-bit unsigned result.\r | |
3638 | \r | |
3639 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
3640 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3641 | bit unsigned result is returned.\r | |
3642 | \r | |
ac644614 | 3643 | @param Multiplicand A 64-bit unsigned value.\r |
3644 | @param Multiplier A 64-bit unsigned value.\r | |
3645 | \r | |
af2dc6a7 | 3646 | @return Multiplicand * Multiplier.\r |
ac644614 | 3647 | \r |
3648 | **/\r | |
3649 | UINT64\r | |
3650 | EFIAPI\r | |
3651 | MultU64x64 (\r | |
3652 | IN UINT64 Multiplicand,\r | |
3653 | IN UINT64 Multiplier\r | |
3654 | );\r | |
3655 | \r | |
3656 | \r | |
3657 | /**\r | |
3658 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3659 | 64-bit signed result.\r | |
3660 | \r | |
3661 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
3662 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
3663 | signed result is returned.\r | |
3664 | \r | |
ac644614 | 3665 | @param Multiplicand A 64-bit signed value.\r |
3666 | @param Multiplier A 64-bit signed value.\r | |
3667 | \r | |
3668 | @return Multiplicand * Multiplier\r | |
3669 | \r | |
3670 | **/\r | |
3671 | INT64\r | |
3672 | EFIAPI\r | |
3673 | MultS64x64 (\r | |
3674 | IN INT64 Multiplicand,\r | |
3675 | IN INT64 Multiplier\r | |
3676 | );\r | |
3677 | \r | |
3678 | \r | |
3679 | /**\r | |
3680 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3681 | a 64-bit unsigned result.\r | |
3682 | \r | |
3683 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3684 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
3685 | function returns the 64-bit unsigned quotient.\r | |
3686 | \r | |
3687 | If Divisor is 0, then ASSERT().\r | |
3688 | \r | |
3689 | @param Dividend A 64-bit unsigned value.\r | |
3690 | @param Divisor A 32-bit unsigned value.\r | |
3691 | \r | |
af2dc6a7 | 3692 | @return Dividend / Divisor.\r |
ac644614 | 3693 | \r |
3694 | **/\r | |
3695 | UINT64\r | |
3696 | EFIAPI\r | |
3697 | DivU64x32 (\r | |
3698 | IN UINT64 Dividend,\r | |
3699 | IN UINT32 Divisor\r | |
3700 | );\r | |
3701 | \r | |
3702 | \r | |
3703 | /**\r | |
3704 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3705 | a 32-bit unsigned remainder.\r | |
3706 | \r | |
3707 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3708 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
3709 | returns the 32-bit unsigned remainder.\r | |
3710 | \r | |
3711 | If Divisor is 0, then ASSERT().\r | |
3712 | \r | |
3713 | @param Dividend A 64-bit unsigned value.\r | |
3714 | @param Divisor A 32-bit unsigned value.\r | |
3715 | \r | |
af2dc6a7 | 3716 | @return Dividend % Divisor.\r |
ac644614 | 3717 | \r |
3718 | **/\r | |
3719 | UINT32\r | |
3720 | EFIAPI\r | |
3721 | ModU64x32 (\r | |
3722 | IN UINT64 Dividend,\r | |
3723 | IN UINT32 Divisor\r | |
3724 | );\r | |
3725 | \r | |
3726 | \r | |
3727 | /**\r | |
3728 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3729 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
3730 | \r | |
3731 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3732 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3733 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
3734 | This function returns the 64-bit unsigned quotient.\r | |
3735 | \r | |
3736 | If Divisor is 0, then ASSERT().\r | |
3737 | \r | |
3738 | @param Dividend A 64-bit unsigned value.\r | |
3739 | @param Divisor A 32-bit unsigned value.\r | |
3740 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
3741 | optional and may be NULL.\r | |
3742 | \r | |
af2dc6a7 | 3743 | @return Dividend / Divisor.\r |
ac644614 | 3744 | \r |
3745 | **/\r | |
3746 | UINT64\r | |
3747 | EFIAPI\r | |
3748 | DivU64x32Remainder (\r | |
3749 | IN UINT64 Dividend,\r | |
3750 | IN UINT32 Divisor,\r | |
3751 | OUT UINT32 *Remainder OPTIONAL\r | |
3752 | );\r | |
3753 | \r | |
3754 | \r | |
3755 | /**\r | |
3756 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
3757 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
3758 | \r | |
3759 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
3760 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3761 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
3762 | This function returns the 64-bit unsigned quotient.\r | |
3763 | \r | |
3764 | If Divisor is 0, then ASSERT().\r | |
3765 | \r | |
3766 | @param Dividend A 64-bit unsigned value.\r | |
3767 | @param Divisor A 64-bit unsigned value.\r | |
3768 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
3769 | optional and may be NULL.\r | |
3770 | \r | |
af2dc6a7 | 3771 | @return Dividend / Divisor.\r |
ac644614 | 3772 | \r |
3773 | **/\r | |
3774 | UINT64\r | |
3775 | EFIAPI\r | |
3776 | DivU64x64Remainder (\r | |
3777 | IN UINT64 Dividend,\r | |
3778 | IN UINT64 Divisor,\r | |
3779 | OUT UINT64 *Remainder OPTIONAL\r | |
3780 | );\r | |
3781 | \r | |
3782 | \r | |
3783 | /**\r | |
3784 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3785 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
3786 | \r | |
3787 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
3788 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
3789 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
3790 | function returns the 64-bit signed quotient.\r | |
3791 | \r | |
9aa049d9 | 3792 | It is the caller's responsibility to not call this function with a Divisor of 0.\r |
9095d37b | 3793 | If Divisor is 0, then the quotient and remainder should be assumed to be\r |
17f695ed | 3794 | the largest negative integer.\r |
3795 | \r | |
ac644614 | 3796 | If Divisor is 0, then ASSERT().\r |
3797 | \r | |
3798 | @param Dividend A 64-bit signed value.\r | |
3799 | @param Divisor A 64-bit signed value.\r | |
3800 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
3801 | optional and may be NULL.\r | |
3802 | \r | |
af2dc6a7 | 3803 | @return Dividend / Divisor.\r |
ac644614 | 3804 | \r |
3805 | **/\r | |
3806 | INT64\r | |
3807 | EFIAPI\r | |
3808 | DivS64x64Remainder (\r | |
3809 | IN INT64 Dividend,\r | |
3810 | IN INT64 Divisor,\r | |
3811 | OUT INT64 *Remainder OPTIONAL\r | |
3812 | );\r | |
3813 | \r | |
3814 | \r | |
3815 | /**\r | |
3816 | Reads a 16-bit value from memory that may be unaligned.\r | |
3817 | \r | |
3818 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
3819 | guarantees that the read operation does not produce an alignment fault.\r | |
3820 | \r | |
3821 | If the Buffer is NULL, then ASSERT().\r | |
3822 | \r | |
af2dc6a7 | 3823 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3824 | \r |
5385a579 | 3825 | @return The 16-bit value read from Buffer.\r |
ac644614 | 3826 | \r |
3827 | **/\r | |
3828 | UINT16\r | |
3829 | EFIAPI\r | |
3830 | ReadUnaligned16 (\r | |
5385a579 | 3831 | IN CONST UINT16 *Buffer\r |
ac644614 | 3832 | );\r |
3833 | \r | |
3834 | \r | |
3835 | /**\r | |
3836 | Writes a 16-bit value to memory that may be unaligned.\r | |
3837 | \r | |
3838 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
3839 | returned. The function guarantees that the write operation does not produce\r | |
3840 | an alignment fault.\r | |
3841 | \r | |
3842 | If the Buffer is NULL, then ASSERT().\r | |
3843 | \r | |
af2dc6a7 | 3844 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3845 | @param Value 16-bit value to write to Buffer.\r |
3846 | \r | |
5385a579 | 3847 | @return The 16-bit value to write to Buffer.\r |
ac644614 | 3848 | \r |
3849 | **/\r | |
3850 | UINT16\r | |
3851 | EFIAPI\r | |
3852 | WriteUnaligned16 (\r | |
5385a579 | 3853 | OUT UINT16 *Buffer,\r |
3854 | IN UINT16 Value\r | |
ac644614 | 3855 | );\r |
3856 | \r | |
3857 | \r | |
3858 | /**\r | |
3859 | Reads a 24-bit value from memory that may be unaligned.\r | |
3860 | \r | |
3861 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
3862 | guarantees that the read operation does not produce an alignment fault.\r | |
3863 | \r | |
3864 | If the Buffer is NULL, then ASSERT().\r | |
3865 | \r | |
af2dc6a7 | 3866 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3867 | \r |
5385a579 | 3868 | @return The 24-bit value read from Buffer.\r |
ac644614 | 3869 | \r |
3870 | **/\r | |
3871 | UINT32\r | |
3872 | EFIAPI\r | |
3873 | ReadUnaligned24 (\r | |
5385a579 | 3874 | IN CONST UINT32 *Buffer\r |
ac644614 | 3875 | );\r |
3876 | \r | |
3877 | \r | |
3878 | /**\r | |
3879 | Writes a 24-bit value to memory that may be unaligned.\r | |
3880 | \r | |
3881 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
3882 | returned. The function guarantees that the write operation does not produce\r | |
3883 | an alignment fault.\r | |
3884 | \r | |
3885 | If the Buffer is NULL, then ASSERT().\r | |
3886 | \r | |
af2dc6a7 | 3887 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3888 | @param Value 24-bit value to write to Buffer.\r |
3889 | \r | |
5385a579 | 3890 | @return The 24-bit value to write to Buffer.\r |
ac644614 | 3891 | \r |
3892 | **/\r | |
3893 | UINT32\r | |
3894 | EFIAPI\r | |
3895 | WriteUnaligned24 (\r | |
5385a579 | 3896 | OUT UINT32 *Buffer,\r |
3897 | IN UINT32 Value\r | |
ac644614 | 3898 | );\r |
3899 | \r | |
3900 | \r | |
3901 | /**\r | |
3902 | Reads a 32-bit value from memory that may be unaligned.\r | |
3903 | \r | |
3904 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
3905 | guarantees that the read operation does not produce an alignment fault.\r | |
3906 | \r | |
3907 | If the Buffer is NULL, then ASSERT().\r | |
3908 | \r | |
af2dc6a7 | 3909 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3910 | \r |
5385a579 | 3911 | @return The 32-bit value read from Buffer.\r |
ac644614 | 3912 | \r |
3913 | **/\r | |
3914 | UINT32\r | |
3915 | EFIAPI\r | |
3916 | ReadUnaligned32 (\r | |
5385a579 | 3917 | IN CONST UINT32 *Buffer\r |
ac644614 | 3918 | );\r |
3919 | \r | |
3920 | \r | |
3921 | /**\r | |
3922 | Writes a 32-bit value to memory that may be unaligned.\r | |
3923 | \r | |
3924 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
3925 | returned. The function guarantees that the write operation does not produce\r | |
3926 | an alignment fault.\r | |
3927 | \r | |
3928 | If the Buffer is NULL, then ASSERT().\r | |
3929 | \r | |
af2dc6a7 | 3930 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3931 | @param Value 32-bit value to write to Buffer.\r |
3932 | \r | |
5385a579 | 3933 | @return The 32-bit value to write to Buffer.\r |
ac644614 | 3934 | \r |
3935 | **/\r | |
3936 | UINT32\r | |
3937 | EFIAPI\r | |
3938 | WriteUnaligned32 (\r | |
5385a579 | 3939 | OUT UINT32 *Buffer,\r |
3940 | IN UINT32 Value\r | |
ac644614 | 3941 | );\r |
3942 | \r | |
3943 | \r | |
3944 | /**\r | |
3945 | Reads a 64-bit value from memory that may be unaligned.\r | |
3946 | \r | |
3947 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
3948 | guarantees that the read operation does not produce an alignment fault.\r | |
3949 | \r | |
3950 | If the Buffer is NULL, then ASSERT().\r | |
3951 | \r | |
af2dc6a7 | 3952 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3953 | \r |
5385a579 | 3954 | @return The 64-bit value read from Buffer.\r |
ac644614 | 3955 | \r |
3956 | **/\r | |
3957 | UINT64\r | |
3958 | EFIAPI\r | |
3959 | ReadUnaligned64 (\r | |
5385a579 | 3960 | IN CONST UINT64 *Buffer\r |
ac644614 | 3961 | );\r |
3962 | \r | |
3963 | \r | |
3964 | /**\r | |
3965 | Writes a 64-bit value to memory that may be unaligned.\r | |
3966 | \r | |
3967 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
3968 | returned. The function guarantees that the write operation does not produce\r | |
3969 | an alignment fault.\r | |
3970 | \r | |
3971 | If the Buffer is NULL, then ASSERT().\r | |
3972 | \r | |
af2dc6a7 | 3973 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3974 | @param Value 64-bit value to write to Buffer.\r |
3975 | \r | |
5385a579 | 3976 | @return The 64-bit value to write to Buffer.\r |
ac644614 | 3977 | \r |
3978 | **/\r | |
3979 | UINT64\r | |
3980 | EFIAPI\r | |
3981 | WriteUnaligned64 (\r | |
5385a579 | 3982 | OUT UINT64 *Buffer,\r |
3983 | IN UINT64 Value\r | |
ac644614 | 3984 | );\r |
3985 | \r | |
3986 | \r | |
3987 | //\r | |
3988 | // Bit Field Functions\r | |
3989 | //\r | |
3990 | \r | |
3991 | /**\r | |
3992 | Returns a bit field from an 8-bit value.\r | |
3993 | \r | |
3994 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3995 | \r | |
3996 | If 8-bit operations are not supported, then ASSERT().\r | |
3997 | If StartBit is greater than 7, then ASSERT().\r | |
3998 | If EndBit is greater than 7, then ASSERT().\r | |
3999 | If EndBit is less than StartBit, then ASSERT().\r | |
4000 | \r | |
4001 | @param Operand Operand on which to perform the bitfield operation.\r | |
4002 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4003 | Range 0..7.\r | |
4004 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4005 | Range 0..7.\r | |
4006 | \r | |
4007 | @return The bit field read.\r | |
4008 | \r | |
4009 | **/\r | |
4010 | UINT8\r | |
4011 | EFIAPI\r | |
4012 | BitFieldRead8 (\r | |
4013 | IN UINT8 Operand,\r | |
4014 | IN UINTN StartBit,\r | |
4015 | IN UINTN EndBit\r | |
4016 | );\r | |
4017 | \r | |
4018 | \r | |
4019 | /**\r | |
4020 | Writes a bit field to an 8-bit value, and returns the result.\r | |
4021 | \r | |
4022 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4023 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
4024 | returned.\r | |
4025 | \r | |
4026 | If 8-bit operations are not supported, then ASSERT().\r | |
4027 | If StartBit is greater than 7, then ASSERT().\r | |
4028 | If EndBit is greater than 7, then ASSERT().\r | |
4029 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4030 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4031 | \r |
4032 | @param Operand Operand on which to perform the bitfield operation.\r | |
4033 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4034 | Range 0..7.\r | |
4035 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4036 | Range 0..7.\r | |
4037 | @param Value New value of the bit field.\r | |
4038 | \r | |
4039 | @return The new 8-bit value.\r | |
4040 | \r | |
4041 | **/\r | |
4042 | UINT8\r | |
4043 | EFIAPI\r | |
4044 | BitFieldWrite8 (\r | |
4045 | IN UINT8 Operand,\r | |
4046 | IN UINTN StartBit,\r | |
4047 | IN UINTN EndBit,\r | |
4048 | IN UINT8 Value\r | |
4049 | );\r | |
4050 | \r | |
4051 | \r | |
4052 | /**\r | |
4053 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
4054 | result.\r | |
4055 | \r | |
62991af2 | 4056 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4057 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4058 | Operand are preserved. The new 8-bit value is returned.\r | |
4059 | \r | |
4060 | If 8-bit operations are not supported, then ASSERT().\r | |
4061 | If StartBit is greater than 7, then ASSERT().\r | |
4062 | If EndBit is greater than 7, then ASSERT().\r | |
4063 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4064 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4065 | \r |
4066 | @param Operand Operand on which to perform the bitfield operation.\r | |
4067 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4068 | Range 0..7.\r | |
4069 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4070 | Range 0..7.\r | |
4071 | @param OrData The value to OR with the read value from the value\r | |
4072 | \r | |
4073 | @return The new 8-bit value.\r | |
4074 | \r | |
4075 | **/\r | |
4076 | UINT8\r | |
4077 | EFIAPI\r | |
4078 | BitFieldOr8 (\r | |
4079 | IN UINT8 Operand,\r | |
4080 | IN UINTN StartBit,\r | |
4081 | IN UINTN EndBit,\r | |
4082 | IN UINT8 OrData\r | |
4083 | );\r | |
4084 | \r | |
4085 | \r | |
4086 | /**\r | |
4087 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
4088 | the result.\r | |
4089 | \r | |
4090 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4091 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4092 | preserved. The new 8-bit value is returned.\r | |
4093 | \r | |
4094 | If 8-bit operations are not supported, then ASSERT().\r | |
4095 | If StartBit is greater than 7, then ASSERT().\r | |
4096 | If EndBit is greater than 7, then ASSERT().\r | |
4097 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4098 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4099 | \r |
4100 | @param Operand Operand on which to perform the bitfield operation.\r | |
4101 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4102 | Range 0..7.\r | |
4103 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4104 | Range 0..7.\r | |
4105 | @param AndData The value to AND with the read value from the value.\r | |
4106 | \r | |
4107 | @return The new 8-bit value.\r | |
4108 | \r | |
4109 | **/\r | |
4110 | UINT8\r | |
4111 | EFIAPI\r | |
4112 | BitFieldAnd8 (\r | |
4113 | IN UINT8 Operand,\r | |
4114 | IN UINTN StartBit,\r | |
4115 | IN UINTN EndBit,\r | |
4116 | IN UINT8 AndData\r | |
4117 | );\r | |
4118 | \r | |
4119 | \r | |
4120 | /**\r | |
4121 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
4122 | bitwise OR, and returns the result.\r | |
4123 | \r | |
4124 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4125 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4126 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4127 | preserved. The new 8-bit value is returned.\r |
4128 | \r | |
4129 | If 8-bit operations are not supported, then ASSERT().\r | |
4130 | If StartBit is greater than 7, then ASSERT().\r | |
4131 | If EndBit is greater than 7, then ASSERT().\r | |
4132 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4133 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4134 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4135 | \r |
4136 | @param Operand Operand on which to perform the bitfield operation.\r | |
4137 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4138 | Range 0..7.\r | |
4139 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4140 | Range 0..7.\r | |
4141 | @param AndData The value to AND with the read value from the value.\r | |
4142 | @param OrData The value to OR with the result of the AND operation.\r | |
4143 | \r | |
4144 | @return The new 8-bit value.\r | |
4145 | \r | |
4146 | **/\r | |
4147 | UINT8\r | |
4148 | EFIAPI\r | |
4149 | BitFieldAndThenOr8 (\r | |
4150 | IN UINT8 Operand,\r | |
4151 | IN UINTN StartBit,\r | |
4152 | IN UINTN EndBit,\r | |
4153 | IN UINT8 AndData,\r | |
4154 | IN UINT8 OrData\r | |
4155 | );\r | |
4156 | \r | |
4157 | \r | |
4158 | /**\r | |
4159 | Returns a bit field from a 16-bit value.\r | |
4160 | \r | |
4161 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4162 | \r | |
4163 | If 16-bit operations are not supported, then ASSERT().\r | |
4164 | If StartBit is greater than 15, then ASSERT().\r | |
4165 | If EndBit is greater than 15, then ASSERT().\r | |
4166 | If EndBit is less than StartBit, then ASSERT().\r | |
4167 | \r | |
4168 | @param Operand Operand on which to perform the bitfield operation.\r | |
4169 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4170 | Range 0..15.\r | |
4171 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4172 | Range 0..15.\r | |
4173 | \r | |
4174 | @return The bit field read.\r | |
4175 | \r | |
4176 | **/\r | |
4177 | UINT16\r | |
4178 | EFIAPI\r | |
4179 | BitFieldRead16 (\r | |
4180 | IN UINT16 Operand,\r | |
4181 | IN UINTN StartBit,\r | |
4182 | IN UINTN EndBit\r | |
4183 | );\r | |
4184 | \r | |
4185 | \r | |
4186 | /**\r | |
4187 | Writes a bit field to a 16-bit value, and returns the result.\r | |
4188 | \r | |
4189 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4190 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
4191 | returned.\r | |
4192 | \r | |
4193 | If 16-bit operations are not supported, then ASSERT().\r | |
4194 | If StartBit is greater than 15, then ASSERT().\r | |
4195 | If EndBit is greater than 15, then ASSERT().\r | |
4196 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4197 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4198 | \r |
4199 | @param Operand Operand on which to perform the bitfield operation.\r | |
4200 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4201 | Range 0..15.\r | |
4202 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4203 | Range 0..15.\r | |
4204 | @param Value New value of the bit field.\r | |
4205 | \r | |
4206 | @return The new 16-bit value.\r | |
4207 | \r | |
4208 | **/\r | |
4209 | UINT16\r | |
4210 | EFIAPI\r | |
4211 | BitFieldWrite16 (\r | |
4212 | IN UINT16 Operand,\r | |
4213 | IN UINTN StartBit,\r | |
4214 | IN UINTN EndBit,\r | |
4215 | IN UINT16 Value\r | |
4216 | );\r | |
4217 | \r | |
4218 | \r | |
4219 | /**\r | |
4220 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
4221 | result.\r | |
4222 | \r | |
62991af2 | 4223 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4224 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4225 | Operand are preserved. The new 16-bit value is returned.\r | |
4226 | \r | |
4227 | If 16-bit operations are not supported, then ASSERT().\r | |
4228 | If StartBit is greater than 15, then ASSERT().\r | |
4229 | If EndBit is greater than 15, then ASSERT().\r | |
4230 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4231 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4232 | \r |
4233 | @param Operand Operand on which to perform the bitfield operation.\r | |
4234 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4235 | Range 0..15.\r | |
4236 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4237 | Range 0..15.\r | |
4238 | @param OrData The value to OR with the read value from the value\r | |
4239 | \r | |
4240 | @return The new 16-bit value.\r | |
4241 | \r | |
4242 | **/\r | |
4243 | UINT16\r | |
4244 | EFIAPI\r | |
4245 | BitFieldOr16 (\r | |
4246 | IN UINT16 Operand,\r | |
4247 | IN UINTN StartBit,\r | |
4248 | IN UINTN EndBit,\r | |
4249 | IN UINT16 OrData\r | |
4250 | );\r | |
4251 | \r | |
4252 | \r | |
4253 | /**\r | |
4254 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
4255 | the result.\r | |
4256 | \r | |
4257 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4258 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4259 | preserved. The new 16-bit value is returned.\r | |
4260 | \r | |
4261 | If 16-bit operations are not supported, then ASSERT().\r | |
4262 | If StartBit is greater than 15, then ASSERT().\r | |
4263 | If EndBit is greater than 15, then ASSERT().\r | |
4264 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4265 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4266 | \r |
4267 | @param Operand Operand on which to perform the bitfield operation.\r | |
4268 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4269 | Range 0..15.\r | |
4270 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4271 | Range 0..15.\r | |
4272 | @param AndData The value to AND with the read value from the value\r | |
4273 | \r | |
4274 | @return The new 16-bit value.\r | |
4275 | \r | |
4276 | **/\r | |
4277 | UINT16\r | |
4278 | EFIAPI\r | |
4279 | BitFieldAnd16 (\r | |
4280 | IN UINT16 Operand,\r | |
4281 | IN UINTN StartBit,\r | |
4282 | IN UINTN EndBit,\r | |
4283 | IN UINT16 AndData\r | |
4284 | );\r | |
4285 | \r | |
4286 | \r | |
4287 | /**\r | |
4288 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
4289 | bitwise OR, and returns the result.\r | |
4290 | \r | |
4291 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4292 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4293 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4294 | preserved. The new 16-bit value is returned.\r |
4295 | \r | |
4296 | If 16-bit operations are not supported, then ASSERT().\r | |
4297 | If StartBit is greater than 15, then ASSERT().\r | |
4298 | If EndBit is greater than 15, then ASSERT().\r | |
4299 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4300 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4301 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4302 | \r |
4303 | @param Operand Operand on which to perform the bitfield operation.\r | |
4304 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4305 | Range 0..15.\r | |
4306 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4307 | Range 0..15.\r | |
4308 | @param AndData The value to AND with the read value from the value.\r | |
4309 | @param OrData The value to OR with the result of the AND operation.\r | |
4310 | \r | |
4311 | @return The new 16-bit value.\r | |
4312 | \r | |
4313 | **/\r | |
4314 | UINT16\r | |
4315 | EFIAPI\r | |
4316 | BitFieldAndThenOr16 (\r | |
4317 | IN UINT16 Operand,\r | |
4318 | IN UINTN StartBit,\r | |
4319 | IN UINTN EndBit,\r | |
4320 | IN UINT16 AndData,\r | |
4321 | IN UINT16 OrData\r | |
4322 | );\r | |
4323 | \r | |
4324 | \r | |
4325 | /**\r | |
4326 | Returns a bit field from a 32-bit value.\r | |
4327 | \r | |
4328 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4329 | \r | |
4330 | If 32-bit operations are not supported, then ASSERT().\r | |
4331 | If StartBit is greater than 31, then ASSERT().\r | |
4332 | If EndBit is greater than 31, then ASSERT().\r | |
4333 | If EndBit is less than StartBit, then ASSERT().\r | |
4334 | \r | |
4335 | @param Operand Operand on which to perform the bitfield operation.\r | |
4336 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4337 | Range 0..31.\r | |
4338 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4339 | Range 0..31.\r | |
4340 | \r | |
4341 | @return The bit field read.\r | |
4342 | \r | |
4343 | **/\r | |
4344 | UINT32\r | |
4345 | EFIAPI\r | |
4346 | BitFieldRead32 (\r | |
4347 | IN UINT32 Operand,\r | |
4348 | IN UINTN StartBit,\r | |
4349 | IN UINTN EndBit\r | |
4350 | );\r | |
4351 | \r | |
4352 | \r | |
4353 | /**\r | |
4354 | Writes a bit field to a 32-bit value, and returns the result.\r | |
4355 | \r | |
4356 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4357 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
4358 | returned.\r | |
4359 | \r | |
4360 | If 32-bit operations are not supported, then ASSERT().\r | |
4361 | If StartBit is greater than 31, then ASSERT().\r | |
4362 | If EndBit is greater than 31, then ASSERT().\r | |
4363 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4364 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4365 | \r |
4366 | @param Operand Operand on which to perform the bitfield operation.\r | |
4367 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4368 | Range 0..31.\r | |
4369 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4370 | Range 0..31.\r | |
4371 | @param Value New value of the bit field.\r | |
4372 | \r | |
4373 | @return The new 32-bit value.\r | |
4374 | \r | |
4375 | **/\r | |
4376 | UINT32\r | |
4377 | EFIAPI\r | |
4378 | BitFieldWrite32 (\r | |
4379 | IN UINT32 Operand,\r | |
4380 | IN UINTN StartBit,\r | |
4381 | IN UINTN EndBit,\r | |
4382 | IN UINT32 Value\r | |
4383 | );\r | |
4384 | \r | |
4385 | \r | |
4386 | /**\r | |
4387 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
4388 | result.\r | |
4389 | \r | |
62991af2 | 4390 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4391 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4392 | Operand are preserved. The new 32-bit value is returned.\r | |
4393 | \r | |
4394 | If 32-bit operations are not supported, then ASSERT().\r | |
4395 | If StartBit is greater than 31, then ASSERT().\r | |
4396 | If EndBit is greater than 31, then ASSERT().\r | |
4397 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4398 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4399 | \r |
4400 | @param Operand Operand on which to perform the bitfield operation.\r | |
4401 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4402 | Range 0..31.\r | |
4403 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4404 | Range 0..31.\r | |
af2dc6a7 | 4405 | @param OrData The value to OR with the read value from the value.\r |
ac644614 | 4406 | \r |
4407 | @return The new 32-bit value.\r | |
4408 | \r | |
4409 | **/\r | |
4410 | UINT32\r | |
4411 | EFIAPI\r | |
4412 | BitFieldOr32 (\r | |
4413 | IN UINT32 Operand,\r | |
4414 | IN UINTN StartBit,\r | |
4415 | IN UINTN EndBit,\r | |
4416 | IN UINT32 OrData\r | |
4417 | );\r | |
4418 | \r | |
4419 | \r | |
4420 | /**\r | |
4421 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
4422 | the result.\r | |
4423 | \r | |
4424 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4425 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4426 | preserved. The new 32-bit value is returned.\r | |
4427 | \r | |
4428 | If 32-bit operations are not supported, then ASSERT().\r | |
4429 | If StartBit is greater than 31, then ASSERT().\r | |
4430 | If EndBit is greater than 31, then ASSERT().\r | |
4431 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4432 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4433 | \r |
4434 | @param Operand Operand on which to perform the bitfield operation.\r | |
4435 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4436 | Range 0..31.\r | |
4437 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4438 | Range 0..31.\r | |
4439 | @param AndData The value to AND with the read value from the value\r | |
4440 | \r | |
4441 | @return The new 32-bit value.\r | |
4442 | \r | |
4443 | **/\r | |
4444 | UINT32\r | |
4445 | EFIAPI\r | |
4446 | BitFieldAnd32 (\r | |
4447 | IN UINT32 Operand,\r | |
4448 | IN UINTN StartBit,\r | |
4449 | IN UINTN EndBit,\r | |
4450 | IN UINT32 AndData\r | |
4451 | );\r | |
4452 | \r | |
4453 | \r | |
4454 | /**\r | |
4455 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
4456 | bitwise OR, and returns the result.\r | |
4457 | \r | |
4458 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4459 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4460 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4461 | preserved. The new 32-bit value is returned.\r |
4462 | \r | |
4463 | If 32-bit operations are not supported, then ASSERT().\r | |
4464 | If StartBit is greater than 31, then ASSERT().\r | |
4465 | If EndBit is greater than 31, then ASSERT().\r | |
4466 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4467 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4468 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4469 | \r |
4470 | @param Operand Operand on which to perform the bitfield operation.\r | |
4471 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4472 | Range 0..31.\r | |
4473 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4474 | Range 0..31.\r | |
4475 | @param AndData The value to AND with the read value from the value.\r | |
4476 | @param OrData The value to OR with the result of the AND operation.\r | |
4477 | \r | |
4478 | @return The new 32-bit value.\r | |
4479 | \r | |
4480 | **/\r | |
4481 | UINT32\r | |
4482 | EFIAPI\r | |
4483 | BitFieldAndThenOr32 (\r | |
4484 | IN UINT32 Operand,\r | |
4485 | IN UINTN StartBit,\r | |
4486 | IN UINTN EndBit,\r | |
4487 | IN UINT32 AndData,\r | |
4488 | IN UINT32 OrData\r | |
4489 | );\r | |
4490 | \r | |
4491 | \r | |
4492 | /**\r | |
4493 | Returns a bit field from a 64-bit value.\r | |
4494 | \r | |
4495 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4496 | \r | |
4497 | If 64-bit operations are not supported, then ASSERT().\r | |
4498 | If StartBit is greater than 63, then ASSERT().\r | |
4499 | If EndBit is greater than 63, then ASSERT().\r | |
4500 | If EndBit is less than StartBit, then ASSERT().\r | |
4501 | \r | |
4502 | @param Operand Operand on which to perform the bitfield operation.\r | |
4503 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4504 | Range 0..63.\r | |
4505 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4506 | Range 0..63.\r | |
4507 | \r | |
4508 | @return The bit field read.\r | |
4509 | \r | |
4510 | **/\r | |
4511 | UINT64\r | |
4512 | EFIAPI\r | |
4513 | BitFieldRead64 (\r | |
4514 | IN UINT64 Operand,\r | |
4515 | IN UINTN StartBit,\r | |
4516 | IN UINTN EndBit\r | |
4517 | );\r | |
4518 | \r | |
4519 | \r | |
4520 | /**\r | |
4521 | Writes a bit field to a 64-bit value, and returns the result.\r | |
4522 | \r | |
4523 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4524 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
4525 | returned.\r | |
4526 | \r | |
4527 | If 64-bit operations are not supported, then ASSERT().\r | |
4528 | If StartBit is greater than 63, then ASSERT().\r | |
4529 | If EndBit is greater than 63, then ASSERT().\r | |
4530 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4531 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4532 | \r |
4533 | @param Operand Operand on which to perform the bitfield operation.\r | |
4534 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4535 | Range 0..63.\r | |
4536 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4537 | Range 0..63.\r | |
4538 | @param Value New value of the bit field.\r | |
4539 | \r | |
4540 | @return The new 64-bit value.\r | |
4541 | \r | |
4542 | **/\r | |
4543 | UINT64\r | |
4544 | EFIAPI\r | |
4545 | BitFieldWrite64 (\r | |
4546 | IN UINT64 Operand,\r | |
4547 | IN UINTN StartBit,\r | |
4548 | IN UINTN EndBit,\r | |
4549 | IN UINT64 Value\r | |
4550 | );\r | |
4551 | \r | |
4552 | \r | |
4553 | /**\r | |
4554 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
4555 | result.\r | |
4556 | \r | |
62991af2 | 4557 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4558 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4559 | Operand are preserved. The new 64-bit value is returned.\r | |
4560 | \r | |
4561 | If 64-bit operations are not supported, then ASSERT().\r | |
4562 | If StartBit is greater than 63, then ASSERT().\r | |
4563 | If EndBit is greater than 63, then ASSERT().\r | |
4564 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4565 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4566 | \r |
4567 | @param Operand Operand on which to perform the bitfield operation.\r | |
4568 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4569 | Range 0..63.\r | |
4570 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4571 | Range 0..63.\r | |
4572 | @param OrData The value to OR with the read value from the value\r | |
4573 | \r | |
4574 | @return The new 64-bit value.\r | |
4575 | \r | |
4576 | **/\r | |
4577 | UINT64\r | |
4578 | EFIAPI\r | |
4579 | BitFieldOr64 (\r | |
4580 | IN UINT64 Operand,\r | |
4581 | IN UINTN StartBit,\r | |
4582 | IN UINTN EndBit,\r | |
4583 | IN UINT64 OrData\r | |
4584 | );\r | |
4585 | \r | |
4586 | \r | |
4587 | /**\r | |
4588 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
4589 | the result.\r | |
4590 | \r | |
4591 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4592 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4593 | preserved. The new 64-bit value is returned.\r | |
4594 | \r | |
4595 | If 64-bit operations are not supported, then ASSERT().\r | |
4596 | If StartBit is greater than 63, then ASSERT().\r | |
4597 | If EndBit is greater than 63, then ASSERT().\r | |
4598 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4599 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4600 | \r |
4601 | @param Operand Operand on which to perform the bitfield operation.\r | |
4602 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4603 | Range 0..63.\r | |
4604 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4605 | Range 0..63.\r | |
4606 | @param AndData The value to AND with the read value from the value\r | |
4607 | \r | |
4608 | @return The new 64-bit value.\r | |
4609 | \r | |
4610 | **/\r | |
4611 | UINT64\r | |
4612 | EFIAPI\r | |
4613 | BitFieldAnd64 (\r | |
4614 | IN UINT64 Operand,\r | |
4615 | IN UINTN StartBit,\r | |
4616 | IN UINTN EndBit,\r | |
4617 | IN UINT64 AndData\r | |
4618 | );\r | |
4619 | \r | |
4620 | \r | |
4621 | /**\r | |
4622 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
4623 | bitwise OR, and returns the result.\r | |
4624 | \r | |
4625 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4626 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4627 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4628 | preserved. The new 64-bit value is returned.\r |
4629 | \r | |
4630 | If 64-bit operations are not supported, then ASSERT().\r | |
4631 | If StartBit is greater than 63, then ASSERT().\r | |
4632 | If EndBit is greater than 63, then ASSERT().\r | |
4633 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4634 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4635 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4636 | \r |
4637 | @param Operand Operand on which to perform the bitfield operation.\r | |
4638 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4639 | Range 0..63.\r | |
4640 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4641 | Range 0..63.\r | |
4642 | @param AndData The value to AND with the read value from the value.\r | |
4643 | @param OrData The value to OR with the result of the AND operation.\r | |
4644 | \r | |
4645 | @return The new 64-bit value.\r | |
4646 | \r | |
4647 | **/\r | |
4648 | UINT64\r | |
4649 | EFIAPI\r | |
4650 | BitFieldAndThenOr64 (\r | |
4651 | IN UINT64 Operand,\r | |
4652 | IN UINTN StartBit,\r | |
4653 | IN UINTN EndBit,\r | |
4654 | IN UINT64 AndData,\r | |
4655 | IN UINT64 OrData\r | |
4656 | );\r | |
4657 | \r | |
d7634dc0 TP |
4658 | /**\r |
4659 | Reads a bit field from a 32-bit value, counts and returns\r | |
4660 | the number of set bits.\r | |
4661 | \r | |
4662 | Counts the number of set bits in the bit field specified by\r | |
4663 | StartBit and EndBit in Operand. The count is returned.\r | |
4664 | \r | |
4665 | If StartBit is greater than 31, then ASSERT().\r | |
4666 | If EndBit is greater than 31, then ASSERT().\r | |
4667 | If EndBit is less than StartBit, then ASSERT().\r | |
4668 | \r | |
4669 | @param Operand Operand on which to perform the bitfield operation.\r | |
4670 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4671 | Range 0..31.\r | |
4672 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4673 | Range 0..31.\r | |
4674 | \r | |
4675 | @return The number of bits set between StartBit and EndBit.\r | |
4676 | \r | |
4677 | **/\r | |
4678 | UINT8\r | |
4679 | EFIAPI\r | |
4680 | BitFieldCountOnes32 (\r | |
4681 | IN UINT32 Operand,\r | |
4682 | IN UINTN StartBit,\r | |
4683 | IN UINTN EndBit\r | |
4684 | );\r | |
4685 | \r | |
4686 | /**\r | |
4687 | Reads a bit field from a 64-bit value, counts and returns\r | |
4688 | the number of set bits.\r | |
4689 | \r | |
4690 | Counts the number of set bits in the bit field specified by\r | |
4691 | StartBit and EndBit in Operand. The count is returned.\r | |
4692 | \r | |
4693 | If StartBit is greater than 63, then ASSERT().\r | |
4694 | If EndBit is greater than 63, then ASSERT().\r | |
4695 | If EndBit is less than StartBit, then ASSERT().\r | |
4696 | \r | |
4697 | @param Operand Operand on which to perform the bitfield operation.\r | |
4698 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4699 | Range 0..63.\r | |
4700 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4701 | Range 0..63.\r | |
4702 | \r | |
4703 | @return The number of bits set between StartBit and EndBit.\r | |
4704 | \r | |
4705 | **/\r | |
4706 | UINT8\r | |
4707 | EFIAPI\r | |
4708 | BitFieldCountOnes64 (\r | |
4709 | IN UINT64 Operand,\r | |
4710 | IN UINTN StartBit,\r | |
4711 | IN UINTN EndBit\r | |
4712 | );\r | |
4713 | \r | |
ac644614 | 4714 | //\r |
4715 | // Base Library Checksum Functions\r | |
4716 | //\r | |
4717 | \r | |
4718 | /**\r | |
17f695ed | 4719 | Returns the sum of all elements in a buffer in unit of UINT8.\r |
ac644614 | 4720 | During calculation, the carry bits are dropped.\r |
4721 | \r | |
4722 | This function calculates the sum of all elements in a buffer\r | |
4723 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
4724 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
4725 | returned.\r | |
4726 | \r | |
4727 | If Buffer is NULL, then ASSERT().\r | |
4728 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4729 | \r | |
af2dc6a7 | 4730 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
17f695ed | 4731 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4732 | \r |
4733 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4734 | \r | |
4735 | **/\r | |
4736 | UINT8\r | |
4737 | EFIAPI\r | |
4738 | CalculateSum8 (\r | |
ee6c452c | 4739 | IN CONST UINT8 *Buffer,\r |
4740 | IN UINTN Length\r | |
ac644614 | 4741 | );\r |
4742 | \r | |
4743 | \r | |
4744 | /**\r | |
4745 | Returns the two's complement checksum of all elements in a buffer\r | |
4746 | of 8-bit values.\r | |
4747 | \r | |
4748 | This function first calculates the sum of the 8-bit values in the\r | |
4749 | buffer specified by Buffer and Length. The carry bits in the result\r | |
4750 | of addition are dropped. Then, the two's complement of the sum is\r | |
4751 | returned. If Length is 0, then 0 is returned.\r | |
4752 | \r | |
4753 | If Buffer is NULL, then ASSERT().\r | |
4754 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4755 | \r | |
af2dc6a7 | 4756 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4757 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4758 | \r |
af2dc6a7 | 4759 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4760 | \r |
4761 | **/\r | |
4762 | UINT8\r | |
4763 | EFIAPI\r | |
4764 | CalculateCheckSum8 (\r | |
ee6c452c | 4765 | IN CONST UINT8 *Buffer,\r |
4766 | IN UINTN Length\r | |
ac644614 | 4767 | );\r |
4768 | \r | |
4769 | \r | |
4770 | /**\r | |
4771 | Returns the sum of all elements in a buffer of 16-bit values. During\r | |
4772 | calculation, the carry bits are dropped.\r | |
4773 | \r | |
4774 | This function calculates the sum of the 16-bit values in the buffer\r | |
4775 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4776 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
4777 | \r | |
4778 | If Buffer is NULL, then ASSERT().\r | |
4779 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4780 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4781 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4782 | \r | |
af2dc6a7 | 4783 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4784 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4785 | \r |
4786 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4787 | \r | |
4788 | **/\r | |
4789 | UINT16\r | |
4790 | EFIAPI\r | |
4791 | CalculateSum16 (\r | |
ee6c452c | 4792 | IN CONST UINT16 *Buffer,\r |
4793 | IN UINTN Length\r | |
ac644614 | 4794 | );\r |
4795 | \r | |
4796 | \r | |
4797 | /**\r | |
4798 | Returns the two's complement checksum of all elements in a buffer of\r | |
4799 | 16-bit values.\r | |
4800 | \r | |
4801 | This function first calculates the sum of the 16-bit values in the buffer\r | |
4802 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4803 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4804 | is 0, then 0 is returned.\r | |
4805 | \r | |
4806 | If Buffer is NULL, then ASSERT().\r | |
4807 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4808 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4809 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4810 | \r | |
af2dc6a7 | 4811 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4812 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4813 | \r |
af2dc6a7 | 4814 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4815 | \r |
4816 | **/\r | |
4817 | UINT16\r | |
4818 | EFIAPI\r | |
4819 | CalculateCheckSum16 (\r | |
ee6c452c | 4820 | IN CONST UINT16 *Buffer,\r |
4821 | IN UINTN Length\r | |
ac644614 | 4822 | );\r |
4823 | \r | |
4824 | \r | |
4825 | /**\r | |
17f695ed | 4826 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
ac644614 | 4827 | calculation, the carry bits are dropped.\r |
4828 | \r | |
4829 | This function calculates the sum of the 32-bit values in the buffer\r | |
4830 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
17f695ed | 4831 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r |
ac644614 | 4832 | \r |
4833 | If Buffer is NULL, then ASSERT().\r | |
4834 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4835 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4836 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4837 | \r | |
af2dc6a7 | 4838 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4839 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4840 | \r |
4841 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4842 | \r | |
4843 | **/\r | |
4844 | UINT32\r | |
4845 | EFIAPI\r | |
4846 | CalculateSum32 (\r | |
ee6c452c | 4847 | IN CONST UINT32 *Buffer,\r |
4848 | IN UINTN Length\r | |
ac644614 | 4849 | );\r |
4850 | \r | |
4851 | \r | |
4852 | /**\r | |
4853 | Returns the two's complement checksum of all elements in a buffer of\r | |
4854 | 32-bit values.\r | |
4855 | \r | |
4856 | This function first calculates the sum of the 32-bit values in the buffer\r | |
4857 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4858 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4859 | is 0, then 0 is returned.\r | |
4860 | \r | |
4861 | If Buffer is NULL, then ASSERT().\r | |
4862 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4863 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4864 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4865 | \r | |
af2dc6a7 | 4866 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4867 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4868 | \r |
af2dc6a7 | 4869 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4870 | \r |
4871 | **/\r | |
4872 | UINT32\r | |
4873 | EFIAPI\r | |
4874 | CalculateCheckSum32 (\r | |
ee6c452c | 4875 | IN CONST UINT32 *Buffer,\r |
4876 | IN UINTN Length\r | |
ac644614 | 4877 | );\r |
4878 | \r | |
4879 | \r | |
4880 | /**\r | |
4881 | Returns the sum of all elements in a buffer of 64-bit values. During\r | |
4882 | calculation, the carry bits are dropped.\r | |
4883 | \r | |
4884 | This function calculates the sum of the 64-bit values in the buffer\r | |
4885 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4886 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
4887 | \r | |
4888 | If Buffer is NULL, then ASSERT().\r | |
4889 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4890 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4891 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4892 | \r | |
af2dc6a7 | 4893 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4894 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4895 | \r |
4896 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4897 | \r | |
4898 | **/\r | |
4899 | UINT64\r | |
4900 | EFIAPI\r | |
4901 | CalculateSum64 (\r | |
ee6c452c | 4902 | IN CONST UINT64 *Buffer,\r |
4903 | IN UINTN Length\r | |
ac644614 | 4904 | );\r |
4905 | \r | |
4906 | \r | |
4907 | /**\r | |
4908 | Returns the two's complement checksum of all elements in a buffer of\r | |
4909 | 64-bit values.\r | |
4910 | \r | |
4911 | This function first calculates the sum of the 64-bit values in the buffer\r | |
4912 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4913 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4914 | is 0, then 0 is returned.\r | |
4915 | \r | |
4916 | If Buffer is NULL, then ASSERT().\r | |
4917 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4918 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4919 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4920 | \r | |
af2dc6a7 | 4921 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4922 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4923 | \r |
af2dc6a7 | 4924 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4925 | \r |
4926 | **/\r | |
4927 | UINT64\r | |
4928 | EFIAPI\r | |
4929 | CalculateCheckSum64 (\r | |
ee6c452c | 4930 | IN CONST UINT64 *Buffer,\r |
4931 | IN UINTN Length\r | |
ac644614 | 4932 | );\r |
4933 | \r | |
0a8e6f79 LG |
4934 | /**\r |
4935 | Computes and returns a 32-bit CRC for a data buffer.\r | |
4936 | CRC32 value bases on ITU-T V.42.\r | |
4937 | \r | |
4938 | If Buffer is NULL, then ASSERT().\r | |
4939 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4940 | \r | |
4941 | @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.\r | |
4942 | @param[in] Length The number of bytes in the buffer Data.\r | |
4943 | \r | |
4944 | @retval Crc32 The 32-bit CRC was computed for the data buffer.\r | |
4945 | \r | |
4946 | **/\r | |
4947 | UINT32\r | |
4948 | EFIAPI\r | |
4949 | CalculateCrc32(\r | |
4950 | IN VOID *Buffer,\r | |
4951 | IN UINTN Length\r | |
4952 | );\r | |
ac644614 | 4953 | \r |
d75f9fc2 | 4954 | //\r |
4955 | // Base Library CPU Functions\r | |
4956 | //\r | |
4957 | \r | |
4958 | /**\r | |
4959 | Function entry point used when a stack switch is requested with SwitchStack()\r | |
4960 | \r | |
4961 | @param Context1 Context1 parameter passed into SwitchStack().\r | |
4962 | @param Context2 Context2 parameter passed into SwitchStack().\r | |
4963 | \r | |
4964 | **/\r | |
ac644614 | 4965 | typedef\r |
4966 | VOID\r | |
9810cdd8 | 4967 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r |
ac644614 | 4968 | IN VOID *Context1, OPTIONAL\r |
4969 | IN VOID *Context2 OPTIONAL\r | |
4970 | );\r | |
4971 | \r | |
4972 | \r | |
4973 | /**\r | |
4974 | Used to serialize load and store operations.\r | |
4975 | \r | |
4976 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
4977 | globally visible when this function returns.\r | |
4978 | \r | |
4979 | **/\r | |
4980 | VOID\r | |
4981 | EFIAPI\r | |
4982 | MemoryFence (\r | |
4983 | VOID\r | |
4984 | );\r | |
4985 | \r | |
4986 | \r | |
4987 | /**\r | |
4988 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
4989 | and returns 0.\r | |
4990 | \r | |
4991 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
4992 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
4993 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
4994 | \r | |
4995 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 4996 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
9095d37b | 4997 | \r |
17f695ed | 4998 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r |
4999 | The same structure must never be used for more than one CPU architecture context.\r | |
9095d37b LG |
5000 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.\r |
5001 | SetJump()/LongJump() is not currently supported for the EBC processor type.\r | |
ac644614 | 5002 | \r |
5003 | @param JumpBuffer A pointer to CPU context buffer.\r | |
5004 | \r | |
5005 | @retval 0 Indicates a return from SetJump().\r | |
5006 | \r | |
5007 | **/\r | |
2117989c | 5008 | RETURNS_TWICE\r |
ac644614 | 5009 | UINTN\r |
5010 | EFIAPI\r | |
5011 | SetJump (\r | |
5012 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
5013 | );\r | |
5014 | \r | |
5015 | \r | |
5016 | /**\r | |
5017 | Restores the CPU context that was saved with SetJump().\r | |
5018 | \r | |
5019 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
5020 | function never returns to the caller. Instead is resumes execution based on\r | |
5021 | the state of JumpBuffer.\r | |
5022 | \r | |
5023 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 5024 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
ac644614 | 5025 | If Value is 0, then ASSERT().\r |
5026 | \r | |
5027 | @param JumpBuffer A pointer to CPU context buffer.\r | |
5028 | @param Value The value to return when the SetJump() context is\r | |
5029 | restored and must be non-zero.\r | |
5030 | \r | |
5031 | **/\r | |
5032 | VOID\r | |
5033 | EFIAPI\r | |
5034 | LongJump (\r | |
5035 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
5036 | IN UINTN Value\r | |
5037 | );\r | |
5038 | \r | |
5039 | \r | |
5040 | /**\r | |
5041 | Enables CPU interrupts.\r | |
5042 | \r | |
ac644614 | 5043 | **/\r |
5044 | VOID\r | |
5045 | EFIAPI\r | |
5046 | EnableInterrupts (\r | |
5047 | VOID\r | |
5048 | );\r | |
5049 | \r | |
5050 | \r | |
5051 | /**\r | |
5052 | Disables CPU interrupts.\r | |
5053 | \r | |
ac644614 | 5054 | **/\r |
5055 | VOID\r | |
5056 | EFIAPI\r | |
5057 | DisableInterrupts (\r | |
5058 | VOID\r | |
5059 | );\r | |
5060 | \r | |
5061 | \r | |
5062 | /**\r | |
5063 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
5064 | operation.\r | |
5065 | \r | |
ac644614 | 5066 | @retval TRUE CPU interrupts were enabled on entry to this call.\r |
5067 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
5068 | \r | |
5069 | **/\r | |
5070 | BOOLEAN\r | |
5071 | EFIAPI\r | |
5072 | SaveAndDisableInterrupts (\r | |
5073 | VOID\r | |
5074 | );\r | |
5075 | \r | |
5076 | \r | |
5077 | /**\r | |
5078 | Enables CPU interrupts for the smallest window required to capture any\r | |
5079 | pending interrupts.\r | |
5080 | \r | |
ac644614 | 5081 | **/\r |
5082 | VOID\r | |
5083 | EFIAPI\r | |
5084 | EnableDisableInterrupts (\r | |
5085 | VOID\r | |
5086 | );\r | |
5087 | \r | |
5088 | \r | |
5089 | /**\r | |
5090 | Retrieves the current CPU interrupt state.\r | |
5091 | \r | |
af2dc6a7 | 5092 | Returns TRUE if interrupts are currently enabled. Otherwise\r |
38bbd3d9 | 5093 | returns FALSE.\r |
ac644614 | 5094 | \r |
5095 | @retval TRUE CPU interrupts are enabled.\r | |
5096 | @retval FALSE CPU interrupts are disabled.\r | |
5097 | \r | |
5098 | **/\r | |
5099 | BOOLEAN\r | |
5100 | EFIAPI\r | |
5101 | GetInterruptState (\r | |
5102 | VOID\r | |
5103 | );\r | |
5104 | \r | |
5105 | \r | |
5106 | /**\r | |
5107 | Set the current CPU interrupt state.\r | |
5108 | \r | |
5109 | Sets the current CPU interrupt state to the state specified by\r | |
5110 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
5111 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
5112 | returned.\r | |
5113 | \r | |
5114 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
5115 | interrupts should be disabled.\r | |
5116 | \r | |
5117 | @return InterruptState\r | |
5118 | \r | |
5119 | **/\r | |
5120 | BOOLEAN\r | |
5121 | EFIAPI\r | |
5122 | SetInterruptState (\r | |
5123 | IN BOOLEAN InterruptState\r | |
5124 | );\r | |
5125 | \r | |
5126 | \r | |
5127 | /**\r | |
5128 | Requests CPU to pause for a short period of time.\r | |
5129 | \r | |
5130 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
5131 | systems to prevent memory starvation while waiting for a spin lock.\r | |
5132 | \r | |
5133 | **/\r | |
5134 | VOID\r | |
5135 | EFIAPI\r | |
5136 | CpuPause (\r | |
5137 | VOID\r | |
5138 | );\r | |
5139 | \r | |
5140 | \r | |
5141 | /**\r | |
5142 | Transfers control to a function starting with a new stack.\r | |
5143 | \r | |
5144 | Transfers control to the function specified by EntryPoint using the\r | |
5145 | new stack specified by NewStack and passing in the parameters specified\r | |
5146 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
5147 | be NULL. The function EntryPoint must never return. This function\r | |
5148 | supports a variable number of arguments following the NewStack parameter.\r | |
1a2f870c | 5149 | These additional arguments are ignored on IA-32, x64, and EBC architectures.\r |
5150 | Itanium processors expect one additional parameter of type VOID * that specifies\r | |
ac644614 | 5151 | the new backing store pointer.\r |
5152 | \r | |
5153 | If EntryPoint is NULL, then ASSERT().\r | |
5154 | If NewStack is NULL, then ASSERT().\r | |
5155 | \r | |
5156 | @param EntryPoint A pointer to function to call with the new stack.\r | |
5157 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
5158 | function.\r | |
5159 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
5160 | function.\r | |
5161 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
5162 | function.\r | |
9095d37b LG |
5163 | @param ... This variable argument list is ignored for IA-32, x64, and\r |
5164 | EBC architectures. For Itanium processors, this variable\r | |
5165 | argument list is expected to contain a single parameter of\r | |
af2dc6a7 | 5166 | type VOID * that specifies the new backing store pointer.\r |
42eedea9 | 5167 | \r |
ac644614 | 5168 | \r |
5169 | **/\r | |
5170 | VOID\r | |
5171 | EFIAPI\r | |
5172 | SwitchStack (\r | |
5173 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
5174 | IN VOID *Context1, OPTIONAL\r | |
5175 | IN VOID *Context2, OPTIONAL\r | |
5176 | IN VOID *NewStack,\r | |
5177 | ...\r | |
5178 | );\r | |
5179 | \r | |
5180 | \r | |
5181 | /**\r | |
5182 | Generates a breakpoint on the CPU.\r | |
5183 | \r | |
5184 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
5185 | that code can resume normal execution after the breakpoint.\r | |
5186 | \r | |
5187 | **/\r | |
5188 | VOID\r | |
5189 | EFIAPI\r | |
5190 | CpuBreakpoint (\r | |
5191 | VOID\r | |
5192 | );\r | |
5193 | \r | |
5194 | \r | |
5195 | /**\r | |
5196 | Executes an infinite loop.\r | |
5197 | \r | |
5198 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
5199 | past the loop and the code that follows the loop must execute properly. This\r | |
5200 | implies that the infinite loop must not cause the code that follow it to be\r | |
5201 | optimized away.\r | |
5202 | \r | |
5203 | **/\r | |
5204 | VOID\r | |
5205 | EFIAPI\r | |
5206 | CpuDeadLoop (\r | |
5207 | VOID\r | |
5208 | );\r | |
9095d37b | 5209 | \r |
d9f1cac5 HW |
5210 | \r |
5211 | /**\r | |
5212 | Uses as a barrier to stop speculative execution.\r | |
5213 | \r | |
5214 | Ensures that no later instruction will execute speculatively, until all prior\r | |
5215 | instructions have completed.\r | |
5216 | \r | |
5217 | **/\r | |
5218 | VOID\r | |
5219 | EFIAPI\r | |
5220 | SpeculationBarrier (\r | |
5221 | VOID\r | |
5222 | );\r | |
5223 | \r | |
5224 | \r | |
fd163050 | 5225 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
1106ffe1 | 5226 | ///\r |
af2dc6a7 | 5227 | /// IA32 and x64 Specific Functions.\r |
5228 | /// Byte packed structure for 16-bit Real Mode EFLAGS.\r | |
1106ffe1 | 5229 | ///\r |
ac644614 | 5230 | typedef union {\r |
5231 | struct {\r | |
af2dc6a7 | 5232 | UINT32 CF:1; ///< Carry Flag.\r |
5233 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5234 | UINT32 PF:1; ///< Parity Flag.\r | |
5235 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5236 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5237 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5238 | UINT32 ZF:1; ///< Zero Flag.\r | |
5239 | UINT32 SF:1; ///< Sign Flag.\r | |
5240 | UINT32 TF:1; ///< Trap Flag.\r | |
5241 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5242 | UINT32 DF:1; ///< Direction Flag.\r | |
5243 | UINT32 OF:1; ///< Overflow Flag.\r | |
5244 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5245 | UINT32 NT:1; ///< Nested Task.\r | |
5246 | UINT32 Reserved_3:1; ///< Reserved.\r | |
ac644614 | 5247 | } Bits;\r |
5248 | UINT16 Uint16;\r | |
5249 | } IA32_FLAGS16;\r | |
5250 | \r | |
1106ffe1 | 5251 | ///\r |
af2dc6a7 | 5252 | /// Byte packed structure for EFLAGS/RFLAGS.\r |
5253 | /// 32-bits on IA-32.\r | |
5254 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5255 | ///\r |
ac644614 | 5256 | typedef union {\r |
5257 | struct {\r | |
af2dc6a7 | 5258 | UINT32 CF:1; ///< Carry Flag.\r |
5259 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5260 | UINT32 PF:1; ///< Parity Flag.\r | |
5261 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5262 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5263 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5264 | UINT32 ZF:1; ///< Zero Flag.\r | |
5265 | UINT32 SF:1; ///< Sign Flag.\r | |
5266 | UINT32 TF:1; ///< Trap Flag.\r | |
5267 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5268 | UINT32 DF:1; ///< Direction Flag.\r | |
5269 | UINT32 OF:1; ///< Overflow Flag.\r | |
5270 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5271 | UINT32 NT:1; ///< Nested Task.\r | |
5272 | UINT32 Reserved_3:1; ///< Reserved.\r | |
5273 | UINT32 RF:1; ///< Resume Flag.\r | |
5274 | UINT32 VM:1; ///< Virtual 8086 Mode.\r | |
5275 | UINT32 AC:1; ///< Alignment Check.\r | |
5276 | UINT32 VIF:1; ///< Virtual Interrupt Flag.\r | |
5277 | UINT32 VIP:1; ///< Virtual Interrupt Pending.\r | |
5278 | UINT32 ID:1; ///< ID Flag.\r | |
5279 | UINT32 Reserved_4:10; ///< Reserved.\r | |
ac644614 | 5280 | } Bits;\r |
5281 | UINTN UintN;\r | |
5282 | } IA32_EFLAGS32;\r | |
5283 | \r | |
1106ffe1 | 5284 | ///\r |
af2dc6a7 | 5285 | /// Byte packed structure for Control Register 0 (CR0).\r |
5286 | /// 32-bits on IA-32.\r | |
5287 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5288 | ///\r |
ac644614 | 5289 | typedef union {\r |
5290 | struct {\r | |
af2dc6a7 | 5291 | UINT32 PE:1; ///< Protection Enable.\r |
5292 | UINT32 MP:1; ///< Monitor Coprocessor.\r | |
5293 | UINT32 EM:1; ///< Emulation.\r | |
5294 | UINT32 TS:1; ///< Task Switched.\r | |
5295 | UINT32 ET:1; ///< Extension Type.\r | |
5296 | UINT32 NE:1; ///< Numeric Error.\r | |
5297 | UINT32 Reserved_0:10; ///< Reserved.\r | |
5298 | UINT32 WP:1; ///< Write Protect.\r | |
5299 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5300 | UINT32 AM:1; ///< Alignment Mask.\r | |
5301 | UINT32 Reserved_2:10; ///< Reserved.\r | |
5302 | UINT32 NW:1; ///< Mot Write-through.\r | |
5303 | UINT32 CD:1; ///< Cache Disable.\r | |
5304 | UINT32 PG:1; ///< Paging.\r | |
ac644614 | 5305 | } Bits;\r |
5306 | UINTN UintN;\r | |
5307 | } IA32_CR0;\r | |
5308 | \r | |
1106ffe1 | 5309 | ///\r |
af2dc6a7 | 5310 | /// Byte packed structure for Control Register 4 (CR4).\r |
5311 | /// 32-bits on IA-32.\r | |
5312 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5313 | ///\r |
ac644614 | 5314 | typedef union {\r |
5315 | struct {\r | |
af2dc6a7 | 5316 | UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r |
5317 | UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r | |
5318 | UINT32 TSD:1; ///< Time Stamp Disable.\r | |
5319 | UINT32 DE:1; ///< Debugging Extensions.\r | |
5320 | UINT32 PSE:1; ///< Page Size Extensions.\r | |
5321 | UINT32 PAE:1; ///< Physical Address Extension.\r | |
5322 | UINT32 MCE:1; ///< Machine Check Enable.\r | |
5323 | UINT32 PGE:1; ///< Page Global Enable.\r | |
2a53dabf | 5324 | UINT32 PCE:1; ///< Performance Monitoring Counter\r |
af2dc6a7 | 5325 | ///< Enable.\r |
2a53dabf LG |
5326 | UINT32 OSFXSR:1; ///< Operating System Support for\r |
5327 | ///< FXSAVE and FXRSTOR instructions\r | |
5328 | UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r | |
5329 | ///< Unmasked SIMD Floating Point\r | |
af2dc6a7 | 5330 | ///< Exceptions.\r |
5331 | UINT32 Reserved_0:2; ///< Reserved.\r | |
2a53dabf | 5332 | UINT32 VMXE:1; ///< VMX Enable\r |
af2dc6a7 | 5333 | UINT32 Reserved_1:18; ///< Reserved.\r |
ac644614 | 5334 | } Bits;\r |
5335 | UINTN UintN;\r | |
5336 | } IA32_CR4;\r | |
5337 | \r | |
6088db38 | 5338 | ///\r |
5339 | /// Byte packed structure for a segment descriptor in a GDT/LDT.\r | |
5340 | ///\r | |
5341 | typedef union {\r | |
5342 | struct {\r | |
5343 | UINT32 LimitLow:16;\r | |
5344 | UINT32 BaseLow:16;\r | |
5345 | UINT32 BaseMid:8;\r | |
5346 | UINT32 Type:4;\r | |
5347 | UINT32 S:1;\r | |
5348 | UINT32 DPL:2;\r | |
5349 | UINT32 P:1;\r | |
5350 | UINT32 LimitHigh:4;\r | |
5351 | UINT32 AVL:1;\r | |
5352 | UINT32 L:1;\r | |
5353 | UINT32 DB:1;\r | |
5354 | UINT32 G:1;\r | |
5355 | UINT32 BaseHigh:8;\r | |
5356 | } Bits;\r | |
5357 | UINT64 Uint64;\r | |
5358 | } IA32_SEGMENT_DESCRIPTOR;\r | |
5359 | \r | |
1106ffe1 | 5360 | ///\r |
af2dc6a7 | 5361 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r |
1106ffe1 | 5362 | ///\r |
ac644614 | 5363 | #pragma pack (1)\r |
5364 | typedef struct {\r | |
5365 | UINT16 Limit;\r | |
5366 | UINTN Base;\r | |
5367 | } IA32_DESCRIPTOR;\r | |
5368 | #pragma pack ()\r | |
5369 | \r | |
5370 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
5371 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
5372 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
5373 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
5374 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
5375 | \r | |
364a5474 JW |
5376 | #define IA32_GDT_TYPE_TSS 0x9\r |
5377 | #define IA32_GDT_ALIGNMENT 8\r | |
6f4aad3b | 5378 | \r |
5379 | #if defined (MDE_CPU_IA32)\r | |
1106ffe1 | 5380 | ///\r |
af2dc6a7 | 5381 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r |
1106ffe1 | 5382 | ///\r |
dc317713 | 5383 | typedef union {\r |
5384 | struct {\r | |
af2dc6a7 | 5385 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5386 | UINT32 Selector:16; ///< Selector.\r | |
5387 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5388 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5389 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
dc317713 | 5390 | } Bits;\r |
5391 | UINT64 Uint64;\r | |
5392 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
5393 | \r | |
364a5474 JW |
5394 | #pragma pack (1)\r |
5395 | //\r | |
5396 | // IA32 Task-State Segment Definition\r | |
5397 | //\r | |
5398 | typedef struct {\r | |
5399 | UINT16 PreviousTaskLink;\r | |
5400 | UINT16 Reserved_2;\r | |
3ab032fc JW |
5401 | UINT32 ESP0;\r |
5402 | UINT16 SS0;\r | |
364a5474 | 5403 | UINT16 Reserved_10;\r |
3ab032fc JW |
5404 | UINT32 ESP1;\r |
5405 | UINT16 SS1;\r | |
364a5474 | 5406 | UINT16 Reserved_18;\r |
3ab032fc JW |
5407 | UINT32 ESP2;\r |
5408 | UINT16 SS2;\r | |
364a5474 | 5409 | UINT16 Reserved_26;\r |
3ab032fc JW |
5410 | UINT32 CR3;\r |
5411 | UINT32 EIP;\r | |
5412 | UINT32 EFLAGS;\r | |
5413 | UINT32 EAX;\r | |
5414 | UINT32 ECX;\r | |
5415 | UINT32 EDX;\r | |
5416 | UINT32 EBX;\r | |
5417 | UINT32 ESP;\r | |
5418 | UINT32 EBP;\r | |
5419 | UINT32 ESI;\r | |
5420 | UINT32 EDI;\r | |
5421 | UINT16 ES;\r | |
364a5474 | 5422 | UINT16 Reserved_74;\r |
3ab032fc | 5423 | UINT16 CS;\r |
364a5474 | 5424 | UINT16 Reserved_78;\r |
3ab032fc | 5425 | UINT16 SS;\r |
364a5474 | 5426 | UINT16 Reserved_82;\r |
3ab032fc | 5427 | UINT16 DS;\r |
364a5474 | 5428 | UINT16 Reserved_86;\r |
3ab032fc | 5429 | UINT16 FS;\r |
364a5474 | 5430 | UINT16 Reserved_90;\r |
3ab032fc | 5431 | UINT16 GS;\r |
364a5474 JW |
5432 | UINT16 Reserved_94;\r |
5433 | UINT16 LDTSegmentSelector;\r | |
5434 | UINT16 Reserved_98;\r | |
3ab032fc | 5435 | UINT16 T;\r |
364a5474 JW |
5436 | UINT16 IOMapBaseAddress;\r |
5437 | } IA32_TASK_STATE_SEGMENT;\r | |
5438 | \r | |
5439 | typedef union {\r | |
5440 | struct {\r | |
5441 | UINT32 LimitLow:16; ///< Segment Limit 15..00\r | |
5442 | UINT32 BaseLow:16; ///< Base Address 15..00\r | |
5443 | UINT32 BaseMid:8; ///< Base Address 23..16\r | |
5444 | UINT32 Type:4; ///< Type (1 0 B 1)\r | |
5445 | UINT32 Reserved_43:1; ///< 0\r | |
3ab032fc JW |
5446 | UINT32 DPL:2; ///< Descriptor Privilege Level\r |
5447 | UINT32 P:1; ///< Segment Present\r | |
364a5474 | 5448 | UINT32 LimitHigh:4; ///< Segment Limit 19..16\r |
3ab032fc | 5449 | UINT32 AVL:1; ///< Available for use by system software\r |
364a5474 | 5450 | UINT32 Reserved_52:2; ///< 0 0\r |
3ab032fc | 5451 | UINT32 G:1; ///< Granularity\r |
364a5474 JW |
5452 | UINT32 BaseHigh:8; ///< Base Address 31..24\r |
5453 | } Bits;\r | |
5454 | UINT64 Uint64;\r | |
5455 | } IA32_TSS_DESCRIPTOR;\r | |
5456 | #pragma pack ()\r | |
5457 | \r | |
de4f7f52 | 5458 | #endif // defined (MDE_CPU_IA32)\r |
dc317713 | 5459 | \r |
5460 | #if defined (MDE_CPU_X64)\r | |
6f4aad3b | 5461 | ///\r |
af2dc6a7 | 5462 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.\r |
6f4aad3b | 5463 | ///\r |
ac644614 | 5464 | typedef union {\r |
5465 | struct {\r | |
af2dc6a7 | 5466 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5467 | UINT32 Selector:16; ///< Selector.\r | |
5468 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5469 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5470 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
5471 | UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r | |
5472 | UINT32 Reserved_1:32; ///< Reserved.\r | |
ac644614 | 5473 | } Bits;\r |
6f4aad3b | 5474 | struct {\r |
5475 | UINT64 Uint64;\r | |
5476 | UINT64 Uint64_1;\r | |
9095d37b | 5477 | } Uint128;\r |
ac644614 | 5478 | } IA32_IDT_GATE_DESCRIPTOR;\r |
5479 | \r | |
364a5474 JW |
5480 | #pragma pack (1)\r |
5481 | //\r | |
5482 | // IA32 Task-State Segment Definition\r | |
5483 | //\r | |
5484 | typedef struct {\r | |
5485 | UINT32 Reserved_0;\r | |
3ab032fc JW |
5486 | UINT64 RSP0;\r |
5487 | UINT64 RSP1;\r | |
5488 | UINT64 RSP2;\r | |
364a5474 | 5489 | UINT64 Reserved_28;\r |
3ab032fc | 5490 | UINT64 IST[7];\r |
364a5474 JW |
5491 | UINT64 Reserved_92;\r |
5492 | UINT16 Reserved_100;\r | |
5493 | UINT16 IOMapBaseAddress;\r | |
5494 | } IA32_TASK_STATE_SEGMENT;\r | |
5495 | \r | |
5496 | typedef union {\r | |
5497 | struct {\r | |
5498 | UINT32 LimitLow:16; ///< Segment Limit 15..00\r | |
5499 | UINT32 BaseLow:16; ///< Base Address 15..00\r | |
5500 | UINT32 BaseMidl:8; ///< Base Address 23..16\r | |
5501 | UINT32 Type:4; ///< Type (1 0 B 1)\r | |
5502 | UINT32 Reserved_43:1; ///< 0\r | |
3ab032fc JW |
5503 | UINT32 DPL:2; ///< Descriptor Privilege Level\r |
5504 | UINT32 P:1; ///< Segment Present\r | |
364a5474 | 5505 | UINT32 LimitHigh:4; ///< Segment Limit 19..16\r |
3ab032fc | 5506 | UINT32 AVL:1; ///< Available for use by system software\r |
364a5474 | 5507 | UINT32 Reserved_52:2; ///< 0 0\r |
3ab032fc | 5508 | UINT32 G:1; ///< Granularity\r |
364a5474 JW |
5509 | UINT32 BaseMidh:8; ///< Base Address 31..24\r |
5510 | UINT32 BaseHigh:32; ///< Base Address 63..32\r | |
5511 | UINT32 Reserved_96:32; ///< Reserved\r | |
5512 | } Bits;\r | |
5513 | struct {\r | |
5514 | UINT64 Uint64;\r | |
5515 | UINT64 Uint64_1;\r | |
5516 | } Uint128;\r | |
5517 | } IA32_TSS_DESCRIPTOR;\r | |
5518 | #pragma pack ()\r | |
5519 | \r | |
de4f7f52 | 5520 | #endif // defined (MDE_CPU_X64)\r |
dc317713 | 5521 | \r |
1106ffe1 | 5522 | ///\r |
af2dc6a7 | 5523 | /// Byte packed structure for an FP/SSE/SSE2 context.\r |
1106ffe1 | 5524 | ///\r |
ac644614 | 5525 | typedef struct {\r |
5526 | UINT8 Buffer[512];\r | |
5527 | } IA32_FX_BUFFER;\r | |
5528 | \r | |
1106ffe1 | 5529 | ///\r |
af2dc6a7 | 5530 | /// Structures for the 16-bit real mode thunks.\r |
1106ffe1 | 5531 | ///\r |
ac644614 | 5532 | typedef struct {\r |
5533 | UINT32 Reserved1;\r | |
5534 | UINT32 Reserved2;\r | |
5535 | UINT32 Reserved3;\r | |
5536 | UINT32 Reserved4;\r | |
5537 | UINT8 BL;\r | |
5538 | UINT8 BH;\r | |
5539 | UINT16 Reserved5;\r | |
5540 | UINT8 DL;\r | |
5541 | UINT8 DH;\r | |
5542 | UINT16 Reserved6;\r | |
5543 | UINT8 CL;\r | |
5544 | UINT8 CH;\r | |
5545 | UINT16 Reserved7;\r | |
5546 | UINT8 AL;\r | |
5547 | UINT8 AH;\r | |
5548 | UINT16 Reserved8;\r | |
5549 | } IA32_BYTE_REGS;\r | |
5550 | \r | |
5551 | typedef struct {\r | |
5552 | UINT16 DI;\r | |
5553 | UINT16 Reserved1;\r | |
5554 | UINT16 SI;\r | |
5555 | UINT16 Reserved2;\r | |
5556 | UINT16 BP;\r | |
5557 | UINT16 Reserved3;\r | |
5558 | UINT16 SP;\r | |
5559 | UINT16 Reserved4;\r | |
5560 | UINT16 BX;\r | |
5561 | UINT16 Reserved5;\r | |
5562 | UINT16 DX;\r | |
5563 | UINT16 Reserved6;\r | |
5564 | UINT16 CX;\r | |
5565 | UINT16 Reserved7;\r | |
5566 | UINT16 AX;\r | |
5567 | UINT16 Reserved8;\r | |
5568 | } IA32_WORD_REGS;\r | |
5569 | \r | |
5570 | typedef struct {\r | |
5571 | UINT32 EDI;\r | |
5572 | UINT32 ESI;\r | |
5573 | UINT32 EBP;\r | |
5574 | UINT32 ESP;\r | |
5575 | UINT32 EBX;\r | |
5576 | UINT32 EDX;\r | |
5577 | UINT32 ECX;\r | |
5578 | UINT32 EAX;\r | |
5579 | UINT16 DS;\r | |
5580 | UINT16 ES;\r | |
5581 | UINT16 FS;\r | |
5582 | UINT16 GS;\r | |
5583 | IA32_EFLAGS32 EFLAGS;\r | |
5584 | UINT32 Eip;\r | |
5585 | UINT16 CS;\r | |
5586 | UINT16 SS;\r | |
5587 | } IA32_DWORD_REGS;\r | |
5588 | \r | |
5589 | typedef union {\r | |
5590 | IA32_DWORD_REGS E;\r | |
5591 | IA32_WORD_REGS X;\r | |
5592 | IA32_BYTE_REGS H;\r | |
5593 | } IA32_REGISTER_SET;\r | |
5594 | \r | |
1106ffe1 | 5595 | ///\r |
af2dc6a7 | 5596 | /// Byte packed structure for an 16-bit real mode thunks.\r |
1106ffe1 | 5597 | ///\r |
ac644614 | 5598 | typedef struct {\r |
5599 | IA32_REGISTER_SET *RealModeState;\r | |
5600 | VOID *RealModeBuffer;\r | |
5601 | UINT32 RealModeBufferSize;\r | |
5602 | UINT32 ThunkAttributes;\r | |
5603 | } THUNK_CONTEXT;\r | |
5604 | \r | |
5605 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r | |
5606 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
5607 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
5608 | \r | |
8596c140 LE |
5609 | ///\r |
5610 | /// Type definition for representing labels in NASM source code that allow for\r | |
5611 | /// the patching of immediate operands of IA32 and X64 instructions.\r | |
5612 | ///\r | |
5613 | /// While the type is technically defined as a function type (note: not a\r | |
5614 | /// pointer-to-function type), such labels in NASM source code never stand for\r | |
5615 | /// actual functions, and identifiers declared with this function type should\r | |
5616 | /// never be called. This is also why the EFIAPI calling convention specifier\r | |
5617 | /// is missing from the typedef, and why the typedef does not follow the usual\r | |
5618 | /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID\r | |
5619 | /// return type and the VOID argument list are merely artifacts.\r | |
5620 | ///\r | |
5621 | typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (VOID);\r | |
5622 | \r | |
ac644614 | 5623 | /**\r |
5624 | Retrieves CPUID information.\r | |
5625 | \r | |
5626 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
5627 | This function always returns Index.\r | |
5628 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5629 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5630 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5631 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
030cd1a2 | 5632 | This function is only available on IA-32 and x64.\r |
ac644614 | 5633 | \r |
5634 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
5635 | instruction.\r | |
af2dc6a7 | 5636 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5637 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5638 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5639 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5640 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5641 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5642 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5643 | instruction. This is an optional parameter that may be NULL.\r |
5644 | \r | |
2fe241a2 | 5645 | @return Index.\r |
ac644614 | 5646 | \r |
5647 | **/\r | |
5648 | UINT32\r | |
5649 | EFIAPI\r | |
5650 | AsmCpuid (\r | |
5651 | IN UINT32 Index,\r | |
5652 | OUT UINT32 *Eax, OPTIONAL\r | |
5653 | OUT UINT32 *Ebx, OPTIONAL\r | |
5654 | OUT UINT32 *Ecx, OPTIONAL\r | |
5655 | OUT UINT32 *Edx OPTIONAL\r | |
5656 | );\r | |
5657 | \r | |
5658 | \r | |
5659 | /**\r | |
5660 | Retrieves CPUID information using an extended leaf identifier.\r | |
5661 | \r | |
5662 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
5663 | and ECX set to the value specified by SubIndex. This function always returns\r | |
5664 | Index. This function is only available on IA-32 and x64.\r | |
5665 | \r | |
5666 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5667 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5668 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5669 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
5670 | \r | |
5671 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
5672 | CPUID instruction.\r | |
5673 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
5674 | CPUID instruction.\r | |
af2dc6a7 | 5675 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5676 | instruction. This is an optional parameter that may be\r |
5677 | NULL.\r | |
af2dc6a7 | 5678 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5679 | instruction. This is an optional parameter that may be\r |
5680 | NULL.\r | |
af2dc6a7 | 5681 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5682 | instruction. This is an optional parameter that may be\r |
5683 | NULL.\r | |
af2dc6a7 | 5684 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5685 | instruction. This is an optional parameter that may be\r |
5686 | NULL.\r | |
5687 | \r | |
2fe241a2 | 5688 | @return Index.\r |
ac644614 | 5689 | \r |
5690 | **/\r | |
5691 | UINT32\r | |
5692 | EFIAPI\r | |
5693 | AsmCpuidEx (\r | |
5694 | IN UINT32 Index,\r | |
5695 | IN UINT32 SubIndex,\r | |
5696 | OUT UINT32 *Eax, OPTIONAL\r | |
5697 | OUT UINT32 *Ebx, OPTIONAL\r | |
5698 | OUT UINT32 *Ecx, OPTIONAL\r | |
5699 | OUT UINT32 *Edx OPTIONAL\r | |
5700 | );\r | |
5701 | \r | |
5702 | \r | |
be5f1614 | 5703 | /**\r |
5704 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r | |
5705 | \r | |
5706 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r | |
5707 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r | |
5708 | \r | |
5709 | **/\r | |
5710 | VOID\r | |
5711 | EFIAPI\r | |
5712 | AsmDisableCache (\r | |
5713 | VOID\r | |
5714 | );\r | |
5715 | \r | |
5716 | \r | |
5717 | /**\r | |
5718 | Perform a WBINVD and clear both the CD and NW bits of CR0.\r | |
5719 | \r | |
5720 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r | |
5721 | bits of CR0 to 0. This function is only available on IA-32 and x64.\r | |
5722 | \r | |
5723 | **/\r | |
5724 | VOID\r | |
5725 | EFIAPI\r | |
5726 | AsmEnableCache (\r | |
5727 | VOID\r | |
5728 | );\r | |
5729 | \r | |
5730 | \r | |
ac644614 | 5731 | /**\r |
5732 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
5733 | \r | |
5734 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
5735 | No parameter checking is performed on Index, and some Index values may cause\r | |
5736 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
5737 | caller must set up exception handlers to catch the exceptions. This function\r | |
030cd1a2 | 5738 | is only available on IA-32 and x64.\r |
ac644614 | 5739 | \r |
5740 | @param Index The 32-bit MSR index to read.\r | |
5741 | \r | |
5742 | @return The lower 32 bits of the MSR identified by Index.\r | |
5743 | \r | |
5744 | **/\r | |
5745 | UINT32\r | |
5746 | EFIAPI\r | |
5747 | AsmReadMsr32 (\r | |
5748 | IN UINT32 Index\r | |
5749 | );\r | |
5750 | \r | |
5751 | \r | |
5752 | /**\r | |
17f695ed | 5753 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r |
5754 | The upper 32-bits of the MSR are set to zero.\r | |
ac644614 | 5755 | \r |
5756 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
5757 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
5758 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
5759 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
5760 | that Index and Value are valid, or the caller must establish proper exception\r | |
030cd1a2 | 5761 | handlers. This function is only available on IA-32 and x64.\r |
ac644614 | 5762 | \r |
5763 | @param Index The 32-bit MSR index to write.\r | |
5764 | @param Value The 32-bit value to write to the MSR.\r | |
5765 | \r | |
5766 | @return Value\r | |
5767 | \r | |
5768 | **/\r | |
5769 | UINT32\r | |
5770 | EFIAPI\r | |
5771 | AsmWriteMsr32 (\r | |
5772 | IN UINT32 Index,\r | |
5773 | IN UINT32 Value\r | |
5774 | );\r | |
5775 | \r | |
5776 | \r | |
5777 | /**\r | |
62991af2 | 5778 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r |
ac644614 | 5779 | writes the result back to the 64-bit MSR.\r |
5780 | \r | |
62991af2 | 5781 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5782 | between the lower 32-bits of the read result and the value specified by\r |
5783 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
5784 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
5785 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
5786 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
5787 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 5788 | IA-32 and x64.\r |
ac644614 | 5789 | \r |
5790 | @param Index The 32-bit MSR index to write.\r | |
5791 | @param OrData The value to OR with the read value from the MSR.\r | |
5792 | \r | |
5793 | @return The lower 32-bit value written to the MSR.\r | |
5794 | \r | |
5795 | **/\r | |
5796 | UINT32\r | |
5797 | EFIAPI\r | |
5798 | AsmMsrOr32 (\r | |
5799 | IN UINT32 Index,\r | |
5800 | IN UINT32 OrData\r | |
5801 | );\r | |
5802 | \r | |
5803 | \r | |
5804 | /**\r | |
5805 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
5806 | the result back to the 64-bit MSR.\r | |
5807 | \r | |
5808 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5809 | lower 32-bits of the read result and the value specified by AndData, and\r | |
5810 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
5811 | the value written to the MSR is returned. No parameter checking is performed\r | |
5812 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
5813 | must either guarantee that Index and AndData are valid, or the caller must\r | |
5814 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 5815 | and x64.\r |
ac644614 | 5816 | \r |
5817 | @param Index The 32-bit MSR index to write.\r | |
5818 | @param AndData The value to AND with the read value from the MSR.\r | |
5819 | \r | |
5820 | @return The lower 32-bit value written to the MSR.\r | |
5821 | \r | |
5822 | **/\r | |
5823 | UINT32\r | |
5824 | EFIAPI\r | |
5825 | AsmMsrAnd32 (\r | |
5826 | IN UINT32 Index,\r | |
5827 | IN UINT32 AndData\r | |
5828 | );\r | |
5829 | \r | |
5830 | \r | |
5831 | /**\r | |
62991af2 | 5832 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r |
ac644614 | 5833 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r |
5834 | \r | |
5835 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5836 | lower 32-bits of the read result and the value specified by AndData\r | |
62991af2 | 5837 | preserving the upper 32-bits, performs a bitwise OR between the\r |
ac644614 | 5838 | result of the AND operation and the value specified by OrData, and writes the\r |
5839 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
5840 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
5841 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
5842 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
5843 | caller must establish proper exception handlers. This function is only\r | |
030cd1a2 | 5844 | available on IA-32 and x64.\r |
ac644614 | 5845 | \r |
5846 | @param Index The 32-bit MSR index to write.\r | |
5847 | @param AndData The value to AND with the read value from the MSR.\r | |
5848 | @param OrData The value to OR with the result of the AND operation.\r | |
5849 | \r | |
5850 | @return The lower 32-bit value written to the MSR.\r | |
5851 | \r | |
5852 | **/\r | |
5853 | UINT32\r | |
5854 | EFIAPI\r | |
5855 | AsmMsrAndThenOr32 (\r | |
5856 | IN UINT32 Index,\r | |
5857 | IN UINT32 AndData,\r | |
5858 | IN UINT32 OrData\r | |
5859 | );\r | |
5860 | \r | |
5861 | \r | |
5862 | /**\r | |
5863 | Reads a bit field of an MSR.\r | |
5864 | \r | |
5865 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
5866 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
5867 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
5868 | must set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5869 | available on IA-32 and x64.\r |
ac644614 | 5870 | \r |
5871 | If StartBit is greater than 31, then ASSERT().\r | |
5872 | If EndBit is greater than 31, then ASSERT().\r | |
5873 | If EndBit is less than StartBit, then ASSERT().\r | |
5874 | \r | |
5875 | @param Index The 32-bit MSR index to read.\r | |
5876 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5877 | Range 0..31.\r | |
5878 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5879 | Range 0..31.\r | |
5880 | \r | |
5881 | @return The bit field read from the MSR.\r | |
5882 | \r | |
5883 | **/\r | |
5884 | UINT32\r | |
5885 | EFIAPI\r | |
5886 | AsmMsrBitFieldRead32 (\r | |
5887 | IN UINT32 Index,\r | |
5888 | IN UINTN StartBit,\r | |
5889 | IN UINTN EndBit\r | |
5890 | );\r | |
5891 | \r | |
5892 | \r | |
5893 | /**\r | |
5894 | Writes a bit field to an MSR.\r | |
5895 | \r | |
2fe241a2 | 5896 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r |
ac644614 | 5897 | field is specified by the StartBit and the EndBit. All other bits in the\r |
5898 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
9095d37b LG |
5899 | returned. The caller must either guarantee that Index and the data written\r |
5900 | is valid, or the caller must set up exception handlers to catch the exceptions.\r | |
62991af2 | 5901 | This function is only available on IA-32 and x64.\r |
ac644614 | 5902 | \r |
5903 | If StartBit is greater than 31, then ASSERT().\r | |
5904 | If EndBit is greater than 31, then ASSERT().\r | |
5905 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5906 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5907 | \r |
5908 | @param Index The 32-bit MSR index to write.\r | |
5909 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5910 | Range 0..31.\r | |
5911 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5912 | Range 0..31.\r | |
5913 | @param Value New value of the bit field.\r | |
5914 | \r | |
5915 | @return The lower 32-bit of the value written to the MSR.\r | |
5916 | \r | |
5917 | **/\r | |
5918 | UINT32\r | |
5919 | EFIAPI\r | |
5920 | AsmMsrBitFieldWrite32 (\r | |
5921 | IN UINT32 Index,\r | |
5922 | IN UINTN StartBit,\r | |
5923 | IN UINTN EndBit,\r | |
5924 | IN UINT32 Value\r | |
5925 | );\r | |
5926 | \r | |
5927 | \r | |
5928 | /**\r | |
5929 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
5930 | result back to the bit field in the 64-bit MSR.\r | |
5931 | \r | |
62991af2 | 5932 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5933 | between the read result and the value specified by OrData, and writes the\r |
5934 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
5935 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
5936 | caller must either guarantee that Index and the data written is valid, or\r | |
5937 | the caller must set up exception handlers to catch the exceptions. This\r | |
030cd1a2 | 5938 | function is only available on IA-32 and x64.\r |
ac644614 | 5939 | \r |
5940 | If StartBit is greater than 31, then ASSERT().\r | |
5941 | If EndBit is greater than 31, then ASSERT().\r | |
5942 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5943 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5944 | \r |
5945 | @param Index The 32-bit MSR index to write.\r | |
5946 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5947 | Range 0..31.\r | |
5948 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5949 | Range 0..31.\r | |
5950 | @param OrData The value to OR with the read value from the MSR.\r | |
5951 | \r | |
5952 | @return The lower 32-bit of the value written to the MSR.\r | |
5953 | \r | |
5954 | **/\r | |
5955 | UINT32\r | |
5956 | EFIAPI\r | |
5957 | AsmMsrBitFieldOr32 (\r | |
5958 | IN UINT32 Index,\r | |
5959 | IN UINTN StartBit,\r | |
5960 | IN UINTN EndBit,\r | |
5961 | IN UINT32 OrData\r | |
5962 | );\r | |
5963 | \r | |
5964 | \r | |
5965 | /**\r | |
5966 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
5967 | result back to the bit field in the 64-bit MSR.\r | |
5968 | \r | |
5969 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5970 | read result and the value specified by AndData, and writes the result to the\r | |
5971 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
5972 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
5973 | either guarantee that Index and the data written is valid, or the caller must\r | |
5974 | set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5975 | available on IA-32 and x64.\r |
ac644614 | 5976 | \r |
5977 | If StartBit is greater than 31, then ASSERT().\r | |
5978 | If EndBit is greater than 31, then ASSERT().\r | |
5979 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5980 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5981 | \r |
5982 | @param Index The 32-bit MSR index to write.\r | |
5983 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5984 | Range 0..31.\r | |
5985 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5986 | Range 0..31.\r | |
5987 | @param AndData The value to AND with the read value from the MSR.\r | |
5988 | \r | |
5989 | @return The lower 32-bit of the value written to the MSR.\r | |
5990 | \r | |
5991 | **/\r | |
5992 | UINT32\r | |
5993 | EFIAPI\r | |
5994 | AsmMsrBitFieldAnd32 (\r | |
5995 | IN UINT32 Index,\r | |
5996 | IN UINTN StartBit,\r | |
5997 | IN UINTN EndBit,\r | |
5998 | IN UINT32 AndData\r | |
5999 | );\r | |
6000 | \r | |
6001 | \r | |
6002 | /**\r | |
6003 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6004 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6005 | 64-bit MSR.\r |
6006 | \r | |
6007 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
62991af2 | 6008 | bitwise OR between the read result and the value specified by\r |
ac644614 | 6009 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6010 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
6011 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
6012 | that Index and the data written is valid, or the caller must set up exception\r | |
6013 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6014 | and x64.\r |
ac644614 | 6015 | \r |
6016 | If StartBit is greater than 31, then ASSERT().\r | |
6017 | If EndBit is greater than 31, then ASSERT().\r | |
6018 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6019 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6020 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6021 | \r |
6022 | @param Index The 32-bit MSR index to write.\r | |
6023 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6024 | Range 0..31.\r | |
6025 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6026 | Range 0..31.\r | |
6027 | @param AndData The value to AND with the read value from the MSR.\r | |
6028 | @param OrData The value to OR with the result of the AND operation.\r | |
6029 | \r | |
6030 | @return The lower 32-bit of the value written to the MSR.\r | |
6031 | \r | |
6032 | **/\r | |
6033 | UINT32\r | |
6034 | EFIAPI\r | |
6035 | AsmMsrBitFieldAndThenOr32 (\r | |
6036 | IN UINT32 Index,\r | |
6037 | IN UINTN StartBit,\r | |
6038 | IN UINTN EndBit,\r | |
6039 | IN UINT32 AndData,\r | |
6040 | IN UINT32 OrData\r | |
6041 | );\r | |
6042 | \r | |
6043 | \r | |
6044 | /**\r | |
6045 | Returns a 64-bit Machine Specific Register(MSR).\r | |
6046 | \r | |
6047 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
6048 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
6049 | caller must either guarantee that Index is valid, or the caller must set up\r | |
6050 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6051 | on IA-32 and x64.\r |
ac644614 | 6052 | \r |
6053 | @param Index The 32-bit MSR index to read.\r | |
6054 | \r | |
6055 | @return The value of the MSR identified by Index.\r | |
6056 | \r | |
6057 | **/\r | |
6058 | UINT64\r | |
6059 | EFIAPI\r | |
6060 | AsmReadMsr64 (\r | |
6061 | IN UINT32 Index\r | |
6062 | );\r | |
6063 | \r | |
6064 | \r | |
6065 | /**\r | |
6066 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
6067 | value.\r | |
6068 | \r | |
6069 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
6070 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
6071 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
6072 | caller must either guarantee that Index and Value are valid, or the caller\r | |
6073 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 6074 | IA-32 and x64.\r |
ac644614 | 6075 | \r |
6076 | @param Index The 32-bit MSR index to write.\r | |
6077 | @param Value The 64-bit value to write to the MSR.\r | |
6078 | \r | |
6079 | @return Value\r | |
6080 | \r | |
6081 | **/\r | |
6082 | UINT64\r | |
6083 | EFIAPI\r | |
6084 | AsmWriteMsr64 (\r | |
6085 | IN UINT32 Index,\r | |
6086 | IN UINT64 Value\r | |
6087 | );\r | |
6088 | \r | |
6089 | \r | |
6090 | /**\r | |
62991af2 | 6091 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r |
ac644614 | 6092 | back to the 64-bit MSR.\r |
6093 | \r | |
62991af2 | 6094 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6095 | between the read result and the value specified by OrData, and writes the\r |
6096 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6097 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
6098 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
6099 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
030cd1a2 | 6100 | This function is only available on IA-32 and x64.\r |
ac644614 | 6101 | \r |
6102 | @param Index The 32-bit MSR index to write.\r | |
6103 | @param OrData The value to OR with the read value from the MSR.\r | |
6104 | \r | |
6105 | @return The value written back to the MSR.\r | |
6106 | \r | |
6107 | **/\r | |
6108 | UINT64\r | |
6109 | EFIAPI\r | |
6110 | AsmMsrOr64 (\r | |
6111 | IN UINT32 Index,\r | |
6112 | IN UINT64 OrData\r | |
6113 | );\r | |
6114 | \r | |
6115 | \r | |
6116 | /**\r | |
6117 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
6118 | 64-bit MSR.\r | |
6119 | \r | |
6120 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6121 | read result and the value specified by OrData, and writes the result to the\r | |
6122 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
6123 | parameter checking is performed on Index or OrData, and some of these may\r | |
6124 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
6125 | are valid, or the caller must establish proper exception handlers. This\r | |
030cd1a2 | 6126 | function is only available on IA-32 and x64.\r |
ac644614 | 6127 | \r |
6128 | @param Index The 32-bit MSR index to write.\r | |
6129 | @param AndData The value to AND with the read value from the MSR.\r | |
6130 | \r | |
6131 | @return The value written back to the MSR.\r | |
6132 | \r | |
6133 | **/\r | |
6134 | UINT64\r | |
6135 | EFIAPI\r | |
6136 | AsmMsrAnd64 (\r | |
6137 | IN UINT32 Index,\r | |
6138 | IN UINT64 AndData\r | |
6139 | );\r | |
6140 | \r | |
6141 | \r | |
6142 | /**\r | |
9095d37b | 6143 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise\r |
ac644614 | 6144 | OR, and writes the result back to the 64-bit MSR.\r |
6145 | \r | |
6146 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
62991af2 | 6147 | result and the value specified by AndData, performs a bitwise OR\r |
ac644614 | 6148 | between the result of the AND operation and the value specified by OrData,\r |
6149 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
6150 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
6151 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
6152 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
6153 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 6154 | and x64.\r |
ac644614 | 6155 | \r |
6156 | @param Index The 32-bit MSR index to write.\r | |
6157 | @param AndData The value to AND with the read value from the MSR.\r | |
6158 | @param OrData The value to OR with the result of the AND operation.\r | |
6159 | \r | |
6160 | @return The value written back to the MSR.\r | |
6161 | \r | |
6162 | **/\r | |
6163 | UINT64\r | |
6164 | EFIAPI\r | |
6165 | AsmMsrAndThenOr64 (\r | |
6166 | IN UINT32 Index,\r | |
6167 | IN UINT64 AndData,\r | |
6168 | IN UINT64 OrData\r | |
6169 | );\r | |
6170 | \r | |
6171 | \r | |
6172 | /**\r | |
6173 | Reads a bit field of an MSR.\r | |
6174 | \r | |
6175 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
6176 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
6177 | must either guarantee that Index is valid, or the caller must set up\r | |
6178 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6179 | on IA-32 and x64.\r |
ac644614 | 6180 | \r |
6181 | If StartBit is greater than 63, then ASSERT().\r | |
6182 | If EndBit is greater than 63, then ASSERT().\r | |
6183 | If EndBit is less than StartBit, then ASSERT().\r | |
6184 | \r | |
6185 | @param Index The 32-bit MSR index to read.\r | |
6186 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6187 | Range 0..63.\r | |
6188 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6189 | Range 0..63.\r | |
6190 | \r | |
6191 | @return The value read from the MSR.\r | |
6192 | \r | |
6193 | **/\r | |
6194 | UINT64\r | |
6195 | EFIAPI\r | |
6196 | AsmMsrBitFieldRead64 (\r | |
6197 | IN UINT32 Index,\r | |
6198 | IN UINTN StartBit,\r | |
6199 | IN UINTN EndBit\r | |
6200 | );\r | |
6201 | \r | |
6202 | \r | |
6203 | /**\r | |
6204 | Writes a bit field to an MSR.\r | |
6205 | \r | |
6206 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
6207 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
9095d37b LG |
6208 | preserved. The MSR written is returned. The caller must either guarantee\r |
6209 | that Index and the data written is valid, or the caller must set up exception\r | |
62991af2 | 6210 | handlers to catch the exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 6211 | \r |
6212 | If StartBit is greater than 63, then ASSERT().\r | |
6213 | If EndBit is greater than 63, then ASSERT().\r | |
6214 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6215 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6216 | \r |
6217 | @param Index The 32-bit MSR index to write.\r | |
6218 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6219 | Range 0..63.\r | |
6220 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6221 | Range 0..63.\r | |
6222 | @param Value New value of the bit field.\r | |
6223 | \r | |
6224 | @return The value written back to the MSR.\r | |
6225 | \r | |
6226 | **/\r | |
6227 | UINT64\r | |
6228 | EFIAPI\r | |
6229 | AsmMsrBitFieldWrite64 (\r | |
6230 | IN UINT32 Index,\r | |
6231 | IN UINTN StartBit,\r | |
6232 | IN UINTN EndBit,\r | |
6233 | IN UINT64 Value\r | |
6234 | );\r | |
6235 | \r | |
6236 | \r | |
6237 | /**\r | |
62991af2 | 6238 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r |
ac644614 | 6239 | writes the result back to the bit field in the 64-bit MSR.\r |
6240 | \r | |
62991af2 | 6241 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6242 | between the read result and the value specified by OrData, and writes the\r |
6243 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6244 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
6245 | guarantee that Index and the data written is valid, or the caller must set up\r | |
6246 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6247 | on IA-32 and x64.\r |
ac644614 | 6248 | \r |
6249 | If StartBit is greater than 63, then ASSERT().\r | |
6250 | If EndBit is greater than 63, then ASSERT().\r | |
6251 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6252 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6253 | \r |
6254 | @param Index The 32-bit MSR index to write.\r | |
6255 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6256 | Range 0..63.\r | |
6257 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6258 | Range 0..63.\r | |
6259 | @param OrData The value to OR with the read value from the bit field.\r | |
6260 | \r | |
6261 | @return The value written back to the MSR.\r | |
6262 | \r | |
6263 | **/\r | |
6264 | UINT64\r | |
6265 | EFIAPI\r | |
6266 | AsmMsrBitFieldOr64 (\r | |
6267 | IN UINT32 Index,\r | |
6268 | IN UINTN StartBit,\r | |
6269 | IN UINTN EndBit,\r | |
6270 | IN UINT64 OrData\r | |
6271 | );\r | |
6272 | \r | |
6273 | \r | |
6274 | /**\r | |
6275 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
6276 | result back to the bit field in the 64-bit MSR.\r | |
6277 | \r | |
6278 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6279 | read result and the value specified by AndData, and writes the result to the\r | |
6280 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
6281 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
6282 | that Index and the data written is valid, or the caller must set up exception\r | |
6283 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6284 | and x64.\r |
ac644614 | 6285 | \r |
6286 | If StartBit is greater than 63, then ASSERT().\r | |
6287 | If EndBit is greater than 63, then ASSERT().\r | |
6288 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6289 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6290 | \r |
6291 | @param Index The 32-bit MSR index to write.\r | |
6292 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6293 | Range 0..63.\r | |
6294 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6295 | Range 0..63.\r | |
6296 | @param AndData The value to AND with the read value from the bit field.\r | |
6297 | \r | |
6298 | @return The value written back to the MSR.\r | |
6299 | \r | |
6300 | **/\r | |
6301 | UINT64\r | |
6302 | EFIAPI\r | |
6303 | AsmMsrBitFieldAnd64 (\r | |
6304 | IN UINT32 Index,\r | |
6305 | IN UINTN StartBit,\r | |
6306 | IN UINTN EndBit,\r | |
6307 | IN UINT64 AndData\r | |
6308 | );\r | |
6309 | \r | |
6310 | \r | |
6311 | /**\r | |
6312 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6313 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6314 | 64-bit MSR.\r |
6315 | \r | |
6316 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
62991af2 | 6317 | a bitwise OR between the read result and the value specified by\r |
ac644614 | 6318 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6319 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
6320 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
6321 | written is valid, or the caller must set up exception handlers to catch the\r | |
030cd1a2 | 6322 | exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 6323 | \r |
6324 | If StartBit is greater than 63, then ASSERT().\r | |
6325 | If EndBit is greater than 63, then ASSERT().\r | |
6326 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6327 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6328 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6329 | \r |
6330 | @param Index The 32-bit MSR index to write.\r | |
6331 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6332 | Range 0..63.\r | |
6333 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6334 | Range 0..63.\r | |
6335 | @param AndData The value to AND with the read value from the bit field.\r | |
6336 | @param OrData The value to OR with the result of the AND operation.\r | |
6337 | \r | |
6338 | @return The value written back to the MSR.\r | |
6339 | \r | |
6340 | **/\r | |
6341 | UINT64\r | |
6342 | EFIAPI\r | |
6343 | AsmMsrBitFieldAndThenOr64 (\r | |
6344 | IN UINT32 Index,\r | |
6345 | IN UINTN StartBit,\r | |
6346 | IN UINTN EndBit,\r | |
6347 | IN UINT64 AndData,\r | |
6348 | IN UINT64 OrData\r | |
6349 | );\r | |
6350 | \r | |
6351 | \r | |
6352 | /**\r | |
6353 | Reads the current value of the EFLAGS register.\r | |
6354 | \r | |
6355 | Reads and returns the current value of the EFLAGS register. This function is\r | |
030cd1a2 | 6356 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r |
6357 | 64-bit value on x64.\r | |
ac644614 | 6358 | \r |
030cd1a2 | 6359 | @return EFLAGS on IA-32 or RFLAGS on x64.\r |
ac644614 | 6360 | \r |
6361 | **/\r | |
6362 | UINTN\r | |
6363 | EFIAPI\r | |
6364 | AsmReadEflags (\r | |
6365 | VOID\r | |
6366 | );\r | |
6367 | \r | |
6368 | \r | |
6369 | /**\r | |
6370 | Reads the current value of the Control Register 0 (CR0).\r | |
6371 | \r | |
6372 | Reads and returns the current value of CR0. This function is only available\r | |
030cd1a2 | 6373 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6374 | x64.\r | |
ac644614 | 6375 | \r |
6376 | @return The value of the Control Register 0 (CR0).\r | |
6377 | \r | |
6378 | **/\r | |
6379 | UINTN\r | |
6380 | EFIAPI\r | |
6381 | AsmReadCr0 (\r | |
6382 | VOID\r | |
6383 | );\r | |
6384 | \r | |
6385 | \r | |
6386 | /**\r | |
6387 | Reads the current value of the Control Register 2 (CR2).\r | |
6388 | \r | |
6389 | Reads and returns the current value of CR2. This function is only available\r | |
030cd1a2 | 6390 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6391 | x64.\r | |
ac644614 | 6392 | \r |
6393 | @return The value of the Control Register 2 (CR2).\r | |
6394 | \r | |
6395 | **/\r | |
6396 | UINTN\r | |
6397 | EFIAPI\r | |
6398 | AsmReadCr2 (\r | |
6399 | VOID\r | |
6400 | );\r | |
6401 | \r | |
6402 | \r | |
6403 | /**\r | |
6404 | Reads the current value of the Control Register 3 (CR3).\r | |
6405 | \r | |
6406 | Reads and returns the current value of CR3. This function is only available\r | |
030cd1a2 | 6407 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6408 | x64.\r | |
ac644614 | 6409 | \r |
6410 | @return The value of the Control Register 3 (CR3).\r | |
6411 | \r | |
6412 | **/\r | |
6413 | UINTN\r | |
6414 | EFIAPI\r | |
6415 | AsmReadCr3 (\r | |
6416 | VOID\r | |
6417 | );\r | |
6418 | \r | |
6419 | \r | |
6420 | /**\r | |
6421 | Reads the current value of the Control Register 4 (CR4).\r | |
6422 | \r | |
6423 | Reads and returns the current value of CR4. This function is only available\r | |
030cd1a2 | 6424 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6425 | x64.\r | |
ac644614 | 6426 | \r |
6427 | @return The value of the Control Register 4 (CR4).\r | |
6428 | \r | |
6429 | **/\r | |
6430 | UINTN\r | |
6431 | EFIAPI\r | |
6432 | AsmReadCr4 (\r | |
6433 | VOID\r | |
6434 | );\r | |
6435 | \r | |
6436 | \r | |
6437 | /**\r | |
6438 | Writes a value to Control Register 0 (CR0).\r | |
6439 | \r | |
6440 | Writes and returns a new value to CR0. This function is only available on\r | |
030cd1a2 | 6441 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6442 | \r |
6443 | @param Cr0 The value to write to CR0.\r | |
6444 | \r | |
6445 | @return The value written to CR0.\r | |
6446 | \r | |
6447 | **/\r | |
6448 | UINTN\r | |
6449 | EFIAPI\r | |
6450 | AsmWriteCr0 (\r | |
6451 | UINTN Cr0\r | |
6452 | );\r | |
6453 | \r | |
6454 | \r | |
6455 | /**\r | |
6456 | Writes a value to Control Register 2 (CR2).\r | |
6457 | \r | |
6458 | Writes and returns a new value to CR2. This function is only available on\r | |
030cd1a2 | 6459 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6460 | \r |
6461 | @param Cr2 The value to write to CR2.\r | |
6462 | \r | |
6463 | @return The value written to CR2.\r | |
6464 | \r | |
6465 | **/\r | |
6466 | UINTN\r | |
6467 | EFIAPI\r | |
6468 | AsmWriteCr2 (\r | |
6469 | UINTN Cr2\r | |
6470 | );\r | |
6471 | \r | |
6472 | \r | |
6473 | /**\r | |
6474 | Writes a value to Control Register 3 (CR3).\r | |
6475 | \r | |
6476 | Writes and returns a new value to CR3. This function is only available on\r | |
030cd1a2 | 6477 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6478 | \r |
6479 | @param Cr3 The value to write to CR3.\r | |
6480 | \r | |
6481 | @return The value written to CR3.\r | |
6482 | \r | |
6483 | **/\r | |
6484 | UINTN\r | |
6485 | EFIAPI\r | |
6486 | AsmWriteCr3 (\r | |
6487 | UINTN Cr3\r | |
6488 | );\r | |
6489 | \r | |
6490 | \r | |
6491 | /**\r | |
6492 | Writes a value to Control Register 4 (CR4).\r | |
6493 | \r | |
6494 | Writes and returns a new value to CR4. This function is only available on\r | |
030cd1a2 | 6495 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6496 | \r |
6497 | @param Cr4 The value to write to CR4.\r | |
6498 | \r | |
6499 | @return The value written to CR4.\r | |
6500 | \r | |
6501 | **/\r | |
6502 | UINTN\r | |
6503 | EFIAPI\r | |
6504 | AsmWriteCr4 (\r | |
6505 | UINTN Cr4\r | |
6506 | );\r | |
6507 | \r | |
6508 | \r | |
6509 | /**\r | |
6510 | Reads the current value of Debug Register 0 (DR0).\r | |
6511 | \r | |
6512 | Reads and returns the current value of DR0. This function is only available\r | |
030cd1a2 | 6513 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6514 | x64.\r | |
ac644614 | 6515 | \r |
6516 | @return The value of Debug Register 0 (DR0).\r | |
6517 | \r | |
6518 | **/\r | |
6519 | UINTN\r | |
6520 | EFIAPI\r | |
6521 | AsmReadDr0 (\r | |
6522 | VOID\r | |
6523 | );\r | |
6524 | \r | |
6525 | \r | |
6526 | /**\r | |
6527 | Reads the current value of Debug Register 1 (DR1).\r | |
6528 | \r | |
6529 | Reads and returns the current value of DR1. This function is only available\r | |
030cd1a2 | 6530 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6531 | x64.\r | |
ac644614 | 6532 | \r |
6533 | @return The value of Debug Register 1 (DR1).\r | |
6534 | \r | |
6535 | **/\r | |
6536 | UINTN\r | |
6537 | EFIAPI\r | |
6538 | AsmReadDr1 (\r | |
6539 | VOID\r | |
6540 | );\r | |
6541 | \r | |
6542 | \r | |
6543 | /**\r | |
6544 | Reads the current value of Debug Register 2 (DR2).\r | |
6545 | \r | |
6546 | Reads and returns the current value of DR2. This function is only available\r | |
030cd1a2 | 6547 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6548 | x64.\r | |
ac644614 | 6549 | \r |
6550 | @return The value of Debug Register 2 (DR2).\r | |
6551 | \r | |
6552 | **/\r | |
6553 | UINTN\r | |
6554 | EFIAPI\r | |
6555 | AsmReadDr2 (\r | |
6556 | VOID\r | |
6557 | );\r | |
6558 | \r | |
6559 | \r | |
6560 | /**\r | |
6561 | Reads the current value of Debug Register 3 (DR3).\r | |
6562 | \r | |
6563 | Reads and returns the current value of DR3. This function is only available\r | |
030cd1a2 | 6564 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6565 | x64.\r | |
ac644614 | 6566 | \r |
6567 | @return The value of Debug Register 3 (DR3).\r | |
6568 | \r | |
6569 | **/\r | |
6570 | UINTN\r | |
6571 | EFIAPI\r | |
6572 | AsmReadDr3 (\r | |
6573 | VOID\r | |
6574 | );\r | |
6575 | \r | |
6576 | \r | |
6577 | /**\r | |
6578 | Reads the current value of Debug Register 4 (DR4).\r | |
6579 | \r | |
6580 | Reads and returns the current value of DR4. This function is only available\r | |
030cd1a2 | 6581 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6582 | x64.\r | |
ac644614 | 6583 | \r |
6584 | @return The value of Debug Register 4 (DR4).\r | |
6585 | \r | |
6586 | **/\r | |
6587 | UINTN\r | |
6588 | EFIAPI\r | |
6589 | AsmReadDr4 (\r | |
6590 | VOID\r | |
6591 | );\r | |
6592 | \r | |
6593 | \r | |
6594 | /**\r | |
6595 | Reads the current value of Debug Register 5 (DR5).\r | |
6596 | \r | |
6597 | Reads and returns the current value of DR5. This function is only available\r | |
030cd1a2 | 6598 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6599 | x64.\r | |
ac644614 | 6600 | \r |
6601 | @return The value of Debug Register 5 (DR5).\r | |
6602 | \r | |
6603 | **/\r | |
6604 | UINTN\r | |
6605 | EFIAPI\r | |
6606 | AsmReadDr5 (\r | |
6607 | VOID\r | |
6608 | );\r | |
6609 | \r | |
6610 | \r | |
6611 | /**\r | |
6612 | Reads the current value of Debug Register 6 (DR6).\r | |
6613 | \r | |
6614 | Reads and returns the current value of DR6. This function is only available\r | |
030cd1a2 | 6615 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6616 | x64.\r | |
ac644614 | 6617 | \r |
6618 | @return The value of Debug Register 6 (DR6).\r | |
6619 | \r | |
6620 | **/\r | |
6621 | UINTN\r | |
6622 | EFIAPI\r | |
6623 | AsmReadDr6 (\r | |
6624 | VOID\r | |
6625 | );\r | |
6626 | \r | |
6627 | \r | |
6628 | /**\r | |
6629 | Reads the current value of Debug Register 7 (DR7).\r | |
6630 | \r | |
6631 | Reads and returns the current value of DR7. This function is only available\r | |
030cd1a2 | 6632 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6633 | x64.\r | |
ac644614 | 6634 | \r |
6635 | @return The value of Debug Register 7 (DR7).\r | |
6636 | \r | |
6637 | **/\r | |
6638 | UINTN\r | |
6639 | EFIAPI\r | |
6640 | AsmReadDr7 (\r | |
6641 | VOID\r | |
6642 | );\r | |
6643 | \r | |
6644 | \r | |
6645 | /**\r | |
6646 | Writes a value to Debug Register 0 (DR0).\r | |
6647 | \r | |
6648 | Writes and returns a new value to DR0. This function is only available on\r | |
030cd1a2 | 6649 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6650 | \r |
6651 | @param Dr0 The value to write to Dr0.\r | |
6652 | \r | |
6653 | @return The value written to Debug Register 0 (DR0).\r | |
6654 | \r | |
6655 | **/\r | |
6656 | UINTN\r | |
6657 | EFIAPI\r | |
6658 | AsmWriteDr0 (\r | |
6659 | UINTN Dr0\r | |
6660 | );\r | |
6661 | \r | |
6662 | \r | |
6663 | /**\r | |
6664 | Writes a value to Debug Register 1 (DR1).\r | |
6665 | \r | |
6666 | Writes and returns a new value to DR1. This function is only available on\r | |
030cd1a2 | 6667 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6668 | \r |
6669 | @param Dr1 The value to write to Dr1.\r | |
6670 | \r | |
6671 | @return The value written to Debug Register 1 (DR1).\r | |
6672 | \r | |
6673 | **/\r | |
6674 | UINTN\r | |
6675 | EFIAPI\r | |
6676 | AsmWriteDr1 (\r | |
6677 | UINTN Dr1\r | |
6678 | );\r | |
6679 | \r | |
6680 | \r | |
6681 | /**\r | |
6682 | Writes a value to Debug Register 2 (DR2).\r | |
6683 | \r | |
6684 | Writes and returns a new value to DR2. This function is only available on\r | |
030cd1a2 | 6685 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6686 | \r |
6687 | @param Dr2 The value to write to Dr2.\r | |
6688 | \r | |
6689 | @return The value written to Debug Register 2 (DR2).\r | |
6690 | \r | |
6691 | **/\r | |
6692 | UINTN\r | |
6693 | EFIAPI\r | |
6694 | AsmWriteDr2 (\r | |
6695 | UINTN Dr2\r | |
6696 | );\r | |
6697 | \r | |
6698 | \r | |
6699 | /**\r | |
6700 | Writes a value to Debug Register 3 (DR3).\r | |
6701 | \r | |
6702 | Writes and returns a new value to DR3. This function is only available on\r | |
030cd1a2 | 6703 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6704 | \r |
6705 | @param Dr3 The value to write to Dr3.\r | |
6706 | \r | |
6707 | @return The value written to Debug Register 3 (DR3).\r | |
6708 | \r | |
6709 | **/\r | |
6710 | UINTN\r | |
6711 | EFIAPI\r | |
6712 | AsmWriteDr3 (\r | |
6713 | UINTN Dr3\r | |
6714 | );\r | |
6715 | \r | |
6716 | \r | |
6717 | /**\r | |
6718 | Writes a value to Debug Register 4 (DR4).\r | |
6719 | \r | |
6720 | Writes and returns a new value to DR4. This function is only available on\r | |
030cd1a2 | 6721 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6722 | \r |
6723 | @param Dr4 The value to write to Dr4.\r | |
6724 | \r | |
6725 | @return The value written to Debug Register 4 (DR4).\r | |
6726 | \r | |
6727 | **/\r | |
6728 | UINTN\r | |
6729 | EFIAPI\r | |
6730 | AsmWriteDr4 (\r | |
6731 | UINTN Dr4\r | |
6732 | );\r | |
6733 | \r | |
6734 | \r | |
6735 | /**\r | |
6736 | Writes a value to Debug Register 5 (DR5).\r | |
6737 | \r | |
6738 | Writes and returns a new value to DR5. This function is only available on\r | |
030cd1a2 | 6739 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6740 | \r |
6741 | @param Dr5 The value to write to Dr5.\r | |
6742 | \r | |
6743 | @return The value written to Debug Register 5 (DR5).\r | |
6744 | \r | |
6745 | **/\r | |
6746 | UINTN\r | |
6747 | EFIAPI\r | |
6748 | AsmWriteDr5 (\r | |
6749 | UINTN Dr5\r | |
6750 | );\r | |
6751 | \r | |
6752 | \r | |
6753 | /**\r | |
6754 | Writes a value to Debug Register 6 (DR6).\r | |
6755 | \r | |
6756 | Writes and returns a new value to DR6. This function is only available on\r | |
030cd1a2 | 6757 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6758 | \r |
6759 | @param Dr6 The value to write to Dr6.\r | |
6760 | \r | |
6761 | @return The value written to Debug Register 6 (DR6).\r | |
6762 | \r | |
6763 | **/\r | |
6764 | UINTN\r | |
6765 | EFIAPI\r | |
6766 | AsmWriteDr6 (\r | |
6767 | UINTN Dr6\r | |
6768 | );\r | |
6769 | \r | |
6770 | \r | |
6771 | /**\r | |
6772 | Writes a value to Debug Register 7 (DR7).\r | |
6773 | \r | |
6774 | Writes and returns a new value to DR7. This function is only available on\r | |
030cd1a2 | 6775 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6776 | \r |
6777 | @param Dr7 The value to write to Dr7.\r | |
6778 | \r | |
6779 | @return The value written to Debug Register 7 (DR7).\r | |
6780 | \r | |
6781 | **/\r | |
6782 | UINTN\r | |
6783 | EFIAPI\r | |
6784 | AsmWriteDr7 (\r | |
6785 | UINTN Dr7\r | |
6786 | );\r | |
6787 | \r | |
6788 | \r | |
6789 | /**\r | |
6790 | Reads the current value of Code Segment Register (CS).\r | |
6791 | \r | |
6792 | Reads and returns the current value of CS. This function is only available on\r | |
030cd1a2 | 6793 | IA-32 and x64.\r |
ac644614 | 6794 | \r |
6795 | @return The current value of CS.\r | |
6796 | \r | |
6797 | **/\r | |
6798 | UINT16\r | |
6799 | EFIAPI\r | |
6800 | AsmReadCs (\r | |
6801 | VOID\r | |
6802 | );\r | |
6803 | \r | |
6804 | \r | |
6805 | /**\r | |
6806 | Reads the current value of Data Segment Register (DS).\r | |
6807 | \r | |
6808 | Reads and returns the current value of DS. This function is only available on\r | |
030cd1a2 | 6809 | IA-32 and x64.\r |
ac644614 | 6810 | \r |
6811 | @return The current value of DS.\r | |
6812 | \r | |
6813 | **/\r | |
6814 | UINT16\r | |
6815 | EFIAPI\r | |
6816 | AsmReadDs (\r | |
6817 | VOID\r | |
6818 | );\r | |
6819 | \r | |
6820 | \r | |
6821 | /**\r | |
6822 | Reads the current value of Extra Segment Register (ES).\r | |
6823 | \r | |
6824 | Reads and returns the current value of ES. This function is only available on\r | |
030cd1a2 | 6825 | IA-32 and x64.\r |
ac644614 | 6826 | \r |
6827 | @return The current value of ES.\r | |
6828 | \r | |
6829 | **/\r | |
6830 | UINT16\r | |
6831 | EFIAPI\r | |
6832 | AsmReadEs (\r | |
6833 | VOID\r | |
6834 | );\r | |
6835 | \r | |
6836 | \r | |
6837 | /**\r | |
6838 | Reads the current value of FS Data Segment Register (FS).\r | |
6839 | \r | |
6840 | Reads and returns the current value of FS. This function is only available on\r | |
030cd1a2 | 6841 | IA-32 and x64.\r |
ac644614 | 6842 | \r |
6843 | @return The current value of FS.\r | |
6844 | \r | |
6845 | **/\r | |
6846 | UINT16\r | |
6847 | EFIAPI\r | |
6848 | AsmReadFs (\r | |
6849 | VOID\r | |
6850 | );\r | |
6851 | \r | |
6852 | \r | |
6853 | /**\r | |
6854 | Reads the current value of GS Data Segment Register (GS).\r | |
6855 | \r | |
6856 | Reads and returns the current value of GS. This function is only available on\r | |
030cd1a2 | 6857 | IA-32 and x64.\r |
ac644614 | 6858 | \r |
6859 | @return The current value of GS.\r | |
6860 | \r | |
6861 | **/\r | |
6862 | UINT16\r | |
6863 | EFIAPI\r | |
6864 | AsmReadGs (\r | |
6865 | VOID\r | |
6866 | );\r | |
6867 | \r | |
6868 | \r | |
6869 | /**\r | |
6870 | Reads the current value of Stack Segment Register (SS).\r | |
6871 | \r | |
6872 | Reads and returns the current value of SS. This function is only available on\r | |
030cd1a2 | 6873 | IA-32 and x64.\r |
ac644614 | 6874 | \r |
6875 | @return The current value of SS.\r | |
6876 | \r | |
6877 | **/\r | |
6878 | UINT16\r | |
6879 | EFIAPI\r | |
6880 | AsmReadSs (\r | |
6881 | VOID\r | |
6882 | );\r | |
6883 | \r | |
6884 | \r | |
6885 | /**\r | |
6886 | Reads the current value of Task Register (TR).\r | |
6887 | \r | |
6888 | Reads and returns the current value of TR. This function is only available on\r | |
030cd1a2 | 6889 | IA-32 and x64.\r |
ac644614 | 6890 | \r |
6891 | @return The current value of TR.\r | |
6892 | \r | |
6893 | **/\r | |
6894 | UINT16\r | |
6895 | EFIAPI\r | |
6896 | AsmReadTr (\r | |
6897 | VOID\r | |
6898 | );\r | |
6899 | \r | |
6900 | \r | |
6901 | /**\r | |
6902 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
6903 | \r | |
6904 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
030cd1a2 | 6905 | function is only available on IA-32 and x64.\r |
ac644614 | 6906 | \r |
6907 | If Gdtr is NULL, then ASSERT().\r | |
6908 | \r | |
af2dc6a7 | 6909 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6910 | \r |
6911 | **/\r | |
6912 | VOID\r | |
6913 | EFIAPI\r | |
6914 | AsmReadGdtr (\r | |
6915 | OUT IA32_DESCRIPTOR *Gdtr\r | |
6916 | );\r | |
6917 | \r | |
6918 | \r | |
6919 | /**\r | |
6920 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
6921 | \r | |
6922 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
030cd1a2 | 6923 | only available on IA-32 and x64.\r |
ac644614 | 6924 | \r |
6925 | If Gdtr is NULL, then ASSERT().\r | |
6926 | \r | |
af2dc6a7 | 6927 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6928 | \r |
6929 | **/\r | |
6930 | VOID\r | |
6931 | EFIAPI\r | |
6932 | AsmWriteGdtr (\r | |
6933 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
6934 | );\r | |
6935 | \r | |
6936 | \r | |
6937 | /**\r | |
17f695ed | 6938 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6939 | \r |
6940 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
030cd1a2 | 6941 | function is only available on IA-32 and x64.\r |
ac644614 | 6942 | \r |
6943 | If Idtr is NULL, then ASSERT().\r | |
6944 | \r | |
af2dc6a7 | 6945 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6946 | \r |
6947 | **/\r | |
6948 | VOID\r | |
6949 | EFIAPI\r | |
6950 | AsmReadIdtr (\r | |
6951 | OUT IA32_DESCRIPTOR *Idtr\r | |
6952 | );\r | |
6953 | \r | |
6954 | \r | |
6955 | /**\r | |
17f695ed | 6956 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 6957 | \r |
6958 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
030cd1a2 | 6959 | only available on IA-32 and x64.\r |
ac644614 | 6960 | \r |
6961 | If Idtr is NULL, then ASSERT().\r | |
6962 | \r | |
af2dc6a7 | 6963 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 6964 | \r |
6965 | **/\r | |
6966 | VOID\r | |
6967 | EFIAPI\r | |
6968 | AsmWriteIdtr (\r | |
6969 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
6970 | );\r | |
6971 | \r | |
6972 | \r | |
6973 | /**\r | |
6974 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
6975 | \r | |
6976 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
030cd1a2 | 6977 | only available on IA-32 and x64.\r |
ac644614 | 6978 | \r |
6979 | @return The current selector of LDT.\r | |
6980 | \r | |
6981 | **/\r | |
6982 | UINT16\r | |
6983 | EFIAPI\r | |
6984 | AsmReadLdtr (\r | |
6985 | VOID\r | |
6986 | );\r | |
6987 | \r | |
6988 | \r | |
6989 | /**\r | |
17f695ed | 6990 | Writes the current Local Descriptor Table Register (LDTR) selector.\r |
ac644614 | 6991 | \r |
6992 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
030cd1a2 | 6993 | only available on IA-32 and x64.\r |
ac644614 | 6994 | \r |
6995 | @param Ldtr 16-bit LDTR selector value.\r | |
6996 | \r | |
6997 | **/\r | |
6998 | VOID\r | |
6999 | EFIAPI\r | |
7000 | AsmWriteLdtr (\r | |
7001 | IN UINT16 Ldtr\r | |
7002 | );\r | |
7003 | \r | |
7004 | \r | |
7005 | /**\r | |
7006 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
7007 | \r | |
7008 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
7009 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
030cd1a2 | 7010 | available on IA-32 and x64.\r |
ac644614 | 7011 | \r |
7012 | If Buffer is NULL, then ASSERT().\r | |
7013 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7014 | \r | |
af2dc6a7 | 7015 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7016 | \r |
7017 | **/\r | |
7018 | VOID\r | |
7019 | EFIAPI\r | |
7020 | AsmFxSave (\r | |
7021 | OUT IA32_FX_BUFFER *Buffer\r | |
7022 | );\r | |
7023 | \r | |
7024 | \r | |
7025 | /**\r | |
7026 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
7027 | \r | |
7028 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
7029 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
030cd1a2 | 7030 | only available on IA-32 and x64.\r |
ac644614 | 7031 | \r |
7032 | If Buffer is NULL, then ASSERT().\r | |
7033 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7034 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
7035 | \r | |
af2dc6a7 | 7036 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7037 | \r |
7038 | **/\r | |
7039 | VOID\r | |
7040 | EFIAPI\r | |
7041 | AsmFxRestore (\r | |
7042 | IN CONST IA32_FX_BUFFER *Buffer\r | |
7043 | );\r | |
7044 | \r | |
7045 | \r | |
7046 | /**\r | |
7047 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
7048 | \r | |
7049 | Reads and returns the current value of MM0. This function is only available\r | |
030cd1a2 | 7050 | on IA-32 and x64.\r |
ac644614 | 7051 | \r |
7052 | @return The current value of MM0.\r | |
7053 | \r | |
7054 | **/\r | |
7055 | UINT64\r | |
7056 | EFIAPI\r | |
7057 | AsmReadMm0 (\r | |
7058 | VOID\r | |
7059 | );\r | |
7060 | \r | |
7061 | \r | |
7062 | /**\r | |
7063 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
7064 | \r | |
7065 | Reads and returns the current value of MM1. This function is only available\r | |
030cd1a2 | 7066 | on IA-32 and x64.\r |
ac644614 | 7067 | \r |
7068 | @return The current value of MM1.\r | |
7069 | \r | |
7070 | **/\r | |
7071 | UINT64\r | |
7072 | EFIAPI\r | |
7073 | AsmReadMm1 (\r | |
7074 | VOID\r | |
7075 | );\r | |
7076 | \r | |
7077 | \r | |
7078 | /**\r | |
7079 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
7080 | \r | |
7081 | Reads and returns the current value of MM2. This function is only available\r | |
030cd1a2 | 7082 | on IA-32 and x64.\r |
ac644614 | 7083 | \r |
7084 | @return The current value of MM2.\r | |
7085 | \r | |
7086 | **/\r | |
7087 | UINT64\r | |
7088 | EFIAPI\r | |
7089 | AsmReadMm2 (\r | |
7090 | VOID\r | |
7091 | );\r | |
7092 | \r | |
7093 | \r | |
7094 | /**\r | |
7095 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
7096 | \r | |
7097 | Reads and returns the current value of MM3. This function is only available\r | |
030cd1a2 | 7098 | on IA-32 and x64.\r |
ac644614 | 7099 | \r |
7100 | @return The current value of MM3.\r | |
7101 | \r | |
7102 | **/\r | |
7103 | UINT64\r | |
7104 | EFIAPI\r | |
7105 | AsmReadMm3 (\r | |
7106 | VOID\r | |
7107 | );\r | |
7108 | \r | |
7109 | \r | |
7110 | /**\r | |
7111 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
7112 | \r | |
7113 | Reads and returns the current value of MM4. This function is only available\r | |
030cd1a2 | 7114 | on IA-32 and x64.\r |
ac644614 | 7115 | \r |
7116 | @return The current value of MM4.\r | |
7117 | \r | |
7118 | **/\r | |
7119 | UINT64\r | |
7120 | EFIAPI\r | |
7121 | AsmReadMm4 (\r | |
7122 | VOID\r | |
7123 | );\r | |
7124 | \r | |
7125 | \r | |
7126 | /**\r | |
7127 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
7128 | \r | |
7129 | Reads and returns the current value of MM5. This function is only available\r | |
030cd1a2 | 7130 | on IA-32 and x64.\r |
ac644614 | 7131 | \r |
7132 | @return The current value of MM5.\r | |
7133 | \r | |
7134 | **/\r | |
7135 | UINT64\r | |
7136 | EFIAPI\r | |
7137 | AsmReadMm5 (\r | |
7138 | VOID\r | |
7139 | );\r | |
7140 | \r | |
7141 | \r | |
7142 | /**\r | |
7143 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
7144 | \r | |
7145 | Reads and returns the current value of MM6. This function is only available\r | |
030cd1a2 | 7146 | on IA-32 and x64.\r |
ac644614 | 7147 | \r |
7148 | @return The current value of MM6.\r | |
7149 | \r | |
7150 | **/\r | |
7151 | UINT64\r | |
7152 | EFIAPI\r | |
7153 | AsmReadMm6 (\r | |
7154 | VOID\r | |
7155 | );\r | |
7156 | \r | |
7157 | \r | |
7158 | /**\r | |
7159 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
7160 | \r | |
7161 | Reads and returns the current value of MM7. This function is only available\r | |
030cd1a2 | 7162 | on IA-32 and x64.\r |
ac644614 | 7163 | \r |
7164 | @return The current value of MM7.\r | |
7165 | \r | |
7166 | **/\r | |
7167 | UINT64\r | |
7168 | EFIAPI\r | |
7169 | AsmReadMm7 (\r | |
7170 | VOID\r | |
7171 | );\r | |
7172 | \r | |
7173 | \r | |
7174 | /**\r | |
7175 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
7176 | \r | |
7177 | Writes the current value of MM0. This function is only available on IA32 and\r | |
030cd1a2 | 7178 | x64.\r |
ac644614 | 7179 | \r |
7180 | @param Value The 64-bit value to write to MM0.\r | |
7181 | \r | |
7182 | **/\r | |
7183 | VOID\r | |
7184 | EFIAPI\r | |
7185 | AsmWriteMm0 (\r | |
7186 | IN UINT64 Value\r | |
7187 | );\r | |
7188 | \r | |
7189 | \r | |
7190 | /**\r | |
7191 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
7192 | \r | |
7193 | Writes the current value of MM1. This function is only available on IA32 and\r | |
030cd1a2 | 7194 | x64.\r |
ac644614 | 7195 | \r |
7196 | @param Value The 64-bit value to write to MM1.\r | |
7197 | \r | |
7198 | **/\r | |
7199 | VOID\r | |
7200 | EFIAPI\r | |
7201 | AsmWriteMm1 (\r | |
7202 | IN UINT64 Value\r | |
7203 | );\r | |
7204 | \r | |
7205 | \r | |
7206 | /**\r | |
7207 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
7208 | \r | |
7209 | Writes the current value of MM2. This function is only available on IA32 and\r | |
030cd1a2 | 7210 | x64.\r |
ac644614 | 7211 | \r |
7212 | @param Value The 64-bit value to write to MM2.\r | |
7213 | \r | |
7214 | **/\r | |
7215 | VOID\r | |
7216 | EFIAPI\r | |
7217 | AsmWriteMm2 (\r | |
7218 | IN UINT64 Value\r | |
7219 | );\r | |
7220 | \r | |
7221 | \r | |
7222 | /**\r | |
7223 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
7224 | \r | |
7225 | Writes the current value of MM3. This function is only available on IA32 and\r | |
030cd1a2 | 7226 | x64.\r |
ac644614 | 7227 | \r |
7228 | @param Value The 64-bit value to write to MM3.\r | |
7229 | \r | |
7230 | **/\r | |
7231 | VOID\r | |
7232 | EFIAPI\r | |
7233 | AsmWriteMm3 (\r | |
7234 | IN UINT64 Value\r | |
7235 | );\r | |
7236 | \r | |
7237 | \r | |
7238 | /**\r | |
7239 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
7240 | \r | |
7241 | Writes the current value of MM4. This function is only available on IA32 and\r | |
030cd1a2 | 7242 | x64.\r |
ac644614 | 7243 | \r |
7244 | @param Value The 64-bit value to write to MM4.\r | |
7245 | \r | |
7246 | **/\r | |
7247 | VOID\r | |
7248 | EFIAPI\r | |
7249 | AsmWriteMm4 (\r | |
7250 | IN UINT64 Value\r | |
7251 | );\r | |
7252 | \r | |
7253 | \r | |
7254 | /**\r | |
7255 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
7256 | \r | |
7257 | Writes the current value of MM5. This function is only available on IA32 and\r | |
030cd1a2 | 7258 | x64.\r |
ac644614 | 7259 | \r |
7260 | @param Value The 64-bit value to write to MM5.\r | |
7261 | \r | |
7262 | **/\r | |
7263 | VOID\r | |
7264 | EFIAPI\r | |
7265 | AsmWriteMm5 (\r | |
7266 | IN UINT64 Value\r | |
7267 | );\r | |
7268 | \r | |
7269 | \r | |
7270 | /**\r | |
7271 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
7272 | \r | |
7273 | Writes the current value of MM6. This function is only available on IA32 and\r | |
030cd1a2 | 7274 | x64.\r |
ac644614 | 7275 | \r |
7276 | @param Value The 64-bit value to write to MM6.\r | |
7277 | \r | |
7278 | **/\r | |
7279 | VOID\r | |
7280 | EFIAPI\r | |
7281 | AsmWriteMm6 (\r | |
7282 | IN UINT64 Value\r | |
7283 | );\r | |
7284 | \r | |
7285 | \r | |
7286 | /**\r | |
7287 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
7288 | \r | |
7289 | Writes the current value of MM7. This function is only available on IA32 and\r | |
030cd1a2 | 7290 | x64.\r |
ac644614 | 7291 | \r |
7292 | @param Value The 64-bit value to write to MM7.\r | |
7293 | \r | |
7294 | **/\r | |
7295 | VOID\r | |
7296 | EFIAPI\r | |
7297 | AsmWriteMm7 (\r | |
7298 | IN UINT64 Value\r | |
7299 | );\r | |
7300 | \r | |
7301 | \r | |
7302 | /**\r | |
7303 | Reads the current value of Time Stamp Counter (TSC).\r | |
7304 | \r | |
7305 | Reads and returns the current value of TSC. This function is only available\r | |
030cd1a2 | 7306 | on IA-32 and x64.\r |
ac644614 | 7307 | \r |
7308 | @return The current value of TSC\r | |
7309 | \r | |
7310 | **/\r | |
7311 | UINT64\r | |
7312 | EFIAPI\r | |
7313 | AsmReadTsc (\r | |
7314 | VOID\r | |
7315 | );\r | |
7316 | \r | |
7317 | \r | |
7318 | /**\r | |
7319 | Reads the current value of a Performance Counter (PMC).\r | |
7320 | \r | |
7321 | Reads and returns the current value of performance counter specified by\r | |
030cd1a2 | 7322 | Index. This function is only available on IA-32 and x64.\r |
ac644614 | 7323 | \r |
7324 | @param Index The 32-bit Performance Counter index to read.\r | |
7325 | \r | |
7326 | @return The value of the PMC specified by Index.\r | |
7327 | \r | |
7328 | **/\r | |
7329 | UINT64\r | |
7330 | EFIAPI\r | |
7331 | AsmReadPmc (\r | |
7332 | IN UINT32 Index\r | |
7333 | );\r | |
7334 | \r | |
7335 | \r | |
7336 | /**\r | |
7337 | Sets up a monitor buffer that is used by AsmMwait().\r | |
7338 | \r | |
7339 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
030cd1a2 | 7340 | and Edx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7341 | \r |
7342 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7343 | instruction.\r | |
7344 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7345 | instruction.\r | |
7346 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
7347 | instruction.\r | |
7348 | \r | |
7349 | @return Eax\r | |
7350 | \r | |
7351 | **/\r | |
7352 | UINTN\r | |
7353 | EFIAPI\r | |
7354 | AsmMonitor (\r | |
7355 | IN UINTN Eax,\r | |
7356 | IN UINTN Ecx,\r | |
7357 | IN UINTN Edx\r | |
7358 | );\r | |
7359 | \r | |
7360 | \r | |
7361 | /**\r | |
7362 | Executes an MWAIT instruction.\r | |
7363 | \r | |
7364 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
030cd1a2 | 7365 | Ecx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7366 | \r |
7367 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7368 | instruction.\r | |
7369 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7370 | instruction.\r | |
7371 | \r | |
7372 | @return Eax\r | |
7373 | \r | |
7374 | **/\r | |
7375 | UINTN\r | |
7376 | EFIAPI\r | |
7377 | AsmMwait (\r | |
7378 | IN UINTN Eax,\r | |
7379 | IN UINTN Ecx\r | |
7380 | );\r | |
7381 | \r | |
7382 | \r | |
7383 | /**\r | |
7384 | Executes a WBINVD instruction.\r | |
7385 | \r | |
7386 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7387 | x64.\r |
ac644614 | 7388 | \r |
7389 | **/\r | |
7390 | VOID\r | |
7391 | EFIAPI\r | |
7392 | AsmWbinvd (\r | |
7393 | VOID\r | |
7394 | );\r | |
7395 | \r | |
7396 | \r | |
7397 | /**\r | |
7398 | Executes a INVD instruction.\r | |
7399 | \r | |
7400 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7401 | x64.\r |
ac644614 | 7402 | \r |
7403 | **/\r | |
7404 | VOID\r | |
7405 | EFIAPI\r | |
7406 | AsmInvd (\r | |
7407 | VOID\r | |
7408 | );\r | |
7409 | \r | |
7410 | \r | |
7411 | /**\r | |
7412 | Flushes a cache line from all the instruction and data caches within the\r | |
7413 | coherency domain of the CPU.\r | |
7414 | \r | |
7415 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
030cd1a2 | 7416 | This function is only available on IA-32 and x64.\r |
ac644614 | 7417 | \r |
7418 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
7419 | in a physical addressing mode, then LinearAddress is a\r | |
7420 | physical address. If the CPU is in a virtual\r | |
7421 | addressing mode, then LinearAddress is a virtual\r | |
7422 | address.\r | |
7423 | \r | |
af2dc6a7 | 7424 | @return LinearAddress.\r |
ac644614 | 7425 | **/\r |
7426 | VOID *\r | |
7427 | EFIAPI\r | |
7428 | AsmFlushCacheLine (\r | |
7429 | IN VOID *LinearAddress\r | |
7430 | );\r | |
7431 | \r | |
7432 | \r | |
7433 | /**\r | |
7434 | Enables the 32-bit paging mode on the CPU.\r | |
7435 | \r | |
7436 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7437 | must be properly initialized prior to calling this service. This function\r | |
7438 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
7439 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
7440 | transferred to the function specified by EntryPoint using the new stack\r | |
7441 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
7442 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
7443 | EntryPoint must never return.\r | |
7444 | \r | |
7445 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
7446 | If EntryPoint is NULL, then ASSERT().\r | |
7447 | If NewStack is NULL, then ASSERT().\r | |
7448 | \r | |
7449 | There are a number of constraints that must be followed before calling this\r | |
7450 | function:\r | |
7451 | 1) Interrupts must be disabled.\r | |
7452 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
7453 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
7454 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
7455 | descriptors.\r | |
7456 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
7457 | is complete, and those page tables must guarantee that the pages for this\r | |
7458 | function and the stack are identity mapped.\r | |
7459 | \r | |
7460 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7461 | paging is enabled.\r | |
7462 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7463 | function as the first parameter after paging is enabled.\r | |
7464 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7465 | function as the second parameter after paging is enabled.\r | |
7466 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7467 | function after paging is enabled.\r | |
7468 | \r | |
7469 | **/\r | |
7470 | VOID\r | |
7471 | EFIAPI\r | |
7472 | AsmEnablePaging32 (\r | |
7473 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7474 | IN VOID *Context1, OPTIONAL\r | |
7475 | IN VOID *Context2, OPTIONAL\r | |
7476 | IN VOID *NewStack\r | |
7477 | );\r | |
7478 | \r | |
7479 | \r | |
7480 | /**\r | |
7481 | Disables the 32-bit paging mode on the CPU.\r | |
7482 | \r | |
7483 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
7484 | mode. This function assumes the current execution mode is 32-paged protected\r | |
7485 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
7486 | is disabled, control is transferred to the function specified by EntryPoint\r | |
7487 | using the new stack specified by NewStack and passing in the parameters\r | |
7488 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7489 | may be NULL. The function EntryPoint must never return.\r | |
7490 | \r | |
7491 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
7492 | If EntryPoint is NULL, then ASSERT().\r | |
7493 | If NewStack is NULL, then ASSERT().\r | |
7494 | \r | |
7495 | There are a number of constraints that must be followed before calling this\r | |
7496 | function:\r | |
7497 | 1) Interrupts must be disabled.\r | |
7498 | 2) The caller must be in 32-bit paged mode.\r | |
7499 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
7500 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
7501 | this function and the stack are identity mapped.\r | |
7502 | \r | |
7503 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7504 | paging is disabled.\r | |
7505 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7506 | function as the first parameter after paging is disabled.\r | |
7507 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7508 | function as the second parameter after paging is\r | |
7509 | disabled.\r | |
7510 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7511 | function after paging is disabled.\r | |
7512 | \r | |
7513 | **/\r | |
7514 | VOID\r | |
7515 | EFIAPI\r | |
7516 | AsmDisablePaging32 (\r | |
7517 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7518 | IN VOID *Context1, OPTIONAL\r | |
7519 | IN VOID *Context2, OPTIONAL\r | |
7520 | IN VOID *NewStack\r | |
7521 | );\r | |
7522 | \r | |
7523 | \r | |
7524 | /**\r | |
7525 | Enables the 64-bit paging mode on the CPU.\r | |
7526 | \r | |
7527 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7528 | must be properly initialized prior to calling this service. This function\r | |
7529 | assumes the current execution mode is 32-bit protected mode with flat\r | |
7530 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
7531 | paging mode is enabled, control is transferred to the function specified by\r | |
7532 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
7533 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
7534 | optional and may be 0. The function EntryPoint must never return.\r | |
7535 | \r | |
7536 | If the current execution mode is not 32-bit protected mode with flat\r | |
7537 | descriptors, then ASSERT().\r | |
7538 | If EntryPoint is 0, then ASSERT().\r | |
7539 | If NewStack is 0, then ASSERT().\r | |
7540 | \r | |
17f695ed | 7541 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7542 | is called. The descriptor in the GDT that this selector\r |
7543 | references must be setup for long mode.\r | |
7544 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7545 | the new stack after paging is enabled.\r | |
7546 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7547 | the EntryPoint function as the first parameter after\r | |
7548 | paging is enabled.\r | |
7549 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7550 | the EntryPoint function as the second parameter after\r | |
7551 | paging is enabled.\r | |
7552 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7553 | the EntryPoint function after paging is enabled.\r | |
7554 | \r | |
7555 | **/\r | |
7556 | VOID\r | |
7557 | EFIAPI\r | |
7558 | AsmEnablePaging64 (\r | |
17f695ed | 7559 | IN UINT16 Cs,\r |
ac644614 | 7560 | IN UINT64 EntryPoint,\r |
7561 | IN UINT64 Context1, OPTIONAL\r | |
7562 | IN UINT64 Context2, OPTIONAL\r | |
7563 | IN UINT64 NewStack\r | |
7564 | );\r | |
7565 | \r | |
7566 | \r | |
7567 | /**\r | |
7568 | Disables the 64-bit paging mode on the CPU.\r | |
7569 | \r | |
7570 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
7571 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
030cd1a2 | 7572 | This function is only available on x64. After the 64-bit paging mode is\r |
ac644614 | 7573 | disabled, control is transferred to the function specified by EntryPoint\r |
7574 | using the new stack specified by NewStack and passing in the parameters\r | |
7575 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7576 | may be 0. The function EntryPoint must never return.\r | |
7577 | \r | |
7578 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
7579 | If EntryPoint is 0, then ASSERT().\r | |
7580 | If NewStack is 0, then ASSERT().\r | |
7581 | \r | |
17f695ed | 7582 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7583 | is called. The descriptor in the GDT that this selector\r |
7584 | references must be setup for 32-bit protected mode.\r | |
7585 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7586 | the new stack after paging is disabled.\r | |
7587 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7588 | the EntryPoint function as the first parameter after\r | |
7589 | paging is disabled.\r | |
7590 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7591 | the EntryPoint function as the second parameter after\r | |
7592 | paging is disabled.\r | |
7593 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7594 | the EntryPoint function after paging is disabled.\r | |
7595 | \r | |
7596 | **/\r | |
7597 | VOID\r | |
7598 | EFIAPI\r | |
7599 | AsmDisablePaging64 (\r | |
17f695ed | 7600 | IN UINT16 Cs,\r |
ac644614 | 7601 | IN UINT32 EntryPoint,\r |
7602 | IN UINT32 Context1, OPTIONAL\r | |
7603 | IN UINT32 Context2, OPTIONAL\r | |
7604 | IN UINT32 NewStack\r | |
7605 | );\r | |
7606 | \r | |
7607 | \r | |
7608 | //\r | |
7609 | // 16-bit thunking services\r | |
7610 | //\r | |
7611 | \r | |
7612 | /**\r | |
7613 | Retrieves the properties for 16-bit thunk functions.\r | |
7614 | \r | |
7615 | Computes the size of the buffer and stack below 1MB required to use the\r | |
7616 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
7617 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
7618 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
7619 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
7620 | of bytes that need to be passed to the 16-bit real mode code.\r | |
9095d37b | 7621 | \r |
ac644614 | 7622 | If RealModeBufferSize is NULL, then ASSERT().\r |
7623 | If ExtraStackSize is NULL, then ASSERT().\r | |
7624 | \r | |
7625 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
7626 | required to use the 16-bit thunk functions.\r | |
7627 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
7628 | that the 16-bit thunk functions require for\r | |
7629 | temporary storage in the transition to and from\r | |
7630 | 16-bit real mode.\r | |
7631 | \r | |
7632 | **/\r | |
7633 | VOID\r | |
7634 | EFIAPI\r | |
7635 | AsmGetThunk16Properties (\r | |
7636 | OUT UINT32 *RealModeBufferSize,\r | |
7637 | OUT UINT32 *ExtraStackSize\r | |
7638 | );\r | |
7639 | \r | |
7640 | \r | |
7641 | /**\r | |
7642 | Prepares all structures a code required to use AsmThunk16().\r | |
7643 | \r | |
7644 | Prepares all structures and code required to use AsmThunk16().\r | |
9095d37b | 7645 | \r |
8243b089 | 7646 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7647 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
ac644614 | 7648 | \r |
7649 | If ThunkContext is NULL, then ASSERT().\r | |
7650 | \r | |
7651 | @param ThunkContext A pointer to the context structure that describes the\r | |
7652 | 16-bit real mode code to call.\r | |
7653 | \r | |
7654 | **/\r | |
7655 | VOID\r | |
7656 | EFIAPI\r | |
7657 | AsmPrepareThunk16 (\r | |
1445300f | 7658 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7659 | );\r |
7660 | \r | |
7661 | \r | |
7662 | /**\r | |
7663 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
7664 | \r | |
7665 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
17f695ed | 7666 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r |
7667 | This function must be called with interrupts disabled.\r | |
7668 | \r | |
9095d37b LG |
7669 | The register state from the RealModeState field of ThunkContext is restored just prior\r |
7670 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,\r | |
17f695ed | 7671 | which is used to set the interrupt state when a 16-bit real mode entry point is called.\r |
7672 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r | |
9095d37b LG |
7673 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to\r |
7674 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.\r | |
17f695ed | 7675 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r |
9095d37b LG |
7676 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment\r |
7677 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry\r | |
7678 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately\r | |
17f695ed | 7679 | after the RETF instruction is executed.\r |
9095d37b LG |
7680 | \r |
7681 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7682 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure\r | |
7683 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.\r | |
7684 | \r | |
7685 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7686 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.\r | |
17f695ed | 7687 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r |
9095d37b LG |
7688 | \r |
7689 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code\r | |
17f695ed | 7690 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r |
9095d37b LG |
7691 | \r |
7692 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r | |
7693 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to\r | |
17f695ed | 7694 | disable the A20 mask.\r |
9095d37b LG |
7695 | \r |
7696 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in\r | |
7697 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,\r | |
17f695ed | 7698 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b LG |
7699 | \r |
7700 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in\r | |
17f695ed | 7701 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b | 7702 | \r |
ac644614 | 7703 | If ThunkContext is NULL, then ASSERT().\r |
7704 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
9095d37b | 7705 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r |
17f695ed | 7706 | ThunkAttributes, then ASSERT().\r |
ac644614 | 7707 | \r |
8243b089 | 7708 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
af2dc6a7 | 7709 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r |
52fa075c | 7710 | \r |
ac644614 | 7711 | @param ThunkContext A pointer to the context structure that describes the\r |
7712 | 16-bit real mode code to call.\r | |
7713 | \r | |
7714 | **/\r | |
7715 | VOID\r | |
7716 | EFIAPI\r | |
7717 | AsmThunk16 (\r | |
7718 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7719 | );\r | |
7720 | \r | |
7721 | \r | |
7722 | /**\r | |
7723 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7724 | control to a 16-bit real mode entry point, and returns the results.\r | |
7725 | \r | |
7726 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7727 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
7728 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
7729 | service should be used. If the caller intends to make more than one 16-bit\r | |
7730 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
7731 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
7732 | \r | |
8243b089 | 7733 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7734 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
52fa075c | 7735 | \r |
17f695ed | 7736 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r |
ac644614 | 7737 | \r |
7738 | @param ThunkContext A pointer to the context structure that describes the\r | |
7739 | 16-bit real mode code to call.\r | |
7740 | \r | |
7741 | **/\r | |
7742 | VOID\r | |
7743 | EFIAPI\r | |
7744 | AsmPrepareAndThunk16 (\r | |
7745 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7746 | );\r | |
7747 | \r | |
3cfc7813 QL |
7748 | /**\r |
7749 | Generates a 16-bit random number through RDRAND instruction.\r | |
7750 | \r | |
7751 | if Rand is NULL, then ASSERT().\r | |
7752 | \r | |
7753 | @param[out] Rand Buffer pointer to store the random result.\r | |
7754 | \r | |
7755 | @retval TRUE RDRAND call was successful.\r | |
7756 | @retval FALSE Failed attempts to call RDRAND.\r | |
7757 | \r | |
7758 | **/\r | |
7759 | BOOLEAN\r | |
7760 | EFIAPI\r | |
7761 | AsmRdRand16 (\r | |
7762 | OUT UINT16 *Rand\r | |
7763 | );\r | |
7764 | \r | |
7765 | /**\r | |
7766 | Generates a 32-bit random number through RDRAND instruction.\r | |
7767 | \r | |
7768 | if Rand is NULL, then ASSERT().\r | |
7769 | \r | |
7770 | @param[out] Rand Buffer pointer to store the random result.\r | |
7771 | \r | |
7772 | @retval TRUE RDRAND call was successful.\r | |
7773 | @retval FALSE Failed attempts to call RDRAND.\r | |
7774 | \r | |
7775 | **/\r | |
7776 | BOOLEAN\r | |
7777 | EFIAPI\r | |
7778 | AsmRdRand32 (\r | |
7779 | OUT UINT32 *Rand\r | |
7780 | );\r | |
7781 | \r | |
7782 | /**\r | |
7783 | Generates a 64-bit random number through RDRAND instruction.\r | |
7784 | \r | |
7785 | if Rand is NULL, then ASSERT().\r | |
7786 | \r | |
7787 | @param[out] Rand Buffer pointer to store the random result.\r | |
7788 | \r | |
7789 | @retval TRUE RDRAND call was successful.\r | |
7790 | @retval FALSE Failed attempts to call RDRAND.\r | |
7791 | \r | |
7792 | **/\r | |
7793 | BOOLEAN\r | |
7794 | EFIAPI\r | |
7795 | AsmRdRand64 (\r | |
7796 | OUT UINT64 *Rand\r | |
7797 | );\r | |
7798 | \r | |
364a5474 | 7799 | /**\r |
47595ac0 | 7800 | Load given selector into TR register.\r |
364a5474 JW |
7801 | \r |
7802 | @param[in] Selector Task segment selector\r | |
7803 | **/\r | |
7804 | VOID\r | |
7805 | EFIAPI\r | |
7806 | AsmWriteTr (\r | |
7807 | IN UINT16 Selector\r | |
7808 | );\r | |
7809 | \r | |
2ecd8299 HW |
7810 | /**\r |
7811 | Performs a serializing operation on all load-from-memory instructions that\r | |
7812 | were issued prior the AsmLfence function.\r | |
7813 | \r | |
7814 | Executes a LFENCE instruction. This function is only available on IA-32 and x64.\r | |
7815 | \r | |
7816 | **/\r | |
7817 | VOID\r | |
7818 | EFIAPI\r | |
7819 | AsmLfence (\r | |
7820 | VOID\r | |
7821 | );\r | |
7822 | \r | |
8596c140 LE |
7823 | /**\r |
7824 | Patch the immediate operand of an IA32 or X64 instruction such that the byte,\r | |
7825 | word, dword or qword operand is encoded at the end of the instruction's\r | |
7826 | binary representation.\r | |
7827 | \r | |
7828 | This function should be used to update object code that was compiled with\r | |
7829 | NASM from assembly source code. Example:\r | |
7830 | \r | |
7831 | NASM source code:\r | |
7832 | \r | |
7833 | mov eax, strict dword 0 ; the imm32 zero operand will be patched\r | |
7834 | ASM_PFX(gPatchCr3):\r | |
7835 | mov cr3, eax\r | |
7836 | \r | |
7837 | C source code:\r | |
7838 | \r | |
7839 | X86_ASSEMBLY_PATCH_LABEL gPatchCr3;\r | |
7840 | PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);\r | |
7841 | \r | |
7842 | @param[out] InstructionEnd Pointer right past the instruction to patch. The\r | |
7843 | immediate operand to patch is expected to\r | |
7844 | comprise the trailing bytes of the instruction.\r | |
7845 | If InstructionEnd is closer to address 0 than\r | |
7846 | ValueSize permits, then ASSERT().\r | |
7847 | \r | |
7848 | @param[in] PatchValue The constant to write to the immediate operand.\r | |
7849 | The caller is responsible for ensuring that\r | |
7850 | PatchValue can be represented in the byte, word,\r | |
7851 | dword or qword operand (as indicated through\r | |
7852 | ValueSize); otherwise ASSERT().\r | |
7853 | \r | |
7854 | @param[in] ValueSize The size of the operand in bytes; must be 1, 2,\r | |
7855 | 4, or 8. ASSERT() otherwise.\r | |
7856 | **/\r | |
7857 | VOID\r | |
7858 | EFIAPI\r | |
7859 | PatchInstructionX86 (\r | |
7860 | OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd,\r | |
7861 | IN UINT64 PatchValue,\r | |
7862 | IN UINTN ValueSize\r | |
7863 | );\r | |
7864 | \r | |
de4f7f52 LE |
7865 | #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
7866 | #endif // !defined (__BASE_LIB__)\r |