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