]>
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 | |
5d68fc67 LE |
2788 | Decode Base64 ASCII encoded data to 8-bit binary representation, based on\r |
2789 | RFC4648.\r | |
2790 | \r | |
2791 | Decoding occurs according to "Table 1: The Base 64 Alphabet" in RFC4648.\r | |
2792 | \r | |
2793 | Whitespace is ignored at all positions:\r | |
2794 | - 0x09 ('\t') horizontal tab\r | |
2795 | - 0x0A ('\n') new line\r | |
2796 | - 0x0B ('\v') vertical tab\r | |
2797 | - 0x0C ('\f') form feed\r | |
2798 | - 0x0D ('\r') carriage return\r | |
2799 | - 0x20 (' ') space\r | |
2800 | \r | |
2801 | The minimum amount of required padding (with ASCII 0x3D, '=') is tolerated\r | |
2802 | and enforced at the end of the Base64 ASCII encoded data, and only there.\r | |
2803 | \r | |
2804 | Other characters outside of the encoding alphabet cause the function to\r | |
2805 | reject the Base64 ASCII encoded data.\r | |
2806 | \r | |
2807 | @param[in] Source Array of CHAR8 elements containing the Base64\r | |
2808 | ASCII encoding. May be NULL if SourceSize is\r | |
2809 | zero.\r | |
2810 | \r | |
2811 | @param[in] SourceSize Number of CHAR8 elements in Source.\r | |
2812 | \r | |
2813 | @param[out] Destination Array of UINT8 elements receiving the decoded\r | |
2814 | 8-bit binary representation. Allocated by the\r | |
2815 | caller. May be NULL if DestinationSize is\r | |
2816 | zero on input. If NULL, decoding is\r | |
2817 | performed, but the 8-bit binary\r | |
2818 | representation is not stored. If non-NULL and\r | |
2819 | the function returns an error, the contents\r | |
2820 | of Destination are indeterminate.\r | |
2821 | \r | |
2822 | @param[in,out] DestinationSize On input, the number of UINT8 elements that\r | |
2823 | the caller allocated for Destination. On\r | |
2824 | output, if the function returns\r | |
2825 | RETURN_SUCCESS or RETURN_BUFFER_TOO_SMALL,\r | |
2826 | the number of UINT8 elements that are\r | |
2827 | required for decoding the Base64 ASCII\r | |
2828 | representation. If the function returns a\r | |
2829 | value different from both RETURN_SUCCESS and\r | |
2830 | RETURN_BUFFER_TOO_SMALL, then DestinationSize\r | |
2831 | is indeterminate on output.\r | |
2832 | \r | |
2833 | @retval RETURN_SUCCESS SourceSize CHAR8 elements at Source have\r | |
2834 | been decoded to on-output DestinationSize\r | |
2835 | UINT8 elements at Destination. Note that\r | |
2836 | RETURN_SUCCESS covers the case when\r | |
2837 | DestinationSize is zero on input, and\r | |
2838 | Source decodes to zero bytes (due to\r | |
2839 | containing at most ignored whitespace).\r | |
2840 | \r | |
2841 | @retval RETURN_BUFFER_TOO_SMALL The input value of DestinationSize is not\r | |
2842 | large enough for decoding SourceSize CHAR8\r | |
2843 | elements at Source. The required number of\r | |
2844 | UINT8 elements has been stored to\r | |
2845 | DestinationSize.\r | |
2846 | \r | |
2847 | @retval RETURN_INVALID_PARAMETER DestinationSize is NULL.\r | |
2848 | \r | |
2849 | @retval RETURN_INVALID_PARAMETER Source is NULL, but SourceSize is not zero.\r | |
2850 | \r | |
2851 | @retval RETURN_INVALID_PARAMETER Destination is NULL, but DestinationSize is\r | |
2852 | not zero on input.\r | |
2853 | \r | |
2854 | @retval RETURN_INVALID_PARAMETER Source is non-NULL, and (Source +\r | |
2855 | SourceSize) would wrap around MAX_ADDRESS.\r | |
2856 | \r | |
2857 | @retval RETURN_INVALID_PARAMETER Destination is non-NULL, and (Destination +\r | |
2858 | DestinationSize) would wrap around\r | |
2859 | MAX_ADDRESS, as specified on input.\r | |
2860 | \r | |
2861 | @retval RETURN_INVALID_PARAMETER None of Source and Destination are NULL,\r | |
2862 | and CHAR8[SourceSize] at Source overlaps\r | |
2863 | UINT8[DestinationSize] at Destination, as\r | |
2864 | specified on input.\r | |
2865 | \r | |
2866 | @retval RETURN_INVALID_PARAMETER Invalid CHAR8 element encountered in\r | |
2867 | Source.\r | |
2868 | **/\r | |
1f7af69d MT |
2869 | RETURN_STATUS\r |
2870 | EFIAPI\r | |
2871 | Base64Decode (\r | |
5d68fc67 LE |
2872 | IN CONST CHAR8 *Source OPTIONAL,\r |
2873 | IN UINTN SourceSize,\r | |
2874 | OUT UINT8 *Destination OPTIONAL,\r | |
2875 | IN OUT UINTN *DestinationSize\r | |
1f7af69d MT |
2876 | );\r |
2877 | \r | |
ac644614 | 2878 | /**\r |
2879 | Converts an 8-bit value to an 8-bit BCD value.\r | |
2880 | \r | |
2881 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
2882 | returned.\r | |
2883 | \r | |
2884 | If Value >= 100, then ASSERT().\r | |
2885 | \r | |
2886 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
2887 | \r | |
9aa049d9 | 2888 | @return The BCD value.\r |
ac644614 | 2889 | \r |
2890 | **/\r | |
2891 | UINT8\r | |
2892 | EFIAPI\r | |
2893 | DecimalToBcd8 (\r | |
2894 | IN UINT8 Value\r | |
2895 | );\r | |
2896 | \r | |
2897 | \r | |
2898 | /**\r | |
2899 | Converts an 8-bit BCD value to an 8-bit value.\r | |
2900 | \r | |
2901 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
2902 | value is returned.\r | |
2903 | \r | |
2904 | If Value >= 0xA0, then ASSERT().\r | |
2905 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2906 | \r | |
2907 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
2908 | \r | |
2909 | @return The 8-bit value is returned.\r | |
2910 | \r | |
2911 | **/\r | |
2912 | UINT8\r | |
2913 | EFIAPI\r | |
2914 | BcdToDecimal8 (\r | |
2915 | IN UINT8 Value\r | |
2916 | );\r | |
2917 | \r | |
ae591c14 DM |
2918 | //\r |
2919 | // File Path Manipulation Functions\r | |
2920 | //\r | |
2921 | \r | |
2922 | /**\r | |
6a623094 | 2923 | Removes the last directory or file entry in a path.\r |
ae591c14 DM |
2924 | \r |
2925 | @param[in, out] Path The pointer to the path to modify.\r | |
2926 | \r | |
2927 | @retval FALSE Nothing was found to remove.\r | |
2928 | @retval TRUE A directory or file was removed.\r | |
2929 | **/\r | |
2930 | BOOLEAN\r | |
2931 | EFIAPI\r | |
2932 | PathRemoveLastItem(\r | |
2933 | IN OUT CHAR16 *Path\r | |
2934 | );\r | |
2935 | \r | |
2936 | /**\r | |
2937 | Function to clean up paths.\r | |
2938 | - Single periods in the path are removed.\r | |
2939 | - Double periods in the path are removed along with a single parent directory.\r | |
2940 | - Forward slashes L'/' are converted to backward slashes L'\'.\r | |
2941 | \r | |
2942 | This will be done inline and the existing buffer may be larger than required\r | |
2943 | upon completion.\r | |
2944 | \r | |
2945 | @param[in] Path The pointer to the string containing the path.\r | |
2946 | \r | |
00b7cc0f | 2947 | @return Returns Path, otherwise returns NULL to indicate that an error has occurred.\r |
ae591c14 DM |
2948 | **/\r |
2949 | CHAR16*\r | |
2950 | EFIAPI\r | |
2951 | PathCleanUpDirectories(\r | |
2952 | IN CHAR16 *Path\r | |
909ac47b | 2953 | );\r |
ac644614 | 2954 | \r |
2955 | //\r | |
2956 | // Linked List Functions and Macros\r | |
2957 | //\r | |
2958 | \r | |
2959 | /**\r | |
2960 | Initializes the head node of a doubly linked list that is declared as a\r | |
2961 | global variable in a module.\r | |
2962 | \r | |
2963 | Initializes the forward and backward links of a new linked list. After\r | |
2964 | initializing a linked list with this macro, the other linked list functions\r | |
2965 | may be used to add and remove nodes from the linked list. This macro results\r | |
2966 | in smaller executables by initializing the linked list in the data section,\r | |
2967 | instead if calling the InitializeListHead() function to perform the\r | |
2968 | equivalent operation.\r | |
2969 | \r | |
77f863ee | 2970 | @param ListHead The head note of a list to initialize.\r |
ac644614 | 2971 | \r |
2972 | **/\r | |
17f695ed | 2973 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r |
ac644614 | 2974 | \r |
2975 | \r | |
d0aef615 MH |
2976 | /**\r |
2977 | Checks whether FirstEntry and SecondEntry are part of the same doubly-linked\r | |
2978 | list.\r | |
2979 | \r | |
2980 | If FirstEntry is NULL, then ASSERT().\r | |
2981 | If FirstEntry->ForwardLink is NULL, then ASSERT().\r | |
2982 | If FirstEntry->BackLink is NULL, then ASSERT().\r | |
2983 | If SecondEntry is NULL, then ASSERT();\r | |
2984 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r | |
2985 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
2986 | \r | |
2987 | @param FirstEntry A pointer to a node in a linked list.\r | |
2988 | @param SecondEntry A pointer to the node to locate.\r | |
2989 | \r | |
2990 | @retval TRUE SecondEntry is in the same doubly-linked list as FirstEntry.\r | |
2991 | @retval FALSE SecondEntry isn't in the same doubly-linked list as FirstEntry,\r | |
2992 | or FirstEntry is invalid.\r | |
2993 | \r | |
2994 | **/\r | |
2995 | BOOLEAN\r | |
2996 | EFIAPI\r | |
2997 | IsNodeInList (\r | |
2998 | IN CONST LIST_ENTRY *FirstEntry,\r | |
2999 | IN CONST LIST_ENTRY *SecondEntry\r | |
3000 | );\r | |
3001 | \r | |
3002 | \r | |
ac644614 | 3003 | /**\r |
3004 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
3005 | the head node of the doubly linked list.\r | |
3006 | \r | |
3007 | Initializes the forward and backward links of a new linked list. After\r | |
3008 | initializing a linked list with this function, the other linked list\r | |
3009 | functions may be used to add and remove nodes from the linked list. It is up\r | |
3010 | to the caller of this function to allocate the memory for ListHead.\r | |
3011 | \r | |
3012 | If ListHead is NULL, then ASSERT().\r | |
3013 | \r | |
3014 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
3015 | \r | |
3016 | @return ListHead\r | |
3017 | \r | |
3018 | **/\r | |
3019 | LIST_ENTRY *\r | |
3020 | EFIAPI\r | |
3021 | InitializeListHead (\r | |
aa0583c7 | 3022 | IN OUT LIST_ENTRY *ListHead\r |
ac644614 | 3023 | );\r |
3024 | \r | |
3025 | \r | |
3026 | /**\r | |
3027 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
3028 | to the head node of the doubly linked list.\r | |
3029 | \r | |
3030 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
3031 | ListHead, and returns ListHead.\r | |
3032 | \r | |
3033 | If ListHead is NULL, then ASSERT().\r | |
3034 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 3035 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
3036 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 3037 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 3038 | of nodes in ListHead, including the ListHead node, is greater than or\r |
3039 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
3040 | \r | |
3041 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
3042 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
3043 | of a doubly linked list.\r | |
3044 | \r | |
3045 | @return ListHead\r | |
3046 | \r | |
3047 | **/\r | |
3048 | LIST_ENTRY *\r | |
3049 | EFIAPI\r | |
3050 | InsertHeadList (\r | |
aa0583c7 | 3051 | IN OUT LIST_ENTRY *ListHead,\r |
3052 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 3053 | );\r |
3054 | \r | |
3055 | \r | |
3056 | /**\r | |
3057 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
3058 | the head node of the doubly linked list.\r | |
3059 | \r | |
3060 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
3061 | and returns ListHead.\r | |
3062 | \r | |
3063 | If ListHead is NULL, then ASSERT().\r | |
3064 | If Entry is NULL, then ASSERT().\r | |
9095d37b | 3065 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3066 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3067 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 3068 | of nodes in ListHead, including the ListHead node, is greater than or\r |
3069 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
3070 | \r | |
3071 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
3072 | @param Entry A pointer to a node that is to be added at the end of the\r | |
3073 | doubly linked list.\r | |
3074 | \r | |
3075 | @return ListHead\r | |
3076 | \r | |
3077 | **/\r | |
3078 | LIST_ENTRY *\r | |
3079 | EFIAPI\r | |
3080 | InsertTailList (\r | |
aa0583c7 | 3081 | IN OUT LIST_ENTRY *ListHead,\r |
3082 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 3083 | );\r |
3084 | \r | |
3085 | \r | |
3086 | /**\r | |
3087 | Retrieves the first node of a doubly linked list.\r | |
3088 | \r | |
9095d37b | 3089 | Returns the first node of a doubly linked list. List must have been\r |
17f695ed | 3090 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
3091 | If List is empty, then List is returned.\r | |
ac644614 | 3092 | \r |
3093 | If List is NULL, then ASSERT().\r | |
9095d37b | 3094 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3095 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3096 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3097 | in List, including the List node, is greater than or equal to\r |
3098 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3099 | \r | |
3100 | @param List A pointer to the head node of a doubly linked list.\r | |
3101 | \r | |
3102 | @return The first node of a doubly linked list.\r | |
e01a125f | 3103 | @retval List The list is empty.\r |
ac644614 | 3104 | \r |
3105 | **/\r | |
3106 | LIST_ENTRY *\r | |
3107 | EFIAPI\r | |
3108 | GetFirstNode (\r | |
3109 | IN CONST LIST_ENTRY *List\r | |
3110 | );\r | |
3111 | \r | |
3112 | \r | |
3113 | /**\r | |
3114 | Retrieves the next node of a doubly linked list.\r | |
3115 | \r | |
9095d37b | 3116 | Returns the node of a doubly linked list that follows Node.\r |
17f695ed | 3117 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
3118 | or InitializeListHead(). If List is empty, then List is returned.\r | |
ac644614 | 3119 | \r |
3120 | If List is NULL, then ASSERT().\r | |
3121 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3122 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3123 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
3124 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
3125 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
1081f624 | 3126 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 3127 | \r |
3128 | @param List A pointer to the head node of a doubly linked list.\r | |
3129 | @param Node A pointer to a node in the doubly linked list.\r | |
3130 | \r | |
af2dc6a7 | 3131 | @return The pointer to the next node if one exists. Otherwise List is returned.\r |
ac644614 | 3132 | \r |
3133 | **/\r | |
3134 | LIST_ENTRY *\r | |
3135 | EFIAPI\r | |
3136 | GetNextNode (\r | |
3137 | IN CONST LIST_ENTRY *List,\r | |
3138 | IN CONST LIST_ENTRY *Node\r | |
3139 | );\r | |
3140 | \r | |
9095d37b | 3141 | \r |
cbca8de5 | 3142 | /**\r |
3143 | Retrieves the previous node of a doubly linked list.\r | |
9095d37b LG |
3144 | \r |
3145 | Returns the node of a doubly linked list that precedes Node.\r | |
cbca8de5 | 3146 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r |
3147 | or InitializeListHead(). If List is empty, then List is returned.\r | |
9095d37b | 3148 | \r |
cbca8de5 | 3149 | If List is NULL, then ASSERT().\r |
3150 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3151 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
cbca8de5 | 3152 | InitializeListHead(), then ASSERT().\r |
a71865b1 LG |
3153 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
3154 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
cbca8de5 | 3155 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
9095d37b | 3156 | \r |
cbca8de5 | 3157 | @param List A pointer to the head node of a doubly linked list.\r |
3158 | @param Node A pointer to a node in the doubly linked list.\r | |
9095d37b | 3159 | \r |
af2dc6a7 | 3160 | @return The pointer to the previous node if one exists. Otherwise List is returned.\r |
9095d37b | 3161 | \r |
cbca8de5 | 3162 | **/\r |
3163 | LIST_ENTRY *\r | |
3164 | EFIAPI\r | |
3165 | GetPreviousNode (\r | |
3166 | IN CONST LIST_ENTRY *List,\r | |
3167 | IN CONST LIST_ENTRY *Node\r | |
3168 | );\r | |
ac644614 | 3169 | \r |
9095d37b | 3170 | \r |
ac644614 | 3171 | /**\r |
3172 | Checks to see if a doubly linked list is empty or not.\r | |
3173 | \r | |
3174 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
3175 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
3176 | \r | |
3177 | If ListHead is NULL, then ASSERT().\r | |
9095d37b | 3178 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
17f695ed | 3179 | InitializeListHead(), then ASSERT().\r |
a71865b1 | 3180 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3181 | in List, including the List node, is greater than or equal to\r |
3182 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3183 | \r | |
3184 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
3185 | \r | |
3186 | @retval TRUE The linked list is empty.\r | |
3187 | @retval FALSE The linked list is not empty.\r | |
3188 | \r | |
3189 | **/\r | |
3190 | BOOLEAN\r | |
3191 | EFIAPI\r | |
3192 | IsListEmpty (\r | |
3193 | IN CONST LIST_ENTRY *ListHead\r | |
3194 | );\r | |
3195 | \r | |
3196 | \r | |
3197 | /**\r | |
aa0583c7 | 3198 | Determines if a node in a doubly linked list is the head node of a the same\r |
3199 | doubly linked list. This function is typically used to terminate a loop that\r | |
3200 | traverses all the nodes in a doubly linked list starting with the head node.\r | |
ac644614 | 3201 | \r |
aa0583c7 | 3202 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r |
3203 | nodes in the doubly linked list specified by List. List must have been\r | |
17f695ed | 3204 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 3205 | \r |
3206 | If List is NULL, then ASSERT().\r | |
3207 | If Node is NULL, then ASSERT().\r | |
9095d37b | 3208 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(),\r |
17f695ed | 3209 | then ASSERT().\r |
a71865b1 | 3210 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3211 | in List, including the List node, is greater than or equal to\r |
3212 | PcdMaximumLinkedListLength, then ASSERT().\r | |
9095d37b | 3213 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal\r |
1081f624 | 3214 | to List, then ASSERT().\r |
ac644614 | 3215 | \r |
3216 | @param List A pointer to the head node of a doubly linked list.\r | |
3217 | @param Node A pointer to a node in the doubly linked list.\r | |
3218 | \r | |
1955808d LG |
3219 | @retval TRUE Node is the head of the doubly-linked list pointed by List.\r |
3220 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r | |
ac644614 | 3221 | \r |
3222 | **/\r | |
3223 | BOOLEAN\r | |
3224 | EFIAPI\r | |
3225 | IsNull (\r | |
3226 | IN CONST LIST_ENTRY *List,\r | |
3227 | IN CONST LIST_ENTRY *Node\r | |
3228 | );\r | |
3229 | \r | |
3230 | \r | |
3231 | /**\r | |
3232 | Determines if a node the last node in a doubly linked list.\r | |
3233 | \r | |
3234 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
3235 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
17f695ed | 3236 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 3237 | \r |
3238 | If List is NULL, then ASSERT().\r | |
3239 | If Node is NULL, then ASSERT().\r | |
17f695ed | 3240 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
3241 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 3242 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 3243 | in List, including the List node, is greater than or equal to\r |
3244 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 3245 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 3246 | \r |
3247 | @param List A pointer to the head node of a doubly linked list.\r | |
3248 | @param Node A pointer to a node in the doubly linked list.\r | |
3249 | \r | |
3250 | @retval TRUE Node is the last node in the linked list.\r | |
3251 | @retval FALSE Node is not the last node in the linked list.\r | |
3252 | \r | |
3253 | **/\r | |
3254 | BOOLEAN\r | |
3255 | EFIAPI\r | |
3256 | IsNodeAtEnd (\r | |
3257 | IN CONST LIST_ENTRY *List,\r | |
3258 | IN CONST LIST_ENTRY *Node\r | |
3259 | );\r | |
3260 | \r | |
3261 | \r | |
3262 | /**\r | |
3263 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
3264 | first node after the swap.\r | |
3265 | \r | |
3266 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
3267 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
3268 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
3269 | same double linked list as FirstEntry and that double linked list must have\r | |
9095d37b | 3270 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
17f695ed | 3271 | SecondEntry is returned after the nodes are swapped.\r |
ac644614 | 3272 | \r |
3273 | If FirstEntry is NULL, then ASSERT().\r | |
3274 | If SecondEntry is NULL, then ASSERT().\r | |
9095d37b | 3275 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the\r |
1081f624 | 3276 | same linked list, then ASSERT().\r |
ac644614 | 3277 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r |
3278 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
3279 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
3280 | PcdMaximumLinkedListLength, then ASSERT().\r | |
3281 | \r | |
3282 | @param FirstEntry A pointer to a node in a linked list.\r | |
3283 | @param SecondEntry A pointer to another node in the same linked list.\r | |
9095d37b | 3284 | \r |
9aa049d9 | 3285 | @return SecondEntry.\r |
ac644614 | 3286 | \r |
3287 | **/\r | |
3288 | LIST_ENTRY *\r | |
3289 | EFIAPI\r | |
3290 | SwapListEntries (\r | |
aa0583c7 | 3291 | IN OUT LIST_ENTRY *FirstEntry,\r |
3292 | IN OUT LIST_ENTRY *SecondEntry\r | |
ac644614 | 3293 | );\r |
3294 | \r | |
3295 | \r | |
3296 | /**\r | |
3297 | Removes a node from a doubly linked list, and returns the node that follows\r | |
3298 | the removed node.\r | |
3299 | \r | |
3300 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
3301 | this function to release the memory used by this node if that is required. On\r | |
3302 | exit, the node following Entry in the doubly linked list is returned. If\r | |
3303 | Entry is the only node in the linked list, then the head node of the linked\r | |
3304 | list is returned.\r | |
3305 | \r | |
3306 | If Entry is NULL, then ASSERT().\r | |
3307 | If Entry is the head node of an empty list, then ASSERT().\r | |
3308 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
3309 | linked list containing Entry, including the Entry node, is greater than\r | |
3310 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
3311 | \r | |
9aa049d9 | 3312 | @param Entry A pointer to a node in a linked list.\r |
ac644614 | 3313 | \r |
9aa049d9 | 3314 | @return Entry.\r |
ac644614 | 3315 | \r |
3316 | **/\r | |
3317 | LIST_ENTRY *\r | |
3318 | EFIAPI\r | |
3319 | RemoveEntryList (\r | |
3320 | IN CONST LIST_ENTRY *Entry\r | |
3321 | );\r | |
3322 | \r | |
3323 | //\r | |
3324 | // Math Services\r | |
3325 | //\r | |
3326 | \r | |
3327 | /**\r | |
3328 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
3329 | with zeros. The shifted value is returned.\r | |
3330 | \r | |
3331 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
3332 | low Count bits are set to zero. The shifted value is returned.\r | |
3333 | \r | |
3334 | If Count is greater than 63, then ASSERT().\r | |
3335 | \r | |
3336 | @param Operand The 64-bit operand to shift left.\r | |
3337 | @param Count The number of bits to shift left.\r | |
3338 | \r | |
9aa049d9 | 3339 | @return Operand << Count.\r |
ac644614 | 3340 | \r |
3341 | **/\r | |
3342 | UINT64\r | |
3343 | EFIAPI\r | |
3344 | LShiftU64 (\r | |
3345 | IN UINT64 Operand,\r | |
3346 | IN UINTN Count\r | |
3347 | );\r | |
3348 | \r | |
3349 | \r | |
3350 | /**\r | |
3351 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
3352 | filled with zeros. The shifted value is returned.\r | |
3353 | \r | |
3354 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3355 | high Count bits are set to zero. The shifted value is returned.\r | |
3356 | \r | |
3357 | If Count is greater than 63, then ASSERT().\r | |
3358 | \r | |
3359 | @param Operand The 64-bit operand to shift right.\r | |
3360 | @param Count The number of bits to shift right.\r | |
3361 | \r | |
3362 | @return Operand >> Count\r | |
3363 | \r | |
3364 | **/\r | |
3365 | UINT64\r | |
3366 | EFIAPI\r | |
3367 | RShiftU64 (\r | |
3368 | IN UINT64 Operand,\r | |
3369 | IN UINTN Count\r | |
3370 | );\r | |
3371 | \r | |
3372 | \r | |
3373 | /**\r | |
3374 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
3375 | with original integer's bit 63. The shifted value is returned.\r | |
3376 | \r | |
3377 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3378 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
3379 | \r | |
3380 | If Count is greater than 63, then ASSERT().\r | |
3381 | \r | |
3382 | @param Operand The 64-bit operand to shift right.\r | |
3383 | @param Count The number of bits to shift right.\r | |
3384 | \r | |
3385 | @return Operand >> Count\r | |
3386 | \r | |
3387 | **/\r | |
3388 | UINT64\r | |
3389 | EFIAPI\r | |
3390 | ARShiftU64 (\r | |
3391 | IN UINT64 Operand,\r | |
3392 | IN UINTN Count\r | |
3393 | );\r | |
3394 | \r | |
3395 | \r | |
3396 | /**\r | |
3397 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
3398 | with the high bits that were rotated.\r | |
3399 | \r | |
3400 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
3401 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3402 | value is returned.\r | |
3403 | \r | |
3404 | If Count is greater than 31, then ASSERT().\r | |
3405 | \r | |
3406 | @param Operand The 32-bit operand to rotate left.\r | |
3407 | @param Count The number of bits to rotate left.\r | |
3408 | \r | |
17f695ed | 3409 | @return Operand << Count\r |
ac644614 | 3410 | \r |
3411 | **/\r | |
3412 | UINT32\r | |
3413 | EFIAPI\r | |
3414 | LRotU32 (\r | |
3415 | IN UINT32 Operand,\r | |
3416 | IN UINTN Count\r | |
3417 | );\r | |
3418 | \r | |
3419 | \r | |
3420 | /**\r | |
3421 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
3422 | with the low bits that were rotated.\r | |
3423 | \r | |
3424 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
3425 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3426 | value is returned.\r | |
3427 | \r | |
3428 | If Count is greater than 31, then ASSERT().\r | |
3429 | \r | |
3430 | @param Operand The 32-bit operand to rotate right.\r | |
3431 | @param Count The number of bits to rotate right.\r | |
3432 | \r | |
2fe241a2 | 3433 | @return Operand >> Count\r |
ac644614 | 3434 | \r |
3435 | **/\r | |
3436 | UINT32\r | |
3437 | EFIAPI\r | |
3438 | RRotU32 (\r | |
3439 | IN UINT32 Operand,\r | |
3440 | IN UINTN Count\r | |
3441 | );\r | |
3442 | \r | |
3443 | \r | |
3444 | /**\r | |
3445 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
3446 | with the high bits that were rotated.\r | |
3447 | \r | |
3448 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
3449 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3450 | value is returned.\r | |
3451 | \r | |
3452 | If Count is greater than 63, then ASSERT().\r | |
3453 | \r | |
3454 | @param Operand The 64-bit operand to rotate left.\r | |
3455 | @param Count The number of bits to rotate left.\r | |
3456 | \r | |
17f695ed | 3457 | @return Operand << Count\r |
ac644614 | 3458 | \r |
3459 | **/\r | |
3460 | UINT64\r | |
3461 | EFIAPI\r | |
3462 | LRotU64 (\r | |
3463 | IN UINT64 Operand,\r | |
3464 | IN UINTN Count\r | |
3465 | );\r | |
3466 | \r | |
3467 | \r | |
3468 | /**\r | |
3469 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
3470 | with the high low bits that were rotated.\r | |
3471 | \r | |
3472 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
3473 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3474 | value is returned.\r | |
3475 | \r | |
3476 | If Count is greater than 63, then ASSERT().\r | |
3477 | \r | |
3478 | @param Operand The 64-bit operand to rotate right.\r | |
3479 | @param Count The number of bits to rotate right.\r | |
3480 | \r | |
17f695ed | 3481 | @return Operand >> Count\r |
ac644614 | 3482 | \r |
3483 | **/\r | |
3484 | UINT64\r | |
3485 | EFIAPI\r | |
3486 | RRotU64 (\r | |
3487 | IN UINT64 Operand,\r | |
3488 | IN UINTN Count\r | |
3489 | );\r | |
3490 | \r | |
3491 | \r | |
3492 | /**\r | |
3493 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
3494 | \r | |
3495 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
3496 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3497 | Otherwise, a value between 0 and 31 is returned.\r | |
3498 | \r | |
3499 | @param Operand The 32-bit operand to evaluate.\r | |
3500 | \r | |
9aa049d9 | 3501 | @retval 0..31 The lowest bit set in Operand was found.\r |
17f695ed | 3502 | @retval -1 Operand is zero.\r |
ac644614 | 3503 | \r |
3504 | **/\r | |
3505 | INTN\r | |
3506 | EFIAPI\r | |
3507 | LowBitSet32 (\r | |
3508 | IN UINT32 Operand\r | |
3509 | );\r | |
3510 | \r | |
3511 | \r | |
3512 | /**\r | |
3513 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
3514 | \r | |
3515 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
3516 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3517 | Otherwise, a value between 0 and 63 is returned.\r | |
3518 | \r | |
3519 | @param Operand The 64-bit operand to evaluate.\r | |
3520 | \r | |
9aa049d9 | 3521 | @retval 0..63 The lowest bit set in Operand was found.\r |
17f695ed | 3522 | @retval -1 Operand is zero.\r |
3523 | \r | |
ac644614 | 3524 | \r |
3525 | **/\r | |
3526 | INTN\r | |
3527 | EFIAPI\r | |
3528 | LowBitSet64 (\r | |
3529 | IN UINT64 Operand\r | |
3530 | );\r | |
3531 | \r | |
3532 | \r | |
3533 | /**\r | |
3534 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
3535 | to log2(x).\r | |
3536 | \r | |
3537 | This function computes the bit position of the highest bit set in the 32-bit\r | |
3538 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3539 | Otherwise, a value between 0 and 31 is returned.\r | |
3540 | \r | |
3541 | @param Operand The 32-bit operand to evaluate.\r | |
3542 | \r | |
9aa049d9 | 3543 | @retval 0..31 Position of the highest bit set in Operand if found.\r |
17f695ed | 3544 | @retval -1 Operand is zero.\r |
ac644614 | 3545 | \r |
3546 | **/\r | |
3547 | INTN\r | |
3548 | EFIAPI\r | |
3549 | HighBitSet32 (\r | |
3550 | IN UINT32 Operand\r | |
3551 | );\r | |
3552 | \r | |
3553 | \r | |
3554 | /**\r | |
3555 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
3556 | to log2(x).\r | |
3557 | \r | |
3558 | This function computes the bit position of the highest bit set in the 64-bit\r | |
3559 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3560 | Otherwise, a value between 0 and 63 is returned.\r | |
3561 | \r | |
3562 | @param Operand The 64-bit operand to evaluate.\r | |
3563 | \r | |
9aa049d9 | 3564 | @retval 0..63 Position of the highest bit set in Operand if found.\r |
17f695ed | 3565 | @retval -1 Operand is zero.\r |
ac644614 | 3566 | \r |
3567 | **/\r | |
3568 | INTN\r | |
3569 | EFIAPI\r | |
3570 | HighBitSet64 (\r | |
3571 | IN UINT64 Operand\r | |
3572 | );\r | |
3573 | \r | |
3574 | \r | |
3575 | /**\r | |
3576 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
17f695ed | 3577 | 1 << log2(x).\r |
ac644614 | 3578 | \r |
3579 | This function computes the value of the highest bit set in the 32-bit value\r | |
3580 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3581 | \r | |
3582 | @param Operand The 32-bit operand to evaluate.\r | |
3583 | \r | |
3584 | @return 1 << HighBitSet32(Operand)\r | |
3585 | @retval 0 Operand is zero.\r | |
3586 | \r | |
3587 | **/\r | |
3588 | UINT32\r | |
3589 | EFIAPI\r | |
3590 | GetPowerOfTwo32 (\r | |
3591 | IN UINT32 Operand\r | |
3592 | );\r | |
3593 | \r | |
3594 | \r | |
3595 | /**\r | |
3596 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
17f695ed | 3597 | 1 << log2(x).\r |
ac644614 | 3598 | \r |
3599 | This function computes the value of the highest bit set in the 64-bit value\r | |
3600 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3601 | \r | |
3602 | @param Operand The 64-bit operand to evaluate.\r | |
3603 | \r | |
3604 | @return 1 << HighBitSet64(Operand)\r | |
3605 | @retval 0 Operand is zero.\r | |
3606 | \r | |
3607 | **/\r | |
3608 | UINT64\r | |
3609 | EFIAPI\r | |
3610 | GetPowerOfTwo64 (\r | |
3611 | IN UINT64 Operand\r | |
3612 | );\r | |
3613 | \r | |
3614 | \r | |
3615 | /**\r | |
af2dc6a7 | 3616 | Switches the endianness of a 16-bit integer.\r |
ac644614 | 3617 | \r |
3618 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
3619 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3620 | returned.\r | |
3621 | \r | |
2a53dabf | 3622 | @param Value A 16-bit unsigned value.\r |
ac644614 | 3623 | \r |
efb23117 | 3624 | @return The byte swapped Value.\r |
ac644614 | 3625 | \r |
3626 | **/\r | |
3627 | UINT16\r | |
3628 | EFIAPI\r | |
3629 | SwapBytes16 (\r | |
3630 | IN UINT16 Value\r | |
3631 | );\r | |
3632 | \r | |
3633 | \r | |
3634 | /**\r | |
af2dc6a7 | 3635 | Switches the endianness of a 32-bit integer.\r |
ac644614 | 3636 | \r |
3637 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
3638 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3639 | returned.\r | |
3640 | \r | |
2a53dabf | 3641 | @param Value A 32-bit unsigned value.\r |
ac644614 | 3642 | \r |
efb23117 | 3643 | @return The byte swapped Value.\r |
ac644614 | 3644 | \r |
3645 | **/\r | |
3646 | UINT32\r | |
3647 | EFIAPI\r | |
3648 | SwapBytes32 (\r | |
3649 | IN UINT32 Value\r | |
3650 | );\r | |
3651 | \r | |
3652 | \r | |
3653 | /**\r | |
af2dc6a7 | 3654 | Switches the endianness of a 64-bit integer.\r |
ac644614 | 3655 | \r |
3656 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
3657 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3658 | returned.\r | |
3659 | \r | |
2a53dabf | 3660 | @param Value A 64-bit unsigned value.\r |
ac644614 | 3661 | \r |
efb23117 | 3662 | @return The byte swapped Value.\r |
ac644614 | 3663 | \r |
3664 | **/\r | |
3665 | UINT64\r | |
3666 | EFIAPI\r | |
3667 | SwapBytes64 (\r | |
3668 | IN UINT64 Value\r | |
3669 | );\r | |
3670 | \r | |
3671 | \r | |
3672 | /**\r | |
3673 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
3674 | generates a 64-bit unsigned result.\r | |
3675 | \r | |
3676 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
3677 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3678 | bit unsigned result is returned.\r | |
3679 | \r | |
ac644614 | 3680 | @param Multiplicand A 64-bit unsigned value.\r |
3681 | @param Multiplier A 32-bit unsigned value.\r | |
3682 | \r | |
3683 | @return Multiplicand * Multiplier\r | |
3684 | \r | |
3685 | **/\r | |
3686 | UINT64\r | |
3687 | EFIAPI\r | |
3688 | MultU64x32 (\r | |
3689 | IN UINT64 Multiplicand,\r | |
3690 | IN UINT32 Multiplier\r | |
3691 | );\r | |
3692 | \r | |
3693 | \r | |
3694 | /**\r | |
3695 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
3696 | generates a 64-bit unsigned result.\r | |
3697 | \r | |
3698 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
3699 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3700 | bit unsigned result is returned.\r | |
3701 | \r | |
ac644614 | 3702 | @param Multiplicand A 64-bit unsigned value.\r |
3703 | @param Multiplier A 64-bit unsigned value.\r | |
3704 | \r | |
af2dc6a7 | 3705 | @return Multiplicand * Multiplier.\r |
ac644614 | 3706 | \r |
3707 | **/\r | |
3708 | UINT64\r | |
3709 | EFIAPI\r | |
3710 | MultU64x64 (\r | |
3711 | IN UINT64 Multiplicand,\r | |
3712 | IN UINT64 Multiplier\r | |
3713 | );\r | |
3714 | \r | |
3715 | \r | |
3716 | /**\r | |
3717 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3718 | 64-bit signed result.\r | |
3719 | \r | |
3720 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
3721 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
3722 | signed result is returned.\r | |
3723 | \r | |
ac644614 | 3724 | @param Multiplicand A 64-bit signed value.\r |
3725 | @param Multiplier A 64-bit signed value.\r | |
3726 | \r | |
3727 | @return Multiplicand * Multiplier\r | |
3728 | \r | |
3729 | **/\r | |
3730 | INT64\r | |
3731 | EFIAPI\r | |
3732 | MultS64x64 (\r | |
3733 | IN INT64 Multiplicand,\r | |
3734 | IN INT64 Multiplier\r | |
3735 | );\r | |
3736 | \r | |
3737 | \r | |
3738 | /**\r | |
3739 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3740 | a 64-bit unsigned result.\r | |
3741 | \r | |
3742 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3743 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
3744 | function returns the 64-bit unsigned quotient.\r | |
3745 | \r | |
3746 | If Divisor is 0, then ASSERT().\r | |
3747 | \r | |
3748 | @param Dividend A 64-bit unsigned value.\r | |
3749 | @param Divisor A 32-bit unsigned value.\r | |
3750 | \r | |
af2dc6a7 | 3751 | @return Dividend / Divisor.\r |
ac644614 | 3752 | \r |
3753 | **/\r | |
3754 | UINT64\r | |
3755 | EFIAPI\r | |
3756 | DivU64x32 (\r | |
3757 | IN UINT64 Dividend,\r | |
3758 | IN UINT32 Divisor\r | |
3759 | );\r | |
3760 | \r | |
3761 | \r | |
3762 | /**\r | |
3763 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3764 | a 32-bit unsigned remainder.\r | |
3765 | \r | |
3766 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3767 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
3768 | returns the 32-bit unsigned remainder.\r | |
3769 | \r | |
3770 | If Divisor is 0, then ASSERT().\r | |
3771 | \r | |
3772 | @param Dividend A 64-bit unsigned value.\r | |
3773 | @param Divisor A 32-bit unsigned value.\r | |
3774 | \r | |
af2dc6a7 | 3775 | @return Dividend % Divisor.\r |
ac644614 | 3776 | \r |
3777 | **/\r | |
3778 | UINT32\r | |
3779 | EFIAPI\r | |
3780 | ModU64x32 (\r | |
3781 | IN UINT64 Dividend,\r | |
3782 | IN UINT32 Divisor\r | |
3783 | );\r | |
3784 | \r | |
3785 | \r | |
3786 | /**\r | |
3787 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3788 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
3789 | \r | |
3790 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3791 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3792 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
3793 | This function returns the 64-bit unsigned quotient.\r | |
3794 | \r | |
3795 | If Divisor is 0, then ASSERT().\r | |
3796 | \r | |
3797 | @param Dividend A 64-bit unsigned value.\r | |
3798 | @param Divisor A 32-bit unsigned value.\r | |
3799 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
3800 | optional and may be NULL.\r | |
3801 | \r | |
af2dc6a7 | 3802 | @return Dividend / Divisor.\r |
ac644614 | 3803 | \r |
3804 | **/\r | |
3805 | UINT64\r | |
3806 | EFIAPI\r | |
3807 | DivU64x32Remainder (\r | |
3808 | IN UINT64 Dividend,\r | |
3809 | IN UINT32 Divisor,\r | |
3810 | OUT UINT32 *Remainder OPTIONAL\r | |
3811 | );\r | |
3812 | \r | |
3813 | \r | |
3814 | /**\r | |
3815 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
3816 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
3817 | \r | |
3818 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
3819 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3820 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
3821 | This function returns the 64-bit unsigned quotient.\r | |
3822 | \r | |
3823 | If Divisor is 0, then ASSERT().\r | |
3824 | \r | |
3825 | @param Dividend A 64-bit unsigned value.\r | |
3826 | @param Divisor A 64-bit unsigned value.\r | |
3827 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
3828 | optional and may be NULL.\r | |
3829 | \r | |
af2dc6a7 | 3830 | @return Dividend / Divisor.\r |
ac644614 | 3831 | \r |
3832 | **/\r | |
3833 | UINT64\r | |
3834 | EFIAPI\r | |
3835 | DivU64x64Remainder (\r | |
3836 | IN UINT64 Dividend,\r | |
3837 | IN UINT64 Divisor,\r | |
3838 | OUT UINT64 *Remainder OPTIONAL\r | |
3839 | );\r | |
3840 | \r | |
3841 | \r | |
3842 | /**\r | |
3843 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3844 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
3845 | \r | |
3846 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
3847 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
3848 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
3849 | function returns the 64-bit signed quotient.\r | |
3850 | \r | |
9aa049d9 | 3851 | It is the caller's responsibility to not call this function with a Divisor of 0.\r |
9095d37b | 3852 | If Divisor is 0, then the quotient and remainder should be assumed to be\r |
17f695ed | 3853 | the largest negative integer.\r |
3854 | \r | |
ac644614 | 3855 | If Divisor is 0, then ASSERT().\r |
3856 | \r | |
3857 | @param Dividend A 64-bit signed value.\r | |
3858 | @param Divisor A 64-bit signed value.\r | |
3859 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
3860 | optional and may be NULL.\r | |
3861 | \r | |
af2dc6a7 | 3862 | @return Dividend / Divisor.\r |
ac644614 | 3863 | \r |
3864 | **/\r | |
3865 | INT64\r | |
3866 | EFIAPI\r | |
3867 | DivS64x64Remainder (\r | |
3868 | IN INT64 Dividend,\r | |
3869 | IN INT64 Divisor,\r | |
3870 | OUT INT64 *Remainder OPTIONAL\r | |
3871 | );\r | |
3872 | \r | |
3873 | \r | |
3874 | /**\r | |
3875 | Reads a 16-bit value from memory that may be unaligned.\r | |
3876 | \r | |
3877 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
3878 | guarantees that the read operation does not produce an alignment fault.\r | |
3879 | \r | |
3880 | If the Buffer is NULL, then ASSERT().\r | |
3881 | \r | |
af2dc6a7 | 3882 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3883 | \r |
5385a579 | 3884 | @return The 16-bit value read from Buffer.\r |
ac644614 | 3885 | \r |
3886 | **/\r | |
3887 | UINT16\r | |
3888 | EFIAPI\r | |
3889 | ReadUnaligned16 (\r | |
5385a579 | 3890 | IN CONST UINT16 *Buffer\r |
ac644614 | 3891 | );\r |
3892 | \r | |
3893 | \r | |
3894 | /**\r | |
3895 | Writes a 16-bit value to memory that may be unaligned.\r | |
3896 | \r | |
3897 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
3898 | returned. The function guarantees that the write operation does not produce\r | |
3899 | an alignment fault.\r | |
3900 | \r | |
3901 | If the Buffer is NULL, then ASSERT().\r | |
3902 | \r | |
af2dc6a7 | 3903 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3904 | @param Value 16-bit value to write to Buffer.\r |
3905 | \r | |
5385a579 | 3906 | @return The 16-bit value to write to Buffer.\r |
ac644614 | 3907 | \r |
3908 | **/\r | |
3909 | UINT16\r | |
3910 | EFIAPI\r | |
3911 | WriteUnaligned16 (\r | |
5385a579 | 3912 | OUT UINT16 *Buffer,\r |
3913 | IN UINT16 Value\r | |
ac644614 | 3914 | );\r |
3915 | \r | |
3916 | \r | |
3917 | /**\r | |
3918 | Reads a 24-bit value from memory that may be unaligned.\r | |
3919 | \r | |
3920 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
3921 | guarantees that the read operation does not produce an alignment fault.\r | |
3922 | \r | |
3923 | If the Buffer is NULL, then ASSERT().\r | |
3924 | \r | |
af2dc6a7 | 3925 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3926 | \r |
5385a579 | 3927 | @return The 24-bit value read from Buffer.\r |
ac644614 | 3928 | \r |
3929 | **/\r | |
3930 | UINT32\r | |
3931 | EFIAPI\r | |
3932 | ReadUnaligned24 (\r | |
5385a579 | 3933 | IN CONST UINT32 *Buffer\r |
ac644614 | 3934 | );\r |
3935 | \r | |
3936 | \r | |
3937 | /**\r | |
3938 | Writes a 24-bit value to memory that may be unaligned.\r | |
3939 | \r | |
3940 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
3941 | returned. The function guarantees that the write operation does not produce\r | |
3942 | an alignment fault.\r | |
3943 | \r | |
3944 | If the Buffer is NULL, then ASSERT().\r | |
3945 | \r | |
af2dc6a7 | 3946 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3947 | @param Value 24-bit value to write to Buffer.\r |
3948 | \r | |
5385a579 | 3949 | @return The 24-bit value to write to Buffer.\r |
ac644614 | 3950 | \r |
3951 | **/\r | |
3952 | UINT32\r | |
3953 | EFIAPI\r | |
3954 | WriteUnaligned24 (\r | |
5385a579 | 3955 | OUT UINT32 *Buffer,\r |
3956 | IN UINT32 Value\r | |
ac644614 | 3957 | );\r |
3958 | \r | |
3959 | \r | |
3960 | /**\r | |
3961 | Reads a 32-bit value from memory that may be unaligned.\r | |
3962 | \r | |
3963 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
3964 | guarantees that the read operation does not produce an alignment fault.\r | |
3965 | \r | |
3966 | If the Buffer is NULL, then ASSERT().\r | |
3967 | \r | |
af2dc6a7 | 3968 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3969 | \r |
5385a579 | 3970 | @return The 32-bit value read from Buffer.\r |
ac644614 | 3971 | \r |
3972 | **/\r | |
3973 | UINT32\r | |
3974 | EFIAPI\r | |
3975 | ReadUnaligned32 (\r | |
5385a579 | 3976 | IN CONST UINT32 *Buffer\r |
ac644614 | 3977 | );\r |
3978 | \r | |
3979 | \r | |
3980 | /**\r | |
3981 | Writes a 32-bit value to memory that may be unaligned.\r | |
3982 | \r | |
3983 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
3984 | returned. The function guarantees that the write operation does not produce\r | |
3985 | an alignment fault.\r | |
3986 | \r | |
3987 | If the Buffer is NULL, then ASSERT().\r | |
3988 | \r | |
af2dc6a7 | 3989 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3990 | @param Value 32-bit value to write to Buffer.\r |
3991 | \r | |
5385a579 | 3992 | @return The 32-bit value to write to Buffer.\r |
ac644614 | 3993 | \r |
3994 | **/\r | |
3995 | UINT32\r | |
3996 | EFIAPI\r | |
3997 | WriteUnaligned32 (\r | |
5385a579 | 3998 | OUT UINT32 *Buffer,\r |
3999 | IN UINT32 Value\r | |
ac644614 | 4000 | );\r |
4001 | \r | |
4002 | \r | |
4003 | /**\r | |
4004 | Reads a 64-bit value from memory that may be unaligned.\r | |
4005 | \r | |
4006 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
4007 | guarantees that the read operation does not produce an alignment fault.\r | |
4008 | \r | |
4009 | If the Buffer is NULL, then ASSERT().\r | |
4010 | \r | |
af2dc6a7 | 4011 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 4012 | \r |
5385a579 | 4013 | @return The 64-bit value read from Buffer.\r |
ac644614 | 4014 | \r |
4015 | **/\r | |
4016 | UINT64\r | |
4017 | EFIAPI\r | |
4018 | ReadUnaligned64 (\r | |
5385a579 | 4019 | IN CONST UINT64 *Buffer\r |
ac644614 | 4020 | );\r |
4021 | \r | |
4022 | \r | |
4023 | /**\r | |
4024 | Writes a 64-bit value to memory that may be unaligned.\r | |
4025 | \r | |
4026 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
4027 | returned. The function guarantees that the write operation does not produce\r | |
4028 | an alignment fault.\r | |
4029 | \r | |
4030 | If the Buffer is NULL, then ASSERT().\r | |
4031 | \r | |
af2dc6a7 | 4032 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 4033 | @param Value 64-bit value to write to Buffer.\r |
4034 | \r | |
5385a579 | 4035 | @return The 64-bit value to write to Buffer.\r |
ac644614 | 4036 | \r |
4037 | **/\r | |
4038 | UINT64\r | |
4039 | EFIAPI\r | |
4040 | WriteUnaligned64 (\r | |
5385a579 | 4041 | OUT UINT64 *Buffer,\r |
4042 | IN UINT64 Value\r | |
ac644614 | 4043 | );\r |
4044 | \r | |
4045 | \r | |
4046 | //\r | |
4047 | // Bit Field Functions\r | |
4048 | //\r | |
4049 | \r | |
4050 | /**\r | |
4051 | Returns a bit field from an 8-bit value.\r | |
4052 | \r | |
4053 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4054 | \r | |
4055 | If 8-bit operations are not supported, then ASSERT().\r | |
4056 | If StartBit is greater than 7, then ASSERT().\r | |
4057 | If EndBit is greater than 7, then ASSERT().\r | |
4058 | If EndBit is less than StartBit, then ASSERT().\r | |
4059 | \r | |
4060 | @param Operand Operand on which to perform the bitfield operation.\r | |
4061 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4062 | Range 0..7.\r | |
4063 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4064 | Range 0..7.\r | |
4065 | \r | |
4066 | @return The bit field read.\r | |
4067 | \r | |
4068 | **/\r | |
4069 | UINT8\r | |
4070 | EFIAPI\r | |
4071 | BitFieldRead8 (\r | |
4072 | IN UINT8 Operand,\r | |
4073 | IN UINTN StartBit,\r | |
4074 | IN UINTN EndBit\r | |
4075 | );\r | |
4076 | \r | |
4077 | \r | |
4078 | /**\r | |
4079 | Writes a bit field to an 8-bit value, and returns the result.\r | |
4080 | \r | |
4081 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4082 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
4083 | returned.\r | |
4084 | \r | |
4085 | If 8-bit operations are not supported, then ASSERT().\r | |
4086 | If StartBit is greater than 7, then ASSERT().\r | |
4087 | If EndBit is greater than 7, then ASSERT().\r | |
4088 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4089 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4090 | \r |
4091 | @param Operand Operand on which to perform the bitfield operation.\r | |
4092 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4093 | Range 0..7.\r | |
4094 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4095 | Range 0..7.\r | |
4096 | @param Value New value of the bit field.\r | |
4097 | \r | |
4098 | @return The new 8-bit value.\r | |
4099 | \r | |
4100 | **/\r | |
4101 | UINT8\r | |
4102 | EFIAPI\r | |
4103 | BitFieldWrite8 (\r | |
4104 | IN UINT8 Operand,\r | |
4105 | IN UINTN StartBit,\r | |
4106 | IN UINTN EndBit,\r | |
4107 | IN UINT8 Value\r | |
4108 | );\r | |
4109 | \r | |
4110 | \r | |
4111 | /**\r | |
4112 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
4113 | result.\r | |
4114 | \r | |
62991af2 | 4115 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4116 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4117 | Operand are preserved. The new 8-bit value is returned.\r | |
4118 | \r | |
4119 | If 8-bit operations are not supported, then ASSERT().\r | |
4120 | If StartBit is greater than 7, then ASSERT().\r | |
4121 | If EndBit is greater than 7, then ASSERT().\r | |
4122 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4123 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4124 | \r |
4125 | @param Operand Operand on which to perform the bitfield operation.\r | |
4126 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4127 | Range 0..7.\r | |
4128 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4129 | Range 0..7.\r | |
4130 | @param OrData The value to OR with the read value from the value\r | |
4131 | \r | |
4132 | @return The new 8-bit value.\r | |
4133 | \r | |
4134 | **/\r | |
4135 | UINT8\r | |
4136 | EFIAPI\r | |
4137 | BitFieldOr8 (\r | |
4138 | IN UINT8 Operand,\r | |
4139 | IN UINTN StartBit,\r | |
4140 | IN UINTN EndBit,\r | |
4141 | IN UINT8 OrData\r | |
4142 | );\r | |
4143 | \r | |
4144 | \r | |
4145 | /**\r | |
4146 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
4147 | the result.\r | |
4148 | \r | |
4149 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4150 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4151 | preserved. The new 8-bit value is returned.\r | |
4152 | \r | |
4153 | If 8-bit operations are not supported, then ASSERT().\r | |
4154 | If StartBit is greater than 7, then ASSERT().\r | |
4155 | If EndBit is greater than 7, then ASSERT().\r | |
4156 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4157 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4158 | \r |
4159 | @param Operand Operand on which to perform the bitfield operation.\r | |
4160 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4161 | Range 0..7.\r | |
4162 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4163 | Range 0..7.\r | |
4164 | @param AndData The value to AND with the read value from the value.\r | |
4165 | \r | |
4166 | @return The new 8-bit value.\r | |
4167 | \r | |
4168 | **/\r | |
4169 | UINT8\r | |
4170 | EFIAPI\r | |
4171 | BitFieldAnd8 (\r | |
4172 | IN UINT8 Operand,\r | |
4173 | IN UINTN StartBit,\r | |
4174 | IN UINTN EndBit,\r | |
4175 | IN UINT8 AndData\r | |
4176 | );\r | |
4177 | \r | |
4178 | \r | |
4179 | /**\r | |
4180 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
4181 | bitwise OR, and returns the result.\r | |
4182 | \r | |
4183 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4184 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4185 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4186 | preserved. The new 8-bit value is returned.\r |
4187 | \r | |
4188 | If 8-bit operations are not supported, then ASSERT().\r | |
4189 | If StartBit is greater than 7, then ASSERT().\r | |
4190 | If EndBit is greater than 7, then ASSERT().\r | |
4191 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4192 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4193 | If OrData 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..7.\r | |
4198 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4199 | Range 0..7.\r | |
4200 | @param AndData The value to AND with the read value from the value.\r | |
4201 | @param OrData The value to OR with the result of the AND operation.\r | |
4202 | \r | |
4203 | @return The new 8-bit value.\r | |
4204 | \r | |
4205 | **/\r | |
4206 | UINT8\r | |
4207 | EFIAPI\r | |
4208 | BitFieldAndThenOr8 (\r | |
4209 | IN UINT8 Operand,\r | |
4210 | IN UINTN StartBit,\r | |
4211 | IN UINTN EndBit,\r | |
4212 | IN UINT8 AndData,\r | |
4213 | IN UINT8 OrData\r | |
4214 | );\r | |
4215 | \r | |
4216 | \r | |
4217 | /**\r | |
4218 | Returns a bit field from a 16-bit value.\r | |
4219 | \r | |
4220 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4221 | \r | |
4222 | If 16-bit operations are not supported, then ASSERT().\r | |
4223 | If StartBit is greater than 15, then ASSERT().\r | |
4224 | If EndBit is greater than 15, then ASSERT().\r | |
4225 | If EndBit is less than StartBit, then ASSERT().\r | |
4226 | \r | |
4227 | @param Operand Operand on which to perform the bitfield operation.\r | |
4228 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4229 | Range 0..15.\r | |
4230 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4231 | Range 0..15.\r | |
4232 | \r | |
4233 | @return The bit field read.\r | |
4234 | \r | |
4235 | **/\r | |
4236 | UINT16\r | |
4237 | EFIAPI\r | |
4238 | BitFieldRead16 (\r | |
4239 | IN UINT16 Operand,\r | |
4240 | IN UINTN StartBit,\r | |
4241 | IN UINTN EndBit\r | |
4242 | );\r | |
4243 | \r | |
4244 | \r | |
4245 | /**\r | |
4246 | Writes a bit field to a 16-bit value, and returns the result.\r | |
4247 | \r | |
4248 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4249 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
4250 | returned.\r | |
4251 | \r | |
4252 | If 16-bit operations are not supported, then ASSERT().\r | |
4253 | If StartBit is greater than 15, then ASSERT().\r | |
4254 | If EndBit is greater than 15, then ASSERT().\r | |
4255 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4256 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4257 | \r |
4258 | @param Operand Operand on which to perform the bitfield operation.\r | |
4259 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4260 | Range 0..15.\r | |
4261 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4262 | Range 0..15.\r | |
4263 | @param Value New value of the bit field.\r | |
4264 | \r | |
4265 | @return The new 16-bit value.\r | |
4266 | \r | |
4267 | **/\r | |
4268 | UINT16\r | |
4269 | EFIAPI\r | |
4270 | BitFieldWrite16 (\r | |
4271 | IN UINT16 Operand,\r | |
4272 | IN UINTN StartBit,\r | |
4273 | IN UINTN EndBit,\r | |
4274 | IN UINT16 Value\r | |
4275 | );\r | |
4276 | \r | |
4277 | \r | |
4278 | /**\r | |
4279 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
4280 | result.\r | |
4281 | \r | |
62991af2 | 4282 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4283 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4284 | Operand are preserved. The new 16-bit value is returned.\r | |
4285 | \r | |
4286 | If 16-bit operations are not supported, then ASSERT().\r | |
4287 | If StartBit is greater than 15, then ASSERT().\r | |
4288 | If EndBit is greater than 15, then ASSERT().\r | |
4289 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4290 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4291 | \r |
4292 | @param Operand Operand on which to perform the bitfield operation.\r | |
4293 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4294 | Range 0..15.\r | |
4295 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4296 | Range 0..15.\r | |
4297 | @param OrData The value to OR with the read value from the value\r | |
4298 | \r | |
4299 | @return The new 16-bit value.\r | |
4300 | \r | |
4301 | **/\r | |
4302 | UINT16\r | |
4303 | EFIAPI\r | |
4304 | BitFieldOr16 (\r | |
4305 | IN UINT16 Operand,\r | |
4306 | IN UINTN StartBit,\r | |
4307 | IN UINTN EndBit,\r | |
4308 | IN UINT16 OrData\r | |
4309 | );\r | |
4310 | \r | |
4311 | \r | |
4312 | /**\r | |
4313 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
4314 | the result.\r | |
4315 | \r | |
4316 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4317 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4318 | preserved. The new 16-bit value is returned.\r | |
4319 | \r | |
4320 | If 16-bit operations are not supported, then ASSERT().\r | |
4321 | If StartBit is greater than 15, then ASSERT().\r | |
4322 | If EndBit is greater than 15, then ASSERT().\r | |
4323 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4324 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4325 | \r |
4326 | @param Operand Operand on which to perform the bitfield operation.\r | |
4327 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4328 | Range 0..15.\r | |
4329 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4330 | Range 0..15.\r | |
4331 | @param AndData The value to AND with the read value from the value\r | |
4332 | \r | |
4333 | @return The new 16-bit value.\r | |
4334 | \r | |
4335 | **/\r | |
4336 | UINT16\r | |
4337 | EFIAPI\r | |
4338 | BitFieldAnd16 (\r | |
4339 | IN UINT16 Operand,\r | |
4340 | IN UINTN StartBit,\r | |
4341 | IN UINTN EndBit,\r | |
4342 | IN UINT16 AndData\r | |
4343 | );\r | |
4344 | \r | |
4345 | \r | |
4346 | /**\r | |
4347 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
4348 | bitwise OR, and returns the result.\r | |
4349 | \r | |
4350 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4351 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4352 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4353 | preserved. The new 16-bit value is returned.\r |
4354 | \r | |
4355 | If 16-bit operations are not supported, then ASSERT().\r | |
4356 | If StartBit is greater than 15, then ASSERT().\r | |
4357 | If EndBit is greater than 15, then ASSERT().\r | |
4358 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4359 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4360 | If OrData 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..15.\r | |
4365 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4366 | Range 0..15.\r | |
4367 | @param AndData The value to AND with the read value from the value.\r | |
4368 | @param OrData The value to OR with the result of the AND operation.\r | |
4369 | \r | |
4370 | @return The new 16-bit value.\r | |
4371 | \r | |
4372 | **/\r | |
4373 | UINT16\r | |
4374 | EFIAPI\r | |
4375 | BitFieldAndThenOr16 (\r | |
4376 | IN UINT16 Operand,\r | |
4377 | IN UINTN StartBit,\r | |
4378 | IN UINTN EndBit,\r | |
4379 | IN UINT16 AndData,\r | |
4380 | IN UINT16 OrData\r | |
4381 | );\r | |
4382 | \r | |
4383 | \r | |
4384 | /**\r | |
4385 | Returns a bit field from a 32-bit value.\r | |
4386 | \r | |
4387 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4388 | \r | |
4389 | If 32-bit operations are not supported, then ASSERT().\r | |
4390 | If StartBit is greater than 31, then ASSERT().\r | |
4391 | If EndBit is greater than 31, then ASSERT().\r | |
4392 | If EndBit is less than StartBit, then ASSERT().\r | |
4393 | \r | |
4394 | @param Operand Operand on which to perform the bitfield operation.\r | |
4395 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4396 | Range 0..31.\r | |
4397 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4398 | Range 0..31.\r | |
4399 | \r | |
4400 | @return The bit field read.\r | |
4401 | \r | |
4402 | **/\r | |
4403 | UINT32\r | |
4404 | EFIAPI\r | |
4405 | BitFieldRead32 (\r | |
4406 | IN UINT32 Operand,\r | |
4407 | IN UINTN StartBit,\r | |
4408 | IN UINTN EndBit\r | |
4409 | );\r | |
4410 | \r | |
4411 | \r | |
4412 | /**\r | |
4413 | Writes a bit field to a 32-bit value, and returns the result.\r | |
4414 | \r | |
4415 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4416 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
4417 | returned.\r | |
4418 | \r | |
4419 | If 32-bit operations are not supported, then ASSERT().\r | |
4420 | If StartBit is greater than 31, then ASSERT().\r | |
4421 | If EndBit is greater than 31, then ASSERT().\r | |
4422 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4423 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4424 | \r |
4425 | @param Operand Operand on which to perform the bitfield operation.\r | |
4426 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4427 | Range 0..31.\r | |
4428 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4429 | Range 0..31.\r | |
4430 | @param Value New value of the bit field.\r | |
4431 | \r | |
4432 | @return The new 32-bit value.\r | |
4433 | \r | |
4434 | **/\r | |
4435 | UINT32\r | |
4436 | EFIAPI\r | |
4437 | BitFieldWrite32 (\r | |
4438 | IN UINT32 Operand,\r | |
4439 | IN UINTN StartBit,\r | |
4440 | IN UINTN EndBit,\r | |
4441 | IN UINT32 Value\r | |
4442 | );\r | |
4443 | \r | |
4444 | \r | |
4445 | /**\r | |
4446 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
4447 | result.\r | |
4448 | \r | |
62991af2 | 4449 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4450 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4451 | Operand are preserved. The new 32-bit value is returned.\r | |
4452 | \r | |
4453 | If 32-bit operations are not supported, then ASSERT().\r | |
4454 | If StartBit is greater than 31, then ASSERT().\r | |
4455 | If EndBit is greater than 31, then ASSERT().\r | |
4456 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4457 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4458 | \r |
4459 | @param Operand Operand on which to perform the bitfield operation.\r | |
4460 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4461 | Range 0..31.\r | |
4462 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4463 | Range 0..31.\r | |
af2dc6a7 | 4464 | @param OrData The value to OR with the read value from the value.\r |
ac644614 | 4465 | \r |
4466 | @return The new 32-bit value.\r | |
4467 | \r | |
4468 | **/\r | |
4469 | UINT32\r | |
4470 | EFIAPI\r | |
4471 | BitFieldOr32 (\r | |
4472 | IN UINT32 Operand,\r | |
4473 | IN UINTN StartBit,\r | |
4474 | IN UINTN EndBit,\r | |
4475 | IN UINT32 OrData\r | |
4476 | );\r | |
4477 | \r | |
4478 | \r | |
4479 | /**\r | |
4480 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
4481 | the result.\r | |
4482 | \r | |
4483 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4484 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4485 | preserved. The new 32-bit value is returned.\r | |
4486 | \r | |
4487 | If 32-bit operations are not supported, then ASSERT().\r | |
4488 | If StartBit is greater than 31, then ASSERT().\r | |
4489 | If EndBit is greater than 31, then ASSERT().\r | |
4490 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4491 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4492 | \r |
4493 | @param Operand Operand on which to perform the bitfield operation.\r | |
4494 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4495 | Range 0..31.\r | |
4496 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4497 | Range 0..31.\r | |
4498 | @param AndData The value to AND with the read value from the value\r | |
4499 | \r | |
4500 | @return The new 32-bit value.\r | |
4501 | \r | |
4502 | **/\r | |
4503 | UINT32\r | |
4504 | EFIAPI\r | |
4505 | BitFieldAnd32 (\r | |
4506 | IN UINT32 Operand,\r | |
4507 | IN UINTN StartBit,\r | |
4508 | IN UINTN EndBit,\r | |
4509 | IN UINT32 AndData\r | |
4510 | );\r | |
4511 | \r | |
4512 | \r | |
4513 | /**\r | |
4514 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
4515 | bitwise OR, and returns the result.\r | |
4516 | \r | |
4517 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4518 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4519 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4520 | preserved. The new 32-bit value is returned.\r |
4521 | \r | |
4522 | If 32-bit operations are not supported, then ASSERT().\r | |
4523 | If StartBit is greater than 31, then ASSERT().\r | |
4524 | If EndBit is greater than 31, then ASSERT().\r | |
4525 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4526 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4527 | If OrData 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..31.\r | |
4532 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4533 | Range 0..31.\r | |
4534 | @param AndData The value to AND with the read value from the value.\r | |
4535 | @param OrData The value to OR with the result of the AND operation.\r | |
4536 | \r | |
4537 | @return The new 32-bit value.\r | |
4538 | \r | |
4539 | **/\r | |
4540 | UINT32\r | |
4541 | EFIAPI\r | |
4542 | BitFieldAndThenOr32 (\r | |
4543 | IN UINT32 Operand,\r | |
4544 | IN UINTN StartBit,\r | |
4545 | IN UINTN EndBit,\r | |
4546 | IN UINT32 AndData,\r | |
4547 | IN UINT32 OrData\r | |
4548 | );\r | |
4549 | \r | |
4550 | \r | |
4551 | /**\r | |
4552 | Returns a bit field from a 64-bit value.\r | |
4553 | \r | |
4554 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4555 | \r | |
4556 | If 64-bit operations are not supported, then ASSERT().\r | |
4557 | If StartBit is greater than 63, then ASSERT().\r | |
4558 | If EndBit is greater than 63, then ASSERT().\r | |
4559 | If EndBit is less than StartBit, then ASSERT().\r | |
4560 | \r | |
4561 | @param Operand Operand on which to perform the bitfield operation.\r | |
4562 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4563 | Range 0..63.\r | |
4564 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4565 | Range 0..63.\r | |
4566 | \r | |
4567 | @return The bit field read.\r | |
4568 | \r | |
4569 | **/\r | |
4570 | UINT64\r | |
4571 | EFIAPI\r | |
4572 | BitFieldRead64 (\r | |
4573 | IN UINT64 Operand,\r | |
4574 | IN UINTN StartBit,\r | |
4575 | IN UINTN EndBit\r | |
4576 | );\r | |
4577 | \r | |
4578 | \r | |
4579 | /**\r | |
4580 | Writes a bit field to a 64-bit value, and returns the result.\r | |
4581 | \r | |
4582 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4583 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
4584 | returned.\r | |
4585 | \r | |
4586 | If 64-bit operations are not supported, then ASSERT().\r | |
4587 | If StartBit is greater than 63, then ASSERT().\r | |
4588 | If EndBit is greater than 63, then ASSERT().\r | |
4589 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4590 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4591 | \r |
4592 | @param Operand Operand on which to perform the bitfield operation.\r | |
4593 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4594 | Range 0..63.\r | |
4595 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4596 | Range 0..63.\r | |
4597 | @param Value New value of the bit field.\r | |
4598 | \r | |
4599 | @return The new 64-bit value.\r | |
4600 | \r | |
4601 | **/\r | |
4602 | UINT64\r | |
4603 | EFIAPI\r | |
4604 | BitFieldWrite64 (\r | |
4605 | IN UINT64 Operand,\r | |
4606 | IN UINTN StartBit,\r | |
4607 | IN UINTN EndBit,\r | |
4608 | IN UINT64 Value\r | |
4609 | );\r | |
4610 | \r | |
4611 | \r | |
4612 | /**\r | |
4613 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
4614 | result.\r | |
4615 | \r | |
62991af2 | 4616 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4617 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4618 | Operand are preserved. The new 64-bit value is returned.\r | |
4619 | \r | |
4620 | If 64-bit operations are not supported, then ASSERT().\r | |
4621 | If StartBit is greater than 63, then ASSERT().\r | |
4622 | If EndBit is greater than 63, then ASSERT().\r | |
4623 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4624 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4625 | \r |
4626 | @param Operand Operand on which to perform the bitfield operation.\r | |
4627 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4628 | Range 0..63.\r | |
4629 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4630 | Range 0..63.\r | |
4631 | @param OrData The value to OR with the read value from the value\r | |
4632 | \r | |
4633 | @return The new 64-bit value.\r | |
4634 | \r | |
4635 | **/\r | |
4636 | UINT64\r | |
4637 | EFIAPI\r | |
4638 | BitFieldOr64 (\r | |
4639 | IN UINT64 Operand,\r | |
4640 | IN UINTN StartBit,\r | |
4641 | IN UINTN EndBit,\r | |
4642 | IN UINT64 OrData\r | |
4643 | );\r | |
4644 | \r | |
4645 | \r | |
4646 | /**\r | |
4647 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
4648 | the result.\r | |
4649 | \r | |
4650 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4651 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4652 | preserved. The new 64-bit value is returned.\r | |
4653 | \r | |
4654 | If 64-bit operations are not supported, then ASSERT().\r | |
4655 | If StartBit is greater than 63, then ASSERT().\r | |
4656 | If EndBit is greater than 63, then ASSERT().\r | |
4657 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4658 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4659 | \r |
4660 | @param Operand Operand on which to perform the bitfield operation.\r | |
4661 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4662 | Range 0..63.\r | |
4663 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4664 | Range 0..63.\r | |
4665 | @param AndData The value to AND with the read value from the value\r | |
4666 | \r | |
4667 | @return The new 64-bit value.\r | |
4668 | \r | |
4669 | **/\r | |
4670 | UINT64\r | |
4671 | EFIAPI\r | |
4672 | BitFieldAnd64 (\r | |
4673 | IN UINT64 Operand,\r | |
4674 | IN UINTN StartBit,\r | |
4675 | IN UINTN EndBit,\r | |
4676 | IN UINT64 AndData\r | |
4677 | );\r | |
4678 | \r | |
4679 | \r | |
4680 | /**\r | |
4681 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
4682 | bitwise OR, and returns the result.\r | |
4683 | \r | |
4684 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
9095d37b | 4685 | in Operand and the value specified by AndData, followed by a bitwise\r |
62991af2 | 4686 | OR with value specified by OrData. All other bits in Operand are\r |
ac644614 | 4687 | preserved. The new 64-bit value is returned.\r |
4688 | \r | |
4689 | If 64-bit operations are not supported, then ASSERT().\r | |
4690 | If StartBit is greater than 63, then ASSERT().\r | |
4691 | If EndBit is greater than 63, then ASSERT().\r | |
4692 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4693 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4694 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4695 | \r |
4696 | @param Operand Operand on which to perform the bitfield operation.\r | |
4697 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4698 | Range 0..63.\r | |
4699 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4700 | Range 0..63.\r | |
4701 | @param AndData The value to AND with the read value from the value.\r | |
4702 | @param OrData The value to OR with the result of the AND operation.\r | |
4703 | \r | |
4704 | @return The new 64-bit value.\r | |
4705 | \r | |
4706 | **/\r | |
4707 | UINT64\r | |
4708 | EFIAPI\r | |
4709 | BitFieldAndThenOr64 (\r | |
4710 | IN UINT64 Operand,\r | |
4711 | IN UINTN StartBit,\r | |
4712 | IN UINTN EndBit,\r | |
4713 | IN UINT64 AndData,\r | |
4714 | IN UINT64 OrData\r | |
4715 | );\r | |
4716 | \r | |
d7634dc0 TP |
4717 | /**\r |
4718 | Reads a bit field from a 32-bit value, counts and returns\r | |
4719 | the number of set bits.\r | |
4720 | \r | |
4721 | Counts the number of set bits in the bit field specified by\r | |
4722 | StartBit and EndBit in Operand. The count is returned.\r | |
4723 | \r | |
4724 | If StartBit is greater than 31, then ASSERT().\r | |
4725 | If EndBit is greater than 31, then ASSERT().\r | |
4726 | If EndBit is less than StartBit, then ASSERT().\r | |
4727 | \r | |
4728 | @param Operand Operand on which to perform the bitfield operation.\r | |
4729 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4730 | Range 0..31.\r | |
4731 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4732 | Range 0..31.\r | |
4733 | \r | |
4734 | @return The number of bits set between StartBit and EndBit.\r | |
4735 | \r | |
4736 | **/\r | |
4737 | UINT8\r | |
4738 | EFIAPI\r | |
4739 | BitFieldCountOnes32 (\r | |
4740 | IN UINT32 Operand,\r | |
4741 | IN UINTN StartBit,\r | |
4742 | IN UINTN EndBit\r | |
4743 | );\r | |
4744 | \r | |
4745 | /**\r | |
4746 | Reads a bit field from a 64-bit value, counts and returns\r | |
4747 | the number of set bits.\r | |
4748 | \r | |
4749 | Counts the number of set bits in the bit field specified by\r | |
4750 | StartBit and EndBit in Operand. The count is returned.\r | |
4751 | \r | |
4752 | If StartBit is greater than 63, then ASSERT().\r | |
4753 | If EndBit is greater than 63, then ASSERT().\r | |
4754 | If EndBit is less than StartBit, then ASSERT().\r | |
4755 | \r | |
4756 | @param Operand Operand on which to perform the bitfield operation.\r | |
4757 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4758 | Range 0..63.\r | |
4759 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4760 | Range 0..63.\r | |
4761 | \r | |
4762 | @return The number of bits set between StartBit and EndBit.\r | |
4763 | \r | |
4764 | **/\r | |
4765 | UINT8\r | |
4766 | EFIAPI\r | |
4767 | BitFieldCountOnes64 (\r | |
4768 | IN UINT64 Operand,\r | |
4769 | IN UINTN StartBit,\r | |
4770 | IN UINTN EndBit\r | |
4771 | );\r | |
4772 | \r | |
ac644614 | 4773 | //\r |
4774 | // Base Library Checksum Functions\r | |
4775 | //\r | |
4776 | \r | |
4777 | /**\r | |
17f695ed | 4778 | Returns the sum of all elements in a buffer in unit of UINT8.\r |
ac644614 | 4779 | During calculation, the carry bits are dropped.\r |
4780 | \r | |
4781 | This function calculates the sum of all elements in a buffer\r | |
4782 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
4783 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
4784 | returned.\r | |
4785 | \r | |
4786 | If Buffer is NULL, then ASSERT().\r | |
4787 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4788 | \r | |
af2dc6a7 | 4789 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
17f695ed | 4790 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4791 | \r |
4792 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4793 | \r | |
4794 | **/\r | |
4795 | UINT8\r | |
4796 | EFIAPI\r | |
4797 | CalculateSum8 (\r | |
ee6c452c | 4798 | IN CONST UINT8 *Buffer,\r |
4799 | IN UINTN Length\r | |
ac644614 | 4800 | );\r |
4801 | \r | |
4802 | \r | |
4803 | /**\r | |
4804 | Returns the two's complement checksum of all elements in a buffer\r | |
4805 | of 8-bit values.\r | |
4806 | \r | |
4807 | This function first calculates the sum of the 8-bit values in the\r | |
4808 | buffer specified by Buffer and Length. The carry bits in the result\r | |
4809 | of addition are dropped. Then, the two's complement of the sum is\r | |
4810 | returned. If Length is 0, then 0 is returned.\r | |
4811 | \r | |
4812 | If Buffer is NULL, then ASSERT().\r | |
4813 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4814 | \r | |
af2dc6a7 | 4815 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4816 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4817 | \r |
af2dc6a7 | 4818 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4819 | \r |
4820 | **/\r | |
4821 | UINT8\r | |
4822 | EFIAPI\r | |
4823 | CalculateCheckSum8 (\r | |
ee6c452c | 4824 | IN CONST UINT8 *Buffer,\r |
4825 | IN UINTN Length\r | |
ac644614 | 4826 | );\r |
4827 | \r | |
4828 | \r | |
4829 | /**\r | |
4830 | Returns the sum of all elements in a buffer of 16-bit values. During\r | |
4831 | calculation, the carry bits are dropped.\r | |
4832 | \r | |
4833 | This function calculates the sum of the 16-bit values in the buffer\r | |
4834 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4835 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
4836 | \r | |
4837 | If Buffer is NULL, then ASSERT().\r | |
4838 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4839 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4840 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4841 | \r | |
af2dc6a7 | 4842 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4843 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4844 | \r |
4845 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4846 | \r | |
4847 | **/\r | |
4848 | UINT16\r | |
4849 | EFIAPI\r | |
4850 | CalculateSum16 (\r | |
ee6c452c | 4851 | IN CONST UINT16 *Buffer,\r |
4852 | IN UINTN Length\r | |
ac644614 | 4853 | );\r |
4854 | \r | |
4855 | \r | |
4856 | /**\r | |
4857 | Returns the two's complement checksum of all elements in a buffer of\r | |
4858 | 16-bit values.\r | |
4859 | \r | |
4860 | This function first calculates the sum of the 16-bit values in the buffer\r | |
4861 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4862 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4863 | is 0, then 0 is returned.\r | |
4864 | \r | |
4865 | If Buffer is NULL, then ASSERT().\r | |
4866 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4867 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4868 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4869 | \r | |
af2dc6a7 | 4870 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4871 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4872 | \r |
af2dc6a7 | 4873 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4874 | \r |
4875 | **/\r | |
4876 | UINT16\r | |
4877 | EFIAPI\r | |
4878 | CalculateCheckSum16 (\r | |
ee6c452c | 4879 | IN CONST UINT16 *Buffer,\r |
4880 | IN UINTN Length\r | |
ac644614 | 4881 | );\r |
4882 | \r | |
4883 | \r | |
4884 | /**\r | |
17f695ed | 4885 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
ac644614 | 4886 | calculation, the carry bits are dropped.\r |
4887 | \r | |
4888 | This function calculates the sum of the 32-bit values in the buffer\r | |
4889 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
17f695ed | 4890 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r |
ac644614 | 4891 | \r |
4892 | If Buffer is NULL, then ASSERT().\r | |
4893 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4894 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4895 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4896 | \r | |
af2dc6a7 | 4897 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4898 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4899 | \r |
4900 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4901 | \r | |
4902 | **/\r | |
4903 | UINT32\r | |
4904 | EFIAPI\r | |
4905 | CalculateSum32 (\r | |
ee6c452c | 4906 | IN CONST UINT32 *Buffer,\r |
4907 | IN UINTN Length\r | |
ac644614 | 4908 | );\r |
4909 | \r | |
4910 | \r | |
4911 | /**\r | |
4912 | Returns the two's complement checksum of all elements in a buffer of\r | |
4913 | 32-bit values.\r | |
4914 | \r | |
4915 | This function first calculates the sum of the 32-bit values in the buffer\r | |
4916 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4917 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4918 | is 0, then 0 is returned.\r | |
4919 | \r | |
4920 | If Buffer is NULL, then ASSERT().\r | |
4921 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4922 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4923 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4924 | \r | |
af2dc6a7 | 4925 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4926 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4927 | \r |
af2dc6a7 | 4928 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4929 | \r |
4930 | **/\r | |
4931 | UINT32\r | |
4932 | EFIAPI\r | |
4933 | CalculateCheckSum32 (\r | |
ee6c452c | 4934 | IN CONST UINT32 *Buffer,\r |
4935 | IN UINTN Length\r | |
ac644614 | 4936 | );\r |
4937 | \r | |
4938 | \r | |
4939 | /**\r | |
4940 | Returns the sum of all elements in a buffer of 64-bit values. During\r | |
4941 | calculation, the carry bits are dropped.\r | |
4942 | \r | |
4943 | This function calculates the sum of the 64-bit values in the buffer\r | |
4944 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4945 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
4946 | \r | |
4947 | If Buffer is NULL, then ASSERT().\r | |
4948 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4949 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4950 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4951 | \r | |
af2dc6a7 | 4952 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4953 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4954 | \r |
4955 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4956 | \r | |
4957 | **/\r | |
4958 | UINT64\r | |
4959 | EFIAPI\r | |
4960 | CalculateSum64 (\r | |
ee6c452c | 4961 | IN CONST UINT64 *Buffer,\r |
4962 | IN UINTN Length\r | |
ac644614 | 4963 | );\r |
4964 | \r | |
4965 | \r | |
4966 | /**\r | |
4967 | Returns the two's complement checksum of all elements in a buffer of\r | |
4968 | 64-bit values.\r | |
4969 | \r | |
4970 | This function first calculates the sum of the 64-bit values in the buffer\r | |
4971 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4972 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4973 | is 0, then 0 is returned.\r | |
4974 | \r | |
4975 | If Buffer is NULL, then ASSERT().\r | |
4976 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4977 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4978 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4979 | \r | |
af2dc6a7 | 4980 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4981 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4982 | \r |
af2dc6a7 | 4983 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4984 | \r |
4985 | **/\r | |
4986 | UINT64\r | |
4987 | EFIAPI\r | |
4988 | CalculateCheckSum64 (\r | |
ee6c452c | 4989 | IN CONST UINT64 *Buffer,\r |
4990 | IN UINTN Length\r | |
ac644614 | 4991 | );\r |
4992 | \r | |
0a8e6f79 LG |
4993 | /**\r |
4994 | Computes and returns a 32-bit CRC for a data buffer.\r | |
4995 | CRC32 value bases on ITU-T V.42.\r | |
4996 | \r | |
4997 | If Buffer is NULL, then ASSERT().\r | |
4998 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4999 | \r | |
5000 | @param[in] Buffer A pointer to the buffer on which the 32-bit CRC is to be computed.\r | |
5001 | @param[in] Length The number of bytes in the buffer Data.\r | |
5002 | \r | |
5003 | @retval Crc32 The 32-bit CRC was computed for the data buffer.\r | |
5004 | \r | |
5005 | **/\r | |
5006 | UINT32\r | |
5007 | EFIAPI\r | |
5008 | CalculateCrc32(\r | |
5009 | IN VOID *Buffer,\r | |
5010 | IN UINTN Length\r | |
5011 | );\r | |
ac644614 | 5012 | \r |
d75f9fc2 | 5013 | //\r |
5014 | // Base Library CPU Functions\r | |
5015 | //\r | |
5016 | \r | |
5017 | /**\r | |
5018 | Function entry point used when a stack switch is requested with SwitchStack()\r | |
5019 | \r | |
5020 | @param Context1 Context1 parameter passed into SwitchStack().\r | |
5021 | @param Context2 Context2 parameter passed into SwitchStack().\r | |
5022 | \r | |
5023 | **/\r | |
ac644614 | 5024 | typedef\r |
5025 | VOID\r | |
9810cdd8 | 5026 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r |
ac644614 | 5027 | IN VOID *Context1, OPTIONAL\r |
5028 | IN VOID *Context2 OPTIONAL\r | |
5029 | );\r | |
5030 | \r | |
5031 | \r | |
5032 | /**\r | |
5033 | Used to serialize load and store operations.\r | |
5034 | \r | |
5035 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
5036 | globally visible when this function returns.\r | |
5037 | \r | |
5038 | **/\r | |
5039 | VOID\r | |
5040 | EFIAPI\r | |
5041 | MemoryFence (\r | |
5042 | VOID\r | |
5043 | );\r | |
5044 | \r | |
5045 | \r | |
5046 | /**\r | |
5047 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
5048 | and returns 0.\r | |
5049 | \r | |
5050 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
5051 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
5052 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
5053 | \r | |
5054 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 5055 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
9095d37b | 5056 | \r |
17f695ed | 5057 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r |
5058 | The same structure must never be used for more than one CPU architecture context.\r | |
9095d37b LG |
5059 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module.\r |
5060 | SetJump()/LongJump() is not currently supported for the EBC processor type.\r | |
ac644614 | 5061 | \r |
5062 | @param JumpBuffer A pointer to CPU context buffer.\r | |
5063 | \r | |
5064 | @retval 0 Indicates a return from SetJump().\r | |
5065 | \r | |
5066 | **/\r | |
2117989c | 5067 | RETURNS_TWICE\r |
ac644614 | 5068 | UINTN\r |
5069 | EFIAPI\r | |
5070 | SetJump (\r | |
5071 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
5072 | );\r | |
5073 | \r | |
5074 | \r | |
5075 | /**\r | |
5076 | Restores the CPU context that was saved with SetJump().\r | |
5077 | \r | |
5078 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
5079 | function never returns to the caller. Instead is resumes execution based on\r | |
5080 | the state of JumpBuffer.\r | |
5081 | \r | |
5082 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 5083 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
ac644614 | 5084 | If Value is 0, then ASSERT().\r |
5085 | \r | |
5086 | @param JumpBuffer A pointer to CPU context buffer.\r | |
5087 | @param Value The value to return when the SetJump() context is\r | |
5088 | restored and must be non-zero.\r | |
5089 | \r | |
5090 | **/\r | |
5091 | VOID\r | |
5092 | EFIAPI\r | |
5093 | LongJump (\r | |
5094 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
5095 | IN UINTN Value\r | |
5096 | );\r | |
5097 | \r | |
5098 | \r | |
5099 | /**\r | |
5100 | Enables CPU interrupts.\r | |
5101 | \r | |
ac644614 | 5102 | **/\r |
5103 | VOID\r | |
5104 | EFIAPI\r | |
5105 | EnableInterrupts (\r | |
5106 | VOID\r | |
5107 | );\r | |
5108 | \r | |
5109 | \r | |
5110 | /**\r | |
5111 | Disables CPU interrupts.\r | |
5112 | \r | |
ac644614 | 5113 | **/\r |
5114 | VOID\r | |
5115 | EFIAPI\r | |
5116 | DisableInterrupts (\r | |
5117 | VOID\r | |
5118 | );\r | |
5119 | \r | |
5120 | \r | |
5121 | /**\r | |
5122 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
5123 | operation.\r | |
5124 | \r | |
ac644614 | 5125 | @retval TRUE CPU interrupts were enabled on entry to this call.\r |
5126 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
5127 | \r | |
5128 | **/\r | |
5129 | BOOLEAN\r | |
5130 | EFIAPI\r | |
5131 | SaveAndDisableInterrupts (\r | |
5132 | VOID\r | |
5133 | );\r | |
5134 | \r | |
5135 | \r | |
5136 | /**\r | |
5137 | Enables CPU interrupts for the smallest window required to capture any\r | |
5138 | pending interrupts.\r | |
5139 | \r | |
ac644614 | 5140 | **/\r |
5141 | VOID\r | |
5142 | EFIAPI\r | |
5143 | EnableDisableInterrupts (\r | |
5144 | VOID\r | |
5145 | );\r | |
5146 | \r | |
5147 | \r | |
5148 | /**\r | |
5149 | Retrieves the current CPU interrupt state.\r | |
5150 | \r | |
af2dc6a7 | 5151 | Returns TRUE if interrupts are currently enabled. Otherwise\r |
38bbd3d9 | 5152 | returns FALSE.\r |
ac644614 | 5153 | \r |
5154 | @retval TRUE CPU interrupts are enabled.\r | |
5155 | @retval FALSE CPU interrupts are disabled.\r | |
5156 | \r | |
5157 | **/\r | |
5158 | BOOLEAN\r | |
5159 | EFIAPI\r | |
5160 | GetInterruptState (\r | |
5161 | VOID\r | |
5162 | );\r | |
5163 | \r | |
5164 | \r | |
5165 | /**\r | |
5166 | Set the current CPU interrupt state.\r | |
5167 | \r | |
5168 | Sets the current CPU interrupt state to the state specified by\r | |
5169 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
5170 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
5171 | returned.\r | |
5172 | \r | |
5173 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
5174 | interrupts should be disabled.\r | |
5175 | \r | |
5176 | @return InterruptState\r | |
5177 | \r | |
5178 | **/\r | |
5179 | BOOLEAN\r | |
5180 | EFIAPI\r | |
5181 | SetInterruptState (\r | |
5182 | IN BOOLEAN InterruptState\r | |
5183 | );\r | |
5184 | \r | |
5185 | \r | |
5186 | /**\r | |
5187 | Requests CPU to pause for a short period of time.\r | |
5188 | \r | |
5189 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
5190 | systems to prevent memory starvation while waiting for a spin lock.\r | |
5191 | \r | |
5192 | **/\r | |
5193 | VOID\r | |
5194 | EFIAPI\r | |
5195 | CpuPause (\r | |
5196 | VOID\r | |
5197 | );\r | |
5198 | \r | |
5199 | \r | |
5200 | /**\r | |
5201 | Transfers control to a function starting with a new stack.\r | |
5202 | \r | |
5203 | Transfers control to the function specified by EntryPoint using the\r | |
5204 | new stack specified by NewStack and passing in the parameters specified\r | |
5205 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
5206 | be NULL. The function EntryPoint must never return. This function\r | |
5207 | supports a variable number of arguments following the NewStack parameter.\r | |
1a2f870c | 5208 | These additional arguments are ignored on IA-32, x64, and EBC architectures.\r |
5209 | Itanium processors expect one additional parameter of type VOID * that specifies\r | |
ac644614 | 5210 | the new backing store pointer.\r |
5211 | \r | |
5212 | If EntryPoint is NULL, then ASSERT().\r | |
5213 | If NewStack is NULL, then ASSERT().\r | |
5214 | \r | |
5215 | @param EntryPoint A pointer to function to call with the new stack.\r | |
5216 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
5217 | function.\r | |
5218 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
5219 | function.\r | |
5220 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
5221 | function.\r | |
9095d37b LG |
5222 | @param ... This variable argument list is ignored for IA-32, x64, and\r |
5223 | EBC architectures. For Itanium processors, this variable\r | |
5224 | argument list is expected to contain a single parameter of\r | |
af2dc6a7 | 5225 | type VOID * that specifies the new backing store pointer.\r |
42eedea9 | 5226 | \r |
ac644614 | 5227 | \r |
5228 | **/\r | |
5229 | VOID\r | |
5230 | EFIAPI\r | |
5231 | SwitchStack (\r | |
5232 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
5233 | IN VOID *Context1, OPTIONAL\r | |
5234 | IN VOID *Context2, OPTIONAL\r | |
5235 | IN VOID *NewStack,\r | |
5236 | ...\r | |
5237 | );\r | |
5238 | \r | |
5239 | \r | |
5240 | /**\r | |
5241 | Generates a breakpoint on the CPU.\r | |
5242 | \r | |
5243 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
5244 | that code can resume normal execution after the breakpoint.\r | |
5245 | \r | |
5246 | **/\r | |
5247 | VOID\r | |
5248 | EFIAPI\r | |
5249 | CpuBreakpoint (\r | |
5250 | VOID\r | |
5251 | );\r | |
5252 | \r | |
5253 | \r | |
5254 | /**\r | |
5255 | Executes an infinite loop.\r | |
5256 | \r | |
5257 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
5258 | past the loop and the code that follows the loop must execute properly. This\r | |
5259 | implies that the infinite loop must not cause the code that follow it to be\r | |
5260 | optimized away.\r | |
5261 | \r | |
5262 | **/\r | |
5263 | VOID\r | |
5264 | EFIAPI\r | |
5265 | CpuDeadLoop (\r | |
5266 | VOID\r | |
5267 | );\r | |
9095d37b | 5268 | \r |
d9f1cac5 HW |
5269 | \r |
5270 | /**\r | |
5271 | Uses as a barrier to stop speculative execution.\r | |
5272 | \r | |
5273 | Ensures that no later instruction will execute speculatively, until all prior\r | |
5274 | instructions have completed.\r | |
5275 | \r | |
5276 | **/\r | |
5277 | VOID\r | |
5278 | EFIAPI\r | |
5279 | SpeculationBarrier (\r | |
5280 | VOID\r | |
5281 | );\r | |
5282 | \r | |
5283 | \r | |
fd163050 | 5284 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
1106ffe1 | 5285 | ///\r |
af2dc6a7 | 5286 | /// IA32 and x64 Specific Functions.\r |
5287 | /// Byte packed structure for 16-bit Real Mode EFLAGS.\r | |
1106ffe1 | 5288 | ///\r |
ac644614 | 5289 | typedef union {\r |
5290 | struct {\r | |
af2dc6a7 | 5291 | UINT32 CF:1; ///< Carry Flag.\r |
5292 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5293 | UINT32 PF:1; ///< Parity Flag.\r | |
5294 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5295 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5296 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5297 | UINT32 ZF:1; ///< Zero Flag.\r | |
5298 | UINT32 SF:1; ///< Sign Flag.\r | |
5299 | UINT32 TF:1; ///< Trap Flag.\r | |
5300 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5301 | UINT32 DF:1; ///< Direction Flag.\r | |
5302 | UINT32 OF:1; ///< Overflow Flag.\r | |
5303 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5304 | UINT32 NT:1; ///< Nested Task.\r | |
5305 | UINT32 Reserved_3:1; ///< Reserved.\r | |
ac644614 | 5306 | } Bits;\r |
5307 | UINT16 Uint16;\r | |
5308 | } IA32_FLAGS16;\r | |
5309 | \r | |
1106ffe1 | 5310 | ///\r |
af2dc6a7 | 5311 | /// Byte packed structure for EFLAGS/RFLAGS.\r |
5312 | /// 32-bits on IA-32.\r | |
5313 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5314 | ///\r |
ac644614 | 5315 | typedef union {\r |
5316 | struct {\r | |
af2dc6a7 | 5317 | UINT32 CF:1; ///< Carry Flag.\r |
5318 | UINT32 Reserved_0:1; ///< Reserved.\r | |
5319 | UINT32 PF:1; ///< Parity Flag.\r | |
5320 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5321 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
5322 | UINT32 Reserved_2:1; ///< Reserved.\r | |
5323 | UINT32 ZF:1; ///< Zero Flag.\r | |
5324 | UINT32 SF:1; ///< Sign Flag.\r | |
5325 | UINT32 TF:1; ///< Trap Flag.\r | |
5326 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
5327 | UINT32 DF:1; ///< Direction Flag.\r | |
5328 | UINT32 OF:1; ///< Overflow Flag.\r | |
5329 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
5330 | UINT32 NT:1; ///< Nested Task.\r | |
5331 | UINT32 Reserved_3:1; ///< Reserved.\r | |
5332 | UINT32 RF:1; ///< Resume Flag.\r | |
5333 | UINT32 VM:1; ///< Virtual 8086 Mode.\r | |
5334 | UINT32 AC:1; ///< Alignment Check.\r | |
5335 | UINT32 VIF:1; ///< Virtual Interrupt Flag.\r | |
5336 | UINT32 VIP:1; ///< Virtual Interrupt Pending.\r | |
5337 | UINT32 ID:1; ///< ID Flag.\r | |
5338 | UINT32 Reserved_4:10; ///< Reserved.\r | |
ac644614 | 5339 | } Bits;\r |
5340 | UINTN UintN;\r | |
5341 | } IA32_EFLAGS32;\r | |
5342 | \r | |
1106ffe1 | 5343 | ///\r |
af2dc6a7 | 5344 | /// Byte packed structure for Control Register 0 (CR0).\r |
5345 | /// 32-bits on IA-32.\r | |
5346 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5347 | ///\r |
ac644614 | 5348 | typedef union {\r |
5349 | struct {\r | |
af2dc6a7 | 5350 | UINT32 PE:1; ///< Protection Enable.\r |
5351 | UINT32 MP:1; ///< Monitor Coprocessor.\r | |
5352 | UINT32 EM:1; ///< Emulation.\r | |
5353 | UINT32 TS:1; ///< Task Switched.\r | |
5354 | UINT32 ET:1; ///< Extension Type.\r | |
5355 | UINT32 NE:1; ///< Numeric Error.\r | |
5356 | UINT32 Reserved_0:10; ///< Reserved.\r | |
5357 | UINT32 WP:1; ///< Write Protect.\r | |
5358 | UINT32 Reserved_1:1; ///< Reserved.\r | |
5359 | UINT32 AM:1; ///< Alignment Mask.\r | |
5360 | UINT32 Reserved_2:10; ///< Reserved.\r | |
5361 | UINT32 NW:1; ///< Mot Write-through.\r | |
5362 | UINT32 CD:1; ///< Cache Disable.\r | |
5363 | UINT32 PG:1; ///< Paging.\r | |
ac644614 | 5364 | } Bits;\r |
5365 | UINTN UintN;\r | |
5366 | } IA32_CR0;\r | |
5367 | \r | |
1106ffe1 | 5368 | ///\r |
af2dc6a7 | 5369 | /// Byte packed structure for Control Register 4 (CR4).\r |
5370 | /// 32-bits on IA-32.\r | |
5371 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 5372 | ///\r |
ac644614 | 5373 | typedef union {\r |
5374 | struct {\r | |
af2dc6a7 | 5375 | UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r |
5376 | UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r | |
5377 | UINT32 TSD:1; ///< Time Stamp Disable.\r | |
5378 | UINT32 DE:1; ///< Debugging Extensions.\r | |
5379 | UINT32 PSE:1; ///< Page Size Extensions.\r | |
5380 | UINT32 PAE:1; ///< Physical Address Extension.\r | |
5381 | UINT32 MCE:1; ///< Machine Check Enable.\r | |
5382 | UINT32 PGE:1; ///< Page Global Enable.\r | |
2a53dabf | 5383 | UINT32 PCE:1; ///< Performance Monitoring Counter\r |
af2dc6a7 | 5384 | ///< Enable.\r |
2a53dabf LG |
5385 | UINT32 OSFXSR:1; ///< Operating System Support for\r |
5386 | ///< FXSAVE and FXRSTOR instructions\r | |
5387 | UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r | |
5388 | ///< Unmasked SIMD Floating Point\r | |
af2dc6a7 | 5389 | ///< Exceptions.\r |
859046e0 | 5390 | UINT32 UMIP:1; ///< User-Mode Instruction Prevention.\r |
6e5a33d1 | 5391 | UINT32 LA57:1; ///< Linear Address 57bit.\r |
859046e0 JV |
5392 | UINT32 VMXE:1; ///< VMX Enable.\r |
5393 | UINT32 SMXE:1; ///< SMX Enable.\r | |
5394 | UINT32 Reserved_3:1; ///< Reserved.\r | |
5395 | UINT32 FSGSBASE:1; ///< FSGSBASE Enable.\r | |
5396 | UINT32 PCIDE:1; ///< PCID Enable.\r | |
5397 | UINT32 OSXSAVE:1; ///< XSAVE and Processor Extended States Enable.\r | |
5398 | UINT32 Reserved_4:1; ///< Reserved.\r | |
5399 | UINT32 SMEP:1; ///< SMEP Enable.\r | |
5400 | UINT32 SMAP:1; ///< SMAP Enable.\r | |
5401 | UINT32 PKE:1; ///< Protection-Key Enable.\r | |
5402 | UINT32 Reserved_5:9; ///< Reserved.\r | |
ac644614 | 5403 | } Bits;\r |
5404 | UINTN UintN;\r | |
5405 | } IA32_CR4;\r | |
5406 | \r | |
6088db38 | 5407 | ///\r |
5408 | /// Byte packed structure for a segment descriptor in a GDT/LDT.\r | |
5409 | ///\r | |
5410 | typedef union {\r | |
5411 | struct {\r | |
5412 | UINT32 LimitLow:16;\r | |
5413 | UINT32 BaseLow:16;\r | |
5414 | UINT32 BaseMid:8;\r | |
5415 | UINT32 Type:4;\r | |
5416 | UINT32 S:1;\r | |
5417 | UINT32 DPL:2;\r | |
5418 | UINT32 P:1;\r | |
5419 | UINT32 LimitHigh:4;\r | |
5420 | UINT32 AVL:1;\r | |
5421 | UINT32 L:1;\r | |
5422 | UINT32 DB:1;\r | |
5423 | UINT32 G:1;\r | |
5424 | UINT32 BaseHigh:8;\r | |
5425 | } Bits;\r | |
5426 | UINT64 Uint64;\r | |
5427 | } IA32_SEGMENT_DESCRIPTOR;\r | |
5428 | \r | |
1106ffe1 | 5429 | ///\r |
af2dc6a7 | 5430 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r |
1106ffe1 | 5431 | ///\r |
ac644614 | 5432 | #pragma pack (1)\r |
5433 | typedef struct {\r | |
5434 | UINT16 Limit;\r | |
5435 | UINTN Base;\r | |
5436 | } IA32_DESCRIPTOR;\r | |
5437 | #pragma pack ()\r | |
5438 | \r | |
5439 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
5440 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
5441 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
5442 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
5443 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
5444 | \r | |
364a5474 JW |
5445 | #define IA32_GDT_TYPE_TSS 0x9\r |
5446 | #define IA32_GDT_ALIGNMENT 8\r | |
6f4aad3b | 5447 | \r |
5448 | #if defined (MDE_CPU_IA32)\r | |
1106ffe1 | 5449 | ///\r |
af2dc6a7 | 5450 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r |
1106ffe1 | 5451 | ///\r |
dc317713 | 5452 | typedef union {\r |
5453 | struct {\r | |
af2dc6a7 | 5454 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5455 | UINT32 Selector:16; ///< Selector.\r | |
5456 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5457 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5458 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
dc317713 | 5459 | } Bits;\r |
5460 | UINT64 Uint64;\r | |
5461 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
5462 | \r | |
364a5474 JW |
5463 | #pragma pack (1)\r |
5464 | //\r | |
5465 | // IA32 Task-State Segment Definition\r | |
5466 | //\r | |
5467 | typedef struct {\r | |
5468 | UINT16 PreviousTaskLink;\r | |
5469 | UINT16 Reserved_2;\r | |
3ab032fc JW |
5470 | UINT32 ESP0;\r |
5471 | UINT16 SS0;\r | |
364a5474 | 5472 | UINT16 Reserved_10;\r |
3ab032fc JW |
5473 | UINT32 ESP1;\r |
5474 | UINT16 SS1;\r | |
364a5474 | 5475 | UINT16 Reserved_18;\r |
3ab032fc JW |
5476 | UINT32 ESP2;\r |
5477 | UINT16 SS2;\r | |
364a5474 | 5478 | UINT16 Reserved_26;\r |
3ab032fc JW |
5479 | UINT32 CR3;\r |
5480 | UINT32 EIP;\r | |
5481 | UINT32 EFLAGS;\r | |
5482 | UINT32 EAX;\r | |
5483 | UINT32 ECX;\r | |
5484 | UINT32 EDX;\r | |
5485 | UINT32 EBX;\r | |
5486 | UINT32 ESP;\r | |
5487 | UINT32 EBP;\r | |
5488 | UINT32 ESI;\r | |
5489 | UINT32 EDI;\r | |
5490 | UINT16 ES;\r | |
364a5474 | 5491 | UINT16 Reserved_74;\r |
3ab032fc | 5492 | UINT16 CS;\r |
364a5474 | 5493 | UINT16 Reserved_78;\r |
3ab032fc | 5494 | UINT16 SS;\r |
364a5474 | 5495 | UINT16 Reserved_82;\r |
3ab032fc | 5496 | UINT16 DS;\r |
364a5474 | 5497 | UINT16 Reserved_86;\r |
3ab032fc | 5498 | UINT16 FS;\r |
364a5474 | 5499 | UINT16 Reserved_90;\r |
3ab032fc | 5500 | UINT16 GS;\r |
364a5474 JW |
5501 | UINT16 Reserved_94;\r |
5502 | UINT16 LDTSegmentSelector;\r | |
5503 | UINT16 Reserved_98;\r | |
3ab032fc | 5504 | UINT16 T;\r |
364a5474 JW |
5505 | UINT16 IOMapBaseAddress;\r |
5506 | } IA32_TASK_STATE_SEGMENT;\r | |
5507 | \r | |
5508 | typedef union {\r | |
5509 | struct {\r | |
5510 | UINT32 LimitLow:16; ///< Segment Limit 15..00\r | |
5511 | UINT32 BaseLow:16; ///< Base Address 15..00\r | |
5512 | UINT32 BaseMid:8; ///< Base Address 23..16\r | |
5513 | UINT32 Type:4; ///< Type (1 0 B 1)\r | |
5514 | UINT32 Reserved_43:1; ///< 0\r | |
3ab032fc JW |
5515 | UINT32 DPL:2; ///< Descriptor Privilege Level\r |
5516 | UINT32 P:1; ///< Segment Present\r | |
364a5474 | 5517 | UINT32 LimitHigh:4; ///< Segment Limit 19..16\r |
3ab032fc | 5518 | UINT32 AVL:1; ///< Available for use by system software\r |
364a5474 | 5519 | UINT32 Reserved_52:2; ///< 0 0\r |
3ab032fc | 5520 | UINT32 G:1; ///< Granularity\r |
364a5474 JW |
5521 | UINT32 BaseHigh:8; ///< Base Address 31..24\r |
5522 | } Bits;\r | |
5523 | UINT64 Uint64;\r | |
5524 | } IA32_TSS_DESCRIPTOR;\r | |
5525 | #pragma pack ()\r | |
5526 | \r | |
de4f7f52 | 5527 | #endif // defined (MDE_CPU_IA32)\r |
dc317713 | 5528 | \r |
5529 | #if defined (MDE_CPU_X64)\r | |
6f4aad3b | 5530 | ///\r |
af2dc6a7 | 5531 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.\r |
6f4aad3b | 5532 | ///\r |
ac644614 | 5533 | typedef union {\r |
5534 | struct {\r | |
af2dc6a7 | 5535 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
5536 | UINT32 Selector:16; ///< Selector.\r | |
5537 | UINT32 Reserved_0:8; ///< Reserved.\r | |
5538 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
5539 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
5540 | UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r | |
5541 | UINT32 Reserved_1:32; ///< Reserved.\r | |
ac644614 | 5542 | } Bits;\r |
6f4aad3b | 5543 | struct {\r |
5544 | UINT64 Uint64;\r | |
5545 | UINT64 Uint64_1;\r | |
9095d37b | 5546 | } Uint128;\r |
ac644614 | 5547 | } IA32_IDT_GATE_DESCRIPTOR;\r |
5548 | \r | |
364a5474 JW |
5549 | #pragma pack (1)\r |
5550 | //\r | |
5551 | // IA32 Task-State Segment Definition\r | |
5552 | //\r | |
5553 | typedef struct {\r | |
5554 | UINT32 Reserved_0;\r | |
3ab032fc JW |
5555 | UINT64 RSP0;\r |
5556 | UINT64 RSP1;\r | |
5557 | UINT64 RSP2;\r | |
364a5474 | 5558 | UINT64 Reserved_28;\r |
3ab032fc | 5559 | UINT64 IST[7];\r |
364a5474 JW |
5560 | UINT64 Reserved_92;\r |
5561 | UINT16 Reserved_100;\r | |
5562 | UINT16 IOMapBaseAddress;\r | |
5563 | } IA32_TASK_STATE_SEGMENT;\r | |
5564 | \r | |
5565 | typedef union {\r | |
5566 | struct {\r | |
5567 | UINT32 LimitLow:16; ///< Segment Limit 15..00\r | |
5568 | UINT32 BaseLow:16; ///< Base Address 15..00\r | |
5569 | UINT32 BaseMidl:8; ///< Base Address 23..16\r | |
5570 | UINT32 Type:4; ///< Type (1 0 B 1)\r | |
5571 | UINT32 Reserved_43:1; ///< 0\r | |
3ab032fc JW |
5572 | UINT32 DPL:2; ///< Descriptor Privilege Level\r |
5573 | UINT32 P:1; ///< Segment Present\r | |
364a5474 | 5574 | UINT32 LimitHigh:4; ///< Segment Limit 19..16\r |
3ab032fc | 5575 | UINT32 AVL:1; ///< Available for use by system software\r |
364a5474 | 5576 | UINT32 Reserved_52:2; ///< 0 0\r |
3ab032fc | 5577 | UINT32 G:1; ///< Granularity\r |
364a5474 JW |
5578 | UINT32 BaseMidh:8; ///< Base Address 31..24\r |
5579 | UINT32 BaseHigh:32; ///< Base Address 63..32\r | |
5580 | UINT32 Reserved_96:32; ///< Reserved\r | |
5581 | } Bits;\r | |
5582 | struct {\r | |
5583 | UINT64 Uint64;\r | |
5584 | UINT64 Uint64_1;\r | |
5585 | } Uint128;\r | |
5586 | } IA32_TSS_DESCRIPTOR;\r | |
5587 | #pragma pack ()\r | |
5588 | \r | |
de4f7f52 | 5589 | #endif // defined (MDE_CPU_X64)\r |
dc317713 | 5590 | \r |
1106ffe1 | 5591 | ///\r |
af2dc6a7 | 5592 | /// Byte packed structure for an FP/SSE/SSE2 context.\r |
1106ffe1 | 5593 | ///\r |
ac644614 | 5594 | typedef struct {\r |
5595 | UINT8 Buffer[512];\r | |
5596 | } IA32_FX_BUFFER;\r | |
5597 | \r | |
1106ffe1 | 5598 | ///\r |
af2dc6a7 | 5599 | /// Structures for the 16-bit real mode thunks.\r |
1106ffe1 | 5600 | ///\r |
ac644614 | 5601 | typedef struct {\r |
5602 | UINT32 Reserved1;\r | |
5603 | UINT32 Reserved2;\r | |
5604 | UINT32 Reserved3;\r | |
5605 | UINT32 Reserved4;\r | |
5606 | UINT8 BL;\r | |
5607 | UINT8 BH;\r | |
5608 | UINT16 Reserved5;\r | |
5609 | UINT8 DL;\r | |
5610 | UINT8 DH;\r | |
5611 | UINT16 Reserved6;\r | |
5612 | UINT8 CL;\r | |
5613 | UINT8 CH;\r | |
5614 | UINT16 Reserved7;\r | |
5615 | UINT8 AL;\r | |
5616 | UINT8 AH;\r | |
5617 | UINT16 Reserved8;\r | |
5618 | } IA32_BYTE_REGS;\r | |
5619 | \r | |
5620 | typedef struct {\r | |
5621 | UINT16 DI;\r | |
5622 | UINT16 Reserved1;\r | |
5623 | UINT16 SI;\r | |
5624 | UINT16 Reserved2;\r | |
5625 | UINT16 BP;\r | |
5626 | UINT16 Reserved3;\r | |
5627 | UINT16 SP;\r | |
5628 | UINT16 Reserved4;\r | |
5629 | UINT16 BX;\r | |
5630 | UINT16 Reserved5;\r | |
5631 | UINT16 DX;\r | |
5632 | UINT16 Reserved6;\r | |
5633 | UINT16 CX;\r | |
5634 | UINT16 Reserved7;\r | |
5635 | UINT16 AX;\r | |
5636 | UINT16 Reserved8;\r | |
5637 | } IA32_WORD_REGS;\r | |
5638 | \r | |
5639 | typedef struct {\r | |
5640 | UINT32 EDI;\r | |
5641 | UINT32 ESI;\r | |
5642 | UINT32 EBP;\r | |
5643 | UINT32 ESP;\r | |
5644 | UINT32 EBX;\r | |
5645 | UINT32 EDX;\r | |
5646 | UINT32 ECX;\r | |
5647 | UINT32 EAX;\r | |
5648 | UINT16 DS;\r | |
5649 | UINT16 ES;\r | |
5650 | UINT16 FS;\r | |
5651 | UINT16 GS;\r | |
5652 | IA32_EFLAGS32 EFLAGS;\r | |
5653 | UINT32 Eip;\r | |
5654 | UINT16 CS;\r | |
5655 | UINT16 SS;\r | |
5656 | } IA32_DWORD_REGS;\r | |
5657 | \r | |
5658 | typedef union {\r | |
5659 | IA32_DWORD_REGS E;\r | |
5660 | IA32_WORD_REGS X;\r | |
5661 | IA32_BYTE_REGS H;\r | |
5662 | } IA32_REGISTER_SET;\r | |
5663 | \r | |
1106ffe1 | 5664 | ///\r |
af2dc6a7 | 5665 | /// Byte packed structure for an 16-bit real mode thunks.\r |
1106ffe1 | 5666 | ///\r |
ac644614 | 5667 | typedef struct {\r |
5668 | IA32_REGISTER_SET *RealModeState;\r | |
5669 | VOID *RealModeBuffer;\r | |
5670 | UINT32 RealModeBufferSize;\r | |
5671 | UINT32 ThunkAttributes;\r | |
5672 | } THUNK_CONTEXT;\r | |
5673 | \r | |
5674 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r | |
5675 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
5676 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
5677 | \r | |
8596c140 LE |
5678 | ///\r |
5679 | /// Type definition for representing labels in NASM source code that allow for\r | |
5680 | /// the patching of immediate operands of IA32 and X64 instructions.\r | |
5681 | ///\r | |
5682 | /// While the type is technically defined as a function type (note: not a\r | |
5683 | /// pointer-to-function type), such labels in NASM source code never stand for\r | |
5684 | /// actual functions, and identifiers declared with this function type should\r | |
5685 | /// never be called. This is also why the EFIAPI calling convention specifier\r | |
5686 | /// is missing from the typedef, and why the typedef does not follow the usual\r | |
5687 | /// edk2 coding style for function (or pointer-to-function) typedefs. The VOID\r | |
5688 | /// return type and the VOID argument list are merely artifacts.\r | |
5689 | ///\r | |
5690 | typedef VOID (X86_ASSEMBLY_PATCH_LABEL) (VOID);\r | |
5691 | \r | |
ac644614 | 5692 | /**\r |
5693 | Retrieves CPUID information.\r | |
5694 | \r | |
5695 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
5696 | This function always returns Index.\r | |
5697 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5698 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5699 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5700 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
030cd1a2 | 5701 | This function is only available on IA-32 and x64.\r |
ac644614 | 5702 | \r |
5703 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
5704 | instruction.\r | |
af2dc6a7 | 5705 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5706 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5707 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5708 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5709 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5710 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 5711 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5712 | instruction. This is an optional parameter that may be NULL.\r |
5713 | \r | |
2fe241a2 | 5714 | @return Index.\r |
ac644614 | 5715 | \r |
5716 | **/\r | |
5717 | UINT32\r | |
5718 | EFIAPI\r | |
5719 | AsmCpuid (\r | |
5720 | IN UINT32 Index,\r | |
5721 | OUT UINT32 *Eax, OPTIONAL\r | |
5722 | OUT UINT32 *Ebx, OPTIONAL\r | |
5723 | OUT UINT32 *Ecx, OPTIONAL\r | |
5724 | OUT UINT32 *Edx OPTIONAL\r | |
5725 | );\r | |
5726 | \r | |
5727 | \r | |
5728 | /**\r | |
5729 | Retrieves CPUID information using an extended leaf identifier.\r | |
5730 | \r | |
5731 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
5732 | and ECX set to the value specified by SubIndex. This function always returns\r | |
5733 | Index. This function is only available on IA-32 and x64.\r | |
5734 | \r | |
5735 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
5736 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
5737 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
5738 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
5739 | \r | |
5740 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
5741 | CPUID instruction.\r | |
5742 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
5743 | CPUID instruction.\r | |
af2dc6a7 | 5744 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 5745 | instruction. This is an optional parameter that may be\r |
5746 | NULL.\r | |
af2dc6a7 | 5747 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 5748 | instruction. This is an optional parameter that may be\r |
5749 | NULL.\r | |
af2dc6a7 | 5750 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 5751 | instruction. This is an optional parameter that may be\r |
5752 | NULL.\r | |
af2dc6a7 | 5753 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 5754 | instruction. This is an optional parameter that may be\r |
5755 | NULL.\r | |
5756 | \r | |
2fe241a2 | 5757 | @return Index.\r |
ac644614 | 5758 | \r |
5759 | **/\r | |
5760 | UINT32\r | |
5761 | EFIAPI\r | |
5762 | AsmCpuidEx (\r | |
5763 | IN UINT32 Index,\r | |
5764 | IN UINT32 SubIndex,\r | |
5765 | OUT UINT32 *Eax, OPTIONAL\r | |
5766 | OUT UINT32 *Ebx, OPTIONAL\r | |
5767 | OUT UINT32 *Ecx, OPTIONAL\r | |
5768 | OUT UINT32 *Edx OPTIONAL\r | |
5769 | );\r | |
5770 | \r | |
5771 | \r | |
be5f1614 | 5772 | /**\r |
5773 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r | |
5774 | \r | |
5775 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r | |
5776 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r | |
5777 | \r | |
5778 | **/\r | |
5779 | VOID\r | |
5780 | EFIAPI\r | |
5781 | AsmDisableCache (\r | |
5782 | VOID\r | |
5783 | );\r | |
5784 | \r | |
5785 | \r | |
5786 | /**\r | |
5787 | Perform a WBINVD and clear both the CD and NW bits of CR0.\r | |
5788 | \r | |
5789 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r | |
5790 | bits of CR0 to 0. This function is only available on IA-32 and x64.\r | |
5791 | \r | |
5792 | **/\r | |
5793 | VOID\r | |
5794 | EFIAPI\r | |
5795 | AsmEnableCache (\r | |
5796 | VOID\r | |
5797 | );\r | |
5798 | \r | |
5799 | \r | |
ac644614 | 5800 | /**\r |
5801 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
5802 | \r | |
5803 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
5804 | No parameter checking is performed on Index, and some Index values may cause\r | |
5805 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
5806 | caller must set up exception handlers to catch the exceptions. This function\r | |
030cd1a2 | 5807 | is only available on IA-32 and x64.\r |
ac644614 | 5808 | \r |
5809 | @param Index The 32-bit MSR index to read.\r | |
5810 | \r | |
5811 | @return The lower 32 bits of the MSR identified by Index.\r | |
5812 | \r | |
5813 | **/\r | |
5814 | UINT32\r | |
5815 | EFIAPI\r | |
5816 | AsmReadMsr32 (\r | |
5817 | IN UINT32 Index\r | |
5818 | );\r | |
5819 | \r | |
5820 | \r | |
5821 | /**\r | |
17f695ed | 5822 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r |
5823 | The upper 32-bits of the MSR are set to zero.\r | |
ac644614 | 5824 | \r |
5825 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
5826 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
5827 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
5828 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
5829 | that Index and Value are valid, or the caller must establish proper exception\r | |
030cd1a2 | 5830 | handlers. This function is only available on IA-32 and x64.\r |
ac644614 | 5831 | \r |
5832 | @param Index The 32-bit MSR index to write.\r | |
5833 | @param Value The 32-bit value to write to the MSR.\r | |
5834 | \r | |
5835 | @return Value\r | |
5836 | \r | |
5837 | **/\r | |
5838 | UINT32\r | |
5839 | EFIAPI\r | |
5840 | AsmWriteMsr32 (\r | |
5841 | IN UINT32 Index,\r | |
5842 | IN UINT32 Value\r | |
5843 | );\r | |
5844 | \r | |
5845 | \r | |
5846 | /**\r | |
62991af2 | 5847 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r |
ac644614 | 5848 | writes the result back to the 64-bit MSR.\r |
5849 | \r | |
62991af2 | 5850 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 5851 | between the lower 32-bits of the read result and the value specified by\r |
5852 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
5853 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
5854 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
5855 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
5856 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 5857 | IA-32 and x64.\r |
ac644614 | 5858 | \r |
5859 | @param Index The 32-bit MSR index to write.\r | |
5860 | @param OrData The value to OR with the read value from the MSR.\r | |
5861 | \r | |
5862 | @return The lower 32-bit value written to the MSR.\r | |
5863 | \r | |
5864 | **/\r | |
5865 | UINT32\r | |
5866 | EFIAPI\r | |
5867 | AsmMsrOr32 (\r | |
5868 | IN UINT32 Index,\r | |
5869 | IN UINT32 OrData\r | |
5870 | );\r | |
5871 | \r | |
5872 | \r | |
5873 | /**\r | |
5874 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
5875 | the result back to the 64-bit MSR.\r | |
5876 | \r | |
5877 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5878 | lower 32-bits of the read result and the value specified by AndData, and\r | |
5879 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
5880 | the value written to the MSR is returned. No parameter checking is performed\r | |
5881 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
5882 | must either guarantee that Index and AndData are valid, or the caller must\r | |
5883 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 5884 | and x64.\r |
ac644614 | 5885 | \r |
5886 | @param Index The 32-bit MSR index to write.\r | |
5887 | @param AndData The value to AND with the read value from the MSR.\r | |
5888 | \r | |
5889 | @return The lower 32-bit value written to the MSR.\r | |
5890 | \r | |
5891 | **/\r | |
5892 | UINT32\r | |
5893 | EFIAPI\r | |
5894 | AsmMsrAnd32 (\r | |
5895 | IN UINT32 Index,\r | |
5896 | IN UINT32 AndData\r | |
5897 | );\r | |
5898 | \r | |
5899 | \r | |
5900 | /**\r | |
62991af2 | 5901 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r |
ac644614 | 5902 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r |
5903 | \r | |
5904 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
5905 | lower 32-bits of the read result and the value specified by AndData\r | |
62991af2 | 5906 | preserving the upper 32-bits, performs a bitwise OR between the\r |
ac644614 | 5907 | result of the AND operation and the value specified by OrData, and writes the\r |
5908 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
5909 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
5910 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
5911 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
5912 | caller must establish proper exception handlers. This function is only\r | |
030cd1a2 | 5913 | available on IA-32 and x64.\r |
ac644614 | 5914 | \r |
5915 | @param Index The 32-bit MSR index to write.\r | |
5916 | @param AndData The value to AND with the read value from the MSR.\r | |
5917 | @param OrData The value to OR with the result of the AND operation.\r | |
5918 | \r | |
5919 | @return The lower 32-bit value written to the MSR.\r | |
5920 | \r | |
5921 | **/\r | |
5922 | UINT32\r | |
5923 | EFIAPI\r | |
5924 | AsmMsrAndThenOr32 (\r | |
5925 | IN UINT32 Index,\r | |
5926 | IN UINT32 AndData,\r | |
5927 | IN UINT32 OrData\r | |
5928 | );\r | |
5929 | \r | |
5930 | \r | |
5931 | /**\r | |
5932 | Reads a bit field of an MSR.\r | |
5933 | \r | |
5934 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
5935 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
5936 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
5937 | must set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 5938 | available on IA-32 and x64.\r |
ac644614 | 5939 | \r |
5940 | If StartBit is greater than 31, then ASSERT().\r | |
5941 | If EndBit is greater than 31, then ASSERT().\r | |
5942 | If EndBit is less than StartBit, then ASSERT().\r | |
5943 | \r | |
5944 | @param Index The 32-bit MSR index to read.\r | |
5945 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5946 | Range 0..31.\r | |
5947 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5948 | Range 0..31.\r | |
5949 | \r | |
5950 | @return The bit field read from the MSR.\r | |
5951 | \r | |
5952 | **/\r | |
5953 | UINT32\r | |
5954 | EFIAPI\r | |
5955 | AsmMsrBitFieldRead32 (\r | |
5956 | IN UINT32 Index,\r | |
5957 | IN UINTN StartBit,\r | |
5958 | IN UINTN EndBit\r | |
5959 | );\r | |
5960 | \r | |
5961 | \r | |
5962 | /**\r | |
5963 | Writes a bit field to an MSR.\r | |
5964 | \r | |
2fe241a2 | 5965 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r |
ac644614 | 5966 | field is specified by the StartBit and the EndBit. All other bits in the\r |
5967 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
9095d37b LG |
5968 | returned. The caller must either guarantee that Index and the data written\r |
5969 | is valid, or the caller must set up exception handlers to catch the exceptions.\r | |
62991af2 | 5970 | This function is only available on IA-32 and x64.\r |
ac644614 | 5971 | \r |
5972 | If StartBit is greater than 31, then ASSERT().\r | |
5973 | If EndBit is greater than 31, then ASSERT().\r | |
5974 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 5975 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 5976 | \r |
5977 | @param Index The 32-bit MSR index to write.\r | |
5978 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
5979 | Range 0..31.\r | |
5980 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
5981 | Range 0..31.\r | |
5982 | @param Value New value of the bit field.\r | |
5983 | \r | |
5984 | @return The lower 32-bit of the value written to the MSR.\r | |
5985 | \r | |
5986 | **/\r | |
5987 | UINT32\r | |
5988 | EFIAPI\r | |
5989 | AsmMsrBitFieldWrite32 (\r | |
5990 | IN UINT32 Index,\r | |
5991 | IN UINTN StartBit,\r | |
5992 | IN UINTN EndBit,\r | |
5993 | IN UINT32 Value\r | |
5994 | );\r | |
5995 | \r | |
5996 | \r | |
5997 | /**\r | |
5998 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
5999 | result back to the bit field in the 64-bit MSR.\r | |
6000 | \r | |
62991af2 | 6001 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6002 | between the read result and the value specified by OrData, and writes the\r |
6003 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
6004 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
6005 | caller must either guarantee that Index and the data written is valid, or\r | |
6006 | the caller must set up exception handlers to catch the exceptions. This\r | |
030cd1a2 | 6007 | function is only available on IA-32 and x64.\r |
ac644614 | 6008 | \r |
6009 | If StartBit is greater than 31, then ASSERT().\r | |
6010 | If EndBit is greater than 31, then ASSERT().\r | |
6011 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6012 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6013 | \r |
6014 | @param Index The 32-bit MSR index to write.\r | |
6015 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6016 | Range 0..31.\r | |
6017 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6018 | Range 0..31.\r | |
6019 | @param OrData The value to OR with the read value from the MSR.\r | |
6020 | \r | |
6021 | @return The lower 32-bit of the value written to the MSR.\r | |
6022 | \r | |
6023 | **/\r | |
6024 | UINT32\r | |
6025 | EFIAPI\r | |
6026 | AsmMsrBitFieldOr32 (\r | |
6027 | IN UINT32 Index,\r | |
6028 | IN UINTN StartBit,\r | |
6029 | IN UINTN EndBit,\r | |
6030 | IN UINT32 OrData\r | |
6031 | );\r | |
6032 | \r | |
6033 | \r | |
6034 | /**\r | |
6035 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
6036 | result back to the bit field in the 64-bit MSR.\r | |
6037 | \r | |
6038 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6039 | read result and the value specified by AndData, and writes the result to the\r | |
6040 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
6041 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
6042 | either guarantee that Index and the data written is valid, or the caller must\r | |
6043 | set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 6044 | available on IA-32 and x64.\r |
ac644614 | 6045 | \r |
6046 | If StartBit is greater than 31, then ASSERT().\r | |
6047 | If EndBit is greater than 31, then ASSERT().\r | |
6048 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6049 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6050 | \r |
6051 | @param Index The 32-bit MSR index to write.\r | |
6052 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6053 | Range 0..31.\r | |
6054 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6055 | Range 0..31.\r | |
6056 | @param AndData The value to AND with the read value from the MSR.\r | |
6057 | \r | |
6058 | @return The lower 32-bit of the value written to the MSR.\r | |
6059 | \r | |
6060 | **/\r | |
6061 | UINT32\r | |
6062 | EFIAPI\r | |
6063 | AsmMsrBitFieldAnd32 (\r | |
6064 | IN UINT32 Index,\r | |
6065 | IN UINTN StartBit,\r | |
6066 | IN UINTN EndBit,\r | |
6067 | IN UINT32 AndData\r | |
6068 | );\r | |
6069 | \r | |
6070 | \r | |
6071 | /**\r | |
6072 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6073 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6074 | 64-bit MSR.\r |
6075 | \r | |
6076 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
62991af2 | 6077 | bitwise OR between the read result and the value specified by\r |
ac644614 | 6078 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6079 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
6080 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
6081 | that Index and the data written is valid, or the caller must set up exception\r | |
6082 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6083 | and x64.\r |
ac644614 | 6084 | \r |
6085 | If StartBit is greater than 31, then ASSERT().\r | |
6086 | If EndBit is greater than 31, then ASSERT().\r | |
6087 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6088 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6089 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6090 | \r |
6091 | @param Index The 32-bit MSR index to write.\r | |
6092 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6093 | Range 0..31.\r | |
6094 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6095 | Range 0..31.\r | |
6096 | @param AndData The value to AND with the read value from the MSR.\r | |
6097 | @param OrData The value to OR with the result of the AND operation.\r | |
6098 | \r | |
6099 | @return The lower 32-bit of the value written to the MSR.\r | |
6100 | \r | |
6101 | **/\r | |
6102 | UINT32\r | |
6103 | EFIAPI\r | |
6104 | AsmMsrBitFieldAndThenOr32 (\r | |
6105 | IN UINT32 Index,\r | |
6106 | IN UINTN StartBit,\r | |
6107 | IN UINTN EndBit,\r | |
6108 | IN UINT32 AndData,\r | |
6109 | IN UINT32 OrData\r | |
6110 | );\r | |
6111 | \r | |
6112 | \r | |
6113 | /**\r | |
6114 | Returns a 64-bit Machine Specific Register(MSR).\r | |
6115 | \r | |
6116 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
6117 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
6118 | caller must either guarantee that Index is valid, or the caller must set up\r | |
6119 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6120 | on IA-32 and x64.\r |
ac644614 | 6121 | \r |
6122 | @param Index The 32-bit MSR index to read.\r | |
6123 | \r | |
6124 | @return The value of the MSR identified by Index.\r | |
6125 | \r | |
6126 | **/\r | |
6127 | UINT64\r | |
6128 | EFIAPI\r | |
6129 | AsmReadMsr64 (\r | |
6130 | IN UINT32 Index\r | |
6131 | );\r | |
6132 | \r | |
6133 | \r | |
6134 | /**\r | |
6135 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
6136 | value.\r | |
6137 | \r | |
6138 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
6139 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
6140 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
6141 | caller must either guarantee that Index and Value are valid, or the caller\r | |
6142 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 6143 | IA-32 and x64.\r |
ac644614 | 6144 | \r |
6145 | @param Index The 32-bit MSR index to write.\r | |
6146 | @param Value The 64-bit value to write to the MSR.\r | |
6147 | \r | |
6148 | @return Value\r | |
6149 | \r | |
6150 | **/\r | |
6151 | UINT64\r | |
6152 | EFIAPI\r | |
6153 | AsmWriteMsr64 (\r | |
6154 | IN UINT32 Index,\r | |
6155 | IN UINT64 Value\r | |
6156 | );\r | |
6157 | \r | |
6158 | \r | |
6159 | /**\r | |
62991af2 | 6160 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r |
ac644614 | 6161 | back to the 64-bit MSR.\r |
6162 | \r | |
62991af2 | 6163 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6164 | between the read result and the value specified by OrData, and writes the\r |
6165 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6166 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
6167 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
6168 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
030cd1a2 | 6169 | This function is only available on IA-32 and x64.\r |
ac644614 | 6170 | \r |
6171 | @param Index The 32-bit MSR index to write.\r | |
6172 | @param OrData The value to OR with the read value from the MSR.\r | |
6173 | \r | |
6174 | @return The value written back to the MSR.\r | |
6175 | \r | |
6176 | **/\r | |
6177 | UINT64\r | |
6178 | EFIAPI\r | |
6179 | AsmMsrOr64 (\r | |
6180 | IN UINT32 Index,\r | |
6181 | IN UINT64 OrData\r | |
6182 | );\r | |
6183 | \r | |
6184 | \r | |
6185 | /**\r | |
6186 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
6187 | 64-bit MSR.\r | |
6188 | \r | |
6189 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6190 | read result and the value specified by OrData, and writes the result to the\r | |
6191 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
6192 | parameter checking is performed on Index or OrData, and some of these may\r | |
6193 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
6194 | are valid, or the caller must establish proper exception handlers. This\r | |
030cd1a2 | 6195 | function is only available on IA-32 and x64.\r |
ac644614 | 6196 | \r |
6197 | @param Index The 32-bit MSR index to write.\r | |
6198 | @param AndData The value to AND with the read value from the MSR.\r | |
6199 | \r | |
6200 | @return The value written back to the MSR.\r | |
6201 | \r | |
6202 | **/\r | |
6203 | UINT64\r | |
6204 | EFIAPI\r | |
6205 | AsmMsrAnd64 (\r | |
6206 | IN UINT32 Index,\r | |
6207 | IN UINT64 AndData\r | |
6208 | );\r | |
6209 | \r | |
6210 | \r | |
6211 | /**\r | |
9095d37b | 6212 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise\r |
ac644614 | 6213 | OR, and writes the result back to the 64-bit MSR.\r |
6214 | \r | |
6215 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
62991af2 | 6216 | result and the value specified by AndData, performs a bitwise OR\r |
ac644614 | 6217 | between the result of the AND operation and the value specified by OrData,\r |
6218 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
6219 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
6220 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
6221 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
6222 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 6223 | and x64.\r |
ac644614 | 6224 | \r |
6225 | @param Index The 32-bit MSR index to write.\r | |
6226 | @param AndData The value to AND with the read value from the MSR.\r | |
6227 | @param OrData The value to OR with the result of the AND operation.\r | |
6228 | \r | |
6229 | @return The value written back to the MSR.\r | |
6230 | \r | |
6231 | **/\r | |
6232 | UINT64\r | |
6233 | EFIAPI\r | |
6234 | AsmMsrAndThenOr64 (\r | |
6235 | IN UINT32 Index,\r | |
6236 | IN UINT64 AndData,\r | |
6237 | IN UINT64 OrData\r | |
6238 | );\r | |
6239 | \r | |
6240 | \r | |
6241 | /**\r | |
6242 | Reads a bit field of an MSR.\r | |
6243 | \r | |
6244 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
6245 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
6246 | must either guarantee that Index is valid, or the caller must set up\r | |
6247 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6248 | on IA-32 and x64.\r |
ac644614 | 6249 | \r |
6250 | If StartBit is greater than 63, then ASSERT().\r | |
6251 | If EndBit is greater than 63, then ASSERT().\r | |
6252 | If EndBit is less than StartBit, then ASSERT().\r | |
6253 | \r | |
6254 | @param Index The 32-bit MSR index to read.\r | |
6255 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6256 | Range 0..63.\r | |
6257 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6258 | Range 0..63.\r | |
6259 | \r | |
6260 | @return The value read from the MSR.\r | |
6261 | \r | |
6262 | **/\r | |
6263 | UINT64\r | |
6264 | EFIAPI\r | |
6265 | AsmMsrBitFieldRead64 (\r | |
6266 | IN UINT32 Index,\r | |
6267 | IN UINTN StartBit,\r | |
6268 | IN UINTN EndBit\r | |
6269 | );\r | |
6270 | \r | |
6271 | \r | |
6272 | /**\r | |
6273 | Writes a bit field to an MSR.\r | |
6274 | \r | |
6275 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
6276 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
9095d37b LG |
6277 | preserved. The MSR written is returned. The caller must either guarantee\r |
6278 | that Index and the data written is valid, or the caller must set up exception\r | |
62991af2 | 6279 | handlers to catch the exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 6280 | \r |
6281 | If StartBit is greater than 63, then ASSERT().\r | |
6282 | If EndBit is greater than 63, then ASSERT().\r | |
6283 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6284 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6285 | \r |
6286 | @param Index The 32-bit MSR index to write.\r | |
6287 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6288 | Range 0..63.\r | |
6289 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6290 | Range 0..63.\r | |
6291 | @param Value New value of the bit field.\r | |
6292 | \r | |
6293 | @return The value written back to the MSR.\r | |
6294 | \r | |
6295 | **/\r | |
6296 | UINT64\r | |
6297 | EFIAPI\r | |
6298 | AsmMsrBitFieldWrite64 (\r | |
6299 | IN UINT32 Index,\r | |
6300 | IN UINTN StartBit,\r | |
6301 | IN UINTN EndBit,\r | |
6302 | IN UINT64 Value\r | |
6303 | );\r | |
6304 | \r | |
6305 | \r | |
6306 | /**\r | |
62991af2 | 6307 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r |
ac644614 | 6308 | writes the result back to the bit field in the 64-bit MSR.\r |
6309 | \r | |
62991af2 | 6310 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6311 | between the read result and the value specified by OrData, and writes the\r |
6312 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6313 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
6314 | guarantee that Index and the data written is valid, or the caller must set up\r | |
6315 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6316 | on IA-32 and x64.\r |
ac644614 | 6317 | \r |
6318 | If StartBit is greater than 63, then ASSERT().\r | |
6319 | If EndBit is greater than 63, then ASSERT().\r | |
6320 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6321 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6322 | \r |
6323 | @param Index The 32-bit MSR index to write.\r | |
6324 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6325 | Range 0..63.\r | |
6326 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6327 | Range 0..63.\r | |
6328 | @param OrData The value to OR with the read value from the bit field.\r | |
6329 | \r | |
6330 | @return The value written back to the MSR.\r | |
6331 | \r | |
6332 | **/\r | |
6333 | UINT64\r | |
6334 | EFIAPI\r | |
6335 | AsmMsrBitFieldOr64 (\r | |
6336 | IN UINT32 Index,\r | |
6337 | IN UINTN StartBit,\r | |
6338 | IN UINTN EndBit,\r | |
6339 | IN UINT64 OrData\r | |
6340 | );\r | |
6341 | \r | |
6342 | \r | |
6343 | /**\r | |
6344 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
6345 | result back to the bit field in the 64-bit MSR.\r | |
6346 | \r | |
6347 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6348 | read result and the value specified by AndData, and writes the result to the\r | |
6349 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
6350 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
6351 | that Index and the data written is valid, or the caller must set up exception\r | |
6352 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6353 | and x64.\r |
ac644614 | 6354 | \r |
6355 | If StartBit is greater than 63, then ASSERT().\r | |
6356 | If EndBit is greater than 63, then ASSERT().\r | |
6357 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6358 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6359 | \r |
6360 | @param Index The 32-bit MSR index to write.\r | |
6361 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6362 | Range 0..63.\r | |
6363 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6364 | Range 0..63.\r | |
6365 | @param AndData The value to AND with the read value from the bit field.\r | |
6366 | \r | |
6367 | @return The value written back to the MSR.\r | |
6368 | \r | |
6369 | **/\r | |
6370 | UINT64\r | |
6371 | EFIAPI\r | |
6372 | AsmMsrBitFieldAnd64 (\r | |
6373 | IN UINT32 Index,\r | |
6374 | IN UINTN StartBit,\r | |
6375 | IN UINTN EndBit,\r | |
6376 | IN UINT64 AndData\r | |
6377 | );\r | |
6378 | \r | |
6379 | \r | |
6380 | /**\r | |
6381 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6382 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6383 | 64-bit MSR.\r |
6384 | \r | |
6385 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
62991af2 | 6386 | a bitwise OR between the read result and the value specified by\r |
ac644614 | 6387 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6388 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
6389 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
6390 | written is valid, or the caller must set up exception handlers to catch the\r | |
030cd1a2 | 6391 | exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 6392 | \r |
6393 | If StartBit is greater than 63, then ASSERT().\r | |
6394 | If EndBit is greater than 63, then ASSERT().\r | |
6395 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6396 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6397 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6398 | \r |
6399 | @param Index The 32-bit MSR index to write.\r | |
6400 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6401 | Range 0..63.\r | |
6402 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6403 | Range 0..63.\r | |
6404 | @param AndData The value to AND with the read value from the bit field.\r | |
6405 | @param OrData The value to OR with the result of the AND operation.\r | |
6406 | \r | |
6407 | @return The value written back to the MSR.\r | |
6408 | \r | |
6409 | **/\r | |
6410 | UINT64\r | |
6411 | EFIAPI\r | |
6412 | AsmMsrBitFieldAndThenOr64 (\r | |
6413 | IN UINT32 Index,\r | |
6414 | IN UINTN StartBit,\r | |
6415 | IN UINTN EndBit,\r | |
6416 | IN UINT64 AndData,\r | |
6417 | IN UINT64 OrData\r | |
6418 | );\r | |
6419 | \r | |
6420 | \r | |
6421 | /**\r | |
6422 | Reads the current value of the EFLAGS register.\r | |
6423 | \r | |
6424 | Reads and returns the current value of the EFLAGS register. This function is\r | |
030cd1a2 | 6425 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r |
6426 | 64-bit value on x64.\r | |
ac644614 | 6427 | \r |
030cd1a2 | 6428 | @return EFLAGS on IA-32 or RFLAGS on x64.\r |
ac644614 | 6429 | \r |
6430 | **/\r | |
6431 | UINTN\r | |
6432 | EFIAPI\r | |
6433 | AsmReadEflags (\r | |
6434 | VOID\r | |
6435 | );\r | |
6436 | \r | |
6437 | \r | |
6438 | /**\r | |
6439 | Reads the current value of the Control Register 0 (CR0).\r | |
6440 | \r | |
6441 | Reads and returns the current value of CR0. This function is only available\r | |
030cd1a2 | 6442 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6443 | x64.\r | |
ac644614 | 6444 | \r |
6445 | @return The value of the Control Register 0 (CR0).\r | |
6446 | \r | |
6447 | **/\r | |
6448 | UINTN\r | |
6449 | EFIAPI\r | |
6450 | AsmReadCr0 (\r | |
6451 | VOID\r | |
6452 | );\r | |
6453 | \r | |
6454 | \r | |
6455 | /**\r | |
6456 | Reads the current value of the Control Register 2 (CR2).\r | |
6457 | \r | |
6458 | Reads and returns the current value of CR2. This function is only available\r | |
030cd1a2 | 6459 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6460 | x64.\r | |
ac644614 | 6461 | \r |
6462 | @return The value of the Control Register 2 (CR2).\r | |
6463 | \r | |
6464 | **/\r | |
6465 | UINTN\r | |
6466 | EFIAPI\r | |
6467 | AsmReadCr2 (\r | |
6468 | VOID\r | |
6469 | );\r | |
6470 | \r | |
6471 | \r | |
6472 | /**\r | |
6473 | Reads the current value of the Control Register 3 (CR3).\r | |
6474 | \r | |
6475 | Reads and returns the current value of CR3. This function is only available\r | |
030cd1a2 | 6476 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6477 | x64.\r | |
ac644614 | 6478 | \r |
6479 | @return The value of the Control Register 3 (CR3).\r | |
6480 | \r | |
6481 | **/\r | |
6482 | UINTN\r | |
6483 | EFIAPI\r | |
6484 | AsmReadCr3 (\r | |
6485 | VOID\r | |
6486 | );\r | |
6487 | \r | |
6488 | \r | |
6489 | /**\r | |
6490 | Reads the current value of the Control Register 4 (CR4).\r | |
6491 | \r | |
6492 | Reads and returns the current value of CR4. This function is only available\r | |
030cd1a2 | 6493 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6494 | x64.\r | |
ac644614 | 6495 | \r |
6496 | @return The value of the Control Register 4 (CR4).\r | |
6497 | \r | |
6498 | **/\r | |
6499 | UINTN\r | |
6500 | EFIAPI\r | |
6501 | AsmReadCr4 (\r | |
6502 | VOID\r | |
6503 | );\r | |
6504 | \r | |
6505 | \r | |
6506 | /**\r | |
6507 | Writes a value to Control Register 0 (CR0).\r | |
6508 | \r | |
6509 | Writes and returns a new value to CR0. This function is only available on\r | |
030cd1a2 | 6510 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6511 | \r |
6512 | @param Cr0 The value to write to CR0.\r | |
6513 | \r | |
6514 | @return The value written to CR0.\r | |
6515 | \r | |
6516 | **/\r | |
6517 | UINTN\r | |
6518 | EFIAPI\r | |
6519 | AsmWriteCr0 (\r | |
6520 | UINTN Cr0\r | |
6521 | );\r | |
6522 | \r | |
6523 | \r | |
6524 | /**\r | |
6525 | Writes a value to Control Register 2 (CR2).\r | |
6526 | \r | |
6527 | Writes and returns a new value to CR2. This function is only available on\r | |
030cd1a2 | 6528 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6529 | \r |
6530 | @param Cr2 The value to write to CR2.\r | |
6531 | \r | |
6532 | @return The value written to CR2.\r | |
6533 | \r | |
6534 | **/\r | |
6535 | UINTN\r | |
6536 | EFIAPI\r | |
6537 | AsmWriteCr2 (\r | |
6538 | UINTN Cr2\r | |
6539 | );\r | |
6540 | \r | |
6541 | \r | |
6542 | /**\r | |
6543 | Writes a value to Control Register 3 (CR3).\r | |
6544 | \r | |
6545 | Writes and returns a new value to CR3. This function is only available on\r | |
030cd1a2 | 6546 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6547 | \r |
6548 | @param Cr3 The value to write to CR3.\r | |
6549 | \r | |
6550 | @return The value written to CR3.\r | |
6551 | \r | |
6552 | **/\r | |
6553 | UINTN\r | |
6554 | EFIAPI\r | |
6555 | AsmWriteCr3 (\r | |
6556 | UINTN Cr3\r | |
6557 | );\r | |
6558 | \r | |
6559 | \r | |
6560 | /**\r | |
6561 | Writes a value to Control Register 4 (CR4).\r | |
6562 | \r | |
6563 | Writes and returns a new value to CR4. This function is only available on\r | |
030cd1a2 | 6564 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6565 | \r |
6566 | @param Cr4 The value to write to CR4.\r | |
6567 | \r | |
6568 | @return The value written to CR4.\r | |
6569 | \r | |
6570 | **/\r | |
6571 | UINTN\r | |
6572 | EFIAPI\r | |
6573 | AsmWriteCr4 (\r | |
6574 | UINTN Cr4\r | |
6575 | );\r | |
6576 | \r | |
6577 | \r | |
6578 | /**\r | |
6579 | Reads the current value of Debug Register 0 (DR0).\r | |
6580 | \r | |
6581 | Reads and returns the current value of DR0. This function is only available\r | |
030cd1a2 | 6582 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6583 | x64.\r | |
ac644614 | 6584 | \r |
6585 | @return The value of Debug Register 0 (DR0).\r | |
6586 | \r | |
6587 | **/\r | |
6588 | UINTN\r | |
6589 | EFIAPI\r | |
6590 | AsmReadDr0 (\r | |
6591 | VOID\r | |
6592 | );\r | |
6593 | \r | |
6594 | \r | |
6595 | /**\r | |
6596 | Reads the current value of Debug Register 1 (DR1).\r | |
6597 | \r | |
6598 | Reads and returns the current value of DR1. This function is only available\r | |
030cd1a2 | 6599 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6600 | x64.\r | |
ac644614 | 6601 | \r |
6602 | @return The value of Debug Register 1 (DR1).\r | |
6603 | \r | |
6604 | **/\r | |
6605 | UINTN\r | |
6606 | EFIAPI\r | |
6607 | AsmReadDr1 (\r | |
6608 | VOID\r | |
6609 | );\r | |
6610 | \r | |
6611 | \r | |
6612 | /**\r | |
6613 | Reads the current value of Debug Register 2 (DR2).\r | |
6614 | \r | |
6615 | Reads and returns the current value of DR2. This function is only available\r | |
030cd1a2 | 6616 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6617 | x64.\r | |
ac644614 | 6618 | \r |
6619 | @return The value of Debug Register 2 (DR2).\r | |
6620 | \r | |
6621 | **/\r | |
6622 | UINTN\r | |
6623 | EFIAPI\r | |
6624 | AsmReadDr2 (\r | |
6625 | VOID\r | |
6626 | );\r | |
6627 | \r | |
6628 | \r | |
6629 | /**\r | |
6630 | Reads the current value of Debug Register 3 (DR3).\r | |
6631 | \r | |
6632 | Reads and returns the current value of DR3. This function is only available\r | |
030cd1a2 | 6633 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6634 | x64.\r | |
ac644614 | 6635 | \r |
6636 | @return The value of Debug Register 3 (DR3).\r | |
6637 | \r | |
6638 | **/\r | |
6639 | UINTN\r | |
6640 | EFIAPI\r | |
6641 | AsmReadDr3 (\r | |
6642 | VOID\r | |
6643 | );\r | |
6644 | \r | |
6645 | \r | |
6646 | /**\r | |
6647 | Reads the current value of Debug Register 4 (DR4).\r | |
6648 | \r | |
6649 | Reads and returns the current value of DR4. This function is only available\r | |
030cd1a2 | 6650 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6651 | x64.\r | |
ac644614 | 6652 | \r |
6653 | @return The value of Debug Register 4 (DR4).\r | |
6654 | \r | |
6655 | **/\r | |
6656 | UINTN\r | |
6657 | EFIAPI\r | |
6658 | AsmReadDr4 (\r | |
6659 | VOID\r | |
6660 | );\r | |
6661 | \r | |
6662 | \r | |
6663 | /**\r | |
6664 | Reads the current value of Debug Register 5 (DR5).\r | |
6665 | \r | |
6666 | Reads and returns the current value of DR5. This function is only available\r | |
030cd1a2 | 6667 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6668 | x64.\r | |
ac644614 | 6669 | \r |
6670 | @return The value of Debug Register 5 (DR5).\r | |
6671 | \r | |
6672 | **/\r | |
6673 | UINTN\r | |
6674 | EFIAPI\r | |
6675 | AsmReadDr5 (\r | |
6676 | VOID\r | |
6677 | );\r | |
6678 | \r | |
6679 | \r | |
6680 | /**\r | |
6681 | Reads the current value of Debug Register 6 (DR6).\r | |
6682 | \r | |
6683 | Reads and returns the current value of DR6. This function is only available\r | |
030cd1a2 | 6684 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6685 | x64.\r | |
ac644614 | 6686 | \r |
6687 | @return The value of Debug Register 6 (DR6).\r | |
6688 | \r | |
6689 | **/\r | |
6690 | UINTN\r | |
6691 | EFIAPI\r | |
6692 | AsmReadDr6 (\r | |
6693 | VOID\r | |
6694 | );\r | |
6695 | \r | |
6696 | \r | |
6697 | /**\r | |
6698 | Reads the current value of Debug Register 7 (DR7).\r | |
6699 | \r | |
6700 | Reads and returns the current value of DR7. This function is only available\r | |
030cd1a2 | 6701 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
6702 | x64.\r | |
ac644614 | 6703 | \r |
6704 | @return The value of Debug Register 7 (DR7).\r | |
6705 | \r | |
6706 | **/\r | |
6707 | UINTN\r | |
6708 | EFIAPI\r | |
6709 | AsmReadDr7 (\r | |
6710 | VOID\r | |
6711 | );\r | |
6712 | \r | |
6713 | \r | |
6714 | /**\r | |
6715 | Writes a value to Debug Register 0 (DR0).\r | |
6716 | \r | |
6717 | Writes and returns a new value to DR0. This function is only available on\r | |
030cd1a2 | 6718 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6719 | \r |
6720 | @param Dr0 The value to write to Dr0.\r | |
6721 | \r | |
6722 | @return The value written to Debug Register 0 (DR0).\r | |
6723 | \r | |
6724 | **/\r | |
6725 | UINTN\r | |
6726 | EFIAPI\r | |
6727 | AsmWriteDr0 (\r | |
6728 | UINTN Dr0\r | |
6729 | );\r | |
6730 | \r | |
6731 | \r | |
6732 | /**\r | |
6733 | Writes a value to Debug Register 1 (DR1).\r | |
6734 | \r | |
6735 | Writes and returns a new value to DR1. This function is only available on\r | |
030cd1a2 | 6736 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6737 | \r |
6738 | @param Dr1 The value to write to Dr1.\r | |
6739 | \r | |
6740 | @return The value written to Debug Register 1 (DR1).\r | |
6741 | \r | |
6742 | **/\r | |
6743 | UINTN\r | |
6744 | EFIAPI\r | |
6745 | AsmWriteDr1 (\r | |
6746 | UINTN Dr1\r | |
6747 | );\r | |
6748 | \r | |
6749 | \r | |
6750 | /**\r | |
6751 | Writes a value to Debug Register 2 (DR2).\r | |
6752 | \r | |
6753 | Writes and returns a new value to DR2. This function is only available on\r | |
030cd1a2 | 6754 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6755 | \r |
6756 | @param Dr2 The value to write to Dr2.\r | |
6757 | \r | |
6758 | @return The value written to Debug Register 2 (DR2).\r | |
6759 | \r | |
6760 | **/\r | |
6761 | UINTN\r | |
6762 | EFIAPI\r | |
6763 | AsmWriteDr2 (\r | |
6764 | UINTN Dr2\r | |
6765 | );\r | |
6766 | \r | |
6767 | \r | |
6768 | /**\r | |
6769 | Writes a value to Debug Register 3 (DR3).\r | |
6770 | \r | |
6771 | Writes and returns a new value to DR3. This function is only available on\r | |
030cd1a2 | 6772 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6773 | \r |
6774 | @param Dr3 The value to write to Dr3.\r | |
6775 | \r | |
6776 | @return The value written to Debug Register 3 (DR3).\r | |
6777 | \r | |
6778 | **/\r | |
6779 | UINTN\r | |
6780 | EFIAPI\r | |
6781 | AsmWriteDr3 (\r | |
6782 | UINTN Dr3\r | |
6783 | );\r | |
6784 | \r | |
6785 | \r | |
6786 | /**\r | |
6787 | Writes a value to Debug Register 4 (DR4).\r | |
6788 | \r | |
6789 | Writes and returns a new value to DR4. This function is only available on\r | |
030cd1a2 | 6790 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6791 | \r |
6792 | @param Dr4 The value to write to Dr4.\r | |
6793 | \r | |
6794 | @return The value written to Debug Register 4 (DR4).\r | |
6795 | \r | |
6796 | **/\r | |
6797 | UINTN\r | |
6798 | EFIAPI\r | |
6799 | AsmWriteDr4 (\r | |
6800 | UINTN Dr4\r | |
6801 | );\r | |
6802 | \r | |
6803 | \r | |
6804 | /**\r | |
6805 | Writes a value to Debug Register 5 (DR5).\r | |
6806 | \r | |
6807 | Writes and returns a new value to DR5. This function is only available on\r | |
030cd1a2 | 6808 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6809 | \r |
6810 | @param Dr5 The value to write to Dr5.\r | |
6811 | \r | |
6812 | @return The value written to Debug Register 5 (DR5).\r | |
6813 | \r | |
6814 | **/\r | |
6815 | UINTN\r | |
6816 | EFIAPI\r | |
6817 | AsmWriteDr5 (\r | |
6818 | UINTN Dr5\r | |
6819 | );\r | |
6820 | \r | |
6821 | \r | |
6822 | /**\r | |
6823 | Writes a value to Debug Register 6 (DR6).\r | |
6824 | \r | |
6825 | Writes and returns a new value to DR6. This function is only available on\r | |
030cd1a2 | 6826 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6827 | \r |
6828 | @param Dr6 The value to write to Dr6.\r | |
6829 | \r | |
6830 | @return The value written to Debug Register 6 (DR6).\r | |
6831 | \r | |
6832 | **/\r | |
6833 | UINTN\r | |
6834 | EFIAPI\r | |
6835 | AsmWriteDr6 (\r | |
6836 | UINTN Dr6\r | |
6837 | );\r | |
6838 | \r | |
6839 | \r | |
6840 | /**\r | |
6841 | Writes a value to Debug Register 7 (DR7).\r | |
6842 | \r | |
6843 | Writes and returns a new value to DR7. This function is only available on\r | |
030cd1a2 | 6844 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 6845 | \r |
6846 | @param Dr7 The value to write to Dr7.\r | |
6847 | \r | |
6848 | @return The value written to Debug Register 7 (DR7).\r | |
6849 | \r | |
6850 | **/\r | |
6851 | UINTN\r | |
6852 | EFIAPI\r | |
6853 | AsmWriteDr7 (\r | |
6854 | UINTN Dr7\r | |
6855 | );\r | |
6856 | \r | |
6857 | \r | |
6858 | /**\r | |
6859 | Reads the current value of Code Segment Register (CS).\r | |
6860 | \r | |
6861 | Reads and returns the current value of CS. This function is only available on\r | |
030cd1a2 | 6862 | IA-32 and x64.\r |
ac644614 | 6863 | \r |
6864 | @return The current value of CS.\r | |
6865 | \r | |
6866 | **/\r | |
6867 | UINT16\r | |
6868 | EFIAPI\r | |
6869 | AsmReadCs (\r | |
6870 | VOID\r | |
6871 | );\r | |
6872 | \r | |
6873 | \r | |
6874 | /**\r | |
6875 | Reads the current value of Data Segment Register (DS).\r | |
6876 | \r | |
6877 | Reads and returns the current value of DS. This function is only available on\r | |
030cd1a2 | 6878 | IA-32 and x64.\r |
ac644614 | 6879 | \r |
6880 | @return The current value of DS.\r | |
6881 | \r | |
6882 | **/\r | |
6883 | UINT16\r | |
6884 | EFIAPI\r | |
6885 | AsmReadDs (\r | |
6886 | VOID\r | |
6887 | );\r | |
6888 | \r | |
6889 | \r | |
6890 | /**\r | |
6891 | Reads the current value of Extra Segment Register (ES).\r | |
6892 | \r | |
6893 | Reads and returns the current value of ES. This function is only available on\r | |
030cd1a2 | 6894 | IA-32 and x64.\r |
ac644614 | 6895 | \r |
6896 | @return The current value of ES.\r | |
6897 | \r | |
6898 | **/\r | |
6899 | UINT16\r | |
6900 | EFIAPI\r | |
6901 | AsmReadEs (\r | |
6902 | VOID\r | |
6903 | );\r | |
6904 | \r | |
6905 | \r | |
6906 | /**\r | |
6907 | Reads the current value of FS Data Segment Register (FS).\r | |
6908 | \r | |
6909 | Reads and returns the current value of FS. This function is only available on\r | |
030cd1a2 | 6910 | IA-32 and x64.\r |
ac644614 | 6911 | \r |
6912 | @return The current value of FS.\r | |
6913 | \r | |
6914 | **/\r | |
6915 | UINT16\r | |
6916 | EFIAPI\r | |
6917 | AsmReadFs (\r | |
6918 | VOID\r | |
6919 | );\r | |
6920 | \r | |
6921 | \r | |
6922 | /**\r | |
6923 | Reads the current value of GS Data Segment Register (GS).\r | |
6924 | \r | |
6925 | Reads and returns the current value of GS. This function is only available on\r | |
030cd1a2 | 6926 | IA-32 and x64.\r |
ac644614 | 6927 | \r |
6928 | @return The current value of GS.\r | |
6929 | \r | |
6930 | **/\r | |
6931 | UINT16\r | |
6932 | EFIAPI\r | |
6933 | AsmReadGs (\r | |
6934 | VOID\r | |
6935 | );\r | |
6936 | \r | |
6937 | \r | |
6938 | /**\r | |
6939 | Reads the current value of Stack Segment Register (SS).\r | |
6940 | \r | |
6941 | Reads and returns the current value of SS. This function is only available on\r | |
030cd1a2 | 6942 | IA-32 and x64.\r |
ac644614 | 6943 | \r |
6944 | @return The current value of SS.\r | |
6945 | \r | |
6946 | **/\r | |
6947 | UINT16\r | |
6948 | EFIAPI\r | |
6949 | AsmReadSs (\r | |
6950 | VOID\r | |
6951 | );\r | |
6952 | \r | |
6953 | \r | |
6954 | /**\r | |
6955 | Reads the current value of Task Register (TR).\r | |
6956 | \r | |
6957 | Reads and returns the current value of TR. This function is only available on\r | |
030cd1a2 | 6958 | IA-32 and x64.\r |
ac644614 | 6959 | \r |
6960 | @return The current value of TR.\r | |
6961 | \r | |
6962 | **/\r | |
6963 | UINT16\r | |
6964 | EFIAPI\r | |
6965 | AsmReadTr (\r | |
6966 | VOID\r | |
6967 | );\r | |
6968 | \r | |
6969 | \r | |
6970 | /**\r | |
6971 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
6972 | \r | |
6973 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
030cd1a2 | 6974 | function is only available on IA-32 and x64.\r |
ac644614 | 6975 | \r |
6976 | If Gdtr is NULL, then ASSERT().\r | |
6977 | \r | |
af2dc6a7 | 6978 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6979 | \r |
6980 | **/\r | |
6981 | VOID\r | |
6982 | EFIAPI\r | |
6983 | AsmReadGdtr (\r | |
6984 | OUT IA32_DESCRIPTOR *Gdtr\r | |
6985 | );\r | |
6986 | \r | |
6987 | \r | |
6988 | /**\r | |
6989 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
6990 | \r | |
6991 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
030cd1a2 | 6992 | only available on IA-32 and x64.\r |
ac644614 | 6993 | \r |
6994 | If Gdtr is NULL, then ASSERT().\r | |
6995 | \r | |
af2dc6a7 | 6996 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 6997 | \r |
6998 | **/\r | |
6999 | VOID\r | |
7000 | EFIAPI\r | |
7001 | AsmWriteGdtr (\r | |
7002 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
7003 | );\r | |
7004 | \r | |
7005 | \r | |
7006 | /**\r | |
17f695ed | 7007 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 7008 | \r |
7009 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
030cd1a2 | 7010 | function is only available on IA-32 and x64.\r |
ac644614 | 7011 | \r |
7012 | If Idtr is NULL, then ASSERT().\r | |
7013 | \r | |
af2dc6a7 | 7014 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 7015 | \r |
7016 | **/\r | |
7017 | VOID\r | |
7018 | EFIAPI\r | |
7019 | AsmReadIdtr (\r | |
7020 | OUT IA32_DESCRIPTOR *Idtr\r | |
7021 | );\r | |
7022 | \r | |
7023 | \r | |
7024 | /**\r | |
17f695ed | 7025 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 7026 | \r |
7027 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
030cd1a2 | 7028 | only available on IA-32 and x64.\r |
ac644614 | 7029 | \r |
7030 | If Idtr is NULL, then ASSERT().\r | |
7031 | \r | |
af2dc6a7 | 7032 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 7033 | \r |
7034 | **/\r | |
7035 | VOID\r | |
7036 | EFIAPI\r | |
7037 | AsmWriteIdtr (\r | |
7038 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
7039 | );\r | |
7040 | \r | |
7041 | \r | |
7042 | /**\r | |
7043 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
7044 | \r | |
7045 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
030cd1a2 | 7046 | only available on IA-32 and x64.\r |
ac644614 | 7047 | \r |
7048 | @return The current selector of LDT.\r | |
7049 | \r | |
7050 | **/\r | |
7051 | UINT16\r | |
7052 | EFIAPI\r | |
7053 | AsmReadLdtr (\r | |
7054 | VOID\r | |
7055 | );\r | |
7056 | \r | |
7057 | \r | |
7058 | /**\r | |
17f695ed | 7059 | Writes the current Local Descriptor Table Register (LDTR) selector.\r |
ac644614 | 7060 | \r |
7061 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
030cd1a2 | 7062 | only available on IA-32 and x64.\r |
ac644614 | 7063 | \r |
7064 | @param Ldtr 16-bit LDTR selector value.\r | |
7065 | \r | |
7066 | **/\r | |
7067 | VOID\r | |
7068 | EFIAPI\r | |
7069 | AsmWriteLdtr (\r | |
7070 | IN UINT16 Ldtr\r | |
7071 | );\r | |
7072 | \r | |
7073 | \r | |
7074 | /**\r | |
7075 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
7076 | \r | |
7077 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
7078 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
030cd1a2 | 7079 | available on IA-32 and x64.\r |
ac644614 | 7080 | \r |
7081 | If Buffer is NULL, then ASSERT().\r | |
7082 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7083 | \r | |
af2dc6a7 | 7084 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7085 | \r |
7086 | **/\r | |
7087 | VOID\r | |
7088 | EFIAPI\r | |
7089 | AsmFxSave (\r | |
7090 | OUT IA32_FX_BUFFER *Buffer\r | |
7091 | );\r | |
7092 | \r | |
7093 | \r | |
7094 | /**\r | |
7095 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
7096 | \r | |
7097 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
7098 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
030cd1a2 | 7099 | only available on IA-32 and x64.\r |
ac644614 | 7100 | \r |
7101 | If Buffer is NULL, then ASSERT().\r | |
7102 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7103 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
7104 | \r | |
af2dc6a7 | 7105 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7106 | \r |
7107 | **/\r | |
7108 | VOID\r | |
7109 | EFIAPI\r | |
7110 | AsmFxRestore (\r | |
7111 | IN CONST IA32_FX_BUFFER *Buffer\r | |
7112 | );\r | |
7113 | \r | |
7114 | \r | |
7115 | /**\r | |
7116 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
7117 | \r | |
7118 | Reads and returns the current value of MM0. This function is only available\r | |
030cd1a2 | 7119 | on IA-32 and x64.\r |
ac644614 | 7120 | \r |
7121 | @return The current value of MM0.\r | |
7122 | \r | |
7123 | **/\r | |
7124 | UINT64\r | |
7125 | EFIAPI\r | |
7126 | AsmReadMm0 (\r | |
7127 | VOID\r | |
7128 | );\r | |
7129 | \r | |
7130 | \r | |
7131 | /**\r | |
7132 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
7133 | \r | |
7134 | Reads and returns the current value of MM1. This function is only available\r | |
030cd1a2 | 7135 | on IA-32 and x64.\r |
ac644614 | 7136 | \r |
7137 | @return The current value of MM1.\r | |
7138 | \r | |
7139 | **/\r | |
7140 | UINT64\r | |
7141 | EFIAPI\r | |
7142 | AsmReadMm1 (\r | |
7143 | VOID\r | |
7144 | );\r | |
7145 | \r | |
7146 | \r | |
7147 | /**\r | |
7148 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
7149 | \r | |
7150 | Reads and returns the current value of MM2. This function is only available\r | |
030cd1a2 | 7151 | on IA-32 and x64.\r |
ac644614 | 7152 | \r |
7153 | @return The current value of MM2.\r | |
7154 | \r | |
7155 | **/\r | |
7156 | UINT64\r | |
7157 | EFIAPI\r | |
7158 | AsmReadMm2 (\r | |
7159 | VOID\r | |
7160 | );\r | |
7161 | \r | |
7162 | \r | |
7163 | /**\r | |
7164 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
7165 | \r | |
7166 | Reads and returns the current value of MM3. This function is only available\r | |
030cd1a2 | 7167 | on IA-32 and x64.\r |
ac644614 | 7168 | \r |
7169 | @return The current value of MM3.\r | |
7170 | \r | |
7171 | **/\r | |
7172 | UINT64\r | |
7173 | EFIAPI\r | |
7174 | AsmReadMm3 (\r | |
7175 | VOID\r | |
7176 | );\r | |
7177 | \r | |
7178 | \r | |
7179 | /**\r | |
7180 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
7181 | \r | |
7182 | Reads and returns the current value of MM4. This function is only available\r | |
030cd1a2 | 7183 | on IA-32 and x64.\r |
ac644614 | 7184 | \r |
7185 | @return The current value of MM4.\r | |
7186 | \r | |
7187 | **/\r | |
7188 | UINT64\r | |
7189 | EFIAPI\r | |
7190 | AsmReadMm4 (\r | |
7191 | VOID\r | |
7192 | );\r | |
7193 | \r | |
7194 | \r | |
7195 | /**\r | |
7196 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
7197 | \r | |
7198 | Reads and returns the current value of MM5. This function is only available\r | |
030cd1a2 | 7199 | on IA-32 and x64.\r |
ac644614 | 7200 | \r |
7201 | @return The current value of MM5.\r | |
7202 | \r | |
7203 | **/\r | |
7204 | UINT64\r | |
7205 | EFIAPI\r | |
7206 | AsmReadMm5 (\r | |
7207 | VOID\r | |
7208 | );\r | |
7209 | \r | |
7210 | \r | |
7211 | /**\r | |
7212 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
7213 | \r | |
7214 | Reads and returns the current value of MM6. This function is only available\r | |
030cd1a2 | 7215 | on IA-32 and x64.\r |
ac644614 | 7216 | \r |
7217 | @return The current value of MM6.\r | |
7218 | \r | |
7219 | **/\r | |
7220 | UINT64\r | |
7221 | EFIAPI\r | |
7222 | AsmReadMm6 (\r | |
7223 | VOID\r | |
7224 | );\r | |
7225 | \r | |
7226 | \r | |
7227 | /**\r | |
7228 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
7229 | \r | |
7230 | Reads and returns the current value of MM7. This function is only available\r | |
030cd1a2 | 7231 | on IA-32 and x64.\r |
ac644614 | 7232 | \r |
7233 | @return The current value of MM7.\r | |
7234 | \r | |
7235 | **/\r | |
7236 | UINT64\r | |
7237 | EFIAPI\r | |
7238 | AsmReadMm7 (\r | |
7239 | VOID\r | |
7240 | );\r | |
7241 | \r | |
7242 | \r | |
7243 | /**\r | |
7244 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
7245 | \r | |
7246 | Writes the current value of MM0. This function is only available on IA32 and\r | |
030cd1a2 | 7247 | x64.\r |
ac644614 | 7248 | \r |
7249 | @param Value The 64-bit value to write to MM0.\r | |
7250 | \r | |
7251 | **/\r | |
7252 | VOID\r | |
7253 | EFIAPI\r | |
7254 | AsmWriteMm0 (\r | |
7255 | IN UINT64 Value\r | |
7256 | );\r | |
7257 | \r | |
7258 | \r | |
7259 | /**\r | |
7260 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
7261 | \r | |
7262 | Writes the current value of MM1. This function is only available on IA32 and\r | |
030cd1a2 | 7263 | x64.\r |
ac644614 | 7264 | \r |
7265 | @param Value The 64-bit value to write to MM1.\r | |
7266 | \r | |
7267 | **/\r | |
7268 | VOID\r | |
7269 | EFIAPI\r | |
7270 | AsmWriteMm1 (\r | |
7271 | IN UINT64 Value\r | |
7272 | );\r | |
7273 | \r | |
7274 | \r | |
7275 | /**\r | |
7276 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
7277 | \r | |
7278 | Writes the current value of MM2. This function is only available on IA32 and\r | |
030cd1a2 | 7279 | x64.\r |
ac644614 | 7280 | \r |
7281 | @param Value The 64-bit value to write to MM2.\r | |
7282 | \r | |
7283 | **/\r | |
7284 | VOID\r | |
7285 | EFIAPI\r | |
7286 | AsmWriteMm2 (\r | |
7287 | IN UINT64 Value\r | |
7288 | );\r | |
7289 | \r | |
7290 | \r | |
7291 | /**\r | |
7292 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
7293 | \r | |
7294 | Writes the current value of MM3. This function is only available on IA32 and\r | |
030cd1a2 | 7295 | x64.\r |
ac644614 | 7296 | \r |
7297 | @param Value The 64-bit value to write to MM3.\r | |
7298 | \r | |
7299 | **/\r | |
7300 | VOID\r | |
7301 | EFIAPI\r | |
7302 | AsmWriteMm3 (\r | |
7303 | IN UINT64 Value\r | |
7304 | );\r | |
7305 | \r | |
7306 | \r | |
7307 | /**\r | |
7308 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
7309 | \r | |
7310 | Writes the current value of MM4. This function is only available on IA32 and\r | |
030cd1a2 | 7311 | x64.\r |
ac644614 | 7312 | \r |
7313 | @param Value The 64-bit value to write to MM4.\r | |
7314 | \r | |
7315 | **/\r | |
7316 | VOID\r | |
7317 | EFIAPI\r | |
7318 | AsmWriteMm4 (\r | |
7319 | IN UINT64 Value\r | |
7320 | );\r | |
7321 | \r | |
7322 | \r | |
7323 | /**\r | |
7324 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
7325 | \r | |
7326 | Writes the current value of MM5. This function is only available on IA32 and\r | |
030cd1a2 | 7327 | x64.\r |
ac644614 | 7328 | \r |
7329 | @param Value The 64-bit value to write to MM5.\r | |
7330 | \r | |
7331 | **/\r | |
7332 | VOID\r | |
7333 | EFIAPI\r | |
7334 | AsmWriteMm5 (\r | |
7335 | IN UINT64 Value\r | |
7336 | );\r | |
7337 | \r | |
7338 | \r | |
7339 | /**\r | |
7340 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
7341 | \r | |
7342 | Writes the current value of MM6. This function is only available on IA32 and\r | |
030cd1a2 | 7343 | x64.\r |
ac644614 | 7344 | \r |
7345 | @param Value The 64-bit value to write to MM6.\r | |
7346 | \r | |
7347 | **/\r | |
7348 | VOID\r | |
7349 | EFIAPI\r | |
7350 | AsmWriteMm6 (\r | |
7351 | IN UINT64 Value\r | |
7352 | );\r | |
7353 | \r | |
7354 | \r | |
7355 | /**\r | |
7356 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
7357 | \r | |
7358 | Writes the current value of MM7. This function is only available on IA32 and\r | |
030cd1a2 | 7359 | x64.\r |
ac644614 | 7360 | \r |
7361 | @param Value The 64-bit value to write to MM7.\r | |
7362 | \r | |
7363 | **/\r | |
7364 | VOID\r | |
7365 | EFIAPI\r | |
7366 | AsmWriteMm7 (\r | |
7367 | IN UINT64 Value\r | |
7368 | );\r | |
7369 | \r | |
7370 | \r | |
7371 | /**\r | |
7372 | Reads the current value of Time Stamp Counter (TSC).\r | |
7373 | \r | |
7374 | Reads and returns the current value of TSC. This function is only available\r | |
030cd1a2 | 7375 | on IA-32 and x64.\r |
ac644614 | 7376 | \r |
7377 | @return The current value of TSC\r | |
7378 | \r | |
7379 | **/\r | |
7380 | UINT64\r | |
7381 | EFIAPI\r | |
7382 | AsmReadTsc (\r | |
7383 | VOID\r | |
7384 | );\r | |
7385 | \r | |
7386 | \r | |
7387 | /**\r | |
7388 | Reads the current value of a Performance Counter (PMC).\r | |
7389 | \r | |
7390 | Reads and returns the current value of performance counter specified by\r | |
030cd1a2 | 7391 | Index. This function is only available on IA-32 and x64.\r |
ac644614 | 7392 | \r |
7393 | @param Index The 32-bit Performance Counter index to read.\r | |
7394 | \r | |
7395 | @return The value of the PMC specified by Index.\r | |
7396 | \r | |
7397 | **/\r | |
7398 | UINT64\r | |
7399 | EFIAPI\r | |
7400 | AsmReadPmc (\r | |
7401 | IN UINT32 Index\r | |
7402 | );\r | |
7403 | \r | |
7404 | \r | |
7405 | /**\r | |
7406 | Sets up a monitor buffer that is used by AsmMwait().\r | |
7407 | \r | |
7408 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
030cd1a2 | 7409 | and Edx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7410 | \r |
7411 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7412 | instruction.\r | |
7413 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7414 | instruction.\r | |
7415 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
7416 | instruction.\r | |
7417 | \r | |
7418 | @return Eax\r | |
7419 | \r | |
7420 | **/\r | |
7421 | UINTN\r | |
7422 | EFIAPI\r | |
7423 | AsmMonitor (\r | |
7424 | IN UINTN Eax,\r | |
7425 | IN UINTN Ecx,\r | |
7426 | IN UINTN Edx\r | |
7427 | );\r | |
7428 | \r | |
7429 | \r | |
7430 | /**\r | |
7431 | Executes an MWAIT instruction.\r | |
7432 | \r | |
7433 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
030cd1a2 | 7434 | Ecx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 7435 | \r |
7436 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
7437 | instruction.\r | |
7438 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
7439 | instruction.\r | |
7440 | \r | |
7441 | @return Eax\r | |
7442 | \r | |
7443 | **/\r | |
7444 | UINTN\r | |
7445 | EFIAPI\r | |
7446 | AsmMwait (\r | |
7447 | IN UINTN Eax,\r | |
7448 | IN UINTN Ecx\r | |
7449 | );\r | |
7450 | \r | |
7451 | \r | |
7452 | /**\r | |
7453 | Executes a WBINVD instruction.\r | |
7454 | \r | |
7455 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7456 | x64.\r |
ac644614 | 7457 | \r |
7458 | **/\r | |
7459 | VOID\r | |
7460 | EFIAPI\r | |
7461 | AsmWbinvd (\r | |
7462 | VOID\r | |
7463 | );\r | |
7464 | \r | |
7465 | \r | |
7466 | /**\r | |
7467 | Executes a INVD instruction.\r | |
7468 | \r | |
7469 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 7470 | x64.\r |
ac644614 | 7471 | \r |
7472 | **/\r | |
7473 | VOID\r | |
7474 | EFIAPI\r | |
7475 | AsmInvd (\r | |
7476 | VOID\r | |
7477 | );\r | |
7478 | \r | |
7479 | \r | |
7480 | /**\r | |
7481 | Flushes a cache line from all the instruction and data caches within the\r | |
7482 | coherency domain of the CPU.\r | |
7483 | \r | |
7484 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
030cd1a2 | 7485 | This function is only available on IA-32 and x64.\r |
ac644614 | 7486 | \r |
7487 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
7488 | in a physical addressing mode, then LinearAddress is a\r | |
7489 | physical address. If the CPU is in a virtual\r | |
7490 | addressing mode, then LinearAddress is a virtual\r | |
7491 | address.\r | |
7492 | \r | |
af2dc6a7 | 7493 | @return LinearAddress.\r |
ac644614 | 7494 | **/\r |
7495 | VOID *\r | |
7496 | EFIAPI\r | |
7497 | AsmFlushCacheLine (\r | |
7498 | IN VOID *LinearAddress\r | |
7499 | );\r | |
7500 | \r | |
7501 | \r | |
7502 | /**\r | |
7503 | Enables the 32-bit paging mode on the CPU.\r | |
7504 | \r | |
7505 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7506 | must be properly initialized prior to calling this service. This function\r | |
7507 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
7508 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
7509 | transferred to the function specified by EntryPoint using the new stack\r | |
7510 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
7511 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
7512 | EntryPoint must never return.\r | |
7513 | \r | |
7514 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
7515 | If EntryPoint is NULL, then ASSERT().\r | |
7516 | If NewStack is NULL, then ASSERT().\r | |
7517 | \r | |
7518 | There are a number of constraints that must be followed before calling this\r | |
7519 | function:\r | |
7520 | 1) Interrupts must be disabled.\r | |
7521 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
7522 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
7523 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
7524 | descriptors.\r | |
7525 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
7526 | is complete, and those page tables must guarantee that the pages for this\r | |
7527 | function and the stack are identity mapped.\r | |
7528 | \r | |
7529 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7530 | paging is enabled.\r | |
7531 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7532 | function as the first parameter after paging is enabled.\r | |
7533 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7534 | function as the second parameter after paging is enabled.\r | |
7535 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7536 | function after paging is enabled.\r | |
7537 | \r | |
7538 | **/\r | |
7539 | VOID\r | |
7540 | EFIAPI\r | |
7541 | AsmEnablePaging32 (\r | |
7542 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7543 | IN VOID *Context1, OPTIONAL\r | |
7544 | IN VOID *Context2, OPTIONAL\r | |
7545 | IN VOID *NewStack\r | |
7546 | );\r | |
7547 | \r | |
7548 | \r | |
7549 | /**\r | |
7550 | Disables the 32-bit paging mode on the CPU.\r | |
7551 | \r | |
7552 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
7553 | mode. This function assumes the current execution mode is 32-paged protected\r | |
7554 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
7555 | is disabled, control is transferred to the function specified by EntryPoint\r | |
7556 | using the new stack specified by NewStack and passing in the parameters\r | |
7557 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7558 | may be NULL. The function EntryPoint must never return.\r | |
7559 | \r | |
7560 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
7561 | If EntryPoint is NULL, then ASSERT().\r | |
7562 | If NewStack is NULL, then ASSERT().\r | |
7563 | \r | |
7564 | There are a number of constraints that must be followed before calling this\r | |
7565 | function:\r | |
7566 | 1) Interrupts must be disabled.\r | |
7567 | 2) The caller must be in 32-bit paged mode.\r | |
7568 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
7569 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
7570 | this function and the stack are identity mapped.\r | |
7571 | \r | |
7572 | @param EntryPoint A pointer to function to call with the new stack after\r | |
7573 | paging is disabled.\r | |
7574 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
7575 | function as the first parameter after paging is disabled.\r | |
7576 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
7577 | function as the second parameter after paging is\r | |
7578 | disabled.\r | |
7579 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
7580 | function after paging is disabled.\r | |
7581 | \r | |
7582 | **/\r | |
7583 | VOID\r | |
7584 | EFIAPI\r | |
7585 | AsmDisablePaging32 (\r | |
7586 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
7587 | IN VOID *Context1, OPTIONAL\r | |
7588 | IN VOID *Context2, OPTIONAL\r | |
7589 | IN VOID *NewStack\r | |
7590 | );\r | |
7591 | \r | |
7592 | \r | |
7593 | /**\r | |
7594 | Enables the 64-bit paging mode on the CPU.\r | |
7595 | \r | |
7596 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
7597 | must be properly initialized prior to calling this service. This function\r | |
7598 | assumes the current execution mode is 32-bit protected mode with flat\r | |
7599 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
7600 | paging mode is enabled, control is transferred to the function specified by\r | |
7601 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
7602 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
7603 | optional and may be 0. The function EntryPoint must never return.\r | |
7604 | \r | |
7605 | If the current execution mode is not 32-bit protected mode with flat\r | |
7606 | descriptors, then ASSERT().\r | |
7607 | If EntryPoint is 0, then ASSERT().\r | |
7608 | If NewStack is 0, then ASSERT().\r | |
7609 | \r | |
17f695ed | 7610 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7611 | is called. The descriptor in the GDT that this selector\r |
7612 | references must be setup for long mode.\r | |
7613 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7614 | the new stack after paging is enabled.\r | |
7615 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7616 | the EntryPoint function as the first parameter after\r | |
7617 | paging is enabled.\r | |
7618 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7619 | the EntryPoint function as the second parameter after\r | |
7620 | paging is enabled.\r | |
7621 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7622 | the EntryPoint function after paging is enabled.\r | |
7623 | \r | |
7624 | **/\r | |
7625 | VOID\r | |
7626 | EFIAPI\r | |
7627 | AsmEnablePaging64 (\r | |
17f695ed | 7628 | IN UINT16 Cs,\r |
ac644614 | 7629 | IN UINT64 EntryPoint,\r |
7630 | IN UINT64 Context1, OPTIONAL\r | |
7631 | IN UINT64 Context2, OPTIONAL\r | |
7632 | IN UINT64 NewStack\r | |
7633 | );\r | |
7634 | \r | |
7635 | \r | |
7636 | /**\r | |
7637 | Disables the 64-bit paging mode on the CPU.\r | |
7638 | \r | |
7639 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
7640 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
030cd1a2 | 7641 | This function is only available on x64. After the 64-bit paging mode is\r |
ac644614 | 7642 | disabled, control is transferred to the function specified by EntryPoint\r |
7643 | using the new stack specified by NewStack and passing in the parameters\r | |
7644 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
7645 | may be 0. The function EntryPoint must never return.\r | |
7646 | \r | |
7647 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
7648 | If EntryPoint is 0, then ASSERT().\r | |
7649 | If NewStack is 0, then ASSERT().\r | |
7650 | \r | |
17f695ed | 7651 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 7652 | is called. The descriptor in the GDT that this selector\r |
7653 | references must be setup for 32-bit protected mode.\r | |
7654 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
7655 | the new stack after paging is disabled.\r | |
7656 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
7657 | the EntryPoint function as the first parameter after\r | |
7658 | paging is disabled.\r | |
7659 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
7660 | the EntryPoint function as the second parameter after\r | |
7661 | paging is disabled.\r | |
7662 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
7663 | the EntryPoint function after paging is disabled.\r | |
7664 | \r | |
7665 | **/\r | |
7666 | VOID\r | |
7667 | EFIAPI\r | |
7668 | AsmDisablePaging64 (\r | |
17f695ed | 7669 | IN UINT16 Cs,\r |
ac644614 | 7670 | IN UINT32 EntryPoint,\r |
7671 | IN UINT32 Context1, OPTIONAL\r | |
7672 | IN UINT32 Context2, OPTIONAL\r | |
7673 | IN UINT32 NewStack\r | |
7674 | );\r | |
7675 | \r | |
7676 | \r | |
7677 | //\r | |
7678 | // 16-bit thunking services\r | |
7679 | //\r | |
7680 | \r | |
7681 | /**\r | |
7682 | Retrieves the properties for 16-bit thunk functions.\r | |
7683 | \r | |
7684 | Computes the size of the buffer and stack below 1MB required to use the\r | |
7685 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
7686 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
7687 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
7688 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
7689 | of bytes that need to be passed to the 16-bit real mode code.\r | |
9095d37b | 7690 | \r |
ac644614 | 7691 | If RealModeBufferSize is NULL, then ASSERT().\r |
7692 | If ExtraStackSize is NULL, then ASSERT().\r | |
7693 | \r | |
7694 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
7695 | required to use the 16-bit thunk functions.\r | |
7696 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
7697 | that the 16-bit thunk functions require for\r | |
7698 | temporary storage in the transition to and from\r | |
7699 | 16-bit real mode.\r | |
7700 | \r | |
7701 | **/\r | |
7702 | VOID\r | |
7703 | EFIAPI\r | |
7704 | AsmGetThunk16Properties (\r | |
7705 | OUT UINT32 *RealModeBufferSize,\r | |
7706 | OUT UINT32 *ExtraStackSize\r | |
7707 | );\r | |
7708 | \r | |
7709 | \r | |
7710 | /**\r | |
7711 | Prepares all structures a code required to use AsmThunk16().\r | |
7712 | \r | |
7713 | Prepares all structures and code required to use AsmThunk16().\r | |
9095d37b | 7714 | \r |
8243b089 | 7715 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7716 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
ac644614 | 7717 | \r |
7718 | If ThunkContext is NULL, then ASSERT().\r | |
7719 | \r | |
7720 | @param ThunkContext A pointer to the context structure that describes the\r | |
7721 | 16-bit real mode code to call.\r | |
7722 | \r | |
7723 | **/\r | |
7724 | VOID\r | |
7725 | EFIAPI\r | |
7726 | AsmPrepareThunk16 (\r | |
1445300f | 7727 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 7728 | );\r |
7729 | \r | |
7730 | \r | |
7731 | /**\r | |
7732 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
7733 | \r | |
7734 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
17f695ed | 7735 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r |
7736 | This function must be called with interrupts disabled.\r | |
7737 | \r | |
9095d37b LG |
7738 | The register state from the RealModeState field of ThunkContext is restored just prior\r |
7739 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState,\r | |
17f695ed | 7740 | which is used to set the interrupt state when a 16-bit real mode entry point is called.\r |
7741 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r | |
9095d37b LG |
7742 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to\r |
7743 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function.\r | |
17f695ed | 7744 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r |
9095d37b LG |
7745 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment\r |
7746 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry\r | |
7747 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately\r | |
17f695ed | 7748 | after the RETF instruction is executed.\r |
9095d37b LG |
7749 | \r |
7750 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7751 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure\r | |
7752 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode.\r | |
7753 | \r | |
7754 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts,\r | |
7755 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode.\r | |
17f695ed | 7756 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r |
9095d37b LG |
7757 | \r |
7758 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code\r | |
17f695ed | 7759 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r |
9095d37b LG |
7760 | \r |
7761 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r | |
7762 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to\r | |
17f695ed | 7763 | disable the A20 mask.\r |
9095d37b LG |
7764 | \r |
7765 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in\r | |
7766 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails,\r | |
17f695ed | 7767 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b LG |
7768 | \r |
7769 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in\r | |
17f695ed | 7770 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r |
9095d37b | 7771 | \r |
ac644614 | 7772 | If ThunkContext is NULL, then ASSERT().\r |
7773 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
9095d37b | 7774 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in\r |
17f695ed | 7775 | ThunkAttributes, then ASSERT().\r |
ac644614 | 7776 | \r |
8243b089 | 7777 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
af2dc6a7 | 7778 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r |
52fa075c | 7779 | \r |
ac644614 | 7780 | @param ThunkContext A pointer to the context structure that describes the\r |
7781 | 16-bit real mode code to call.\r | |
7782 | \r | |
7783 | **/\r | |
7784 | VOID\r | |
7785 | EFIAPI\r | |
7786 | AsmThunk16 (\r | |
7787 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7788 | );\r | |
7789 | \r | |
7790 | \r | |
7791 | /**\r | |
7792 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7793 | control to a 16-bit real mode entry point, and returns the results.\r | |
7794 | \r | |
7795 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
7796 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
7797 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
7798 | service should be used. If the caller intends to make more than one 16-bit\r | |
7799 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
7800 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
7801 | \r | |
8243b089 | 7802 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
7803 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
52fa075c | 7804 | \r |
17f695ed | 7805 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r |
ac644614 | 7806 | \r |
7807 | @param ThunkContext A pointer to the context structure that describes the\r | |
7808 | 16-bit real mode code to call.\r | |
7809 | \r | |
7810 | **/\r | |
7811 | VOID\r | |
7812 | EFIAPI\r | |
7813 | AsmPrepareAndThunk16 (\r | |
7814 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
7815 | );\r | |
7816 | \r | |
3cfc7813 QL |
7817 | /**\r |
7818 | Generates a 16-bit random number through RDRAND instruction.\r | |
7819 | \r | |
7820 | if Rand is NULL, then ASSERT().\r | |
7821 | \r | |
7822 | @param[out] Rand Buffer pointer to store the random result.\r | |
7823 | \r | |
7824 | @retval TRUE RDRAND call was successful.\r | |
7825 | @retval FALSE Failed attempts to call RDRAND.\r | |
7826 | \r | |
7827 | **/\r | |
7828 | BOOLEAN\r | |
7829 | EFIAPI\r | |
7830 | AsmRdRand16 (\r | |
7831 | OUT UINT16 *Rand\r | |
7832 | );\r | |
7833 | \r | |
7834 | /**\r | |
7835 | Generates a 32-bit random number through RDRAND instruction.\r | |
7836 | \r | |
7837 | if Rand is NULL, then ASSERT().\r | |
7838 | \r | |
7839 | @param[out] Rand Buffer pointer to store the random result.\r | |
7840 | \r | |
7841 | @retval TRUE RDRAND call was successful.\r | |
7842 | @retval FALSE Failed attempts to call RDRAND.\r | |
7843 | \r | |
7844 | **/\r | |
7845 | BOOLEAN\r | |
7846 | EFIAPI\r | |
7847 | AsmRdRand32 (\r | |
7848 | OUT UINT32 *Rand\r | |
7849 | );\r | |
7850 | \r | |
7851 | /**\r | |
7852 | Generates a 64-bit random number through RDRAND instruction.\r | |
7853 | \r | |
7854 | if Rand is NULL, then ASSERT().\r | |
7855 | \r | |
7856 | @param[out] Rand Buffer pointer to store the random result.\r | |
7857 | \r | |
7858 | @retval TRUE RDRAND call was successful.\r | |
7859 | @retval FALSE Failed attempts to call RDRAND.\r | |
7860 | \r | |
7861 | **/\r | |
7862 | BOOLEAN\r | |
7863 | EFIAPI\r | |
7864 | AsmRdRand64 (\r | |
7865 | OUT UINT64 *Rand\r | |
7866 | );\r | |
7867 | \r | |
364a5474 | 7868 | /**\r |
47595ac0 | 7869 | Load given selector into TR register.\r |
364a5474 JW |
7870 | \r |
7871 | @param[in] Selector Task segment selector\r | |
7872 | **/\r | |
7873 | VOID\r | |
7874 | EFIAPI\r | |
7875 | AsmWriteTr (\r | |
7876 | IN UINT16 Selector\r | |
7877 | );\r | |
7878 | \r | |
2ecd8299 HW |
7879 | /**\r |
7880 | Performs a serializing operation on all load-from-memory instructions that\r | |
7881 | were issued prior the AsmLfence function.\r | |
7882 | \r | |
7883 | Executes a LFENCE instruction. This function is only available on IA-32 and x64.\r | |
7884 | \r | |
7885 | **/\r | |
7886 | VOID\r | |
7887 | EFIAPI\r | |
7888 | AsmLfence (\r | |
7889 | VOID\r | |
7890 | );\r | |
7891 | \r | |
8596c140 LE |
7892 | /**\r |
7893 | Patch the immediate operand of an IA32 or X64 instruction such that the byte,\r | |
7894 | word, dword or qword operand is encoded at the end of the instruction's\r | |
7895 | binary representation.\r | |
7896 | \r | |
7897 | This function should be used to update object code that was compiled with\r | |
7898 | NASM from assembly source code. Example:\r | |
7899 | \r | |
7900 | NASM source code:\r | |
7901 | \r | |
7902 | mov eax, strict dword 0 ; the imm32 zero operand will be patched\r | |
7903 | ASM_PFX(gPatchCr3):\r | |
7904 | mov cr3, eax\r | |
7905 | \r | |
7906 | C source code:\r | |
7907 | \r | |
7908 | X86_ASSEMBLY_PATCH_LABEL gPatchCr3;\r | |
7909 | PatchInstructionX86 (gPatchCr3, AsmReadCr3 (), 4);\r | |
7910 | \r | |
7911 | @param[out] InstructionEnd Pointer right past the instruction to patch. The\r | |
7912 | immediate operand to patch is expected to\r | |
7913 | comprise the trailing bytes of the instruction.\r | |
7914 | If InstructionEnd is closer to address 0 than\r | |
7915 | ValueSize permits, then ASSERT().\r | |
7916 | \r | |
7917 | @param[in] PatchValue The constant to write to the immediate operand.\r | |
7918 | The caller is responsible for ensuring that\r | |
7919 | PatchValue can be represented in the byte, word,\r | |
7920 | dword or qword operand (as indicated through\r | |
7921 | ValueSize); otherwise ASSERT().\r | |
7922 | \r | |
7923 | @param[in] ValueSize The size of the operand in bytes; must be 1, 2,\r | |
7924 | 4, or 8. ASSERT() otherwise.\r | |
7925 | **/\r | |
7926 | VOID\r | |
7927 | EFIAPI\r | |
7928 | PatchInstructionX86 (\r | |
7929 | OUT X86_ASSEMBLY_PATCH_LABEL *InstructionEnd,\r | |
7930 | IN UINT64 PatchValue,\r | |
7931 | IN UINTN ValueSize\r | |
7932 | );\r | |
7933 | \r | |
de4f7f52 LE |
7934 | #endif // defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
7935 | #endif // !defined (__BASE_LIB__)\r |