]>
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 |
b590e43a | 5 | Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r |
9df063a0 HT |
6 | Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r |
7 | This program and the accompanying materials\r | |
50a64e5b | 8 | are licensed and made available under the terms and conditions of the BSD License\r |
9 | which accompanies this distribution. The full text of the license may be found at\r | |
af2dc6a7 | 10 | http://opensource.org/licenses/bsd-license.php.\r |
ac644614 | 11 | \r |
50a64e5b | 12 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r |
13 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
ac644614 | 14 | \r |
15 | **/\r | |
16 | \r | |
17 | #ifndef __BASE_LIB__\r | |
18 | #define __BASE_LIB__\r | |
19 | \r | |
1106ffe1 | 20 | //\r |
1a2f870c | 21 | // Definitions for architecture-specific types\r |
1106ffe1 | 22 | //\r |
ac644614 | 23 | #if defined (MDE_CPU_IA32)\r |
fc30687f | 24 | ///\r |
af2dc6a7 | 25 | /// The IA-32 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 26 | ///\r |
ac644614 | 27 | typedef struct {\r |
28 | UINT32 Ebx;\r | |
29 | UINT32 Esi;\r | |
30 | UINT32 Edi;\r | |
31 | UINT32 Ebp;\r | |
32 | UINT32 Esp;\r | |
33 | UINT32 Eip;\r | |
34 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
35 | \r | |
36 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
37 | \r | |
aa4df547 | 38 | #endif // defined (MDE_CPU_IA32)\r |
39 | \r | |
40 | #if defined (MDE_CPU_IPF)\r | |
ac644614 | 41 | \r |
fc30687f | 42 | ///\r |
af2dc6a7 | 43 | /// The Itanium architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 44 | ///\r |
ac644614 | 45 | typedef struct {\r |
46 | UINT64 F2[2];\r | |
47 | UINT64 F3[2];\r | |
48 | UINT64 F4[2];\r | |
49 | UINT64 F5[2];\r | |
50 | UINT64 F16[2];\r | |
51 | UINT64 F17[2];\r | |
52 | UINT64 F18[2];\r | |
53 | UINT64 F19[2];\r | |
54 | UINT64 F20[2];\r | |
55 | UINT64 F21[2];\r | |
56 | UINT64 F22[2];\r | |
57 | UINT64 F23[2];\r | |
58 | UINT64 F24[2];\r | |
59 | UINT64 F25[2];\r | |
60 | UINT64 F26[2];\r | |
61 | UINT64 F27[2];\r | |
62 | UINT64 F28[2];\r | |
63 | UINT64 F29[2];\r | |
64 | UINT64 F30[2];\r | |
65 | UINT64 F31[2];\r | |
66 | UINT64 R4;\r | |
67 | UINT64 R5;\r | |
68 | UINT64 R6;\r | |
69 | UINT64 R7;\r | |
70 | UINT64 SP;\r | |
71 | UINT64 BR0;\r | |
72 | UINT64 BR1;\r | |
73 | UINT64 BR2;\r | |
74 | UINT64 BR3;\r | |
75 | UINT64 BR4;\r | |
76 | UINT64 BR5;\r | |
77 | UINT64 InitialUNAT;\r | |
78 | UINT64 AfterSpillUNAT;\r | |
79 | UINT64 PFS;\r | |
80 | UINT64 BSP;\r | |
81 | UINT64 Predicates;\r | |
82 | UINT64 LoopCount;\r | |
83 | UINT64 FPSR;\r | |
84 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
85 | \r | |
86 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 0x10\r | |
87 | \r | |
aa4df547 | 88 | #endif // defined (MDE_CPU_IPF)\r |
89 | \r | |
90 | #if defined (MDE_CPU_X64)\r | |
fc30687f | 91 | ///\r |
af2dc6a7 | 92 | /// The x64 architecture context buffer used by SetJump() and LongJump().\r |
fc30687f | 93 | ///\r |
ac644614 | 94 | typedef struct {\r |
95 | UINT64 Rbx;\r | |
96 | UINT64 Rsp;\r | |
97 | UINT64 Rbp;\r | |
98 | UINT64 Rdi;\r | |
99 | UINT64 Rsi;\r | |
100 | UINT64 R12;\r | |
101 | UINT64 R13;\r | |
102 | UINT64 R14;\r | |
103 | UINT64 R15;\r | |
104 | UINT64 Rip;\r | |
9b9641c6 | 105 | UINT64 MxCsr;\r |
af2dc6a7 | 106 | UINT8 XmmBuffer[160]; ///< XMM6-XMM15.\r |
ac644614 | 107 | } BASE_LIBRARY_JUMP_BUFFER;\r |
108 | \r | |
109 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
110 | \r | |
aa4df547 | 111 | #endif // defined (MDE_CPU_X64)\r |
112 | \r | |
113 | #if defined (MDE_CPU_EBC)\r | |
fc30687f | 114 | ///\r |
af2dc6a7 | 115 | /// The EBC context buffer used by SetJump() and LongJump().\r |
fc30687f | 116 | ///\r |
ac644614 | 117 | typedef struct {\r |
118 | UINT64 R0;\r | |
119 | UINT64 R1;\r | |
120 | UINT64 R2;\r | |
121 | UINT64 R3;\r | |
122 | UINT64 IP;\r | |
123 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
124 | \r | |
125 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
126 | \r | |
aa4df547 | 127 | #endif // defined (MDE_CPU_EBC)\r |
ac644614 | 128 | \r |
ebd04fc2 | 129 | #if defined (MDE_CPU_ARM)\r |
130 | \r | |
131 | typedef struct {\r | |
af2dc6a7 | 132 | UINT32 R3; ///< A copy of R13.\r |
01a54966 | 133 | UINT32 R4;\r |
134 | UINT32 R5;\r | |
135 | UINT32 R6;\r | |
136 | UINT32 R7;\r | |
137 | UINT32 R8;\r | |
138 | UINT32 R9;\r | |
139 | UINT32 R10;\r | |
140 | UINT32 R11;\r | |
141 | UINT32 R12;\r | |
142 | UINT32 R14;\r | |
ebd04fc2 | 143 | } BASE_LIBRARY_JUMP_BUFFER;\r |
144 | \r | |
145 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 4\r | |
146 | \r | |
147 | #endif // defined (MDE_CPU_ARM)\r | |
148 | \r | |
807e2604 HL |
149 | #if defined (MDE_CPU_AARCH64)\r |
150 | typedef struct {\r | |
151 | // GP regs\r | |
152 | UINT64 X19;\r | |
153 | UINT64 X20;\r | |
154 | UINT64 X21;\r | |
155 | UINT64 X22;\r | |
156 | UINT64 X23;\r | |
157 | UINT64 X24;\r | |
158 | UINT64 X25;\r | |
159 | UINT64 X26;\r | |
160 | UINT64 X27;\r | |
161 | UINT64 X28;\r | |
162 | UINT64 FP;\r | |
163 | UINT64 LR;\r | |
164 | UINT64 IP0;\r | |
165 | \r | |
166 | // FP regs\r | |
167 | UINT64 D8;\r | |
168 | UINT64 D9;\r | |
169 | UINT64 D10;\r | |
170 | UINT64 D11;\r | |
171 | UINT64 D12;\r | |
172 | UINT64 D13;\r | |
173 | UINT64 D14;\r | |
174 | UINT64 D15;\r | |
175 | } BASE_LIBRARY_JUMP_BUFFER;\r | |
176 | \r | |
177 | #define BASE_LIBRARY_JUMP_BUFFER_ALIGNMENT 8\r | |
178 | \r | |
179 | #endif // defined (MDE_CPU_AARCH64)\r | |
180 | \r | |
181 | \r | |
ac644614 | 182 | //\r |
183 | // String Services\r | |
184 | //\r | |
185 | \r | |
c058d59f JY |
186 | \r |
187 | /**\r | |
188 | Returns the length of a Null-terminated Unicode string.\r | |
189 | \r | |
328f84b1 JY |
190 | This function is similar as strlen_s defined in C11.\r |
191 | \r | |
c058d59f JY |
192 | If String is not aligned on a 16-bit boundary, then ASSERT().\r |
193 | \r | |
194 | @param String A pointer to a Null-terminated Unicode string.\r | |
195 | @param MaxSize The maximum number of Destination Unicode\r | |
196 | char, including terminating null char.\r | |
197 | \r | |
198 | @retval 0 If String is NULL.\r | |
199 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
200 | @return The number of characters that percede the terminating null character.\r | |
201 | \r | |
202 | **/\r | |
203 | UINTN\r | |
204 | EFIAPI\r | |
205 | StrnLenS (\r | |
206 | IN CONST CHAR16 *String,\r | |
207 | IN UINTN MaxSize\r | |
208 | );\r | |
209 | \r | |
b590e43a HW |
210 | /**\r |
211 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
212 | Null terminator.\r | |
213 | \r | |
214 | This function returns the size of the Null-terminated Unicode string\r | |
215 | specified by String in bytes, including the Null terminator.\r | |
216 | \r | |
217 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
218 | \r | |
219 | @param String A pointer to a Null-terminated Unicode string.\r | |
220 | @param MaxSize The maximum number of Destination Unicode\r | |
221 | char, including the Null terminator.\r | |
222 | \r | |
223 | @retval 0 If String is NULL.\r | |
224 | @retval (sizeof (CHAR16) * (MaxSize + 1))\r | |
225 | If there is no Null terminator in the first MaxSize characters of\r | |
226 | String.\r | |
227 | @return The size of the Null-terminated Unicode string in bytes, including\r | |
228 | the Null terminator.\r | |
229 | \r | |
230 | **/\r | |
231 | UINTN\r | |
232 | EFIAPI\r | |
233 | StrnSizeS (\r | |
234 | IN CONST CHAR16 *String,\r | |
235 | IN UINTN MaxSize\r | |
236 | );\r | |
237 | \r | |
c058d59f JY |
238 | /**\r |
239 | Copies the string pointed to by Source (including the terminating null char)\r | |
240 | to the array pointed to by Destination.\r | |
241 | \r | |
328f84b1 JY |
242 | This function is similar as strcpy_s defined in C11.\r |
243 | \r | |
c058d59f JY |
244 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
245 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 246 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 247 | \r |
328f84b1 JY |
248 | If an error is returned, then the Destination is unmodified.\r |
249 | \r | |
c058d59f JY |
250 | @param Destination A pointer to a Null-terminated Unicode string.\r |
251 | @param DestMax The maximum number of Destination Unicode\r | |
252 | char, including terminating null char.\r | |
253 | @param Source A pointer to a Null-terminated Unicode string.\r | |
254 | \r | |
255 | @retval RETURN_SUCCESS String is copied.\r | |
256 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
257 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
258 | If Source is NULL.\r | |
259 | If PcdMaximumUnicodeStringLength is not zero,\r | |
260 | and DestMax is greater than \r | |
261 | PcdMaximumUnicodeStringLength.\r | |
262 | If DestMax is 0.\r | |
263 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
264 | **/\r | |
265 | RETURN_STATUS\r | |
266 | EFIAPI\r | |
267 | StrCpyS (\r | |
268 | OUT CHAR16 *Destination,\r | |
269 | IN UINTN DestMax,\r | |
270 | IN CONST CHAR16 *Source\r | |
271 | );\r | |
272 | \r | |
273 | /**\r | |
274 | Copies not more than Length successive char from the string pointed to by\r | |
275 | Source to the array pointed to by Destination. If no null char is copied from\r | |
276 | Source, then Destination[Length] is always set to null.\r | |
277 | \r | |
328f84b1 JY |
278 | This function is similar as strncpy_s defined in C11.\r |
279 | \r | |
c058d59f JY |
280 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
281 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 282 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 283 | \r |
328f84b1 JY |
284 | If an error is returned, then the Destination is unmodified.\r |
285 | \r | |
c058d59f JY |
286 | @param Destination A pointer to a Null-terminated Unicode string.\r |
287 | @param DestMax The maximum number of Destination Unicode\r | |
288 | char, including terminating null char.\r | |
289 | @param Source A pointer to a Null-terminated Unicode string.\r | |
290 | @param Length The maximum number of Unicode characters to copy.\r | |
291 | \r | |
292 | @retval RETURN_SUCCESS String is copied.\r | |
293 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than \r | |
294 | MIN(StrLen(Source), Length).\r | |
295 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
296 | If Source is NULL.\r | |
297 | If PcdMaximumUnicodeStringLength is not zero,\r | |
298 | and DestMax is greater than \r | |
299 | PcdMaximumUnicodeStringLength.\r | |
300 | If DestMax is 0.\r | |
301 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
302 | **/\r | |
303 | RETURN_STATUS\r | |
304 | EFIAPI\r | |
305 | StrnCpyS (\r | |
306 | OUT CHAR16 *Destination,\r | |
307 | IN UINTN DestMax,\r | |
308 | IN CONST CHAR16 *Source,\r | |
309 | IN UINTN Length\r | |
310 | );\r | |
311 | \r | |
312 | /**\r | |
313 | Appends a copy of the string pointed to by Source (including the terminating\r | |
314 | null char) to the end of the string pointed to by Destination.\r | |
315 | \r | |
328f84b1 JY |
316 | This function is similar as strcat_s defined in C11.\r |
317 | \r | |
c058d59f JY |
318 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
319 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
0e93edbb | 320 | If an error would be returned, then the function will also ASSERT().\r |
c058d59f | 321 | \r |
328f84b1 JY |
322 | If an error is returned, then the Destination is unmodified.\r |
323 | \r | |
c058d59f JY |
324 | @param Destination A pointer to a Null-terminated Unicode string.\r |
325 | @param DestMax The maximum number of Destination Unicode\r | |
326 | char, including terminating null char.\r | |
327 | @param Source A pointer to a Null-terminated Unicode string.\r | |
328 | \r | |
329 | @retval RETURN_SUCCESS String is appended.\r | |
330 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than \r | |
331 | StrLen(Destination).\r | |
332 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
333 | greater than StrLen(Source).\r | |
334 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
335 | If Source is NULL.\r | |
336 | If PcdMaximumUnicodeStringLength is not zero,\r | |
337 | and DestMax is greater than \r | |
338 | PcdMaximumUnicodeStringLength.\r | |
339 | If DestMax is 0.\r | |
340 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
341 | **/\r | |
342 | RETURN_STATUS\r | |
343 | EFIAPI\r | |
344 | StrCatS (\r | |
345 | IN OUT CHAR16 *Destination,\r | |
346 | IN UINTN DestMax,\r | |
347 | IN CONST CHAR16 *Source\r | |
348 | );\r | |
349 | \r | |
350 | /**\r | |
351 | Appends not more than Length successive char from the string pointed to by\r | |
352 | Source to the end of the string pointed to by Destination. If no null char is\r | |
353 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
354 | set to null.\r | |
355 | \r | |
328f84b1 JY |
356 | This function is similar as strncat_s defined in C11.\r |
357 | \r | |
c058d59f | 358 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
0e93edbb JY |
359 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
360 | If an error would be returned, then the function will also ASSERT().\r | |
c058d59f | 361 | \r |
328f84b1 JY |
362 | If an error is returned, then the Destination is unmodified.\r |
363 | \r | |
c058d59f JY |
364 | @param Destination A pointer to a Null-terminated Unicode string.\r |
365 | @param DestMax The maximum number of Destination Unicode\r | |
366 | char, including terminating null char.\r | |
367 | @param Source A pointer to a Null-terminated Unicode string.\r | |
368 | @param Length The maximum number of Unicode characters to copy.\r | |
369 | \r | |
370 | @retval RETURN_SUCCESS String is appended.\r | |
371 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
372 | StrLen(Destination).\r | |
373 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
374 | greater than MIN(StrLen(Source), Length).\r | |
375 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
376 | If Source is NULL.\r | |
377 | If PcdMaximumUnicodeStringLength is not zero,\r | |
378 | and DestMax is greater than \r | |
379 | PcdMaximumUnicodeStringLength.\r | |
380 | If DestMax is 0.\r | |
381 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
382 | **/\r | |
383 | RETURN_STATUS\r | |
384 | EFIAPI\r | |
385 | StrnCatS (\r | |
386 | IN OUT CHAR16 *Destination,\r | |
387 | IN UINTN DestMax,\r | |
388 | IN CONST CHAR16 *Source,\r | |
389 | IN UINTN Length\r | |
390 | );\r | |
391 | \r | |
d8af3301 HW |
392 | /**\r |
393 | Convert a Null-terminated Unicode decimal string to a value of type UINTN.\r | |
394 | \r | |
395 | This function outputs a value of type UINTN by interpreting the contents of\r | |
396 | the Unicode string specified by String as a decimal number. The format of the\r | |
397 | input Unicode string String is:\r | |
398 | \r | |
399 | [spaces] [decimal digits].\r | |
400 | \r | |
401 | The valid decimal digit character is in the range [0-9]. The function will\r | |
402 | ignore the pad space, which includes spaces or tab characters, before\r | |
403 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
404 | be ignored. Then, the function stops at the first character that is a not a\r | |
405 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
406 | \r | |
407 | If String is NULL, then ASSERT().\r | |
408 | If Data is NULL, then ASSERT().\r | |
409 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
410 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
411 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
412 | Null-terminator, then ASSERT().\r | |
413 | \r | |
414 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
415 | at the location pointed to by Data.\r | |
416 | If the number represented by String exceeds the range defined by UINTN, then\r | |
417 | MAX_UINTN is stored at the location pointed to by Data.\r | |
418 | \r | |
419 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
420 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
421 | decimal digits right after the optional pad spaces, the value of String is\r | |
422 | stored at the location pointed to by EndPointer.\r | |
423 | \r | |
424 | @param String Pointer to a Null-terminated Unicode string.\r | |
425 | @param EndPointer Pointer to character that stops scan.\r | |
426 | @param Data Pointer to the converted value.\r | |
427 | \r | |
428 | @retval RETURN_SUCCESS Value is translated from String.\r | |
429 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
430 | If Data is NULL.\r | |
431 | If PcdMaximumUnicodeStringLength is not\r | |
432 | zero, and String contains more than\r | |
433 | PcdMaximumUnicodeStringLength Unicode\r | |
434 | characters, not including the\r | |
435 | Null-terminator.\r | |
436 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
437 | the range defined by UINTN.\r | |
438 | \r | |
439 | **/\r | |
440 | RETURN_STATUS\r | |
441 | EFIAPI\r | |
442 | StrDecimalToUintnS (\r | |
443 | IN CONST CHAR16 *String,\r | |
444 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
445 | OUT UINTN *Data\r | |
446 | );\r | |
447 | \r | |
448 | /**\r | |
449 | Convert a Null-terminated Unicode decimal string to a value of type UINT64.\r | |
450 | \r | |
451 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
452 | the Unicode string specified by String as a decimal number. The format of the\r | |
453 | input Unicode string String is:\r | |
454 | \r | |
455 | [spaces] [decimal digits].\r | |
456 | \r | |
457 | The valid decimal digit character is in the range [0-9]. The function will\r | |
458 | ignore the pad space, which includes spaces or tab characters, before\r | |
459 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
460 | be ignored. Then, the function stops at the first character that is a not a\r | |
461 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
462 | \r | |
463 | If String is NULL, then ASSERT().\r | |
464 | If Data is NULL, then ASSERT().\r | |
465 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
466 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
467 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
468 | Null-terminator, then ASSERT().\r | |
469 | \r | |
470 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
471 | at the location pointed to by Data.\r | |
472 | If the number represented by String exceeds the range defined by UINT64, then\r | |
473 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
474 | \r | |
475 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
476 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
477 | decimal digits right after the optional pad spaces, the value of String is\r | |
478 | stored at the location pointed to by EndPointer.\r | |
479 | \r | |
480 | @param String Pointer to a Null-terminated Unicode string.\r | |
481 | @param EndPointer Pointer to character that stops scan.\r | |
482 | @param Data Pointer to the converted value.\r | |
483 | \r | |
484 | @retval RETURN_SUCCESS Value is translated from String.\r | |
485 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
486 | If Data is NULL.\r | |
487 | If PcdMaximumUnicodeStringLength is not\r | |
488 | zero, and String contains more than\r | |
489 | PcdMaximumUnicodeStringLength Unicode\r | |
490 | characters, not including the\r | |
491 | Null-terminator.\r | |
492 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
493 | the range defined by UINT64.\r | |
494 | \r | |
495 | **/\r | |
496 | RETURN_STATUS\r | |
497 | EFIAPI\r | |
498 | StrDecimalToUint64S (\r | |
499 | IN CONST CHAR16 *String,\r | |
500 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
501 | OUT UINT64 *Data\r | |
502 | );\r | |
503 | \r | |
504 | /**\r | |
505 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
506 | UINTN.\r | |
507 | \r | |
508 | This function outputs a value of type UINTN by interpreting the contents of\r | |
509 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
510 | the input Unicode string String is:\r | |
511 | \r | |
512 | [spaces][zeros][x][hexadecimal digits].\r | |
513 | \r | |
514 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
515 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
516 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
517 | The function will ignore the pad space, which includes spaces or tab\r | |
518 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
519 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
520 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
521 | the first character that is a not a valid hexadecimal character or NULL,\r | |
522 | whichever one comes first.\r | |
523 | \r | |
524 | If String is NULL, then ASSERT().\r | |
525 | If Data is NULL, then ASSERT().\r | |
526 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
527 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
528 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
529 | Null-terminator, then ASSERT().\r | |
530 | \r | |
531 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
532 | stored at the location pointed to by Data.\r | |
533 | If the number represented by String exceeds the range defined by UINTN, then\r | |
534 | MAX_UINTN is stored at the location pointed to by Data.\r | |
535 | \r | |
536 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
537 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
538 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
539 | is stored at the location pointed to by EndPointer.\r | |
540 | \r | |
541 | @param String Pointer to a Null-terminated Unicode string.\r | |
542 | @param EndPointer Pointer to character that stops scan.\r | |
543 | @param Data Pointer to the converted value.\r | |
544 | \r | |
545 | @retval RETURN_SUCCESS Value is translated from String.\r | |
546 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
547 | If Data is NULL.\r | |
548 | If PcdMaximumUnicodeStringLength is not\r | |
549 | zero, and String contains more than\r | |
550 | PcdMaximumUnicodeStringLength Unicode\r | |
551 | characters, not including the\r | |
552 | Null-terminator.\r | |
553 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
554 | the range defined by UINTN.\r | |
555 | \r | |
556 | **/\r | |
557 | RETURN_STATUS\r | |
558 | EFIAPI\r | |
559 | StrHexToUintnS (\r | |
560 | IN CONST CHAR16 *String,\r | |
561 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
562 | OUT UINTN *Data\r | |
563 | );\r | |
564 | \r | |
565 | /**\r | |
566 | Convert a Null-terminated Unicode hexadecimal string to a value of type\r | |
567 | UINT64.\r | |
568 | \r | |
569 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
570 | the Unicode string specified by String as a hexadecimal number. The format of\r | |
571 | the input Unicode string String is:\r | |
572 | \r | |
573 | [spaces][zeros][x][hexadecimal digits].\r | |
574 | \r | |
575 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
576 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
577 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
578 | The function will ignore the pad space, which includes spaces or tab\r | |
579 | characters, before [zeros], [x] or [hexadecimal digit]. The running zero\r | |
580 | before [x] or [hexadecimal digit] will be ignored. Then, the decoding starts\r | |
581 | after [x] or the first valid hexadecimal digit. Then, the function stops at\r | |
582 | the first character that is a not a valid hexadecimal character or NULL,\r | |
583 | whichever one comes first.\r | |
584 | \r | |
585 | If String is NULL, then ASSERT().\r | |
586 | If Data is NULL, then ASSERT().\r | |
587 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
588 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
589 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
590 | Null-terminator, then ASSERT().\r | |
591 | \r | |
592 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
593 | stored at the location pointed to by Data.\r | |
594 | If the number represented by String exceeds the range defined by UINT64, then\r | |
595 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
596 | \r | |
597 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
598 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
599 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
600 | is stored at the location pointed to by EndPointer.\r | |
601 | \r | |
602 | @param String Pointer to a Null-terminated Unicode string.\r | |
603 | @param EndPointer Pointer to character that stops scan.\r | |
604 | @param Data Pointer to the converted value.\r | |
605 | \r | |
606 | @retval RETURN_SUCCESS Value is translated from String.\r | |
607 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
608 | If Data is NULL.\r | |
609 | If PcdMaximumUnicodeStringLength is not\r | |
610 | zero, and String contains more than\r | |
611 | PcdMaximumUnicodeStringLength Unicode\r | |
612 | characters, not including the\r | |
613 | Null-terminator.\r | |
614 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
615 | the range defined by UINT64.\r | |
616 | \r | |
617 | **/\r | |
618 | RETURN_STATUS\r | |
619 | EFIAPI\r | |
620 | StrHexToUint64S (\r | |
621 | IN CONST CHAR16 *String,\r | |
622 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
623 | OUT UINT64 *Data\r | |
624 | );\r | |
625 | \r | |
c058d59f JY |
626 | /**\r |
627 | Returns the length of a Null-terminated Ascii string.\r | |
628 | \r | |
328f84b1 JY |
629 | This function is similar as strlen_s defined in C11.\r |
630 | \r | |
c058d59f JY |
631 | @param String A pointer to a Null-terminated Ascii string.\r |
632 | @param MaxSize The maximum number of Destination Ascii\r | |
633 | char, including terminating null char.\r | |
634 | \r | |
635 | @retval 0 If String is NULL.\r | |
636 | @retval MaxSize If there is no null character in the first MaxSize characters of String.\r | |
637 | @return The number of characters that percede the terminating null character.\r | |
638 | \r | |
639 | **/\r | |
640 | UINTN\r | |
641 | EFIAPI\r | |
642 | AsciiStrnLenS (\r | |
643 | IN CONST CHAR8 *String,\r | |
644 | IN UINTN MaxSize\r | |
645 | );\r | |
646 | \r | |
b590e43a HW |
647 | /**\r |
648 | Returns the size of a Null-terminated Ascii string in bytes, including the\r | |
649 | Null terminator.\r | |
650 | \r | |
651 | This function returns the size of the Null-terminated Ascii string specified\r | |
652 | by String in bytes, including the Null terminator.\r | |
653 | \r | |
654 | @param String A pointer to a Null-terminated Ascii string.\r | |
655 | @param MaxSize The maximum number of Destination Ascii\r | |
656 | char, including the Null terminator.\r | |
657 | \r | |
658 | @retval 0 If String is NULL.\r | |
659 | @retval (sizeof (CHAR8) * (MaxSize + 1))\r | |
660 | If there is no Null terminator in the first MaxSize characters of\r | |
661 | String.\r | |
662 | @return The size of the Null-terminated Ascii string in bytes, including the\r | |
663 | Null terminator.\r | |
664 | \r | |
665 | **/\r | |
666 | UINTN\r | |
667 | EFIAPI\r | |
668 | AsciiStrnSizeS (\r | |
669 | IN CONST CHAR8 *String,\r | |
670 | IN UINTN MaxSize\r | |
671 | );\r | |
672 | \r | |
c058d59f JY |
673 | /**\r |
674 | Copies the string pointed to by Source (including the terminating null char)\r | |
675 | to the array pointed to by Destination.\r | |
676 | \r | |
328f84b1 JY |
677 | This function is similar as strcpy_s defined in C11.\r |
678 | \r | |
0e93edbb JY |
679 | If an error would be returned, then the function will also ASSERT().\r |
680 | \r | |
328f84b1 JY |
681 | If an error is returned, then the Destination is unmodified.\r |
682 | \r | |
c058d59f JY |
683 | @param Destination A pointer to a Null-terminated Ascii string.\r |
684 | @param DestMax The maximum number of Destination Ascii\r | |
685 | char, including terminating null char.\r | |
686 | @param Source A pointer to a Null-terminated Ascii string.\r | |
687 | \r | |
688 | @retval RETURN_SUCCESS String is copied.\r | |
689 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
690 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
691 | If Source is NULL.\r | |
692 | If PcdMaximumAsciiStringLength is not zero,\r | |
693 | and DestMax is greater than \r | |
694 | PcdMaximumAsciiStringLength.\r | |
695 | If DestMax is 0.\r | |
696 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
697 | **/\r | |
698 | RETURN_STATUS\r | |
699 | EFIAPI\r | |
700 | AsciiStrCpyS (\r | |
701 | OUT CHAR8 *Destination,\r | |
702 | IN UINTN DestMax,\r | |
703 | IN CONST CHAR8 *Source\r | |
704 | );\r | |
705 | \r | |
706 | /**\r | |
707 | Copies not more than Length successive char from the string pointed to by\r | |
708 | Source to the array pointed to by Destination. If no null char is copied from\r | |
709 | Source, then Destination[Length] is always set to null.\r | |
710 | \r | |
328f84b1 JY |
711 | This function is similar as strncpy_s defined in C11.\r |
712 | \r | |
0e93edbb JY |
713 | If an error would be returned, then the function will also ASSERT().\r |
714 | \r | |
328f84b1 JY |
715 | If an error is returned, then the Destination is unmodified.\r |
716 | \r | |
c058d59f JY |
717 | @param Destination A pointer to a Null-terminated Ascii string.\r |
718 | @param DestMax The maximum number of Destination Ascii\r | |
719 | char, including terminating null char.\r | |
720 | @param Source A pointer to a Null-terminated Ascii string.\r | |
721 | @param Length The maximum number of Ascii characters to copy.\r | |
722 | \r | |
723 | @retval RETURN_SUCCESS String is copied.\r | |
724 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than \r | |
725 | MIN(StrLen(Source), Length).\r | |
726 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
727 | If Source is NULL.\r | |
728 | If PcdMaximumAsciiStringLength is not zero,\r | |
729 | and DestMax is greater than \r | |
730 | PcdMaximumAsciiStringLength.\r | |
731 | If DestMax is 0.\r | |
732 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
733 | **/\r | |
734 | RETURN_STATUS\r | |
735 | EFIAPI\r | |
736 | AsciiStrnCpyS (\r | |
737 | OUT CHAR8 *Destination,\r | |
738 | IN UINTN DestMax,\r | |
739 | IN CONST CHAR8 *Source,\r | |
740 | IN UINTN Length\r | |
741 | );\r | |
742 | \r | |
743 | /**\r | |
744 | Appends a copy of the string pointed to by Source (including the terminating\r | |
745 | null char) to the end of the string pointed to by Destination.\r | |
746 | \r | |
328f84b1 JY |
747 | This function is similar as strcat_s defined in C11.\r |
748 | \r | |
0e93edbb JY |
749 | If an error would be returned, then the function will also ASSERT().\r |
750 | \r | |
328f84b1 JY |
751 | If an error is returned, then the Destination is unmodified.\r |
752 | \r | |
c058d59f JY |
753 | @param Destination A pointer to a Null-terminated Ascii string.\r |
754 | @param DestMax The maximum number of Destination Ascii\r | |
755 | char, including terminating null char.\r | |
756 | @param Source A pointer to a Null-terminated Ascii string.\r | |
757 | \r | |
758 | @retval RETURN_SUCCESS String is appended.\r | |
759 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than \r | |
760 | StrLen(Destination).\r | |
761 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
762 | greater than StrLen(Source).\r | |
763 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
764 | If Source is NULL.\r | |
765 | If PcdMaximumAsciiStringLength is not zero,\r | |
766 | and DestMax is greater than \r | |
767 | PcdMaximumAsciiStringLength.\r | |
768 | If DestMax is 0.\r | |
769 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
770 | **/\r | |
771 | RETURN_STATUS\r | |
772 | EFIAPI\r | |
773 | AsciiStrCatS (\r | |
774 | IN OUT CHAR8 *Destination,\r | |
775 | IN UINTN DestMax,\r | |
776 | IN CONST CHAR8 *Source\r | |
777 | );\r | |
778 | \r | |
779 | /**\r | |
780 | Appends not more than Length successive char from the string pointed to by\r | |
781 | Source to the end of the string pointed to by Destination. If no null char is\r | |
782 | copied from Source, then Destination[StrLen(Destination) + Length] is always\r | |
783 | set to null.\r | |
784 | \r | |
328f84b1 JY |
785 | This function is similar as strncat_s defined in C11.\r |
786 | \r | |
0e93edbb JY |
787 | If an error would be returned, then the function will also ASSERT().\r |
788 | \r | |
328f84b1 JY |
789 | If an error is returned, then the Destination is unmodified.\r |
790 | \r | |
c058d59f JY |
791 | @param Destination A pointer to a Null-terminated Ascii string.\r |
792 | @param DestMax The maximum number of Destination Ascii\r | |
793 | char, including terminating null char.\r | |
794 | @param Source A pointer to a Null-terminated Ascii string.\r | |
795 | @param Length The maximum number of Ascii characters to copy.\r | |
796 | \r | |
797 | @retval RETURN_SUCCESS String is appended.\r | |
798 | @retval RETURN_BAD_BUFFER_SIZE If DestMax is NOT greater than\r | |
799 | StrLen(Destination).\r | |
800 | @retval RETURN_BUFFER_TOO_SMALL If (DestMax - StrLen(Destination)) is NOT\r | |
801 | greater than MIN(StrLen(Source), Length).\r | |
802 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
803 | If Source is NULL.\r | |
804 | If PcdMaximumAsciiStringLength is not zero,\r | |
805 | and DestMax is greater than \r | |
806 | PcdMaximumAsciiStringLength.\r | |
807 | If DestMax is 0.\r | |
808 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
809 | **/\r | |
810 | RETURN_STATUS\r | |
811 | EFIAPI\r | |
812 | AsciiStrnCatS (\r | |
813 | IN OUT CHAR8 *Destination,\r | |
814 | IN UINTN DestMax,\r | |
815 | IN CONST CHAR8 *Source,\r | |
816 | IN UINTN Length\r | |
817 | );\r | |
818 | \r | |
d8af3301 HW |
819 | /**\r |
820 | Convert a Null-terminated Ascii decimal string to a value of type UINTN.\r | |
821 | \r | |
822 | This function outputs a value of type UINTN by interpreting the contents of\r | |
823 | the Ascii string specified by String as a decimal number. The format of the\r | |
824 | input Ascii string String is:\r | |
825 | \r | |
826 | [spaces] [decimal digits].\r | |
827 | \r | |
828 | The valid decimal digit character is in the range [0-9]. The function will\r | |
829 | ignore the pad space, which includes spaces or tab characters, before\r | |
830 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
831 | be ignored. Then, the function stops at the first character that is a not a\r | |
832 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
833 | \r | |
834 | If String is NULL, then ASSERT().\r | |
835 | If Data is NULL, then ASSERT().\r | |
836 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
837 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
838 | Null-terminator, then ASSERT().\r | |
839 | \r | |
840 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
841 | at the location pointed to by Data.\r | |
842 | If the number represented by String exceeds the range defined by UINTN, then\r | |
843 | MAX_UINTN is stored at the location pointed to by Data.\r | |
844 | \r | |
845 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
846 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
847 | decimal digits right after the optional pad spaces, the value of String is\r | |
848 | stored at the location pointed to by EndPointer.\r | |
849 | \r | |
850 | @param String Pointer to a Null-terminated Ascii string.\r | |
851 | @param EndPointer Pointer to character that stops scan.\r | |
852 | @param Data Pointer to the converted value.\r | |
853 | \r | |
854 | @retval RETURN_SUCCESS Value is translated from String.\r | |
855 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
856 | If Data is NULL.\r | |
857 | If PcdMaximumAsciiStringLength is not zero,\r | |
858 | and String contains more than\r | |
859 | PcdMaximumAsciiStringLength Ascii\r | |
860 | characters, not including the\r | |
861 | Null-terminator.\r | |
862 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
863 | the range defined by UINTN.\r | |
864 | \r | |
865 | **/\r | |
866 | RETURN_STATUS\r | |
867 | EFIAPI\r | |
868 | AsciiStrDecimalToUintnS (\r | |
869 | IN CONST CHAR8 *String,\r | |
870 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
871 | OUT UINTN *Data\r | |
872 | );\r | |
873 | \r | |
874 | /**\r | |
875 | Convert a Null-terminated Ascii decimal string to a value of type UINT64.\r | |
876 | \r | |
877 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
878 | the Ascii string specified by String as a decimal number. The format of the\r | |
879 | input Ascii string String is:\r | |
880 | \r | |
881 | [spaces] [decimal digits].\r | |
882 | \r | |
883 | The valid decimal digit character is in the range [0-9]. The function will\r | |
884 | ignore the pad space, which includes spaces or tab characters, before\r | |
885 | [decimal digits]. The running zero in the beginning of [decimal digits] will\r | |
886 | be ignored. Then, the function stops at the first character that is a not a\r | |
887 | valid decimal character or a Null-terminator, whichever one comes first.\r | |
888 | \r | |
889 | If String is NULL, then ASSERT().\r | |
890 | If Data is NULL, then ASSERT().\r | |
891 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
892 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
893 | Null-terminator, then ASSERT().\r | |
894 | \r | |
895 | If String has no valid decimal digits in the above format, then 0 is stored\r | |
896 | at the location pointed to by Data.\r | |
897 | If the number represented by String exceeds the range defined by UINT64, then\r | |
898 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
899 | \r | |
900 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
901 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
902 | decimal digits right after the optional pad spaces, the value of String is\r | |
903 | stored at the location pointed to by EndPointer.\r | |
904 | \r | |
905 | @param String Pointer to a Null-terminated Ascii string.\r | |
906 | @param EndPointer Pointer to character that stops scan.\r | |
907 | @param Data Pointer to the converted value.\r | |
908 | \r | |
909 | @retval RETURN_SUCCESS Value is translated from String.\r | |
910 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
911 | If Data is NULL.\r | |
912 | If PcdMaximumAsciiStringLength is not zero,\r | |
913 | and String contains more than\r | |
914 | PcdMaximumAsciiStringLength Ascii\r | |
915 | characters, not including the\r | |
916 | Null-terminator.\r | |
917 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
918 | the range defined by UINT64.\r | |
919 | \r | |
920 | **/\r | |
921 | RETURN_STATUS\r | |
922 | EFIAPI\r | |
923 | AsciiStrDecimalToUint64S (\r | |
924 | IN CONST CHAR8 *String,\r | |
925 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
926 | OUT UINT64 *Data\r | |
927 | );\r | |
928 | \r | |
929 | /**\r | |
930 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINTN.\r | |
931 | \r | |
932 | This function outputs a value of type UINTN by interpreting the contents of\r | |
933 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
934 | the input Ascii string String is:\r | |
935 | \r | |
936 | [spaces][zeros][x][hexadecimal digits].\r | |
937 | \r | |
938 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
939 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
940 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
941 | function will ignore the pad space, which includes spaces or tab characters,\r | |
942 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
943 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
944 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
945 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
946 | whichever on comes first.\r | |
947 | \r | |
948 | If String is NULL, then ASSERT().\r | |
949 | If Data is NULL, then ASSERT().\r | |
950 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
951 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
952 | Null-terminator, then ASSERT().\r | |
953 | \r | |
954 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
955 | stored at the location pointed to by Data.\r | |
956 | If the number represented by String exceeds the range defined by UINTN, then\r | |
957 | MAX_UINTN is stored at the location pointed to by Data.\r | |
958 | \r | |
959 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
960 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
961 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
962 | is stored at the location pointed to by EndPointer.\r | |
963 | \r | |
964 | @param String Pointer to a Null-terminated Ascii string.\r | |
965 | @param EndPointer Pointer to character that stops scan.\r | |
966 | @param Data Pointer to the converted value.\r | |
967 | \r | |
968 | @retval RETURN_SUCCESS Value is translated from String.\r | |
969 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
970 | If Data is NULL.\r | |
971 | If PcdMaximumAsciiStringLength is not zero,\r | |
972 | and String contains more than\r | |
973 | PcdMaximumAsciiStringLength Ascii\r | |
974 | characters, not including the\r | |
975 | Null-terminator.\r | |
976 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
977 | the range defined by UINTN.\r | |
978 | \r | |
979 | **/\r | |
980 | RETURN_STATUS\r | |
981 | EFIAPI\r | |
982 | AsciiStrHexToUintnS (\r | |
983 | IN CONST CHAR8 *String,\r | |
984 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
985 | OUT UINTN *Data\r | |
986 | );\r | |
987 | \r | |
988 | /**\r | |
989 | Convert a Null-terminated Ascii hexadecimal string to a value of type UINT64.\r | |
990 | \r | |
991 | This function outputs a value of type UINT64 by interpreting the contents of\r | |
992 | the Ascii string specified by String as a hexadecimal number. The format of\r | |
993 | the input Ascii string String is:\r | |
994 | \r | |
995 | [spaces][zeros][x][hexadecimal digits].\r | |
996 | \r | |
997 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
998 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If\r | |
999 | "x" appears in the input string, it must be prefixed with at least one 0. The\r | |
1000 | function will ignore the pad space, which includes spaces or tab characters,\r | |
1001 | before [zeros], [x] or [hexadecimal digits]. The running zero before [x] or\r | |
1002 | [hexadecimal digits] will be ignored. Then, the decoding starts after [x] or\r | |
1003 | the first valid hexadecimal digit. Then, the function stops at the first\r | |
1004 | character that is a not a valid hexadecimal character or Null-terminator,\r | |
1005 | whichever on comes first.\r | |
1006 | \r | |
1007 | If String is NULL, then ASSERT().\r | |
1008 | If Data is NULL, then ASSERT().\r | |
1009 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
1010 | PcdMaximumAsciiStringLength Ascii characters, not including the\r | |
1011 | Null-terminator, then ASSERT().\r | |
1012 | \r | |
1013 | If String has no valid hexadecimal digits in the above format, then 0 is\r | |
1014 | stored at the location pointed to by Data.\r | |
1015 | If the number represented by String exceeds the range defined by UINT64, then\r | |
1016 | MAX_UINT64 is stored at the location pointed to by Data.\r | |
1017 | \r | |
1018 | If EndPointer is not NULL, a pointer to the character that stopped the scan\r | |
1019 | is stored at the location pointed to by EndPointer. If String has no valid\r | |
1020 | hexadecimal digits right after the optional pad spaces, the value of String\r | |
1021 | is stored at the location pointed to by EndPointer.\r | |
1022 | \r | |
1023 | @param String Pointer to a Null-terminated Ascii string.\r | |
1024 | @param EndPointer Pointer to character that stops scan.\r | |
1025 | @param Data Pointer to the converted value.\r | |
1026 | \r | |
1027 | @retval RETURN_SUCCESS Value is translated from String.\r | |
1028 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1029 | If Data is NULL.\r | |
1030 | If PcdMaximumAsciiStringLength is not zero,\r | |
1031 | and String contains more than\r | |
1032 | PcdMaximumAsciiStringLength Ascii\r | |
1033 | characters, not including the\r | |
1034 | Null-terminator.\r | |
1035 | @retval RETURN_UNSUPPORTED If the number represented by String exceeds\r | |
1036 | the range defined by UINT64.\r | |
1037 | \r | |
1038 | **/\r | |
1039 | RETURN_STATUS\r | |
1040 | EFIAPI\r | |
1041 | AsciiStrHexToUint64S (\r | |
1042 | IN CONST CHAR8 *String,\r | |
1043 | OUT CHAR8 **EndPointer, OPTIONAL\r | |
1044 | OUT UINT64 *Data\r | |
1045 | );\r | |
1046 | \r | |
c058d59f | 1047 | \r |
1bb390f1 ED |
1048 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1049 | \r | |
ac644614 | 1050 | /**\r |
ae591c14 | 1051 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1052 | \r |
ac644614 | 1053 | Copies one Null-terminated Unicode string to another Null-terminated Unicode\r |
1054 | string and returns the new Unicode string.\r | |
1055 | \r | |
1056 | This function copies the contents of the Unicode string Source to the Unicode\r | |
1057 | string Destination, and returns Destination. If Source and Destination\r | |
1058 | overlap, then the results are undefined.\r | |
1059 | \r | |
1060 | If Destination is NULL, then ASSERT().\r | |
1061 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1062 | If Source is NULL, then ASSERT().\r | |
1063 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1064 | If Source and Destination overlap, then ASSERT().\r | |
1065 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
1066 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1067 | Null-terminator, then ASSERT().\r | |
1068 | \r | |
af2dc6a7 | 1069 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1070 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1071 | \r |
9aa049d9 | 1072 | @return Destination.\r |
ac644614 | 1073 | \r |
1074 | **/\r | |
1075 | CHAR16 *\r | |
1076 | EFIAPI\r | |
1077 | StrCpy (\r | |
1078 | OUT CHAR16 *Destination,\r | |
1079 | IN CONST CHAR16 *Source\r | |
1080 | );\r | |
1081 | \r | |
1082 | \r | |
1083 | /**\r | |
ae591c14 | 1084 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1085 | \r |
af2dc6a7 | 1086 | Copies up to a specified length from one Null-terminated Unicode string to \r |
17f695ed | 1087 | another Null-terminated Unicode string and returns the new Unicode string.\r |
ac644614 | 1088 | \r |
1089 | This function copies the contents of the Unicode string Source to the Unicode\r | |
1090 | string Destination, and returns Destination. At most, Length Unicode\r | |
1091 | characters are copied from Source to Destination. If Length is 0, then\r | |
1092 | Destination is returned unmodified. If Length is greater that the number of\r | |
1093 | Unicode characters in Source, then Destination is padded with Null Unicode\r | |
1094 | characters. If Source and Destination overlap, then the results are\r | |
1095 | undefined.\r | |
1096 | \r | |
1097 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1098 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1099 | If Length > 0 and Source is NULL, then ASSERT().\r | |
77f863ee | 1100 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1101 | If Source and Destination overlap, then ASSERT().\r |
50c247fd | 1102 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
1103 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
ac644614 | 1104 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r |
50c247fd | 1105 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r |
1106 | then ASSERT().\r | |
ac644614 | 1107 | \r |
af2dc6a7 | 1108 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1109 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1110 | @param Length The maximum number of Unicode characters to copy.\r | |
ac644614 | 1111 | \r |
9aa049d9 | 1112 | @return Destination.\r |
ac644614 | 1113 | \r |
1114 | **/\r | |
1115 | CHAR16 *\r | |
1116 | EFIAPI\r | |
1117 | StrnCpy (\r | |
1118 | OUT CHAR16 *Destination,\r | |
1119 | IN CONST CHAR16 *Source,\r | |
1120 | IN UINTN Length\r | |
1121 | );\r | |
1bb390f1 | 1122 | #endif\r |
ac644614 | 1123 | \r |
1124 | /**\r | |
1125 | Returns the length of a Null-terminated Unicode string.\r | |
1126 | \r | |
1127 | This function returns the number of Unicode characters in the Null-terminated\r | |
1128 | Unicode string specified by String.\r | |
1129 | \r | |
1130 | If String is NULL, then ASSERT().\r | |
1131 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1132 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1133 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1134 | Null-terminator, then ASSERT().\r | |
1135 | \r | |
1136 | @param String Pointer to a Null-terminated Unicode string.\r | |
1137 | \r | |
1138 | @return The length of String.\r | |
1139 | \r | |
1140 | **/\r | |
1141 | UINTN\r | |
1142 | EFIAPI\r | |
1143 | StrLen (\r | |
1144 | IN CONST CHAR16 *String\r | |
1145 | );\r | |
1146 | \r | |
1147 | \r | |
1148 | /**\r | |
1149 | Returns the size of a Null-terminated Unicode string in bytes, including the\r | |
1150 | Null terminator.\r | |
1151 | \r | |
17f695ed | 1152 | This function returns the size, in bytes, of the Null-terminated Unicode string \r |
1153 | specified by String.\r | |
ac644614 | 1154 | \r |
1155 | If String is NULL, then ASSERT().\r | |
1156 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1157 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1158 | PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1159 | Null-terminator, then ASSERT().\r | |
1160 | \r | |
af2dc6a7 | 1161 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1162 | \r |
1163 | @return The size of String.\r | |
1164 | \r | |
1165 | **/\r | |
1166 | UINTN\r | |
1167 | EFIAPI\r | |
1168 | StrSize (\r | |
1169 | IN CONST CHAR16 *String\r | |
1170 | );\r | |
1171 | \r | |
1172 | \r | |
1173 | /**\r | |
1174 | Compares two Null-terminated Unicode strings, and returns the difference\r | |
1175 | between the first mismatched Unicode characters.\r | |
1176 | \r | |
1177 | This function compares the Null-terminated Unicode string FirstString to the\r | |
1178 | Null-terminated Unicode string SecondString. If FirstString is identical to\r | |
1179 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
1180 | mismatched Unicode character in SecondString subtracted from the first\r | |
1181 | mismatched Unicode character in FirstString.\r | |
1182 | \r | |
1183 | If FirstString is NULL, then ASSERT().\r | |
1184 | If FirstString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1185 | If SecondString is NULL, then ASSERT().\r | |
1186 | If SecondString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1187 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more\r | |
1188 | than PcdMaximumUnicodeStringLength Unicode characters not including the\r | |
1189 | Null-terminator, then ASSERT().\r | |
1190 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more\r | |
af2dc6a7 | 1191 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1192 | Null-terminator, then ASSERT().\r |
1193 | \r | |
af2dc6a7 | 1194 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1195 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1196 | \r |
1106ffe1 | 1197 | @retval 0 FirstString is identical to SecondString.\r |
1198 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1199 | \r |
1200 | **/\r | |
1201 | INTN\r | |
1202 | EFIAPI\r | |
1203 | StrCmp (\r | |
1204 | IN CONST CHAR16 *FirstString,\r | |
1205 | IN CONST CHAR16 *SecondString\r | |
1206 | );\r | |
1207 | \r | |
1208 | \r | |
1209 | /**\r | |
17f695ed | 1210 | Compares up to a specified length the contents of two Null-terminated Unicode strings,\r |
1211 | and returns the difference between the first mismatched Unicode characters.\r | |
1212 | \r | |
ac644614 | 1213 | This function compares the Null-terminated Unicode string FirstString to the\r |
1214 | Null-terminated Unicode string SecondString. At most, Length Unicode\r | |
1215 | characters will be compared. If Length is 0, then 0 is returned. If\r | |
1216 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
1217 | value returned is the first mismatched Unicode character in SecondString\r | |
1218 | subtracted from the first mismatched Unicode character in FirstString.\r | |
1219 | \r | |
1220 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
77f863ee | 1221 | If Length > 0 and FirstString is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1222 | If Length > 0 and SecondString is NULL, then ASSERT().\r |
77f863ee | 1223 | If Length > 0 and SecondString is not aligned on a 16-bit boundary, then ASSERT().\r |
50c247fd | 1224 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than\r |
1225 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
1226 | If PcdMaximumUnicodeStringLength is not zero, and FirstString contains more than\r | |
1227 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1228 | then ASSERT().\r | |
1229 | If PcdMaximumUnicodeStringLength is not zero, and SecondString contains more than\r | |
1230 | PcdMaximumUnicodeStringLength Unicode characters, not including the Null-terminator,\r | |
1231 | then ASSERT().\r | |
ac644614 | 1232 | \r |
af2dc6a7 | 1233 | @param FirstString The pointer to a Null-terminated Unicode string.\r |
1234 | @param SecondString The pointer to a Null-terminated Unicode string.\r | |
1235 | @param Length The maximum number of Unicode characters to compare.\r | |
ac644614 | 1236 | \r |
1106ffe1 | 1237 | @retval 0 FirstString is identical to SecondString.\r |
1238 | @return others FirstString is not identical to SecondString.\r | |
ac644614 | 1239 | \r |
1240 | **/\r | |
1241 | INTN\r | |
1242 | EFIAPI\r | |
1243 | StrnCmp (\r | |
1244 | IN CONST CHAR16 *FirstString,\r | |
1245 | IN CONST CHAR16 *SecondString,\r | |
1246 | IN UINTN Length\r | |
1247 | );\r | |
1248 | \r | |
1249 | \r | |
1bb390f1 ED |
1250 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1251 | \r | |
ac644614 | 1252 | /**\r |
ae591c14 | 1253 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1254 | \r |
ac644614 | 1255 | Concatenates one Null-terminated Unicode string to another Null-terminated\r |
1256 | Unicode string, and returns the concatenated Unicode string.\r | |
1257 | \r | |
1258 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
1259 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
1260 | Null-terminated Unicode string Destination. The Null-terminated concatenated\r | |
1261 | Unicode String is returned. If Source and Destination overlap, then the\r | |
1262 | results are undefined.\r | |
1263 | \r | |
1264 | If Destination is NULL, then ASSERT().\r | |
77f863ee | 1265 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1266 | If Source is NULL, then ASSERT().\r |
77f863ee | 1267 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r |
ac644614 | 1268 | If Source and Destination overlap, then ASSERT().\r |
1269 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r | |
af2dc6a7 | 1270 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1271 | Null-terminator, then ASSERT().\r |
1272 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
af2dc6a7 | 1273 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1274 | Null-terminator, then ASSERT().\r |
1275 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
1276 | and Source results in a Unicode string with more than\r | |
af2dc6a7 | 1277 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1278 | Null-terminator, then ASSERT().\r |
1279 | \r | |
af2dc6a7 | 1280 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1281 | @param Source The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 1282 | \r |
9aa049d9 | 1283 | @return Destination.\r |
ac644614 | 1284 | \r |
1285 | **/\r | |
1286 | CHAR16 *\r | |
1287 | EFIAPI\r | |
1288 | StrCat (\r | |
1289 | IN OUT CHAR16 *Destination,\r | |
1290 | IN CONST CHAR16 *Source\r | |
1291 | );\r | |
1292 | \r | |
1293 | \r | |
1294 | /**\r | |
ae591c14 | 1295 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1296 | \r |
17f695ed | 1297 | Concatenates up to a specified length one Null-terminated Unicode to the end \r |
1298 | of another Null-terminated Unicode string, and returns the concatenated \r | |
ac644614 | 1299 | Unicode string.\r |
1300 | \r | |
1301 | This function concatenates two Null-terminated Unicode strings. The contents\r | |
1302 | of Null-terminated Unicode string Source are concatenated to the end of\r | |
1303 | Null-terminated Unicode string Destination, and Destination is returned. At\r | |
1304 | most, Length Unicode characters are concatenated from Source to the end of\r | |
1305 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
1306 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
1307 | the results are undefined.\r | |
1308 | \r | |
1309 | If Destination is NULL, then ASSERT().\r | |
1310 | If Length > 0 and Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
1311 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1312 | If Length > 0 and Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1313 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 1314 | If PcdMaximumUnicodeStringLength is not zero, and Length is greater than \r |
1315 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
ac644614 | 1316 | If PcdMaximumUnicodeStringLength is not zero, and Destination contains more\r |
50c247fd | 1317 | than PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1318 | Null-terminator, then ASSERT().\r |
1319 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
50c247fd | 1320 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r |
ac644614 | 1321 | Null-terminator, then ASSERT().\r |
1322 | If PcdMaximumUnicodeStringLength is not zero, and concatenating Destination\r | |
50c247fd | 1323 | and Source results in a Unicode string with more than PcdMaximumUnicodeStringLength\r |
1324 | Unicode characters, not including the Null-terminator, then ASSERT().\r | |
ac644614 | 1325 | \r |
af2dc6a7 | 1326 | @param Destination The pointer to a Null-terminated Unicode string.\r |
1327 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1328 | @param Length The maximum number of Unicode characters to concatenate from\r | |
ac644614 | 1329 | Source.\r |
1330 | \r | |
9aa049d9 | 1331 | @return Destination.\r |
ac644614 | 1332 | \r |
1333 | **/\r | |
1334 | CHAR16 *\r | |
1335 | EFIAPI\r | |
1336 | StrnCat (\r | |
1337 | IN OUT CHAR16 *Destination,\r | |
1338 | IN CONST CHAR16 *Source,\r | |
1339 | IN UINTN Length\r | |
1340 | );\r | |
1bb390f1 | 1341 | #endif\r |
ac644614 | 1342 | \r |
1343 | /**\r | |
9aa049d9 | 1344 | Returns the first occurrence of a Null-terminated Unicode sub-string\r |
ac644614 | 1345 | in a Null-terminated Unicode string.\r |
1346 | \r | |
1347 | This function scans the contents of the Null-terminated Unicode string\r | |
1348 | specified by String and returns the first occurrence of SearchString.\r | |
1349 | If SearchString is not found in String, then NULL is returned. If\r | |
af2dc6a7 | 1350 | the length of SearchString is zero, then String is returned.\r |
ac644614 | 1351 | \r |
1352 | If String is NULL, then ASSERT().\r | |
1353 | If String is not aligned on a 16-bit boundary, then ASSERT().\r | |
1354 | If SearchString is NULL, then ASSERT().\r | |
1355 | If SearchString is not aligned on a 16-bit boundary, then ASSERT().\r | |
1356 | \r | |
1357 | If PcdMaximumUnicodeStringLength is not zero, and SearchString\r | |
1358 | or String contains more than PcdMaximumUnicodeStringLength Unicode\r | |
af2dc6a7 | 1359 | characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 1360 | \r |
af2dc6a7 | 1361 | @param String The pointer to a Null-terminated Unicode string.\r |
1362 | @param SearchString The pointer to a Null-terminated Unicode string to search for.\r | |
ac644614 | 1363 | \r |
1364 | @retval NULL If the SearchString does not appear in String.\r | |
1106ffe1 | 1365 | @return others If there is a match.\r |
ac644614 | 1366 | \r |
1367 | **/\r | |
1368 | CHAR16 *\r | |
1369 | EFIAPI\r | |
1370 | StrStr (\r | |
17f695ed | 1371 | IN CONST CHAR16 *String,\r |
1372 | IN CONST CHAR16 *SearchString\r | |
ac644614 | 1373 | );\r |
1374 | \r | |
1375 | /**\r | |
1376 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1377 | type UINTN.\r | |
1378 | \r | |
1379 | This function returns a value of type UINTN by interpreting the contents\r | |
1380 | of the Unicode string specified by String as a decimal number. The format\r | |
1381 | of the input Unicode string String is:\r | |
1382 | \r | |
1383 | [spaces] [decimal digits].\r | |
1384 | \r | |
1385 | The valid decimal digit character is in the range [0-9]. The\r | |
1386 | function will ignore the pad space, which includes spaces or\r | |
1387 | tab characters, before [decimal digits]. The running zero in the\r | |
1388 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1389 | stops at the first character that is a not a valid decimal character\r | |
1390 | or a Null-terminator, whichever one comes first.\r | |
1391 | \r | |
1392 | If String is NULL, then ASSERT().\r | |
1393 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1394 | If String has only pad spaces, then 0 is returned.\r | |
1395 | If String has no pad spaces or valid decimal digits,\r | |
1396 | then 0 is returned.\r | |
1397 | If the number represented by String overflows according\r | |
ea2e0921 | 1398 | to the range defined by UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1399 | \r |
1400 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1401 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1402 | the Null-terminator, then ASSERT().\r | |
1403 | \r | |
af2dc6a7 | 1404 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1405 | \r |
38bbd3d9 | 1406 | @retval Value translated from String.\r |
ac644614 | 1407 | \r |
1408 | **/\r | |
1409 | UINTN\r | |
1410 | EFIAPI\r | |
1411 | StrDecimalToUintn (\r | |
17f695ed | 1412 | IN CONST CHAR16 *String\r |
ac644614 | 1413 | );\r |
1414 | \r | |
1415 | /**\r | |
1416 | Convert a Null-terminated Unicode decimal string to a value of\r | |
1417 | type UINT64.\r | |
1418 | \r | |
1419 | This function returns a value of type UINT64 by interpreting the contents\r | |
1420 | of the Unicode string specified by String as a decimal number. The format\r | |
1421 | of the input Unicode string String is:\r | |
1422 | \r | |
1423 | [spaces] [decimal digits].\r | |
1424 | \r | |
1425 | The valid decimal digit character is in the range [0-9]. The\r | |
1426 | function will ignore the pad space, which includes spaces or\r | |
1427 | tab characters, before [decimal digits]. The running zero in the\r | |
1428 | beginning of [decimal digits] will be ignored. Then, the function\r | |
1429 | stops at the first character that is a not a valid decimal character\r | |
1430 | or a Null-terminator, whichever one comes first.\r | |
1431 | \r | |
1432 | If String is NULL, then ASSERT().\r | |
1433 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1434 | If String has only pad spaces, then 0 is returned.\r | |
1435 | If String has no pad spaces or valid decimal digits,\r | |
1436 | then 0 is returned.\r | |
1437 | If the number represented by String overflows according\r | |
ea2e0921 | 1438 | to the range defined by UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1439 | \r |
1440 | If PcdMaximumUnicodeStringLength is not zero, and String contains\r | |
1441 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1442 | the Null-terminator, then ASSERT().\r | |
1443 | \r | |
af2dc6a7 | 1444 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1445 | \r |
38bbd3d9 | 1446 | @retval Value translated from String.\r |
ac644614 | 1447 | \r |
1448 | **/\r | |
1449 | UINT64\r | |
1450 | EFIAPI\r | |
1451 | StrDecimalToUint64 (\r | |
17f695ed | 1452 | IN CONST CHAR16 *String\r |
ac644614 | 1453 | );\r |
1454 | \r | |
1455 | \r | |
1456 | /**\r | |
1457 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINTN.\r | |
1458 | \r | |
1459 | This function returns a value of type UINTN by interpreting the contents\r | |
1460 | of the Unicode string specified by String as a hexadecimal number.\r | |
1461 | The format of the input Unicode string String is:\r | |
1462 | \r | |
1463 | [spaces][zeros][x][hexadecimal digits].\r | |
1464 | \r | |
1465 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1466 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1467 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1468 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1469 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1470 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
af2dc6a7 | 1471 | first valid hexadecimal digit. Then, the function stops at the first character \r |
1472 | that is a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
ac644614 | 1473 | \r |
1474 | If String is NULL, then ASSERT().\r | |
1475 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1476 | If String has only pad spaces, then zero is returned.\r | |
1477 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1478 | then zero is returned.\r | |
1479 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1480 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 1481 | \r |
1482 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1483 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1484 | then ASSERT().\r | |
1485 | \r | |
af2dc6a7 | 1486 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1487 | \r |
38bbd3d9 | 1488 | @retval Value translated from String.\r |
ac644614 | 1489 | \r |
1490 | **/\r | |
1491 | UINTN\r | |
1492 | EFIAPI\r | |
1493 | StrHexToUintn (\r | |
17f695ed | 1494 | IN CONST CHAR16 *String\r |
ac644614 | 1495 | );\r |
1496 | \r | |
1497 | \r | |
1498 | /**\r | |
1499 | Convert a Null-terminated Unicode hexadecimal string to a value of type UINT64.\r | |
1500 | \r | |
1501 | This function returns a value of type UINT64 by interpreting the contents\r | |
1502 | of the Unicode string specified by String as a hexadecimal number.\r | |
1503 | The format of the input Unicode string String is\r | |
1504 | \r | |
1505 | [spaces][zeros][x][hexadecimal digits].\r | |
1506 | \r | |
1507 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
1508 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix.\r | |
1509 | If "x" appears in the input string, it must be prefixed with at least one 0.\r | |
1510 | The function will ignore the pad space, which includes spaces or tab characters,\r | |
1511 | before [zeros], [x] or [hexadecimal digit]. The running zero before [x] or\r | |
1512 | [hexadecimal digit] will be ignored. Then, the decoding starts after [x] or the\r | |
1513 | first valid hexadecimal digit. Then, the function stops at the first character that is\r | |
1514 | a not a valid hexadecimal character or NULL, whichever one comes first.\r | |
1515 | \r | |
1516 | If String is NULL, then ASSERT().\r | |
1517 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1518 | If String has only pad spaces, then zero is returned.\r | |
1519 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits,\r | |
1520 | then zero is returned.\r | |
1521 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 1522 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 1523 | \r |
1524 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1525 | PcdMaximumUnicodeStringLength Unicode characters not including the Null-terminator,\r | |
1526 | then ASSERT().\r | |
1527 | \r | |
af2dc6a7 | 1528 | @param String The pointer to a Null-terminated Unicode string.\r |
ac644614 | 1529 | \r |
38bbd3d9 | 1530 | @retval Value translated from String.\r |
ac644614 | 1531 | \r |
1532 | **/\r | |
1533 | UINT64\r | |
1534 | EFIAPI\r | |
1535 | StrHexToUint64 (\r | |
17f695ed | 1536 | IN CONST CHAR16 *String\r |
ac644614 | 1537 | );\r |
1538 | \r | |
36396ea2 RN |
1539 | /**\r |
1540 | Convert a Null-terminated Unicode string to IPv6 address and prefix length.\r | |
1541 | \r | |
1542 | This function outputs a value of type IPv6_ADDRESS and may output a value\r | |
1543 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1544 | by String. The format of the input Unicode string String is as follows:\r | |
1545 | \r | |
1546 | X:X:X:X:X:X:X:X[/P]\r | |
1547 | \r | |
1548 | X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r | |
1549 | [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r | |
1550 | memory address and high byte is stored in high memory address. P contains decimal\r | |
1551 | digit characters in the range [0-9]. The running zero in the beginning of P will\r | |
1552 | be ignored. /P is optional.\r | |
1553 | \r | |
1554 | When /P is not in the String, the function stops at the first character that is\r | |
1555 | not a valid hexadecimal digit character after eight X's are converted.\r | |
1556 | \r | |
1557 | When /P is in the String, the function stops at the first character that is not\r | |
1558 | a valid decimal digit character after P is converted.\r | |
1559 | \r | |
1560 | "::" can be used to compress one or more groups of X when X contains only 0.\r | |
1561 | The "::" can only appear once in the String.\r | |
1562 | \r | |
1563 | If String is NULL, then ASSERT().\r | |
1564 | \r | |
1565 | If Address is NULL, then ASSERT().\r | |
1566 | \r | |
1567 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1568 | \r | |
1569 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1570 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
1571 | Null-terminator, then ASSERT().\r | |
1572 | \r | |
1573 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
1574 | to the character that stopped the scan is stored at the location pointed to\r | |
1575 | by EndPointer.\r | |
1576 | \r | |
1577 | @param String Pointer to a Null-terminated Unicode string.\r | |
1578 | @param EndPointer Pointer to character that stops scan.\r | |
1579 | @param Address Pointer to the converted IPv6 address.\r | |
1580 | @param PrefixLength Pointer to the converted IPv6 address prefix\r | |
1581 | length. MAX_UINT8 is returned when /P is\r | |
1582 | not in the String.\r | |
1583 | \r | |
1584 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1585 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1586 | If Data is NULL.\r | |
1587 | @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r | |
1588 | digit characters.\r | |
1589 | If String contains "::" and number of X\r | |
1590 | is not less than 8.\r | |
1591 | If P starts with character that is not a\r | |
1592 | valid decimal digit character.\r | |
1593 | If the decimal number converted from P\r | |
1594 | exceeds 128.\r | |
1595 | \r | |
1596 | **/\r | |
1597 | RETURN_STATUS\r | |
1598 | EFIAPI\r | |
1599 | StrToIpv6Address (\r | |
1600 | IN CONST CHAR16 *String,\r | |
1601 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
1602 | OUT IPv6_ADDRESS *Address,\r | |
1603 | OUT UINT8 *PrefixLength OPTIONAL\r | |
1604 | );\r | |
1605 | \r | |
1606 | /**\r | |
1607 | Convert a Null-terminated Unicode string to IPv4 address and prefix length.\r | |
1608 | \r | |
1609 | This function outputs a value of type IPv4_ADDRESS and may output a value\r | |
1610 | of type UINT8 by interpreting the contents of the Unicode string specified\r | |
1611 | by String. The format of the input Unicode string String is as follows:\r | |
1612 | \r | |
1613 | D.D.D.D[/P]\r | |
1614 | \r | |
1615 | D and P are decimal digit characters in the range [0-9]. The running zero in\r | |
1616 | the beginning of D and P will be ignored. /P is optional.\r | |
1617 | \r | |
1618 | When /P is not in the String, the function stops at the first character that is\r | |
1619 | not a valid decimal digit character after four D's are converted.\r | |
1620 | \r | |
1621 | When /P is in the String, the function stops at the first character that is not\r | |
1622 | a valid decimal digit character after P is converted.\r | |
1623 | \r | |
1624 | If String is NULL, then ASSERT().\r | |
1625 | \r | |
1626 | If Address is NULL, then ASSERT().\r | |
1627 | \r | |
1628 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1629 | \r | |
1630 | If PcdMaximumUnicodeStringLength is not zero, and String contains more than\r | |
1631 | PcdMaximumUnicodeStringLength Unicode characters, not including the\r | |
1632 | Null-terminator, then ASSERT().\r | |
1633 | \r | |
1634 | If EndPointer is not NULL and Address is translated from String, a pointer\r | |
1635 | to the character that stopped the scan is stored at the location pointed to\r | |
1636 | by EndPointer.\r | |
1637 | \r | |
1638 | @param String Pointer to a Null-terminated Unicode string.\r | |
1639 | @param EndPointer Pointer to character that stops scan.\r | |
1640 | @param Address Pointer to the converted IPv4 address.\r | |
1641 | @param PrefixLength Pointer to the converted IPv4 address prefix\r | |
1642 | length. MAX_UINT8 is returned when /P is\r | |
1643 | not in the String.\r | |
1644 | \r | |
1645 | @retval RETURN_SUCCESS Address is translated from String.\r | |
1646 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1647 | If Data is NULL.\r | |
1648 | @retval RETURN_UNSUPPORTED If String is not in the correct format.\r | |
1649 | If any decimal number converted from D\r | |
1650 | exceeds 255.\r | |
1651 | If the decimal number converted from P\r | |
1652 | exceeds 32.\r | |
1653 | \r | |
1654 | **/\r | |
1655 | RETURN_STATUS\r | |
1656 | EFIAPI\r | |
1657 | StrToIpv4Address (\r | |
1658 | IN CONST CHAR16 *String,\r | |
1659 | OUT CHAR16 **EndPointer, OPTIONAL\r | |
1660 | OUT IPv4_ADDRESS *Address,\r | |
1661 | OUT UINT8 *PrefixLength OPTIONAL\r | |
1662 | );\r | |
1663 | \r | |
1664 | #define GUID_STRING_LENGTH 36\r | |
1665 | \r | |
1666 | /**\r | |
1667 | Convert a Null-terminated Unicode GUID string to a value of type\r | |
1668 | EFI_GUID.\r | |
1669 | \r | |
1670 | This function outputs a GUID value by interpreting the contents of\r | |
1671 | the Unicode string specified by String. The format of the input\r | |
1672 | Unicode string String consists of 36 characters, as follows:\r | |
1673 | \r | |
1674 | aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r | |
1675 | \r | |
1676 | The pairs aa - pp are two characters in the range [0-9], [a-f] and\r | |
1677 | [A-F], with each pair representing a single byte hexadecimal value.\r | |
1678 | \r | |
1679 | The mapping between String and the EFI_GUID structure is as follows:\r | |
1680 | aa Data1[24:31]\r | |
1681 | bb Data1[16:23]\r | |
1682 | cc Data1[8:15]\r | |
1683 | dd Data1[0:7]\r | |
1684 | ee Data2[8:15]\r | |
1685 | ff Data2[0:7]\r | |
1686 | gg Data3[8:15]\r | |
1687 | hh Data3[0:7]\r | |
1688 | ii Data4[0:7]\r | |
1689 | jj Data4[8:15]\r | |
1690 | kk Data4[16:23]\r | |
1691 | ll Data4[24:31]\r | |
1692 | mm Data4[32:39]\r | |
1693 | nn Data4[40:47]\r | |
1694 | oo Data4[48:55]\r | |
1695 | pp Data4[56:63]\r | |
1696 | \r | |
1697 | If String is NULL, then ASSERT().\r | |
1698 | If Guid is NULL, then ASSERT().\r | |
1699 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1700 | \r | |
1701 | @param String Pointer to a Null-terminated Unicode string.\r | |
1702 | @param Guid Pointer to the converted GUID.\r | |
1703 | \r | |
1704 | @retval RETURN_SUCCESS Guid is translated from String.\r | |
1705 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1706 | If Data is NULL.\r | |
1707 | @retval RETURN_UNSUPPORTED If String is not as the above format.\r | |
1708 | \r | |
1709 | **/\r | |
1710 | RETURN_STATUS\r | |
1711 | EFIAPI\r | |
1712 | StrToGuid (\r | |
1713 | IN CONST CHAR16 *String,\r | |
1714 | OUT GUID *Guid\r | |
1715 | );\r | |
1716 | \r | |
1717 | /**\r | |
1718 | Convert a Null-terminated Unicode hexadecimal string to a byte array.\r | |
1719 | \r | |
1720 | This function outputs a byte array by interpreting the contents of\r | |
1721 | the Unicode string specified by String in hexadecimal format. The format of\r | |
1722 | the input Unicode string String is:\r | |
1723 | \r | |
1724 | [XX]*\r | |
1725 | \r | |
1726 | X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r | |
1727 | The function decodes every two hexadecimal digit characters as one byte. The\r | |
1728 | decoding stops after Length of characters and outputs Buffer containing\r | |
1729 | (Length / 2) bytes.\r | |
1730 | \r | |
1731 | If String is not aligned in a 16-bit boundary, then ASSERT().\r | |
1732 | \r | |
1733 | If String is NULL, then ASSERT().\r | |
1734 | \r | |
1735 | If Buffer is NULL, then ASSERT().\r | |
1736 | \r | |
1737 | If Length is not multiple of 2, then ASSERT().\r | |
1738 | \r | |
1739 | If PcdMaximumUnicodeStringLength is not zero and Length is greater than\r | |
1740 | PcdMaximumUnicodeStringLength, then ASSERT().\r | |
1741 | \r | |
1742 | If MaxBufferSize is less than (Length / 2), then ASSERT().\r | |
1743 | \r | |
1744 | @param String Pointer to a Null-terminated Unicode string.\r | |
1745 | @param Length The number of Unicode characters to decode.\r | |
1746 | @param Buffer Pointer to the converted bytes array.\r | |
1747 | @param MaxBufferSize The maximum size of Buffer.\r | |
1748 | \r | |
1749 | @retval RETURN_SUCCESS Buffer is translated from String.\r | |
1750 | @retval RETURN_INVALID_PARAMETER If String is NULL.\r | |
1751 | If Data is NULL.\r | |
1752 | If Length is not multiple of 2.\r | |
1753 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1754 | and Length is greater than\r | |
1755 | PcdMaximumUnicodeStringLength.\r | |
1756 | @retval RETURN_UNSUPPORTED If Length of characters from String contain\r | |
1757 | a character that is not valid hexadecimal\r | |
1758 | digit characters, or a Null-terminator.\r | |
1759 | @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r | |
1760 | **/\r | |
1761 | RETURN_STATUS\r | |
1762 | EFIAPI\r | |
1763 | StrHexToBytes (\r | |
1764 | IN CONST CHAR16 *String,\r | |
1765 | IN UINTN Length,\r | |
1766 | OUT UINT8 *Buffer,\r | |
1767 | IN UINTN MaxBufferSize\r | |
1768 | );\r | |
1769 | \r | |
415aa2f1 SZ |
1770 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1771 | \r | |
ac644614 | 1772 | /**\r |
415aa2f1 SZ |
1773 | [ATTENTION] This function is deprecated for security reason.\r |
1774 | \r | |
17f695ed | 1775 | Convert a Null-terminated Unicode string to a Null-terminated\r |
ac644614 | 1776 | ASCII string and returns the ASCII string.\r |
1777 | \r | |
1778 | This function converts the content of the Unicode string Source\r | |
1779 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1780 | each Unicode character. It returns Destination.\r | |
1781 | \r | |
d3e0289c | 1782 | The caller is responsible to make sure Destination points to a buffer with size\r |
1783 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1784 | \r | |
ac644614 | 1785 | If any Unicode characters in Source contain non-zero value in\r |
1786 | the upper 8 bits, then ASSERT().\r | |
1787 | \r | |
1788 | If Destination is NULL, then ASSERT().\r | |
1789 | If Source is NULL, then ASSERT().\r | |
1790 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1791 | If Source and Destination overlap, then ASSERT().\r | |
1792 | \r | |
1793 | If PcdMaximumUnicodeStringLength is not zero, and Source contains\r | |
1794 | more than PcdMaximumUnicodeStringLength Unicode characters not including\r | |
1795 | the Null-terminator, then ASSERT().\r | |
1796 | \r | |
1797 | If PcdMaximumAsciiStringLength is not zero, and Source contains more\r | |
1798 | than PcdMaximumAsciiStringLength Unicode characters not including the\r | |
1799 | Null-terminator, then ASSERT().\r | |
1800 | \r | |
af2dc6a7 | 1801 | @param Source The pointer to a Null-terminated Unicode string.\r |
1802 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1803 | \r |
9aa049d9 | 1804 | @return Destination.\r |
ac644614 | 1805 | \r |
1806 | **/\r | |
1807 | CHAR8 *\r | |
1808 | EFIAPI\r | |
1809 | UnicodeStrToAsciiStr (\r | |
17f695ed | 1810 | IN CONST CHAR16 *Source,\r |
1811 | OUT CHAR8 *Destination\r | |
ac644614 | 1812 | );\r |
1813 | \r | |
415aa2f1 SZ |
1814 | #endif\r |
1815 | \r | |
3ab41b7a JY |
1816 | /**\r |
1817 | Convert a Null-terminated Unicode string to a Null-terminated\r | |
1818 | ASCII string.\r | |
1819 | \r | |
1820 | This function is similar to AsciiStrCpyS.\r | |
1821 | \r | |
1822 | This function converts the content of the Unicode string Source\r | |
1823 | to the ASCII string Destination by copying the lower 8 bits of\r | |
1824 | each Unicode character. The function terminates the ASCII string\r | |
1825 | Destination by appending a Null-terminator character at the end.\r | |
1826 | \r | |
1827 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1828 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1829 | \r | |
1830 | If any Unicode characters in Source contain non-zero value in\r | |
1831 | the upper 8 bits, then ASSERT().\r | |
1832 | \r | |
1833 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1834 | If an error would be returned, then the function will also ASSERT().\r | |
1835 | \r | |
1836 | If an error is returned, then the Destination is unmodified.\r | |
1837 | \r | |
1838 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1839 | @param Destination The pointer to a Null-terminated ASCII string.\r | |
1840 | @param DestMax The maximum number of Destination Ascii\r | |
1841 | char, including terminating null char.\r | |
1842 | \r | |
1843 | @retval RETURN_SUCCESS String is converted.\r | |
1844 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
1845 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1846 | If Source is NULL.\r | |
1847 | If PcdMaximumAsciiStringLength is not zero,\r | |
1848 | and DestMax is greater than\r | |
1849 | PcdMaximumAsciiStringLength.\r | |
1850 | If PcdMaximumUnicodeStringLength is not zero,\r | |
1851 | and DestMax is greater than\r | |
1852 | PcdMaximumUnicodeStringLength.\r | |
1853 | If DestMax is 0.\r | |
1854 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1855 | \r | |
1856 | **/\r | |
1857 | RETURN_STATUS\r | |
1858 | EFIAPI\r | |
1859 | UnicodeStrToAsciiStrS (\r | |
1860 | IN CONST CHAR16 *Source,\r | |
1861 | OUT CHAR8 *Destination,\r | |
1862 | IN UINTN DestMax\r | |
1863 | );\r | |
ac644614 | 1864 | \r |
02263214 HW |
1865 | /**\r |
1866 | Convert not more than Length successive characters from a Null-terminated\r | |
1867 | Unicode string to a Null-terminated Ascii string. If no null char is copied\r | |
1868 | from Source, then Destination[Length] is always set to null.\r | |
1869 | \r | |
1870 | This function converts not more than Length successive characters from the\r | |
1871 | Unicode string Source to the Ascii string Destination by copying the lower 8\r | |
1872 | bits of each Unicode character. The function terminates the Ascii string\r | |
1873 | Destination by appending a Null-terminator character at the end.\r | |
1874 | \r | |
1875 | The caller is responsible to make sure Destination points to a buffer with size\r | |
1876 | equal or greater than ((StrLen (Source) + 1) * sizeof (CHAR8)) in bytes.\r | |
1877 | \r | |
1878 | If any Unicode characters in Source contain non-zero value in the upper 8\r | |
1879 | bits, then ASSERT().\r | |
1880 | If Source is not aligned on a 16-bit boundary, then ASSERT().\r | |
1881 | If an error would be returned, then the function will also ASSERT().\r | |
1882 | \r | |
1883 | If an error is returned, then the Destination is unmodified.\r | |
1884 | \r | |
1885 | @param Source The pointer to a Null-terminated Unicode string.\r | |
1886 | @param Length The maximum number of Unicode characters to\r | |
1887 | convert.\r | |
1888 | @param Destination The pointer to a Null-terminated Ascii string.\r | |
1889 | @param DestMax The maximum number of Destination Ascii\r | |
1890 | char, including terminating null char.\r | |
1891 | @param DestinationLength The number of Unicode characters converted.\r | |
1892 | \r | |
1893 | @retval RETURN_SUCCESS String is converted.\r | |
1894 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
1895 | If Source is NULL.\r | |
1896 | If DestinationLength is NULL.\r | |
1897 | If PcdMaximumAsciiStringLength is not zero,\r | |
1898 | and Length or DestMax is greater than\r | |
1899 | PcdMaximumAsciiStringLength.\r | |
1900 | If PcdMaximumUnicodeStringLength is not\r | |
1901 | zero, and Length or DestMax is greater than\r | |
1902 | PcdMaximumUnicodeStringLength.\r | |
1903 | If DestMax is 0.\r | |
1904 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
1905 | MIN(StrLen(Source), Length).\r | |
1906 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
1907 | \r | |
1908 | **/\r | |
1909 | RETURN_STATUS\r | |
1910 | EFIAPI\r | |
1911 | UnicodeStrnToAsciiStrS (\r | |
1912 | IN CONST CHAR16 *Source,\r | |
1913 | IN UINTN Length,\r | |
1914 | OUT CHAR8 *Destination,\r | |
1915 | IN UINTN DestMax,\r | |
1916 | OUT UINTN *DestinationLength\r | |
1917 | );\r | |
1918 | \r | |
1bb390f1 ED |
1919 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
1920 | \r | |
ac644614 | 1921 | /**\r |
ae591c14 | 1922 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1923 | \r |
ac644614 | 1924 | Copies one Null-terminated ASCII string to another Null-terminated ASCII\r |
1925 | string and returns the new ASCII string.\r | |
1926 | \r | |
1927 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1928 | string Destination, and returns Destination. If Source and Destination\r | |
1929 | overlap, then the results are undefined.\r | |
1930 | \r | |
1931 | If Destination is NULL, then ASSERT().\r | |
1932 | If Source is NULL, then ASSERT().\r | |
1933 | If Source and Destination overlap, then ASSERT().\r | |
1934 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
1935 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
1936 | then ASSERT().\r | |
1937 | \r | |
af2dc6a7 | 1938 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1939 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 1940 | \r |
1941 | @return Destination\r | |
1942 | \r | |
1943 | **/\r | |
1944 | CHAR8 *\r | |
1945 | EFIAPI\r | |
1946 | AsciiStrCpy (\r | |
1947 | OUT CHAR8 *Destination,\r | |
1948 | IN CONST CHAR8 *Source\r | |
1949 | );\r | |
1950 | \r | |
1951 | \r | |
1952 | /**\r | |
ae591c14 | 1953 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 1954 | \r |
17f695ed | 1955 | Copies up to a specified length one Null-terminated ASCII string to another \r |
1956 | Null-terminated ASCII string and returns the new ASCII string.\r | |
ac644614 | 1957 | \r |
1958 | This function copies the contents of the ASCII string Source to the ASCII\r | |
1959 | string Destination, and returns Destination. At most, Length ASCII characters\r | |
1960 | are copied from Source to Destination. If Length is 0, then Destination is\r | |
1961 | returned unmodified. If Length is greater that the number of ASCII characters\r | |
1962 | in Source, then Destination is padded with Null ASCII characters. If Source\r | |
1963 | and Destination overlap, then the results are undefined.\r | |
1964 | \r | |
1965 | If Destination is NULL, then ASSERT().\r | |
1966 | If Source is NULL, then ASSERT().\r | |
1967 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 1968 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
1969 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
ac644614 | 1970 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r |
50c247fd | 1971 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 1972 | then ASSERT().\r |
1973 | \r | |
af2dc6a7 | 1974 | @param Destination The pointer to a Null-terminated ASCII string.\r |
1975 | @param Source The pointer to a Null-terminated ASCII string.\r | |
1976 | @param Length The maximum number of ASCII characters to copy.\r | |
ac644614 | 1977 | \r |
1978 | @return Destination\r | |
1979 | \r | |
1980 | **/\r | |
1981 | CHAR8 *\r | |
1982 | EFIAPI\r | |
1983 | AsciiStrnCpy (\r | |
1984 | OUT CHAR8 *Destination,\r | |
1985 | IN CONST CHAR8 *Source,\r | |
1986 | IN UINTN Length\r | |
1987 | );\r | |
1bb390f1 | 1988 | #endif\r |
ac644614 | 1989 | \r |
1990 | /**\r | |
1991 | Returns the length of a Null-terminated ASCII string.\r | |
1992 | \r | |
1993 | This function returns the number of ASCII characters in the Null-terminated\r | |
1994 | ASCII string specified by String.\r | |
1995 | \r | |
1996 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
1997 | If Length > 0 and Source is NULL, then ASSERT().\r | |
1998 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
1999 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2000 | then ASSERT().\r | |
2001 | \r | |
af2dc6a7 | 2002 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2003 | \r |
2004 | @return The length of String.\r | |
2005 | \r | |
2006 | **/\r | |
2007 | UINTN\r | |
2008 | EFIAPI\r | |
2009 | AsciiStrLen (\r | |
2010 | IN CONST CHAR8 *String\r | |
2011 | );\r | |
2012 | \r | |
2013 | \r | |
2014 | /**\r | |
2015 | Returns the size of a Null-terminated ASCII string in bytes, including the\r | |
2016 | Null terminator.\r | |
2017 | \r | |
2018 | This function returns the size, in bytes, of the Null-terminated ASCII string\r | |
2019 | specified by String.\r | |
2020 | \r | |
2021 | If String is NULL, then ASSERT().\r | |
2022 | If PcdMaximumAsciiStringLength is not zero and String contains more than\r | |
2023 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2024 | then ASSERT().\r | |
2025 | \r | |
af2dc6a7 | 2026 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2027 | \r |
2028 | @return The size of String.\r | |
2029 | \r | |
2030 | **/\r | |
2031 | UINTN\r | |
2032 | EFIAPI\r | |
2033 | AsciiStrSize (\r | |
2034 | IN CONST CHAR8 *String\r | |
2035 | );\r | |
2036 | \r | |
2037 | \r | |
2038 | /**\r | |
2039 | Compares two Null-terminated ASCII strings, and returns the difference\r | |
2040 | between the first mismatched ASCII characters.\r | |
2041 | \r | |
2042 | This function compares the Null-terminated ASCII string FirstString to the\r | |
2043 | Null-terminated ASCII string SecondString. If FirstString is identical to\r | |
2044 | SecondString, then 0 is returned. Otherwise, the value returned is the first\r | |
2045 | mismatched ASCII character in SecondString subtracted from the first\r | |
2046 | mismatched ASCII character in FirstString.\r | |
2047 | \r | |
2048 | If FirstString is NULL, then ASSERT().\r | |
2049 | If SecondString is NULL, then ASSERT().\r | |
2050 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
2051 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2052 | then ASSERT().\r | |
2053 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
2054 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
2055 | Null-terminator, then ASSERT().\r | |
2056 | \r | |
af2dc6a7 | 2057 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2058 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2059 | \r |
17f695ed | 2060 | @retval ==0 FirstString is identical to SecondString.\r |
2061 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 2062 | \r |
2063 | **/\r | |
2064 | INTN\r | |
2065 | EFIAPI\r | |
2066 | AsciiStrCmp (\r | |
2067 | IN CONST CHAR8 *FirstString,\r | |
2068 | IN CONST CHAR8 *SecondString\r | |
2069 | );\r | |
2070 | \r | |
2071 | \r | |
2072 | /**\r | |
2073 | Performs a case insensitive comparison of two Null-terminated ASCII strings,\r | |
2074 | and returns the difference between the first mismatched ASCII characters.\r | |
2075 | \r | |
2076 | This function performs a case insensitive comparison of the Null-terminated\r | |
2077 | ASCII string FirstString to the Null-terminated ASCII string SecondString. If\r | |
2078 | FirstString is identical to SecondString, then 0 is returned. Otherwise, the\r | |
2079 | value returned is the first mismatched lower case ASCII character in\r | |
2080 | SecondString subtracted from the first mismatched lower case ASCII character\r | |
2081 | in FirstString.\r | |
2082 | \r | |
2083 | If FirstString is NULL, then ASSERT().\r | |
2084 | If SecondString is NULL, then ASSERT().\r | |
2085 | If PcdMaximumAsciiStringLength is not zero and FirstString contains more than\r | |
2086 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2087 | then ASSERT().\r | |
2088 | If PcdMaximumAsciiStringLength is not zero and SecondString contains more\r | |
2089 | than PcdMaximumAsciiStringLength ASCII characters not including the\r | |
2090 | Null-terminator, then ASSERT().\r | |
2091 | \r | |
af2dc6a7 | 2092 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2093 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2094 | \r |
17f695ed | 2095 | @retval ==0 FirstString is identical to SecondString using case insensitive\r |
1106ffe1 | 2096 | comparisons.\r |
17f695ed | 2097 | @retval !=0 FirstString is not identical to SecondString using case\r |
1106ffe1 | 2098 | insensitive comparisons.\r |
ac644614 | 2099 | \r |
2100 | **/\r | |
2101 | INTN\r | |
2102 | EFIAPI\r | |
2103 | AsciiStriCmp (\r | |
2104 | IN CONST CHAR8 *FirstString,\r | |
2105 | IN CONST CHAR8 *SecondString\r | |
2106 | );\r | |
2107 | \r | |
2108 | \r | |
2109 | /**\r | |
2110 | Compares two Null-terminated ASCII strings with maximum lengths, and returns\r | |
2111 | the difference between the first mismatched ASCII characters.\r | |
2112 | \r | |
2113 | This function compares the Null-terminated ASCII string FirstString to the\r | |
2114 | Null-terminated ASCII string SecondString. At most, Length ASCII characters\r | |
2115 | will be compared. If Length is 0, then 0 is returned. If FirstString is\r | |
2116 | identical to SecondString, then 0 is returned. Otherwise, the value returned\r | |
2117 | is the first mismatched ASCII character in SecondString subtracted from the\r | |
2118 | first mismatched ASCII character in FirstString.\r | |
2119 | \r | |
2120 | If Length > 0 and FirstString is NULL, then ASSERT().\r | |
2121 | If Length > 0 and SecondString is NULL, then ASSERT().\r | |
50c247fd | 2122 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than \r |
2123 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
2124 | If PcdMaximumAsciiStringLength is not zero, and FirstString contains more than\r | |
2125 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 2126 | then ASSERT().\r |
50c247fd | 2127 | If PcdMaximumAsciiStringLength is not zero, and SecondString contains more than\r |
2128 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r | |
ac644614 | 2129 | then ASSERT().\r |
2130 | \r | |
af2dc6a7 | 2131 | @param FirstString The pointer to a Null-terminated ASCII string.\r |
2132 | @param SecondString The pointer to a Null-terminated ASCII string.\r | |
2133 | @param Length The maximum number of ASCII characters for compare.\r | |
ac644614 | 2134 | \r |
17f695ed | 2135 | @retval ==0 FirstString is identical to SecondString.\r |
2136 | @retval !=0 FirstString is not identical to SecondString.\r | |
ac644614 | 2137 | \r |
2138 | **/\r | |
2139 | INTN\r | |
2140 | EFIAPI\r | |
2141 | AsciiStrnCmp (\r | |
2142 | IN CONST CHAR8 *FirstString,\r | |
2143 | IN CONST CHAR8 *SecondString,\r | |
2144 | IN UINTN Length\r | |
2145 | );\r | |
2146 | \r | |
2147 | \r | |
1bb390f1 ED |
2148 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
2149 | \r | |
ac644614 | 2150 | /**\r |
ae591c14 | 2151 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 2152 | \r |
ac644614 | 2153 | Concatenates one Null-terminated ASCII string to another Null-terminated\r |
2154 | ASCII string, and returns the concatenated ASCII string.\r | |
2155 | \r | |
2156 | This function concatenates two Null-terminated ASCII strings. The contents of\r | |
2157 | Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
2158 | terminated ASCII string Destination. The Null-terminated concatenated ASCII\r | |
2159 | String is returned.\r | |
2160 | \r | |
2161 | If Destination is NULL, then ASSERT().\r | |
2162 | If Source is NULL, then ASSERT().\r | |
2163 | If PcdMaximumAsciiStringLength is not zero and Destination contains more than\r | |
2164 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2165 | then ASSERT().\r | |
2166 | If PcdMaximumAsciiStringLength is not zero and Source contains more than\r | |
2167 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2168 | then ASSERT().\r | |
2169 | If PcdMaximumAsciiStringLength is not zero and concatenating Destination and\r | |
2170 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
2171 | ASCII characters, then ASSERT().\r | |
2172 | \r | |
af2dc6a7 | 2173 | @param Destination The pointer to a Null-terminated ASCII string.\r |
2174 | @param Source The pointer to a Null-terminated ASCII string.\r | |
ac644614 | 2175 | \r |
2176 | @return Destination\r | |
2177 | \r | |
2178 | **/\r | |
2179 | CHAR8 *\r | |
2180 | EFIAPI\r | |
2181 | AsciiStrCat (\r | |
2182 | IN OUT CHAR8 *Destination,\r | |
2183 | IN CONST CHAR8 *Source\r | |
2184 | );\r | |
2185 | \r | |
2186 | \r | |
2187 | /**\r | |
ae591c14 | 2188 | [ATTENTION] This function is deprecated for security reason.\r |
1bb390f1 | 2189 | \r |
17f695ed | 2190 | Concatenates up to a specified length one Null-terminated ASCII string to \r |
2191 | the end of another Null-terminated ASCII string, and returns the \r | |
2192 | concatenated ASCII string.\r | |
ac644614 | 2193 | \r |
2194 | This function concatenates two Null-terminated ASCII strings. The contents\r | |
2195 | of Null-terminated ASCII string Source are concatenated to the end of Null-\r | |
2196 | terminated ASCII string Destination, and Destination is returned. At most,\r | |
2197 | Length ASCII characters are concatenated from Source to the end of\r | |
2198 | Destination, and Destination is always Null-terminated. If Length is 0, then\r | |
2199 | Destination is returned unmodified. If Source and Destination overlap, then\r | |
2200 | the results are undefined.\r | |
2201 | \r | |
2202 | If Length > 0 and Destination is NULL, then ASSERT().\r | |
2203 | If Length > 0 and Source is NULL, then ASSERT().\r | |
2204 | If Source and Destination overlap, then ASSERT().\r | |
50c247fd | 2205 | If PcdMaximumAsciiStringLength is not zero, and Length is greater than\r |
2206 | PcdMaximumAsciiStringLength, then ASSERT().\r | |
ac644614 | 2207 | If PcdMaximumAsciiStringLength is not zero, and Destination contains more than\r |
50c247fd | 2208 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 2209 | then ASSERT().\r |
2210 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
50c247fd | 2211 | PcdMaximumAsciiStringLength ASCII characters, not including the Null-terminator,\r |
ac644614 | 2212 | then ASSERT().\r |
2213 | If PcdMaximumAsciiStringLength is not zero, and concatenating Destination and\r | |
2214 | Source results in a ASCII string with more than PcdMaximumAsciiStringLength\r | |
50c247fd | 2215 | ASCII characters, not including the Null-terminator, then ASSERT().\r |
ac644614 | 2216 | \r |
af2dc6a7 | 2217 | @param Destination The pointer to a Null-terminated ASCII string.\r |
2218 | @param Source The pointer to a Null-terminated ASCII string.\r | |
2219 | @param Length The maximum number of ASCII characters to concatenate from\r | |
ac644614 | 2220 | Source.\r |
2221 | \r | |
2222 | @return Destination\r | |
2223 | \r | |
2224 | **/\r | |
2225 | CHAR8 *\r | |
2226 | EFIAPI\r | |
2227 | AsciiStrnCat (\r | |
2228 | IN OUT CHAR8 *Destination,\r | |
2229 | IN CONST CHAR8 *Source,\r | |
2230 | IN UINTN Length\r | |
2231 | );\r | |
1bb390f1 | 2232 | #endif\r |
ac644614 | 2233 | \r |
2234 | /**\r | |
9aa049d9 | 2235 | Returns the first occurrence of a Null-terminated ASCII sub-string\r |
ac644614 | 2236 | in a Null-terminated ASCII string.\r |
2237 | \r | |
2238 | This function scans the contents of the ASCII string specified by String\r | |
2239 | and returns the first occurrence of SearchString. If SearchString is not\r | |
2240 | found in String, then NULL is returned. If the length of SearchString is zero,\r | |
2241 | then String is returned.\r | |
2242 | \r | |
2243 | If String is NULL, then ASSERT().\r | |
2244 | If SearchString is NULL, then ASSERT().\r | |
2245 | \r | |
2246 | If PcdMaximumAsciiStringLength is not zero, and SearchString or\r | |
2247 | String contains more than PcdMaximumAsciiStringLength Unicode characters\r | |
2248 | not including the Null-terminator, then ASSERT().\r | |
2249 | \r | |
af2dc6a7 | 2250 | @param String The pointer to a Null-terminated ASCII string.\r |
2251 | @param SearchString The pointer to a Null-terminated ASCII string to search for.\r | |
ac644614 | 2252 | \r |
2253 | @retval NULL If the SearchString does not appear in String.\r | |
17f695ed | 2254 | @retval others If there is a match return the first occurrence of SearchingString.\r |
9aa049d9 | 2255 | If the length of SearchString is zero,return String.\r |
ac644614 | 2256 | \r |
2257 | **/\r | |
2258 | CHAR8 *\r | |
2259 | EFIAPI\r | |
2260 | AsciiStrStr (\r | |
17f695ed | 2261 | IN CONST CHAR8 *String,\r |
2262 | IN CONST CHAR8 *SearchString\r | |
ac644614 | 2263 | );\r |
2264 | \r | |
2265 | \r | |
2266 | /**\r | |
2267 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
2268 | UINTN.\r | |
2269 | \r | |
2270 | This function returns a value of type UINTN by interpreting the contents\r | |
2271 | of the ASCII string String as a decimal number. The format of the input\r | |
2272 | ASCII string String is:\r | |
2273 | \r | |
2274 | [spaces] [decimal digits].\r | |
2275 | \r | |
2276 | The valid decimal digit character is in the range [0-9]. The function will\r | |
2277 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
2278 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
2279 | function stops at the first character that is a not a valid decimal character or\r | |
2280 | Null-terminator, whichever on comes first.\r | |
2281 | \r | |
2282 | If String has only pad spaces, then 0 is returned.\r | |
2283 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
2284 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 2285 | UINTN, then MAX_UINTN is returned.\r |
ac644614 | 2286 | If String is NULL, then ASSERT().\r |
2287 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
2288 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2289 | then ASSERT().\r | |
2290 | \r | |
af2dc6a7 | 2291 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2292 | \r |
af2dc6a7 | 2293 | @retval The value translated from String.\r |
ac644614 | 2294 | \r |
2295 | **/\r | |
2296 | UINTN\r | |
2297 | EFIAPI\r | |
2298 | AsciiStrDecimalToUintn (\r | |
2299 | IN CONST CHAR8 *String\r | |
2300 | );\r | |
2301 | \r | |
2302 | \r | |
2303 | /**\r | |
2304 | Convert a Null-terminated ASCII decimal string to a value of type\r | |
2305 | UINT64.\r | |
2306 | \r | |
2307 | This function returns a value of type UINT64 by interpreting the contents\r | |
2308 | of the ASCII string String as a decimal number. The format of the input\r | |
2309 | ASCII string String is:\r | |
2310 | \r | |
2311 | [spaces] [decimal digits].\r | |
2312 | \r | |
2313 | The valid decimal digit character is in the range [0-9]. The function will\r | |
2314 | ignore the pad space, which includes spaces or tab characters, before the digits.\r | |
2315 | The running zero in the beginning of [decimal digits] will be ignored. Then, the\r | |
2316 | function stops at the first character that is a not a valid decimal character or\r | |
2317 | Null-terminator, whichever on comes first.\r | |
2318 | \r | |
2319 | If String has only pad spaces, then 0 is returned.\r | |
2320 | If String has no pad spaces or valid decimal digits, then 0 is returned.\r | |
2321 | If the number represented by String overflows according to the range defined by\r | |
ea2e0921 | 2322 | UINT64, then MAX_UINT64 is returned.\r |
ac644614 | 2323 | If String is NULL, then ASSERT().\r |
2324 | If PcdMaximumAsciiStringLength is not zero, and String contains more than\r | |
2325 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2326 | then ASSERT().\r | |
2327 | \r | |
af2dc6a7 | 2328 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2329 | \r |
38bbd3d9 | 2330 | @retval Value translated from String.\r |
ac644614 | 2331 | \r |
2332 | **/\r | |
2333 | UINT64\r | |
2334 | EFIAPI\r | |
2335 | AsciiStrDecimalToUint64 (\r | |
17f695ed | 2336 | IN CONST CHAR8 *String\r |
ac644614 | 2337 | );\r |
2338 | \r | |
2339 | \r | |
2340 | /**\r | |
2341 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINTN.\r | |
2342 | \r | |
2343 | This function returns a value of type UINTN by interpreting the contents of\r | |
2344 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
2345 | string String is:\r | |
2346 | \r | |
2347 | [spaces][zeros][x][hexadecimal digits].\r | |
2348 | \r | |
2349 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
2350 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
2351 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
2352 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
2353 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
2354 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
2355 | digit. Then, the function stops at the first character that is a not a valid\r | |
2356 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
2357 | \r | |
2358 | If String has only pad spaces, then 0 is returned.\r | |
2359 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
2360 | 0 is returned.\r | |
2361 | \r | |
2362 | If the number represented by String overflows according to the range defined by UINTN,\r | |
ea2e0921 | 2363 | then MAX_UINTN is returned.\r |
ac644614 | 2364 | If String is NULL, then ASSERT().\r |
2365 | If PcdMaximumAsciiStringLength is not zero,\r | |
2366 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
2367 | the Null-terminator, then ASSERT().\r | |
2368 | \r | |
af2dc6a7 | 2369 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2370 | \r |
38bbd3d9 | 2371 | @retval Value translated from String.\r |
ac644614 | 2372 | \r |
2373 | **/\r | |
2374 | UINTN\r | |
2375 | EFIAPI\r | |
2376 | AsciiStrHexToUintn (\r | |
17f695ed | 2377 | IN CONST CHAR8 *String\r |
ac644614 | 2378 | );\r |
2379 | \r | |
2380 | \r | |
2381 | /**\r | |
2382 | Convert a Null-terminated ASCII hexadecimal string to a value of type UINT64.\r | |
2383 | \r | |
2384 | This function returns a value of type UINT64 by interpreting the contents of\r | |
2385 | the ASCII string String as a hexadecimal number. The format of the input ASCII\r | |
2386 | string String is:\r | |
2387 | \r | |
2388 | [spaces][zeros][x][hexadecimal digits].\r | |
2389 | \r | |
2390 | The valid hexadecimal digit character is in the range [0-9], [a-f] and [A-F].\r | |
2391 | The prefix "0x" is optional. Both "x" and "X" is allowed in "0x" prefix. If "x"\r | |
2392 | appears in the input string, it must be prefixed with at least one 0. The function\r | |
2393 | will ignore the pad space, which includes spaces or tab characters, before [zeros],\r | |
2394 | [x] or [hexadecimal digits]. The running zero before [x] or [hexadecimal digits]\r | |
2395 | will be ignored. Then, the decoding starts after [x] or the first valid hexadecimal\r | |
2396 | digit. Then, the function stops at the first character that is a not a valid\r | |
2397 | hexadecimal character or Null-terminator, whichever on comes first.\r | |
2398 | \r | |
2399 | If String has only pad spaces, then 0 is returned.\r | |
2400 | If String has no leading pad spaces, leading zeros or valid hexadecimal digits, then\r | |
2401 | 0 is returned.\r | |
2402 | \r | |
2403 | If the number represented by String overflows according to the range defined by UINT64,\r | |
ea2e0921 | 2404 | then MAX_UINT64 is returned.\r |
ac644614 | 2405 | If String is NULL, then ASSERT().\r |
2406 | If PcdMaximumAsciiStringLength is not zero,\r | |
2407 | and String contains more than PcdMaximumAsciiStringLength ASCII characters not including\r | |
2408 | the Null-terminator, then ASSERT().\r | |
2409 | \r | |
af2dc6a7 | 2410 | @param String The pointer to a Null-terminated ASCII string.\r |
ac644614 | 2411 | \r |
38bbd3d9 | 2412 | @retval Value translated from String.\r |
ac644614 | 2413 | \r |
2414 | **/\r | |
2415 | UINT64\r | |
2416 | EFIAPI\r | |
2417 | AsciiStrHexToUint64 (\r | |
17f695ed | 2418 | IN CONST CHAR8 *String\r |
ac644614 | 2419 | );\r |
2420 | \r | |
415aa2f1 | 2421 | #ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r |
ac644614 | 2422 | \r |
2423 | /**\r | |
415aa2f1 SZ |
2424 | [ATTENTION] This function is deprecated for security reason.\r |
2425 | \r | |
ac644614 | 2426 | Convert one Null-terminated ASCII string to a Null-terminated\r |
2427 | Unicode string and returns the Unicode string.\r | |
2428 | \r | |
2429 | This function converts the contents of the ASCII string Source to the Unicode\r | |
2430 | string Destination, and returns Destination. The function terminates the\r | |
2431 | Unicode string Destination by appending a Null-terminator character at the end.\r | |
2432 | The caller is responsible to make sure Destination points to a buffer with size\r | |
2433 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
2434 | \r | |
2435 | If Destination is NULL, then ASSERT().\r | |
2436 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2437 | If Source is NULL, then ASSERT().\r | |
2438 | If Source and Destination overlap, then ASSERT().\r | |
2439 | If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r | |
2440 | PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r | |
2441 | then ASSERT().\r | |
2442 | If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r | |
2443 | PcdMaximumUnicodeStringLength ASCII characters not including the\r | |
2444 | Null-terminator, then ASSERT().\r | |
2445 | \r | |
af2dc6a7 | 2446 | @param Source The pointer to a Null-terminated ASCII string.\r |
2447 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
ac644614 | 2448 | \r |
9aa049d9 | 2449 | @return Destination.\r |
ac644614 | 2450 | \r |
2451 | **/\r | |
2452 | CHAR16 *\r | |
2453 | EFIAPI\r | |
2454 | AsciiStrToUnicodeStr (\r | |
17f695ed | 2455 | IN CONST CHAR8 *Source,\r |
2456 | OUT CHAR16 *Destination\r | |
ac644614 | 2457 | );\r |
2458 | \r | |
415aa2f1 SZ |
2459 | #endif\r |
2460 | \r | |
3ab41b7a JY |
2461 | /**\r |
2462 | Convert one Null-terminated ASCII string to a Null-terminated\r | |
2463 | Unicode string.\r | |
2464 | \r | |
2465 | This function is similar to StrCpyS.\r | |
2466 | \r | |
2467 | This function converts the contents of the ASCII string Source to the Unicode\r | |
2468 | string Destination. The function terminates the Unicode string Destination by\r | |
2469 | appending a Null-terminator character at the end.\r | |
2470 | \r | |
2471 | The caller is responsible to make sure Destination points to a buffer with size\r | |
2472 | equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r | |
2473 | \r | |
2474 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2475 | If an error would be returned, then the function will also ASSERT().\r | |
2476 | \r | |
2477 | If an error is returned, then the Destination is unmodified.\r | |
2478 | \r | |
2479 | @param Source The pointer to a Null-terminated ASCII string.\r | |
2480 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2481 | @param DestMax The maximum number of Destination Unicode\r | |
2482 | char, including terminating null char.\r | |
2483 | \r | |
2484 | @retval RETURN_SUCCESS String is converted.\r | |
2485 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r | |
2486 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2487 | If Source is NULL.\r | |
2488 | If PcdMaximumUnicodeStringLength is not zero,\r | |
2489 | and DestMax is greater than\r | |
2490 | PcdMaximumUnicodeStringLength.\r | |
2491 | If PcdMaximumAsciiStringLength is not zero,\r | |
2492 | and DestMax is greater than\r | |
2493 | PcdMaximumAsciiStringLength.\r | |
2494 | If DestMax is 0.\r | |
2495 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2496 | \r | |
2497 | **/\r | |
2498 | RETURN_STATUS\r | |
2499 | EFIAPI\r | |
2500 | AsciiStrToUnicodeStrS (\r | |
2501 | IN CONST CHAR8 *Source,\r | |
2502 | OUT CHAR16 *Destination,\r | |
2503 | IN UINTN DestMax\r | |
2504 | );\r | |
ac644614 | 2505 | \r |
02263214 HW |
2506 | /**\r |
2507 | Convert not more than Length successive characters from a Null-terminated\r | |
2508 | Ascii string to a Null-terminated Unicode string. If no null char is copied\r | |
2509 | from Source, then Destination[Length] is always set to null.\r | |
2510 | \r | |
2511 | This function converts not more than Length successive characters from the\r | |
2512 | Ascii string Source to the Unicode string Destination. The function\r | |
2513 | terminates the Unicode string Destination by appending a Null-terminator\r | |
2514 | character at the end.\r | |
2515 | \r | |
2516 | The caller is responsible to make sure Destination points to a buffer with\r | |
2517 | size not smaller than\r | |
2518 | ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r | |
2519 | \r | |
2520 | If Destination is not aligned on a 16-bit boundary, then ASSERT().\r | |
2521 | If an error would be returned, then the function will also ASSERT().\r | |
2522 | \r | |
2523 | If an error is returned, then Destination and DestinationLength are\r | |
2524 | unmodified.\r | |
2525 | \r | |
2526 | @param Source The pointer to a Null-terminated Ascii string.\r | |
2527 | @param Length The maximum number of Ascii characters to convert.\r | |
2528 | @param Destination The pointer to a Null-terminated Unicode string.\r | |
2529 | @param DestMax The maximum number of Destination Unicode char,\r | |
2530 | including terminating null char.\r | |
2531 | @param DestinationLength The number of Ascii characters converted.\r | |
2532 | \r | |
2533 | @retval RETURN_SUCCESS String is converted.\r | |
2534 | @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r | |
2535 | If Source is NULL.\r | |
2536 | If DestinationLength is NULL.\r | |
2537 | If PcdMaximumUnicodeStringLength is not\r | |
2538 | zero, and Length or DestMax is greater than\r | |
2539 | PcdMaximumUnicodeStringLength.\r | |
2540 | If PcdMaximumAsciiStringLength is not zero,\r | |
2541 | and Length or DestMax is greater than\r | |
2542 | PcdMaximumAsciiStringLength.\r | |
2543 | If DestMax is 0.\r | |
2544 | @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r | |
2545 | MIN(AsciiStrLen(Source), Length).\r | |
2546 | @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r | |
2547 | \r | |
2548 | **/\r | |
2549 | RETURN_STATUS\r | |
2550 | EFIAPI\r | |
2551 | AsciiStrnToUnicodeStrS (\r | |
2552 | IN CONST CHAR8 *Source,\r | |
2553 | IN UINTN Length,\r | |
2554 | OUT CHAR16 *Destination,\r | |
2555 | IN UINTN DestMax,\r | |
2556 | OUT UINTN *DestinationLength\r | |
2557 | );\r | |
2558 | \r | |
ac644614 | 2559 | /**\r |
2560 | Converts an 8-bit value to an 8-bit BCD value.\r | |
2561 | \r | |
2562 | Converts the 8-bit value specified by Value to BCD. The BCD value is\r | |
2563 | returned.\r | |
2564 | \r | |
2565 | If Value >= 100, then ASSERT().\r | |
2566 | \r | |
2567 | @param Value The 8-bit value to convert to BCD. Range 0..99.\r | |
2568 | \r | |
9aa049d9 | 2569 | @return The BCD value.\r |
ac644614 | 2570 | \r |
2571 | **/\r | |
2572 | UINT8\r | |
2573 | EFIAPI\r | |
2574 | DecimalToBcd8 (\r | |
2575 | IN UINT8 Value\r | |
2576 | );\r | |
2577 | \r | |
2578 | \r | |
2579 | /**\r | |
2580 | Converts an 8-bit BCD value to an 8-bit value.\r | |
2581 | \r | |
2582 | Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r | |
2583 | value is returned.\r | |
2584 | \r | |
2585 | If Value >= 0xA0, then ASSERT().\r | |
2586 | If (Value & 0x0F) >= 0x0A, then ASSERT().\r | |
2587 | \r | |
2588 | @param Value The 8-bit BCD value to convert to an 8-bit value.\r | |
2589 | \r | |
2590 | @return The 8-bit value is returned.\r | |
2591 | \r | |
2592 | **/\r | |
2593 | UINT8\r | |
2594 | EFIAPI\r | |
2595 | BcdToDecimal8 (\r | |
2596 | IN UINT8 Value\r | |
2597 | );\r | |
2598 | \r | |
ae591c14 DM |
2599 | //\r |
2600 | // File Path Manipulation Functions\r | |
2601 | //\r | |
2602 | \r | |
2603 | /**\r | |
6a623094 | 2604 | Removes the last directory or file entry in a path.\r |
ae591c14 DM |
2605 | \r |
2606 | @param[in, out] Path The pointer to the path to modify.\r | |
2607 | \r | |
2608 | @retval FALSE Nothing was found to remove.\r | |
2609 | @retval TRUE A directory or file was removed.\r | |
2610 | **/\r | |
2611 | BOOLEAN\r | |
2612 | EFIAPI\r | |
2613 | PathRemoveLastItem(\r | |
2614 | IN OUT CHAR16 *Path\r | |
2615 | );\r | |
2616 | \r | |
2617 | /**\r | |
2618 | Function to clean up paths.\r | |
2619 | - Single periods in the path are removed.\r | |
2620 | - Double periods in the path are removed along with a single parent directory.\r | |
2621 | - Forward slashes L'/' are converted to backward slashes L'\'.\r | |
2622 | \r | |
2623 | This will be done inline and the existing buffer may be larger than required\r | |
2624 | upon completion.\r | |
2625 | \r | |
2626 | @param[in] Path The pointer to the string containing the path.\r | |
2627 | \r | |
00b7cc0f | 2628 | @return Returns Path, otherwise returns NULL to indicate that an error has occurred.\r |
ae591c14 DM |
2629 | **/\r |
2630 | CHAR16*\r | |
2631 | EFIAPI\r | |
2632 | PathCleanUpDirectories(\r | |
2633 | IN CHAR16 *Path\r | |
909ac47b | 2634 | );\r |
ac644614 | 2635 | \r |
2636 | //\r | |
2637 | // Linked List Functions and Macros\r | |
2638 | //\r | |
2639 | \r | |
2640 | /**\r | |
2641 | Initializes the head node of a doubly linked list that is declared as a\r | |
2642 | global variable in a module.\r | |
2643 | \r | |
2644 | Initializes the forward and backward links of a new linked list. After\r | |
2645 | initializing a linked list with this macro, the other linked list functions\r | |
2646 | may be used to add and remove nodes from the linked list. This macro results\r | |
2647 | in smaller executables by initializing the linked list in the data section,\r | |
2648 | instead if calling the InitializeListHead() function to perform the\r | |
2649 | equivalent operation.\r | |
2650 | \r | |
77f863ee | 2651 | @param ListHead The head note of a list to initialize.\r |
ac644614 | 2652 | \r |
2653 | **/\r | |
17f695ed | 2654 | #define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r |
ac644614 | 2655 | \r |
2656 | \r | |
2657 | /**\r | |
2658 | Initializes the head node of a doubly linked list, and returns the pointer to\r | |
2659 | the head node of the doubly linked list.\r | |
2660 | \r | |
2661 | Initializes the forward and backward links of a new linked list. After\r | |
2662 | initializing a linked list with this function, the other linked list\r | |
2663 | functions may be used to add and remove nodes from the linked list. It is up\r | |
2664 | to the caller of this function to allocate the memory for ListHead.\r | |
2665 | \r | |
2666 | If ListHead is NULL, then ASSERT().\r | |
2667 | \r | |
2668 | @param ListHead A pointer to the head node of a new doubly linked list.\r | |
2669 | \r | |
2670 | @return ListHead\r | |
2671 | \r | |
2672 | **/\r | |
2673 | LIST_ENTRY *\r | |
2674 | EFIAPI\r | |
2675 | InitializeListHead (\r | |
aa0583c7 | 2676 | IN OUT LIST_ENTRY *ListHead\r |
ac644614 | 2677 | );\r |
2678 | \r | |
2679 | \r | |
2680 | /**\r | |
2681 | Adds a node to the beginning of a doubly linked list, and returns the pointer\r | |
2682 | to the head node of the doubly linked list.\r | |
2683 | \r | |
2684 | Adds the node Entry at the beginning of the doubly linked list denoted by\r | |
2685 | ListHead, and returns ListHead.\r | |
2686 | \r | |
2687 | If ListHead is NULL, then ASSERT().\r | |
2688 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 2689 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
2690 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2691 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 2692 | of nodes in ListHead, including the ListHead node, is greater than or\r |
2693 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2694 | \r | |
2695 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2696 | @param Entry A pointer to a node that is to be inserted at the beginning\r | |
2697 | of a doubly linked list.\r | |
2698 | \r | |
2699 | @return ListHead\r | |
2700 | \r | |
2701 | **/\r | |
2702 | LIST_ENTRY *\r | |
2703 | EFIAPI\r | |
2704 | InsertHeadList (\r | |
aa0583c7 | 2705 | IN OUT LIST_ENTRY *ListHead,\r |
2706 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 2707 | );\r |
2708 | \r | |
2709 | \r | |
2710 | /**\r | |
2711 | Adds a node to the end of a doubly linked list, and returns the pointer to\r | |
2712 | the head node of the doubly linked list.\r | |
2713 | \r | |
2714 | Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r | |
2715 | and returns ListHead.\r | |
2716 | \r | |
2717 | If ListHead is NULL, then ASSERT().\r | |
2718 | If Entry is NULL, then ASSERT().\r | |
17f695ed | 2719 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
2720 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2721 | If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r |
ac644614 | 2722 | of nodes in ListHead, including the ListHead node, is greater than or\r |
2723 | equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2724 | \r | |
2725 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2726 | @param Entry A pointer to a node that is to be added at the end of the\r | |
2727 | doubly linked list.\r | |
2728 | \r | |
2729 | @return ListHead\r | |
2730 | \r | |
2731 | **/\r | |
2732 | LIST_ENTRY *\r | |
2733 | EFIAPI\r | |
2734 | InsertTailList (\r | |
aa0583c7 | 2735 | IN OUT LIST_ENTRY *ListHead,\r |
2736 | IN OUT LIST_ENTRY *Entry\r | |
ac644614 | 2737 | );\r |
2738 | \r | |
2739 | \r | |
2740 | /**\r | |
2741 | Retrieves the first node of a doubly linked list.\r | |
2742 | \r | |
17f695ed | 2743 | Returns the first node of a doubly linked list. List must have been \r |
2744 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r | |
2745 | If List is empty, then List is returned.\r | |
ac644614 | 2746 | \r |
2747 | If List is NULL, then ASSERT().\r | |
17f695ed | 2748 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
2749 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2750 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2751 | in List, including the List node, is greater than or equal to\r |
2752 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2753 | \r | |
2754 | @param List A pointer to the head node of a doubly linked list.\r | |
2755 | \r | |
2756 | @return The first node of a doubly linked list.\r | |
e01a125f | 2757 | @retval List The list is empty.\r |
ac644614 | 2758 | \r |
2759 | **/\r | |
2760 | LIST_ENTRY *\r | |
2761 | EFIAPI\r | |
2762 | GetFirstNode (\r | |
2763 | IN CONST LIST_ENTRY *List\r | |
2764 | );\r | |
2765 | \r | |
2766 | \r | |
2767 | /**\r | |
2768 | Retrieves the next node of a doubly linked list.\r | |
2769 | \r | |
17f695ed | 2770 | Returns the node of a doubly linked list that follows Node. \r |
2771 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r | |
2772 | or InitializeListHead(). If List is empty, then List is returned.\r | |
ac644614 | 2773 | \r |
2774 | If List is NULL, then ASSERT().\r | |
2775 | If Node is NULL, then ASSERT().\r | |
17f695ed | 2776 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
2777 | InitializeListHead(), then ASSERT().\r | |
a71865b1 LG |
2778 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
2779 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
1081f624 | 2780 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 2781 | \r |
2782 | @param List A pointer to the head node of a doubly linked list.\r | |
2783 | @param Node A pointer to a node in the doubly linked list.\r | |
2784 | \r | |
af2dc6a7 | 2785 | @return The pointer to the next node if one exists. Otherwise List is returned.\r |
ac644614 | 2786 | \r |
2787 | **/\r | |
2788 | LIST_ENTRY *\r | |
2789 | EFIAPI\r | |
2790 | GetNextNode (\r | |
2791 | IN CONST LIST_ENTRY *List,\r | |
2792 | IN CONST LIST_ENTRY *Node\r | |
2793 | );\r | |
2794 | \r | |
cbca8de5 | 2795 | \r |
2796 | /**\r | |
2797 | Retrieves the previous node of a doubly linked list.\r | |
2798 | \r | |
2799 | Returns the node of a doubly linked list that precedes Node. \r | |
2800 | List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r | |
2801 | or InitializeListHead(). If List is empty, then List is returned.\r | |
2802 | \r | |
2803 | If List is NULL, then ASSERT().\r | |
2804 | If Node is NULL, then ASSERT().\r | |
2805 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r | |
2806 | InitializeListHead(), then ASSERT().\r | |
a71865b1 LG |
2807 | If PcdMaximumLinkedListLength is not zero, and List contains more than\r |
2808 | PcdMaximumLinkedListLength nodes, then ASSERT().\r | |
cbca8de5 | 2809 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
2810 | \r | |
2811 | @param List A pointer to the head node of a doubly linked list.\r | |
2812 | @param Node A pointer to a node in the doubly linked list.\r | |
2813 | \r | |
af2dc6a7 | 2814 | @return The pointer to the previous node if one exists. Otherwise List is returned.\r |
cbca8de5 | 2815 | \r |
2816 | **/\r | |
2817 | LIST_ENTRY *\r | |
2818 | EFIAPI\r | |
2819 | GetPreviousNode (\r | |
2820 | IN CONST LIST_ENTRY *List,\r | |
2821 | IN CONST LIST_ENTRY *Node\r | |
2822 | );\r | |
ac644614 | 2823 | \r |
cbca8de5 | 2824 | \r |
ac644614 | 2825 | /**\r |
2826 | Checks to see if a doubly linked list is empty or not.\r | |
2827 | \r | |
2828 | Checks to see if the doubly linked list is empty. If the linked list contains\r | |
2829 | zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r | |
2830 | \r | |
2831 | If ListHead is NULL, then ASSERT().\r | |
17f695ed | 2832 | If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r |
2833 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2834 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2835 | in List, including the List node, is greater than or equal to\r |
2836 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2837 | \r | |
2838 | @param ListHead A pointer to the head node of a doubly linked list.\r | |
2839 | \r | |
2840 | @retval TRUE The linked list is empty.\r | |
2841 | @retval FALSE The linked list is not empty.\r | |
2842 | \r | |
2843 | **/\r | |
2844 | BOOLEAN\r | |
2845 | EFIAPI\r | |
2846 | IsListEmpty (\r | |
2847 | IN CONST LIST_ENTRY *ListHead\r | |
2848 | );\r | |
2849 | \r | |
2850 | \r | |
2851 | /**\r | |
aa0583c7 | 2852 | Determines if a node in a doubly linked list is the head node of a the same\r |
2853 | doubly linked list. This function is typically used to terminate a loop that\r | |
2854 | traverses all the nodes in a doubly linked list starting with the head node.\r | |
ac644614 | 2855 | \r |
aa0583c7 | 2856 | Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r |
2857 | nodes in the doubly linked list specified by List. List must have been\r | |
17f695ed | 2858 | initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 2859 | \r |
2860 | If List is NULL, then ASSERT().\r | |
2861 | If Node is NULL, then ASSERT().\r | |
17f695ed | 2862 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), \r |
2863 | then ASSERT().\r | |
a71865b1 | 2864 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2865 | in List, including the List node, is greater than or equal to\r |
2866 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 2867 | If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r |
2868 | to List, then ASSERT().\r | |
ac644614 | 2869 | \r |
2870 | @param List A pointer to the head node of a doubly linked list.\r | |
2871 | @param Node A pointer to a node in the doubly linked list.\r | |
2872 | \r | |
1955808d LG |
2873 | @retval TRUE Node is the head of the doubly-linked list pointed by List.\r |
2874 | @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r | |
ac644614 | 2875 | \r |
2876 | **/\r | |
2877 | BOOLEAN\r | |
2878 | EFIAPI\r | |
2879 | IsNull (\r | |
2880 | IN CONST LIST_ENTRY *List,\r | |
2881 | IN CONST LIST_ENTRY *Node\r | |
2882 | );\r | |
2883 | \r | |
2884 | \r | |
2885 | /**\r | |
2886 | Determines if a node the last node in a doubly linked list.\r | |
2887 | \r | |
2888 | Returns TRUE if Node is the last node in the doubly linked list specified by\r | |
2889 | List. Otherwise, FALSE is returned. List must have been initialized with\r | |
17f695ed | 2890 | INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r |
ac644614 | 2891 | \r |
2892 | If List is NULL, then ASSERT().\r | |
2893 | If Node is NULL, then ASSERT().\r | |
17f695ed | 2894 | If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r |
2895 | InitializeListHead(), then ASSERT().\r | |
a71865b1 | 2896 | If PcdMaximumLinkedListLength is not zero, and the number of nodes\r |
ac644614 | 2897 | in List, including the List node, is greater than or equal to\r |
2898 | PcdMaximumLinkedListLength, then ASSERT().\r | |
1081f624 | 2899 | If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r |
ac644614 | 2900 | \r |
2901 | @param List A pointer to the head node of a doubly linked list.\r | |
2902 | @param Node A pointer to a node in the doubly linked list.\r | |
2903 | \r | |
2904 | @retval TRUE Node is the last node in the linked list.\r | |
2905 | @retval FALSE Node is not the last node in the linked list.\r | |
2906 | \r | |
2907 | **/\r | |
2908 | BOOLEAN\r | |
2909 | EFIAPI\r | |
2910 | IsNodeAtEnd (\r | |
2911 | IN CONST LIST_ENTRY *List,\r | |
2912 | IN CONST LIST_ENTRY *Node\r | |
2913 | );\r | |
2914 | \r | |
2915 | \r | |
2916 | /**\r | |
2917 | Swaps the location of two nodes in a doubly linked list, and returns the\r | |
2918 | first node after the swap.\r | |
2919 | \r | |
2920 | If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r | |
2921 | Otherwise, the location of the FirstEntry node is swapped with the location\r | |
2922 | of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r | |
2923 | same double linked list as FirstEntry and that double linked list must have\r | |
17f695ed | 2924 | been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). \r |
2925 | SecondEntry is returned after the nodes are swapped.\r | |
ac644614 | 2926 | \r |
2927 | If FirstEntry is NULL, then ASSERT().\r | |
2928 | If SecondEntry is NULL, then ASSERT().\r | |
1081f624 | 2929 | If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r |
2930 | same linked list, then ASSERT().\r | |
ac644614 | 2931 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r |
2932 | linked list containing the FirstEntry and SecondEntry nodes, including\r | |
2933 | the FirstEntry and SecondEntry nodes, is greater than or equal to\r | |
2934 | PcdMaximumLinkedListLength, then ASSERT().\r | |
2935 | \r | |
2936 | @param FirstEntry A pointer to a node in a linked list.\r | |
2937 | @param SecondEntry A pointer to another node in the same linked list.\r | |
38bbd3d9 | 2938 | \r |
9aa049d9 | 2939 | @return SecondEntry.\r |
ac644614 | 2940 | \r |
2941 | **/\r | |
2942 | LIST_ENTRY *\r | |
2943 | EFIAPI\r | |
2944 | SwapListEntries (\r | |
aa0583c7 | 2945 | IN OUT LIST_ENTRY *FirstEntry,\r |
2946 | IN OUT LIST_ENTRY *SecondEntry\r | |
ac644614 | 2947 | );\r |
2948 | \r | |
2949 | \r | |
2950 | /**\r | |
2951 | Removes a node from a doubly linked list, and returns the node that follows\r | |
2952 | the removed node.\r | |
2953 | \r | |
2954 | Removes the node Entry from a doubly linked list. It is up to the caller of\r | |
2955 | this function to release the memory used by this node if that is required. On\r | |
2956 | exit, the node following Entry in the doubly linked list is returned. If\r | |
2957 | Entry is the only node in the linked list, then the head node of the linked\r | |
2958 | list is returned.\r | |
2959 | \r | |
2960 | If Entry is NULL, then ASSERT().\r | |
2961 | If Entry is the head node of an empty list, then ASSERT().\r | |
2962 | If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r | |
2963 | linked list containing Entry, including the Entry node, is greater than\r | |
2964 | or equal to PcdMaximumLinkedListLength, then ASSERT().\r | |
2965 | \r | |
9aa049d9 | 2966 | @param Entry A pointer to a node in a linked list.\r |
ac644614 | 2967 | \r |
9aa049d9 | 2968 | @return Entry.\r |
ac644614 | 2969 | \r |
2970 | **/\r | |
2971 | LIST_ENTRY *\r | |
2972 | EFIAPI\r | |
2973 | RemoveEntryList (\r | |
2974 | IN CONST LIST_ENTRY *Entry\r | |
2975 | );\r | |
2976 | \r | |
2977 | //\r | |
2978 | // Math Services\r | |
2979 | //\r | |
2980 | \r | |
2981 | /**\r | |
2982 | Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r | |
2983 | with zeros. The shifted value is returned.\r | |
2984 | \r | |
2985 | This function shifts the 64-bit value Operand to the left by Count bits. The\r | |
2986 | low Count bits are set to zero. The shifted value is returned.\r | |
2987 | \r | |
2988 | If Count is greater than 63, then ASSERT().\r | |
2989 | \r | |
2990 | @param Operand The 64-bit operand to shift left.\r | |
2991 | @param Count The number of bits to shift left.\r | |
2992 | \r | |
9aa049d9 | 2993 | @return Operand << Count.\r |
ac644614 | 2994 | \r |
2995 | **/\r | |
2996 | UINT64\r | |
2997 | EFIAPI\r | |
2998 | LShiftU64 (\r | |
2999 | IN UINT64 Operand,\r | |
3000 | IN UINTN Count\r | |
3001 | );\r | |
3002 | \r | |
3003 | \r | |
3004 | /**\r | |
3005 | Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r | |
3006 | filled with zeros. The shifted value is returned.\r | |
3007 | \r | |
3008 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3009 | high Count bits are set to zero. The shifted value is returned.\r | |
3010 | \r | |
3011 | If Count is greater than 63, then ASSERT().\r | |
3012 | \r | |
3013 | @param Operand The 64-bit operand to shift right.\r | |
3014 | @param Count The number of bits to shift right.\r | |
3015 | \r | |
3016 | @return Operand >> Count\r | |
3017 | \r | |
3018 | **/\r | |
3019 | UINT64\r | |
3020 | EFIAPI\r | |
3021 | RShiftU64 (\r | |
3022 | IN UINT64 Operand,\r | |
3023 | IN UINTN Count\r | |
3024 | );\r | |
3025 | \r | |
3026 | \r | |
3027 | /**\r | |
3028 | Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r | |
3029 | with original integer's bit 63. The shifted value is returned.\r | |
3030 | \r | |
3031 | This function shifts the 64-bit value Operand to the right by Count bits. The\r | |
3032 | high Count bits are set to bit 63 of Operand. The shifted value is returned.\r | |
3033 | \r | |
3034 | If Count is greater than 63, then ASSERT().\r | |
3035 | \r | |
3036 | @param Operand The 64-bit operand to shift right.\r | |
3037 | @param Count The number of bits to shift right.\r | |
3038 | \r | |
3039 | @return Operand >> Count\r | |
3040 | \r | |
3041 | **/\r | |
3042 | UINT64\r | |
3043 | EFIAPI\r | |
3044 | ARShiftU64 (\r | |
3045 | IN UINT64 Operand,\r | |
3046 | IN UINTN Count\r | |
3047 | );\r | |
3048 | \r | |
3049 | \r | |
3050 | /**\r | |
3051 | Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r | |
3052 | with the high bits that were rotated.\r | |
3053 | \r | |
3054 | This function rotates the 32-bit value Operand to the left by Count bits. The\r | |
3055 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3056 | value is returned.\r | |
3057 | \r | |
3058 | If Count is greater than 31, then ASSERT().\r | |
3059 | \r | |
3060 | @param Operand The 32-bit operand to rotate left.\r | |
3061 | @param Count The number of bits to rotate left.\r | |
3062 | \r | |
17f695ed | 3063 | @return Operand << Count\r |
ac644614 | 3064 | \r |
3065 | **/\r | |
3066 | UINT32\r | |
3067 | EFIAPI\r | |
3068 | LRotU32 (\r | |
3069 | IN UINT32 Operand,\r | |
3070 | IN UINTN Count\r | |
3071 | );\r | |
3072 | \r | |
3073 | \r | |
3074 | /**\r | |
3075 | Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r | |
3076 | with the low bits that were rotated.\r | |
3077 | \r | |
3078 | This function rotates the 32-bit value Operand to the right by Count bits.\r | |
3079 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3080 | value is returned.\r | |
3081 | \r | |
3082 | If Count is greater than 31, then ASSERT().\r | |
3083 | \r | |
3084 | @param Operand The 32-bit operand to rotate right.\r | |
3085 | @param Count The number of bits to rotate right.\r | |
3086 | \r | |
2fe241a2 | 3087 | @return Operand >> Count\r |
ac644614 | 3088 | \r |
3089 | **/\r | |
3090 | UINT32\r | |
3091 | EFIAPI\r | |
3092 | RRotU32 (\r | |
3093 | IN UINT32 Operand,\r | |
3094 | IN UINTN Count\r | |
3095 | );\r | |
3096 | \r | |
3097 | \r | |
3098 | /**\r | |
3099 | Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r | |
3100 | with the high bits that were rotated.\r | |
3101 | \r | |
3102 | This function rotates the 64-bit value Operand to the left by Count bits. The\r | |
3103 | low Count bits are fill with the high Count bits of Operand. The rotated\r | |
3104 | value is returned.\r | |
3105 | \r | |
3106 | If Count is greater than 63, then ASSERT().\r | |
3107 | \r | |
3108 | @param Operand The 64-bit operand to rotate left.\r | |
3109 | @param Count The number of bits to rotate left.\r | |
3110 | \r | |
17f695ed | 3111 | @return Operand << Count\r |
ac644614 | 3112 | \r |
3113 | **/\r | |
3114 | UINT64\r | |
3115 | EFIAPI\r | |
3116 | LRotU64 (\r | |
3117 | IN UINT64 Operand,\r | |
3118 | IN UINTN Count\r | |
3119 | );\r | |
3120 | \r | |
3121 | \r | |
3122 | /**\r | |
3123 | Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r | |
3124 | with the high low bits that were rotated.\r | |
3125 | \r | |
3126 | This function rotates the 64-bit value Operand to the right by Count bits.\r | |
3127 | The high Count bits are fill with the low Count bits of Operand. The rotated\r | |
3128 | value is returned.\r | |
3129 | \r | |
3130 | If Count is greater than 63, then ASSERT().\r | |
3131 | \r | |
3132 | @param Operand The 64-bit operand to rotate right.\r | |
3133 | @param Count The number of bits to rotate right.\r | |
3134 | \r | |
17f695ed | 3135 | @return Operand >> Count\r |
ac644614 | 3136 | \r |
3137 | **/\r | |
3138 | UINT64\r | |
3139 | EFIAPI\r | |
3140 | RRotU64 (\r | |
3141 | IN UINT64 Operand,\r | |
3142 | IN UINTN Count\r | |
3143 | );\r | |
3144 | \r | |
3145 | \r | |
3146 | /**\r | |
3147 | Returns the bit position of the lowest bit set in a 32-bit value.\r | |
3148 | \r | |
3149 | This function computes the bit position of the lowest bit set in the 32-bit\r | |
3150 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3151 | Otherwise, a value between 0 and 31 is returned.\r | |
3152 | \r | |
3153 | @param Operand The 32-bit operand to evaluate.\r | |
3154 | \r | |
9aa049d9 | 3155 | @retval 0..31 The lowest bit set in Operand was found.\r |
17f695ed | 3156 | @retval -1 Operand is zero.\r |
ac644614 | 3157 | \r |
3158 | **/\r | |
3159 | INTN\r | |
3160 | EFIAPI\r | |
3161 | LowBitSet32 (\r | |
3162 | IN UINT32 Operand\r | |
3163 | );\r | |
3164 | \r | |
3165 | \r | |
3166 | /**\r | |
3167 | Returns the bit position of the lowest bit set in a 64-bit value.\r | |
3168 | \r | |
3169 | This function computes the bit position of the lowest bit set in the 64-bit\r | |
3170 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3171 | Otherwise, a value between 0 and 63 is returned.\r | |
3172 | \r | |
3173 | @param Operand The 64-bit operand to evaluate.\r | |
3174 | \r | |
9aa049d9 | 3175 | @retval 0..63 The lowest bit set in Operand was found.\r |
17f695ed | 3176 | @retval -1 Operand is zero.\r |
3177 | \r | |
ac644614 | 3178 | \r |
3179 | **/\r | |
3180 | INTN\r | |
3181 | EFIAPI\r | |
3182 | LowBitSet64 (\r | |
3183 | IN UINT64 Operand\r | |
3184 | );\r | |
3185 | \r | |
3186 | \r | |
3187 | /**\r | |
3188 | Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r | |
3189 | to log2(x).\r | |
3190 | \r | |
3191 | This function computes the bit position of the highest bit set in the 32-bit\r | |
3192 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3193 | Otherwise, a value between 0 and 31 is returned.\r | |
3194 | \r | |
3195 | @param Operand The 32-bit operand to evaluate.\r | |
3196 | \r | |
9aa049d9 | 3197 | @retval 0..31 Position of the highest bit set in Operand if found.\r |
17f695ed | 3198 | @retval -1 Operand is zero.\r |
ac644614 | 3199 | \r |
3200 | **/\r | |
3201 | INTN\r | |
3202 | EFIAPI\r | |
3203 | HighBitSet32 (\r | |
3204 | IN UINT32 Operand\r | |
3205 | );\r | |
3206 | \r | |
3207 | \r | |
3208 | /**\r | |
3209 | Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r | |
3210 | to log2(x).\r | |
3211 | \r | |
3212 | This function computes the bit position of the highest bit set in the 64-bit\r | |
3213 | value specified by Operand. If Operand is zero, then -1 is returned.\r | |
3214 | Otherwise, a value between 0 and 63 is returned.\r | |
3215 | \r | |
3216 | @param Operand The 64-bit operand to evaluate.\r | |
3217 | \r | |
9aa049d9 | 3218 | @retval 0..63 Position of the highest bit set in Operand if found.\r |
17f695ed | 3219 | @retval -1 Operand is zero.\r |
ac644614 | 3220 | \r |
3221 | **/\r | |
3222 | INTN\r | |
3223 | EFIAPI\r | |
3224 | HighBitSet64 (\r | |
3225 | IN UINT64 Operand\r | |
3226 | );\r | |
3227 | \r | |
3228 | \r | |
3229 | /**\r | |
3230 | Returns the value of the highest bit set in a 32-bit value. Equivalent to\r | |
17f695ed | 3231 | 1 << log2(x).\r |
ac644614 | 3232 | \r |
3233 | This function computes the value of the highest bit set in the 32-bit value\r | |
3234 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3235 | \r | |
3236 | @param Operand The 32-bit operand to evaluate.\r | |
3237 | \r | |
3238 | @return 1 << HighBitSet32(Operand)\r | |
3239 | @retval 0 Operand is zero.\r | |
3240 | \r | |
3241 | **/\r | |
3242 | UINT32\r | |
3243 | EFIAPI\r | |
3244 | GetPowerOfTwo32 (\r | |
3245 | IN UINT32 Operand\r | |
3246 | );\r | |
3247 | \r | |
3248 | \r | |
3249 | /**\r | |
3250 | Returns the value of the highest bit set in a 64-bit value. Equivalent to\r | |
17f695ed | 3251 | 1 << log2(x).\r |
ac644614 | 3252 | \r |
3253 | This function computes the value of the highest bit set in the 64-bit value\r | |
3254 | specified by Operand. If Operand is zero, then zero is returned.\r | |
3255 | \r | |
3256 | @param Operand The 64-bit operand to evaluate.\r | |
3257 | \r | |
3258 | @return 1 << HighBitSet64(Operand)\r | |
3259 | @retval 0 Operand is zero.\r | |
3260 | \r | |
3261 | **/\r | |
3262 | UINT64\r | |
3263 | EFIAPI\r | |
3264 | GetPowerOfTwo64 (\r | |
3265 | IN UINT64 Operand\r | |
3266 | );\r | |
3267 | \r | |
3268 | \r | |
3269 | /**\r | |
af2dc6a7 | 3270 | Switches the endianness of a 16-bit integer.\r |
ac644614 | 3271 | \r |
3272 | This function swaps the bytes in a 16-bit unsigned value to switch the value\r | |
3273 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3274 | returned.\r | |
3275 | \r | |
2a53dabf | 3276 | @param Value A 16-bit unsigned value.\r |
ac644614 | 3277 | \r |
efb23117 | 3278 | @return The byte swapped Value.\r |
ac644614 | 3279 | \r |
3280 | **/\r | |
3281 | UINT16\r | |
3282 | EFIAPI\r | |
3283 | SwapBytes16 (\r | |
3284 | IN UINT16 Value\r | |
3285 | );\r | |
3286 | \r | |
3287 | \r | |
3288 | /**\r | |
af2dc6a7 | 3289 | Switches the endianness of a 32-bit integer.\r |
ac644614 | 3290 | \r |
3291 | This function swaps the bytes in a 32-bit unsigned value to switch the value\r | |
3292 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3293 | returned.\r | |
3294 | \r | |
2a53dabf | 3295 | @param Value A 32-bit unsigned value.\r |
ac644614 | 3296 | \r |
efb23117 | 3297 | @return The byte swapped Value.\r |
ac644614 | 3298 | \r |
3299 | **/\r | |
3300 | UINT32\r | |
3301 | EFIAPI\r | |
3302 | SwapBytes32 (\r | |
3303 | IN UINT32 Value\r | |
3304 | );\r | |
3305 | \r | |
3306 | \r | |
3307 | /**\r | |
af2dc6a7 | 3308 | Switches the endianness of a 64-bit integer.\r |
ac644614 | 3309 | \r |
3310 | This function swaps the bytes in a 64-bit unsigned value to switch the value\r | |
3311 | from little endian to big endian or vice versa. The byte swapped value is\r | |
3312 | returned.\r | |
3313 | \r | |
2a53dabf | 3314 | @param Value A 64-bit unsigned value.\r |
ac644614 | 3315 | \r |
efb23117 | 3316 | @return The byte swapped Value.\r |
ac644614 | 3317 | \r |
3318 | **/\r | |
3319 | UINT64\r | |
3320 | EFIAPI\r | |
3321 | SwapBytes64 (\r | |
3322 | IN UINT64 Value\r | |
3323 | );\r | |
3324 | \r | |
3325 | \r | |
3326 | /**\r | |
3327 | Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r | |
3328 | generates a 64-bit unsigned result.\r | |
3329 | \r | |
3330 | This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r | |
3331 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3332 | bit unsigned result is returned.\r | |
3333 | \r | |
ac644614 | 3334 | @param Multiplicand A 64-bit unsigned value.\r |
3335 | @param Multiplier A 32-bit unsigned value.\r | |
3336 | \r | |
3337 | @return Multiplicand * Multiplier\r | |
3338 | \r | |
3339 | **/\r | |
3340 | UINT64\r | |
3341 | EFIAPI\r | |
3342 | MultU64x32 (\r | |
3343 | IN UINT64 Multiplicand,\r | |
3344 | IN UINT32 Multiplier\r | |
3345 | );\r | |
3346 | \r | |
3347 | \r | |
3348 | /**\r | |
3349 | Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r | |
3350 | generates a 64-bit unsigned result.\r | |
3351 | \r | |
3352 | This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r | |
3353 | unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r | |
3354 | bit unsigned result is returned.\r | |
3355 | \r | |
ac644614 | 3356 | @param Multiplicand A 64-bit unsigned value.\r |
3357 | @param Multiplier A 64-bit unsigned value.\r | |
3358 | \r | |
af2dc6a7 | 3359 | @return Multiplicand * Multiplier.\r |
ac644614 | 3360 | \r |
3361 | **/\r | |
3362 | UINT64\r | |
3363 | EFIAPI\r | |
3364 | MultU64x64 (\r | |
3365 | IN UINT64 Multiplicand,\r | |
3366 | IN UINT64 Multiplier\r | |
3367 | );\r | |
3368 | \r | |
3369 | \r | |
3370 | /**\r | |
3371 | Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3372 | 64-bit signed result.\r | |
3373 | \r | |
3374 | This function multiples the 64-bit signed value Multiplicand by the 64-bit\r | |
3375 | signed value Multiplier and generates a 64-bit signed result. This 64-bit\r | |
3376 | signed result is returned.\r | |
3377 | \r | |
ac644614 | 3378 | @param Multiplicand A 64-bit signed value.\r |
3379 | @param Multiplier A 64-bit signed value.\r | |
3380 | \r | |
3381 | @return Multiplicand * Multiplier\r | |
3382 | \r | |
3383 | **/\r | |
3384 | INT64\r | |
3385 | EFIAPI\r | |
3386 | MultS64x64 (\r | |
3387 | IN INT64 Multiplicand,\r | |
3388 | IN INT64 Multiplier\r | |
3389 | );\r | |
3390 | \r | |
3391 | \r | |
3392 | /**\r | |
3393 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3394 | a 64-bit unsigned result.\r | |
3395 | \r | |
3396 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3397 | unsigned value Divisor and generates a 64-bit unsigned quotient. This\r | |
3398 | function returns the 64-bit unsigned quotient.\r | |
3399 | \r | |
3400 | If Divisor is 0, then ASSERT().\r | |
3401 | \r | |
3402 | @param Dividend A 64-bit unsigned value.\r | |
3403 | @param Divisor A 32-bit unsigned value.\r | |
3404 | \r | |
af2dc6a7 | 3405 | @return Dividend / Divisor.\r |
ac644614 | 3406 | \r |
3407 | **/\r | |
3408 | UINT64\r | |
3409 | EFIAPI\r | |
3410 | DivU64x32 (\r | |
3411 | IN UINT64 Dividend,\r | |
3412 | IN UINT32 Divisor\r | |
3413 | );\r | |
3414 | \r | |
3415 | \r | |
3416 | /**\r | |
3417 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3418 | a 32-bit unsigned remainder.\r | |
3419 | \r | |
3420 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3421 | unsigned value Divisor and generates a 32-bit remainder. This function\r | |
3422 | returns the 32-bit unsigned remainder.\r | |
3423 | \r | |
3424 | If Divisor is 0, then ASSERT().\r | |
3425 | \r | |
3426 | @param Dividend A 64-bit unsigned value.\r | |
3427 | @param Divisor A 32-bit unsigned value.\r | |
3428 | \r | |
af2dc6a7 | 3429 | @return Dividend % Divisor.\r |
ac644614 | 3430 | \r |
3431 | **/\r | |
3432 | UINT32\r | |
3433 | EFIAPI\r | |
3434 | ModU64x32 (\r | |
3435 | IN UINT64 Dividend,\r | |
3436 | IN UINT32 Divisor\r | |
3437 | );\r | |
3438 | \r | |
3439 | \r | |
3440 | /**\r | |
3441 | Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r | |
3442 | a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r | |
3443 | \r | |
3444 | This function divides the 64-bit unsigned value Dividend by the 32-bit\r | |
3445 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3446 | is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r | |
3447 | This function returns the 64-bit unsigned quotient.\r | |
3448 | \r | |
3449 | If Divisor is 0, then ASSERT().\r | |
3450 | \r | |
3451 | @param Dividend A 64-bit unsigned value.\r | |
3452 | @param Divisor A 32-bit unsigned value.\r | |
3453 | @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r | |
3454 | optional and may be NULL.\r | |
3455 | \r | |
af2dc6a7 | 3456 | @return Dividend / Divisor.\r |
ac644614 | 3457 | \r |
3458 | **/\r | |
3459 | UINT64\r | |
3460 | EFIAPI\r | |
3461 | DivU64x32Remainder (\r | |
3462 | IN UINT64 Dividend,\r | |
3463 | IN UINT32 Divisor,\r | |
3464 | OUT UINT32 *Remainder OPTIONAL\r | |
3465 | );\r | |
3466 | \r | |
3467 | \r | |
3468 | /**\r | |
3469 | Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r | |
3470 | a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r | |
3471 | \r | |
3472 | This function divides the 64-bit unsigned value Dividend by the 64-bit\r | |
3473 | unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r | |
3474 | is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r | |
3475 | This function returns the 64-bit unsigned quotient.\r | |
3476 | \r | |
3477 | If Divisor is 0, then ASSERT().\r | |
3478 | \r | |
3479 | @param Dividend A 64-bit unsigned value.\r | |
3480 | @param Divisor A 64-bit unsigned value.\r | |
3481 | @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r | |
3482 | optional and may be NULL.\r | |
3483 | \r | |
af2dc6a7 | 3484 | @return Dividend / Divisor.\r |
ac644614 | 3485 | \r |
3486 | **/\r | |
3487 | UINT64\r | |
3488 | EFIAPI\r | |
3489 | DivU64x64Remainder (\r | |
3490 | IN UINT64 Dividend,\r | |
3491 | IN UINT64 Divisor,\r | |
3492 | OUT UINT64 *Remainder OPTIONAL\r | |
3493 | );\r | |
3494 | \r | |
3495 | \r | |
3496 | /**\r | |
3497 | Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r | |
3498 | 64-bit signed result and a optional 64-bit signed remainder.\r | |
3499 | \r | |
3500 | This function divides the 64-bit signed value Dividend by the 64-bit signed\r | |
3501 | value Divisor and generates a 64-bit signed quotient. If Remainder is not\r | |
3502 | NULL, then the 64-bit signed remainder is returned in Remainder. This\r | |
3503 | function returns the 64-bit signed quotient.\r | |
3504 | \r | |
9aa049d9 | 3505 | It is the caller's responsibility to not call this function with a Divisor of 0.\r |
17f695ed | 3506 | If Divisor is 0, then the quotient and remainder should be assumed to be \r |
3507 | the largest negative integer.\r | |
3508 | \r | |
ac644614 | 3509 | If Divisor is 0, then ASSERT().\r |
3510 | \r | |
3511 | @param Dividend A 64-bit signed value.\r | |
3512 | @param Divisor A 64-bit signed value.\r | |
3513 | @param Remainder A pointer to a 64-bit signed value. This parameter is\r | |
3514 | optional and may be NULL.\r | |
3515 | \r | |
af2dc6a7 | 3516 | @return Dividend / Divisor.\r |
ac644614 | 3517 | \r |
3518 | **/\r | |
3519 | INT64\r | |
3520 | EFIAPI\r | |
3521 | DivS64x64Remainder (\r | |
3522 | IN INT64 Dividend,\r | |
3523 | IN INT64 Divisor,\r | |
3524 | OUT INT64 *Remainder OPTIONAL\r | |
3525 | );\r | |
3526 | \r | |
3527 | \r | |
3528 | /**\r | |
3529 | Reads a 16-bit value from memory that may be unaligned.\r | |
3530 | \r | |
3531 | This function returns the 16-bit value pointed to by Buffer. The function\r | |
3532 | guarantees that the read operation does not produce an alignment fault.\r | |
3533 | \r | |
3534 | If the Buffer is NULL, then ASSERT().\r | |
3535 | \r | |
af2dc6a7 | 3536 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3537 | \r |
5385a579 | 3538 | @return The 16-bit value read from Buffer.\r |
ac644614 | 3539 | \r |
3540 | **/\r | |
3541 | UINT16\r | |
3542 | EFIAPI\r | |
3543 | ReadUnaligned16 (\r | |
5385a579 | 3544 | IN CONST UINT16 *Buffer\r |
ac644614 | 3545 | );\r |
3546 | \r | |
3547 | \r | |
3548 | /**\r | |
3549 | Writes a 16-bit value to memory that may be unaligned.\r | |
3550 | \r | |
3551 | This function writes the 16-bit value specified by Value to Buffer. Value is\r | |
3552 | returned. The function guarantees that the write operation does not produce\r | |
3553 | an alignment fault.\r | |
3554 | \r | |
3555 | If the Buffer is NULL, then ASSERT().\r | |
3556 | \r | |
af2dc6a7 | 3557 | @param Buffer The pointer to a 16-bit value that may be unaligned.\r |
ac644614 | 3558 | @param Value 16-bit value to write to Buffer.\r |
3559 | \r | |
5385a579 | 3560 | @return The 16-bit value to write to Buffer.\r |
ac644614 | 3561 | \r |
3562 | **/\r | |
3563 | UINT16\r | |
3564 | EFIAPI\r | |
3565 | WriteUnaligned16 (\r | |
5385a579 | 3566 | OUT UINT16 *Buffer,\r |
3567 | IN UINT16 Value\r | |
ac644614 | 3568 | );\r |
3569 | \r | |
3570 | \r | |
3571 | /**\r | |
3572 | Reads a 24-bit value from memory that may be unaligned.\r | |
3573 | \r | |
3574 | This function returns the 24-bit value pointed to by Buffer. The function\r | |
3575 | guarantees that the read operation does not produce an alignment fault.\r | |
3576 | \r | |
3577 | If the Buffer is NULL, then ASSERT().\r | |
3578 | \r | |
af2dc6a7 | 3579 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3580 | \r |
5385a579 | 3581 | @return The 24-bit value read from Buffer.\r |
ac644614 | 3582 | \r |
3583 | **/\r | |
3584 | UINT32\r | |
3585 | EFIAPI\r | |
3586 | ReadUnaligned24 (\r | |
5385a579 | 3587 | IN CONST UINT32 *Buffer\r |
ac644614 | 3588 | );\r |
3589 | \r | |
3590 | \r | |
3591 | /**\r | |
3592 | Writes a 24-bit value to memory that may be unaligned.\r | |
3593 | \r | |
3594 | This function writes the 24-bit value specified by Value to Buffer. Value is\r | |
3595 | returned. The function guarantees that the write operation does not produce\r | |
3596 | an alignment fault.\r | |
3597 | \r | |
3598 | If the Buffer is NULL, then ASSERT().\r | |
3599 | \r | |
af2dc6a7 | 3600 | @param Buffer The pointer to a 24-bit value that may be unaligned.\r |
ac644614 | 3601 | @param Value 24-bit value to write to Buffer.\r |
3602 | \r | |
5385a579 | 3603 | @return The 24-bit value to write to Buffer.\r |
ac644614 | 3604 | \r |
3605 | **/\r | |
3606 | UINT32\r | |
3607 | EFIAPI\r | |
3608 | WriteUnaligned24 (\r | |
5385a579 | 3609 | OUT UINT32 *Buffer,\r |
3610 | IN UINT32 Value\r | |
ac644614 | 3611 | );\r |
3612 | \r | |
3613 | \r | |
3614 | /**\r | |
3615 | Reads a 32-bit value from memory that may be unaligned.\r | |
3616 | \r | |
3617 | This function returns the 32-bit value pointed to by Buffer. The function\r | |
3618 | guarantees that the read operation does not produce an alignment fault.\r | |
3619 | \r | |
3620 | If the Buffer is NULL, then ASSERT().\r | |
3621 | \r | |
af2dc6a7 | 3622 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3623 | \r |
5385a579 | 3624 | @return The 32-bit value read from Buffer.\r |
ac644614 | 3625 | \r |
3626 | **/\r | |
3627 | UINT32\r | |
3628 | EFIAPI\r | |
3629 | ReadUnaligned32 (\r | |
5385a579 | 3630 | IN CONST UINT32 *Buffer\r |
ac644614 | 3631 | );\r |
3632 | \r | |
3633 | \r | |
3634 | /**\r | |
3635 | Writes a 32-bit value to memory that may be unaligned.\r | |
3636 | \r | |
3637 | This function writes the 32-bit value specified by Value to Buffer. Value is\r | |
3638 | returned. The function guarantees that the write operation does not produce\r | |
3639 | an alignment fault.\r | |
3640 | \r | |
3641 | If the Buffer is NULL, then ASSERT().\r | |
3642 | \r | |
af2dc6a7 | 3643 | @param Buffer The pointer to a 32-bit value that may be unaligned.\r |
ac644614 | 3644 | @param Value 32-bit value to write to Buffer.\r |
3645 | \r | |
5385a579 | 3646 | @return The 32-bit value to write to Buffer.\r |
ac644614 | 3647 | \r |
3648 | **/\r | |
3649 | UINT32\r | |
3650 | EFIAPI\r | |
3651 | WriteUnaligned32 (\r | |
5385a579 | 3652 | OUT UINT32 *Buffer,\r |
3653 | IN UINT32 Value\r | |
ac644614 | 3654 | );\r |
3655 | \r | |
3656 | \r | |
3657 | /**\r | |
3658 | Reads a 64-bit value from memory that may be unaligned.\r | |
3659 | \r | |
3660 | This function returns the 64-bit value pointed to by Buffer. The function\r | |
3661 | guarantees that the read operation does not produce an alignment fault.\r | |
3662 | \r | |
3663 | If the Buffer is NULL, then ASSERT().\r | |
3664 | \r | |
af2dc6a7 | 3665 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3666 | \r |
5385a579 | 3667 | @return The 64-bit value read from Buffer.\r |
ac644614 | 3668 | \r |
3669 | **/\r | |
3670 | UINT64\r | |
3671 | EFIAPI\r | |
3672 | ReadUnaligned64 (\r | |
5385a579 | 3673 | IN CONST UINT64 *Buffer\r |
ac644614 | 3674 | );\r |
3675 | \r | |
3676 | \r | |
3677 | /**\r | |
3678 | Writes a 64-bit value to memory that may be unaligned.\r | |
3679 | \r | |
3680 | This function writes the 64-bit value specified by Value to Buffer. Value is\r | |
3681 | returned. The function guarantees that the write operation does not produce\r | |
3682 | an alignment fault.\r | |
3683 | \r | |
3684 | If the Buffer is NULL, then ASSERT().\r | |
3685 | \r | |
af2dc6a7 | 3686 | @param Buffer The pointer to a 64-bit value that may be unaligned.\r |
ac644614 | 3687 | @param Value 64-bit value to write to Buffer.\r |
3688 | \r | |
5385a579 | 3689 | @return The 64-bit value to write to Buffer.\r |
ac644614 | 3690 | \r |
3691 | **/\r | |
3692 | UINT64\r | |
3693 | EFIAPI\r | |
3694 | WriteUnaligned64 (\r | |
5385a579 | 3695 | OUT UINT64 *Buffer,\r |
3696 | IN UINT64 Value\r | |
ac644614 | 3697 | );\r |
3698 | \r | |
3699 | \r | |
3700 | //\r | |
3701 | // Bit Field Functions\r | |
3702 | //\r | |
3703 | \r | |
3704 | /**\r | |
3705 | Returns a bit field from an 8-bit value.\r | |
3706 | \r | |
3707 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3708 | \r | |
3709 | If 8-bit operations are not supported, then ASSERT().\r | |
3710 | If StartBit is greater than 7, then ASSERT().\r | |
3711 | If EndBit is greater than 7, then ASSERT().\r | |
3712 | If EndBit is less than StartBit, then ASSERT().\r | |
3713 | \r | |
3714 | @param Operand Operand on which to perform the bitfield operation.\r | |
3715 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3716 | Range 0..7.\r | |
3717 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3718 | Range 0..7.\r | |
3719 | \r | |
3720 | @return The bit field read.\r | |
3721 | \r | |
3722 | **/\r | |
3723 | UINT8\r | |
3724 | EFIAPI\r | |
3725 | BitFieldRead8 (\r | |
3726 | IN UINT8 Operand,\r | |
3727 | IN UINTN StartBit,\r | |
3728 | IN UINTN EndBit\r | |
3729 | );\r | |
3730 | \r | |
3731 | \r | |
3732 | /**\r | |
3733 | Writes a bit field to an 8-bit value, and returns the result.\r | |
3734 | \r | |
3735 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3736 | Operand. All other bits in Operand are preserved. The new 8-bit value is\r | |
3737 | returned.\r | |
3738 | \r | |
3739 | If 8-bit operations are not supported, then ASSERT().\r | |
3740 | If StartBit is greater than 7, then ASSERT().\r | |
3741 | If EndBit is greater than 7, then ASSERT().\r | |
3742 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3743 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3744 | \r |
3745 | @param Operand Operand on which to perform the bitfield operation.\r | |
3746 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3747 | Range 0..7.\r | |
3748 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3749 | Range 0..7.\r | |
3750 | @param Value New value of the bit field.\r | |
3751 | \r | |
3752 | @return The new 8-bit value.\r | |
3753 | \r | |
3754 | **/\r | |
3755 | UINT8\r | |
3756 | EFIAPI\r | |
3757 | BitFieldWrite8 (\r | |
3758 | IN UINT8 Operand,\r | |
3759 | IN UINTN StartBit,\r | |
3760 | IN UINTN EndBit,\r | |
3761 | IN UINT8 Value\r | |
3762 | );\r | |
3763 | \r | |
3764 | \r | |
3765 | /**\r | |
3766 | Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r | |
3767 | result.\r | |
3768 | \r | |
62991af2 | 3769 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3770 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3771 | Operand are preserved. The new 8-bit value is returned.\r | |
3772 | \r | |
3773 | If 8-bit operations are not supported, then ASSERT().\r | |
3774 | If StartBit is greater than 7, then ASSERT().\r | |
3775 | If EndBit is greater than 7, then ASSERT().\r | |
3776 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3777 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3778 | \r |
3779 | @param Operand Operand on which to perform the bitfield operation.\r | |
3780 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3781 | Range 0..7.\r | |
3782 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3783 | Range 0..7.\r | |
3784 | @param OrData The value to OR with the read value from the value\r | |
3785 | \r | |
3786 | @return The new 8-bit value.\r | |
3787 | \r | |
3788 | **/\r | |
3789 | UINT8\r | |
3790 | EFIAPI\r | |
3791 | BitFieldOr8 (\r | |
3792 | IN UINT8 Operand,\r | |
3793 | IN UINTN StartBit,\r | |
3794 | IN UINTN EndBit,\r | |
3795 | IN UINT8 OrData\r | |
3796 | );\r | |
3797 | \r | |
3798 | \r | |
3799 | /**\r | |
3800 | Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r | |
3801 | the result.\r | |
3802 | \r | |
3803 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3804 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3805 | preserved. The new 8-bit value is returned.\r | |
3806 | \r | |
3807 | If 8-bit operations are not supported, then ASSERT().\r | |
3808 | If StartBit is greater than 7, then ASSERT().\r | |
3809 | If EndBit is greater than 7, then ASSERT().\r | |
3810 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3811 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3812 | \r |
3813 | @param Operand Operand on which to perform the bitfield operation.\r | |
3814 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3815 | Range 0..7.\r | |
3816 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3817 | Range 0..7.\r | |
3818 | @param AndData The value to AND with the read value from the value.\r | |
3819 | \r | |
3820 | @return The new 8-bit value.\r | |
3821 | \r | |
3822 | **/\r | |
3823 | UINT8\r | |
3824 | EFIAPI\r | |
3825 | BitFieldAnd8 (\r | |
3826 | IN UINT8 Operand,\r | |
3827 | IN UINTN StartBit,\r | |
3828 | IN UINTN EndBit,\r | |
3829 | IN UINT8 AndData\r | |
3830 | );\r | |
3831 | \r | |
3832 | \r | |
3833 | /**\r | |
3834 | Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r | |
3835 | bitwise OR, and returns the result.\r | |
3836 | \r | |
3837 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 3838 | in Operand and the value specified by AndData, followed by a bitwise \r |
3839 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 3840 | preserved. The new 8-bit value is returned.\r |
3841 | \r | |
3842 | If 8-bit operations are not supported, then ASSERT().\r | |
3843 | If StartBit is greater than 7, then ASSERT().\r | |
3844 | If EndBit is greater than 7, then ASSERT().\r | |
3845 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
3846 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
3847 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 3848 | \r |
3849 | @param Operand Operand on which to perform the bitfield operation.\r | |
3850 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3851 | Range 0..7.\r | |
3852 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3853 | Range 0..7.\r | |
3854 | @param AndData The value to AND with the read value from the value.\r | |
3855 | @param OrData The value to OR with the result of the AND operation.\r | |
3856 | \r | |
3857 | @return The new 8-bit value.\r | |
3858 | \r | |
3859 | **/\r | |
3860 | UINT8\r | |
3861 | EFIAPI\r | |
3862 | BitFieldAndThenOr8 (\r | |
3863 | IN UINT8 Operand,\r | |
3864 | IN UINTN StartBit,\r | |
3865 | IN UINTN EndBit,\r | |
3866 | IN UINT8 AndData,\r | |
3867 | IN UINT8 OrData\r | |
3868 | );\r | |
3869 | \r | |
3870 | \r | |
3871 | /**\r | |
3872 | Returns a bit field from a 16-bit value.\r | |
3873 | \r | |
3874 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
3875 | \r | |
3876 | If 16-bit operations are not supported, then ASSERT().\r | |
3877 | If StartBit is greater than 15, then ASSERT().\r | |
3878 | If EndBit is greater than 15, then ASSERT().\r | |
3879 | If EndBit is less than StartBit, then ASSERT().\r | |
3880 | \r | |
3881 | @param Operand Operand on which to perform the bitfield operation.\r | |
3882 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3883 | Range 0..15.\r | |
3884 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3885 | Range 0..15.\r | |
3886 | \r | |
3887 | @return The bit field read.\r | |
3888 | \r | |
3889 | **/\r | |
3890 | UINT16\r | |
3891 | EFIAPI\r | |
3892 | BitFieldRead16 (\r | |
3893 | IN UINT16 Operand,\r | |
3894 | IN UINTN StartBit,\r | |
3895 | IN UINTN EndBit\r | |
3896 | );\r | |
3897 | \r | |
3898 | \r | |
3899 | /**\r | |
3900 | Writes a bit field to a 16-bit value, and returns the result.\r | |
3901 | \r | |
3902 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
3903 | Operand. All other bits in Operand are preserved. The new 16-bit value is\r | |
3904 | returned.\r | |
3905 | \r | |
3906 | If 16-bit operations are not supported, then ASSERT().\r | |
3907 | If StartBit is greater than 15, then ASSERT().\r | |
3908 | If EndBit is greater than 15, then ASSERT().\r | |
3909 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3910 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3911 | \r |
3912 | @param Operand Operand on which to perform the bitfield operation.\r | |
3913 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3914 | Range 0..15.\r | |
3915 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3916 | Range 0..15.\r | |
3917 | @param Value New value of the bit field.\r | |
3918 | \r | |
3919 | @return The new 16-bit value.\r | |
3920 | \r | |
3921 | **/\r | |
3922 | UINT16\r | |
3923 | EFIAPI\r | |
3924 | BitFieldWrite16 (\r | |
3925 | IN UINT16 Operand,\r | |
3926 | IN UINTN StartBit,\r | |
3927 | IN UINTN EndBit,\r | |
3928 | IN UINT16 Value\r | |
3929 | );\r | |
3930 | \r | |
3931 | \r | |
3932 | /**\r | |
3933 | Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r | |
3934 | result.\r | |
3935 | \r | |
62991af2 | 3936 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 3937 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
3938 | Operand are preserved. The new 16-bit value is returned.\r | |
3939 | \r | |
3940 | If 16-bit operations are not supported, then ASSERT().\r | |
3941 | If StartBit is greater than 15, then ASSERT().\r | |
3942 | If EndBit is greater than 15, then ASSERT().\r | |
3943 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3944 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3945 | \r |
3946 | @param Operand Operand on which to perform the bitfield operation.\r | |
3947 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3948 | Range 0..15.\r | |
3949 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3950 | Range 0..15.\r | |
3951 | @param OrData The value to OR with the read value from the value\r | |
3952 | \r | |
3953 | @return The new 16-bit value.\r | |
3954 | \r | |
3955 | **/\r | |
3956 | UINT16\r | |
3957 | EFIAPI\r | |
3958 | BitFieldOr16 (\r | |
3959 | IN UINT16 Operand,\r | |
3960 | IN UINTN StartBit,\r | |
3961 | IN UINTN EndBit,\r | |
3962 | IN UINT16 OrData\r | |
3963 | );\r | |
3964 | \r | |
3965 | \r | |
3966 | /**\r | |
3967 | Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r | |
3968 | the result.\r | |
3969 | \r | |
3970 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
3971 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
3972 | preserved. The new 16-bit value is returned.\r | |
3973 | \r | |
3974 | If 16-bit operations are not supported, then ASSERT().\r | |
3975 | If StartBit is greater than 15, then ASSERT().\r | |
3976 | If EndBit is greater than 15, then ASSERT().\r | |
3977 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 3978 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 3979 | \r |
3980 | @param Operand Operand on which to perform the bitfield operation.\r | |
3981 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
3982 | Range 0..15.\r | |
3983 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
3984 | Range 0..15.\r | |
3985 | @param AndData The value to AND with the read value from the value\r | |
3986 | \r | |
3987 | @return The new 16-bit value.\r | |
3988 | \r | |
3989 | **/\r | |
3990 | UINT16\r | |
3991 | EFIAPI\r | |
3992 | BitFieldAnd16 (\r | |
3993 | IN UINT16 Operand,\r | |
3994 | IN UINTN StartBit,\r | |
3995 | IN UINTN EndBit,\r | |
3996 | IN UINT16 AndData\r | |
3997 | );\r | |
3998 | \r | |
3999 | \r | |
4000 | /**\r | |
4001 | Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r | |
4002 | bitwise OR, and returns the result.\r | |
4003 | \r | |
4004 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 4005 | in Operand and the value specified by AndData, followed by a bitwise \r |
4006 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 4007 | preserved. The new 16-bit value is returned.\r |
4008 | \r | |
4009 | If 16-bit operations are not supported, then ASSERT().\r | |
4010 | If StartBit is greater than 15, then ASSERT().\r | |
4011 | If EndBit is greater than 15, then ASSERT().\r | |
4012 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4013 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4014 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4015 | \r |
4016 | @param Operand Operand on which to perform the bitfield operation.\r | |
4017 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4018 | Range 0..15.\r | |
4019 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4020 | Range 0..15.\r | |
4021 | @param AndData The value to AND with the read value from the value.\r | |
4022 | @param OrData The value to OR with the result of the AND operation.\r | |
4023 | \r | |
4024 | @return The new 16-bit value.\r | |
4025 | \r | |
4026 | **/\r | |
4027 | UINT16\r | |
4028 | EFIAPI\r | |
4029 | BitFieldAndThenOr16 (\r | |
4030 | IN UINT16 Operand,\r | |
4031 | IN UINTN StartBit,\r | |
4032 | IN UINTN EndBit,\r | |
4033 | IN UINT16 AndData,\r | |
4034 | IN UINT16 OrData\r | |
4035 | );\r | |
4036 | \r | |
4037 | \r | |
4038 | /**\r | |
4039 | Returns a bit field from a 32-bit value.\r | |
4040 | \r | |
4041 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4042 | \r | |
4043 | If 32-bit operations are not supported, then ASSERT().\r | |
4044 | If StartBit is greater than 31, then ASSERT().\r | |
4045 | If EndBit is greater than 31, then ASSERT().\r | |
4046 | If EndBit is less than StartBit, then ASSERT().\r | |
4047 | \r | |
4048 | @param Operand Operand on which to perform the bitfield operation.\r | |
4049 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4050 | Range 0..31.\r | |
4051 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4052 | Range 0..31.\r | |
4053 | \r | |
4054 | @return The bit field read.\r | |
4055 | \r | |
4056 | **/\r | |
4057 | UINT32\r | |
4058 | EFIAPI\r | |
4059 | BitFieldRead32 (\r | |
4060 | IN UINT32 Operand,\r | |
4061 | IN UINTN StartBit,\r | |
4062 | IN UINTN EndBit\r | |
4063 | );\r | |
4064 | \r | |
4065 | \r | |
4066 | /**\r | |
4067 | Writes a bit field to a 32-bit value, and returns the result.\r | |
4068 | \r | |
4069 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4070 | Operand. All other bits in Operand are preserved. The new 32-bit value is\r | |
4071 | returned.\r | |
4072 | \r | |
4073 | If 32-bit operations are not supported, then ASSERT().\r | |
4074 | If StartBit is greater than 31, then ASSERT().\r | |
4075 | If EndBit is greater than 31, then ASSERT().\r | |
4076 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4077 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4078 | \r |
4079 | @param Operand Operand on which to perform the bitfield operation.\r | |
4080 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4081 | Range 0..31.\r | |
4082 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4083 | Range 0..31.\r | |
4084 | @param Value New value of the bit field.\r | |
4085 | \r | |
4086 | @return The new 32-bit value.\r | |
4087 | \r | |
4088 | **/\r | |
4089 | UINT32\r | |
4090 | EFIAPI\r | |
4091 | BitFieldWrite32 (\r | |
4092 | IN UINT32 Operand,\r | |
4093 | IN UINTN StartBit,\r | |
4094 | IN UINTN EndBit,\r | |
4095 | IN UINT32 Value\r | |
4096 | );\r | |
4097 | \r | |
4098 | \r | |
4099 | /**\r | |
4100 | Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r | |
4101 | result.\r | |
4102 | \r | |
62991af2 | 4103 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4104 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4105 | Operand are preserved. The new 32-bit value is returned.\r | |
4106 | \r | |
4107 | If 32-bit operations are not supported, then ASSERT().\r | |
4108 | If StartBit is greater than 31, then ASSERT().\r | |
4109 | If EndBit is greater than 31, then ASSERT().\r | |
4110 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4111 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4112 | \r |
4113 | @param Operand Operand on which to perform the bitfield operation.\r | |
4114 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4115 | Range 0..31.\r | |
4116 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4117 | Range 0..31.\r | |
af2dc6a7 | 4118 | @param OrData The value to OR with the read value from the value.\r |
ac644614 | 4119 | \r |
4120 | @return The new 32-bit value.\r | |
4121 | \r | |
4122 | **/\r | |
4123 | UINT32\r | |
4124 | EFIAPI\r | |
4125 | BitFieldOr32 (\r | |
4126 | IN UINT32 Operand,\r | |
4127 | IN UINTN StartBit,\r | |
4128 | IN UINTN EndBit,\r | |
4129 | IN UINT32 OrData\r | |
4130 | );\r | |
4131 | \r | |
4132 | \r | |
4133 | /**\r | |
4134 | Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r | |
4135 | the result.\r | |
4136 | \r | |
4137 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4138 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4139 | preserved. The new 32-bit value is returned.\r | |
4140 | \r | |
4141 | If 32-bit operations are not supported, then ASSERT().\r | |
4142 | If StartBit is greater than 31, then ASSERT().\r | |
4143 | If EndBit is greater than 31, then ASSERT().\r | |
4144 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4145 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4146 | \r |
4147 | @param Operand Operand on which to perform the bitfield operation.\r | |
4148 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4149 | Range 0..31.\r | |
4150 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4151 | Range 0..31.\r | |
4152 | @param AndData The value to AND with the read value from the value\r | |
4153 | \r | |
4154 | @return The new 32-bit value.\r | |
4155 | \r | |
4156 | **/\r | |
4157 | UINT32\r | |
4158 | EFIAPI\r | |
4159 | BitFieldAnd32 (\r | |
4160 | IN UINT32 Operand,\r | |
4161 | IN UINTN StartBit,\r | |
4162 | IN UINTN EndBit,\r | |
4163 | IN UINT32 AndData\r | |
4164 | );\r | |
4165 | \r | |
4166 | \r | |
4167 | /**\r | |
4168 | Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r | |
4169 | bitwise OR, and returns the result.\r | |
4170 | \r | |
4171 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 4172 | in Operand and the value specified by AndData, followed by a bitwise \r |
4173 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 4174 | preserved. The new 32-bit value is returned.\r |
4175 | \r | |
4176 | If 32-bit operations are not supported, then ASSERT().\r | |
4177 | If StartBit is greater than 31, then ASSERT().\r | |
4178 | If EndBit is greater than 31, then ASSERT().\r | |
4179 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4180 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4181 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4182 | \r |
4183 | @param Operand Operand on which to perform the bitfield operation.\r | |
4184 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4185 | Range 0..31.\r | |
4186 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4187 | Range 0..31.\r | |
4188 | @param AndData The value to AND with the read value from the value.\r | |
4189 | @param OrData The value to OR with the result of the AND operation.\r | |
4190 | \r | |
4191 | @return The new 32-bit value.\r | |
4192 | \r | |
4193 | **/\r | |
4194 | UINT32\r | |
4195 | EFIAPI\r | |
4196 | BitFieldAndThenOr32 (\r | |
4197 | IN UINT32 Operand,\r | |
4198 | IN UINTN StartBit,\r | |
4199 | IN UINTN EndBit,\r | |
4200 | IN UINT32 AndData,\r | |
4201 | IN UINT32 OrData\r | |
4202 | );\r | |
4203 | \r | |
4204 | \r | |
4205 | /**\r | |
4206 | Returns a bit field from a 64-bit value.\r | |
4207 | \r | |
4208 | Returns the bitfield specified by the StartBit and the EndBit from Operand.\r | |
4209 | \r | |
4210 | If 64-bit operations are not supported, then ASSERT().\r | |
4211 | If StartBit is greater than 63, then ASSERT().\r | |
4212 | If EndBit is greater than 63, then ASSERT().\r | |
4213 | If EndBit is less than StartBit, then ASSERT().\r | |
4214 | \r | |
4215 | @param Operand Operand on which to perform the bitfield operation.\r | |
4216 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4217 | Range 0..63.\r | |
4218 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4219 | Range 0..63.\r | |
4220 | \r | |
4221 | @return The bit field read.\r | |
4222 | \r | |
4223 | **/\r | |
4224 | UINT64\r | |
4225 | EFIAPI\r | |
4226 | BitFieldRead64 (\r | |
4227 | IN UINT64 Operand,\r | |
4228 | IN UINTN StartBit,\r | |
4229 | IN UINTN EndBit\r | |
4230 | );\r | |
4231 | \r | |
4232 | \r | |
4233 | /**\r | |
4234 | Writes a bit field to a 64-bit value, and returns the result.\r | |
4235 | \r | |
4236 | Writes Value to the bit field specified by the StartBit and the EndBit in\r | |
4237 | Operand. All other bits in Operand are preserved. The new 64-bit value is\r | |
4238 | returned.\r | |
4239 | \r | |
4240 | If 64-bit operations are not supported, then ASSERT().\r | |
4241 | If StartBit is greater than 63, then ASSERT().\r | |
4242 | If EndBit is greater than 63, then ASSERT().\r | |
4243 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4244 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4245 | \r |
4246 | @param Operand Operand on which to perform the bitfield operation.\r | |
4247 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4248 | Range 0..63.\r | |
4249 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4250 | Range 0..63.\r | |
4251 | @param Value New value of the bit field.\r | |
4252 | \r | |
4253 | @return The new 64-bit value.\r | |
4254 | \r | |
4255 | **/\r | |
4256 | UINT64\r | |
4257 | EFIAPI\r | |
4258 | BitFieldWrite64 (\r | |
4259 | IN UINT64 Operand,\r | |
4260 | IN UINTN StartBit,\r | |
4261 | IN UINTN EndBit,\r | |
4262 | IN UINT64 Value\r | |
4263 | );\r | |
4264 | \r | |
4265 | \r | |
4266 | /**\r | |
4267 | Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r | |
4268 | result.\r | |
4269 | \r | |
62991af2 | 4270 | Performs a bitwise OR between the bit field specified by StartBit\r |
ac644614 | 4271 | and EndBit in Operand and the value specified by OrData. All other bits in\r |
4272 | Operand are preserved. The new 64-bit value is returned.\r | |
4273 | \r | |
4274 | If 64-bit operations are not supported, then ASSERT().\r | |
4275 | If StartBit is greater than 63, then ASSERT().\r | |
4276 | If EndBit is greater than 63, then ASSERT().\r | |
4277 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4278 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4279 | \r |
4280 | @param Operand Operand on which to perform the bitfield operation.\r | |
4281 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4282 | Range 0..63.\r | |
4283 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4284 | Range 0..63.\r | |
4285 | @param OrData The value to OR with the read value from the value\r | |
4286 | \r | |
4287 | @return The new 64-bit value.\r | |
4288 | \r | |
4289 | **/\r | |
4290 | UINT64\r | |
4291 | EFIAPI\r | |
4292 | BitFieldOr64 (\r | |
4293 | IN UINT64 Operand,\r | |
4294 | IN UINTN StartBit,\r | |
4295 | IN UINTN EndBit,\r | |
4296 | IN UINT64 OrData\r | |
4297 | );\r | |
4298 | \r | |
4299 | \r | |
4300 | /**\r | |
4301 | Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r | |
4302 | the result.\r | |
4303 | \r | |
4304 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
4305 | in Operand and the value specified by AndData. All other bits in Operand are\r | |
4306 | preserved. The new 64-bit value is returned.\r | |
4307 | \r | |
4308 | If 64-bit operations are not supported, then ASSERT().\r | |
4309 | If StartBit is greater than 63, then ASSERT().\r | |
4310 | If EndBit is greater than 63, then ASSERT().\r | |
4311 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 4312 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 4313 | \r |
4314 | @param Operand Operand on which to perform the bitfield operation.\r | |
4315 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4316 | Range 0..63.\r | |
4317 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4318 | Range 0..63.\r | |
4319 | @param AndData The value to AND with the read value from the value\r | |
4320 | \r | |
4321 | @return The new 64-bit value.\r | |
4322 | \r | |
4323 | **/\r | |
4324 | UINT64\r | |
4325 | EFIAPI\r | |
4326 | BitFieldAnd64 (\r | |
4327 | IN UINT64 Operand,\r | |
4328 | IN UINTN StartBit,\r | |
4329 | IN UINTN EndBit,\r | |
4330 | IN UINT64 AndData\r | |
4331 | );\r | |
4332 | \r | |
4333 | \r | |
4334 | /**\r | |
4335 | Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r | |
4336 | bitwise OR, and returns the result.\r | |
4337 | \r | |
4338 | Performs a bitwise AND between the bit field specified by StartBit and EndBit\r | |
62991af2 | 4339 | in Operand and the value specified by AndData, followed by a bitwise \r |
4340 | OR with value specified by OrData. All other bits in Operand are\r | |
ac644614 | 4341 | preserved. The new 64-bit value is returned.\r |
4342 | \r | |
4343 | If 64-bit operations are not supported, then ASSERT().\r | |
4344 | If StartBit is greater than 63, then ASSERT().\r | |
4345 | If EndBit is greater than 63, then ASSERT().\r | |
4346 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
4347 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
4348 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 4349 | \r |
4350 | @param Operand Operand on which to perform the bitfield operation.\r | |
4351 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
4352 | Range 0..63.\r | |
4353 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
4354 | Range 0..63.\r | |
4355 | @param AndData The value to AND with the read value from the value.\r | |
4356 | @param OrData The value to OR with the result of the AND operation.\r | |
4357 | \r | |
4358 | @return The new 64-bit value.\r | |
4359 | \r | |
4360 | **/\r | |
4361 | UINT64\r | |
4362 | EFIAPI\r | |
4363 | BitFieldAndThenOr64 (\r | |
4364 | IN UINT64 Operand,\r | |
4365 | IN UINTN StartBit,\r | |
4366 | IN UINTN EndBit,\r | |
4367 | IN UINT64 AndData,\r | |
4368 | IN UINT64 OrData\r | |
4369 | );\r | |
4370 | \r | |
ac644614 | 4371 | //\r |
4372 | // Base Library Checksum Functions\r | |
4373 | //\r | |
4374 | \r | |
4375 | /**\r | |
17f695ed | 4376 | Returns the sum of all elements in a buffer in unit of UINT8.\r |
ac644614 | 4377 | During calculation, the carry bits are dropped.\r |
4378 | \r | |
4379 | This function calculates the sum of all elements in a buffer\r | |
4380 | in unit of UINT8. The carry bits in result of addition are dropped.\r | |
4381 | The result is returned as UINT8. If Length is Zero, then Zero is\r | |
4382 | returned.\r | |
4383 | \r | |
4384 | If Buffer is NULL, then ASSERT().\r | |
4385 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4386 | \r | |
af2dc6a7 | 4387 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
17f695ed | 4388 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4389 | \r |
4390 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4391 | \r | |
4392 | **/\r | |
4393 | UINT8\r | |
4394 | EFIAPI\r | |
4395 | CalculateSum8 (\r | |
ee6c452c | 4396 | IN CONST UINT8 *Buffer,\r |
4397 | IN UINTN Length\r | |
ac644614 | 4398 | );\r |
4399 | \r | |
4400 | \r | |
4401 | /**\r | |
4402 | Returns the two's complement checksum of all elements in a buffer\r | |
4403 | of 8-bit values.\r | |
4404 | \r | |
4405 | This function first calculates the sum of the 8-bit values in the\r | |
4406 | buffer specified by Buffer and Length. The carry bits in the result\r | |
4407 | of addition are dropped. Then, the two's complement of the sum is\r | |
4408 | returned. If Length is 0, then 0 is returned.\r | |
4409 | \r | |
4410 | If Buffer is NULL, then ASSERT().\r | |
4411 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4412 | \r | |
af2dc6a7 | 4413 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4414 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4415 | \r |
af2dc6a7 | 4416 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4417 | \r |
4418 | **/\r | |
4419 | UINT8\r | |
4420 | EFIAPI\r | |
4421 | CalculateCheckSum8 (\r | |
ee6c452c | 4422 | IN CONST UINT8 *Buffer,\r |
4423 | IN UINTN Length\r | |
ac644614 | 4424 | );\r |
4425 | \r | |
4426 | \r | |
4427 | /**\r | |
4428 | Returns the sum of all elements in a buffer of 16-bit values. During\r | |
4429 | calculation, the carry bits are dropped.\r | |
4430 | \r | |
4431 | This function calculates the sum of the 16-bit values in the buffer\r | |
4432 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4433 | The 16-bit result is returned. If Length is 0, then 0 is returned.\r | |
4434 | \r | |
4435 | If Buffer is NULL, then ASSERT().\r | |
4436 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4437 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4438 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4439 | \r | |
af2dc6a7 | 4440 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4441 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4442 | \r |
4443 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4444 | \r | |
4445 | **/\r | |
4446 | UINT16\r | |
4447 | EFIAPI\r | |
4448 | CalculateSum16 (\r | |
ee6c452c | 4449 | IN CONST UINT16 *Buffer,\r |
4450 | IN UINTN Length\r | |
ac644614 | 4451 | );\r |
4452 | \r | |
4453 | \r | |
4454 | /**\r | |
4455 | Returns the two's complement checksum of all elements in a buffer of\r | |
4456 | 16-bit values.\r | |
4457 | \r | |
4458 | This function first calculates the sum of the 16-bit values in the buffer\r | |
4459 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4460 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4461 | is 0, then 0 is returned.\r | |
4462 | \r | |
4463 | If Buffer is NULL, then ASSERT().\r | |
4464 | If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r | |
4465 | If Length is not aligned on a 16-bit boundary, then ASSERT().\r | |
4466 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4467 | \r | |
af2dc6a7 | 4468 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4469 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4470 | \r |
af2dc6a7 | 4471 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4472 | \r |
4473 | **/\r | |
4474 | UINT16\r | |
4475 | EFIAPI\r | |
4476 | CalculateCheckSum16 (\r | |
ee6c452c | 4477 | IN CONST UINT16 *Buffer,\r |
4478 | IN UINTN Length\r | |
ac644614 | 4479 | );\r |
4480 | \r | |
4481 | \r | |
4482 | /**\r | |
17f695ed | 4483 | Returns the sum of all elements in a buffer of 32-bit values. During\r |
ac644614 | 4484 | calculation, the carry bits are dropped.\r |
4485 | \r | |
4486 | This function calculates the sum of the 32-bit values in the buffer\r | |
4487 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
17f695ed | 4488 | The 32-bit result is returned. If Length is 0, then 0 is returned.\r |
ac644614 | 4489 | \r |
4490 | If Buffer is NULL, then ASSERT().\r | |
4491 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4492 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4493 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4494 | \r | |
af2dc6a7 | 4495 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4496 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4497 | \r |
4498 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4499 | \r | |
4500 | **/\r | |
4501 | UINT32\r | |
4502 | EFIAPI\r | |
4503 | CalculateSum32 (\r | |
ee6c452c | 4504 | IN CONST UINT32 *Buffer,\r |
4505 | IN UINTN Length\r | |
ac644614 | 4506 | );\r |
4507 | \r | |
4508 | \r | |
4509 | /**\r | |
4510 | Returns the two's complement checksum of all elements in a buffer of\r | |
4511 | 32-bit values.\r | |
4512 | \r | |
4513 | This function first calculates the sum of the 32-bit values in the buffer\r | |
4514 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4515 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4516 | is 0, then 0 is returned.\r | |
4517 | \r | |
4518 | If Buffer is NULL, then ASSERT().\r | |
4519 | If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r | |
4520 | If Length is not aligned on a 32-bit boundary, then ASSERT().\r | |
4521 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4522 | \r | |
af2dc6a7 | 4523 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4524 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4525 | \r |
af2dc6a7 | 4526 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4527 | \r |
4528 | **/\r | |
4529 | UINT32\r | |
4530 | EFIAPI\r | |
4531 | CalculateCheckSum32 (\r | |
ee6c452c | 4532 | IN CONST UINT32 *Buffer,\r |
4533 | IN UINTN Length\r | |
ac644614 | 4534 | );\r |
4535 | \r | |
4536 | \r | |
4537 | /**\r | |
4538 | Returns the sum of all elements in a buffer of 64-bit values. During\r | |
4539 | calculation, the carry bits are dropped.\r | |
4540 | \r | |
4541 | This function calculates the sum of the 64-bit values in the buffer\r | |
4542 | specified by Buffer and Length. The carry bits in result of addition are dropped.\r | |
4543 | The 64-bit result is returned. If Length is 0, then 0 is returned.\r | |
4544 | \r | |
4545 | If Buffer is NULL, then ASSERT().\r | |
4546 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4547 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4548 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4549 | \r | |
af2dc6a7 | 4550 | @param Buffer The pointer to the buffer to carry out the sum operation.\r |
1106ffe1 | 4551 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4552 | \r |
4553 | @return Sum The sum of Buffer with carry bits dropped during additions.\r | |
4554 | \r | |
4555 | **/\r | |
4556 | UINT64\r | |
4557 | EFIAPI\r | |
4558 | CalculateSum64 (\r | |
ee6c452c | 4559 | IN CONST UINT64 *Buffer,\r |
4560 | IN UINTN Length\r | |
ac644614 | 4561 | );\r |
4562 | \r | |
4563 | \r | |
4564 | /**\r | |
4565 | Returns the two's complement checksum of all elements in a buffer of\r | |
4566 | 64-bit values.\r | |
4567 | \r | |
4568 | This function first calculates the sum of the 64-bit values in the buffer\r | |
4569 | specified by Buffer and Length. The carry bits in the result of addition\r | |
4570 | are dropped. Then, the two's complement of the sum is returned. If Length\r | |
4571 | is 0, then 0 is returned.\r | |
4572 | \r | |
4573 | If Buffer is NULL, then ASSERT().\r | |
4574 | If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r | |
4575 | If Length is not aligned on a 64-bit boundary, then ASSERT().\r | |
4576 | If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r | |
4577 | \r | |
af2dc6a7 | 4578 | @param Buffer The pointer to the buffer to carry out the checksum operation.\r |
1106ffe1 | 4579 | @param Length The size, in bytes, of Buffer.\r |
ac644614 | 4580 | \r |
af2dc6a7 | 4581 | @return Checksum The two's complement checksum of Buffer.\r |
ac644614 | 4582 | \r |
4583 | **/\r | |
4584 | UINT64\r | |
4585 | EFIAPI\r | |
4586 | CalculateCheckSum64 (\r | |
ee6c452c | 4587 | IN CONST UINT64 *Buffer,\r |
4588 | IN UINTN Length\r | |
ac644614 | 4589 | );\r |
4590 | \r | |
4591 | \r | |
d75f9fc2 | 4592 | //\r |
4593 | // Base Library CPU Functions\r | |
4594 | //\r | |
4595 | \r | |
4596 | /**\r | |
4597 | Function entry point used when a stack switch is requested with SwitchStack()\r | |
4598 | \r | |
4599 | @param Context1 Context1 parameter passed into SwitchStack().\r | |
4600 | @param Context2 Context2 parameter passed into SwitchStack().\r | |
4601 | \r | |
4602 | **/\r | |
ac644614 | 4603 | typedef\r |
4604 | VOID\r | |
9810cdd8 | 4605 | (EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r |
ac644614 | 4606 | IN VOID *Context1, OPTIONAL\r |
4607 | IN VOID *Context2 OPTIONAL\r | |
4608 | );\r | |
4609 | \r | |
4610 | \r | |
4611 | /**\r | |
4612 | Used to serialize load and store operations.\r | |
4613 | \r | |
4614 | All loads and stores that proceed calls to this function are guaranteed to be\r | |
4615 | globally visible when this function returns.\r | |
4616 | \r | |
4617 | **/\r | |
4618 | VOID\r | |
4619 | EFIAPI\r | |
4620 | MemoryFence (\r | |
4621 | VOID\r | |
4622 | );\r | |
4623 | \r | |
4624 | \r | |
4625 | /**\r | |
4626 | Saves the current CPU context that can be restored with a call to LongJump()\r | |
4627 | and returns 0.\r | |
4628 | \r | |
4629 | Saves the current CPU context in the buffer specified by JumpBuffer and\r | |
4630 | returns 0. The initial call to SetJump() must always return 0. Subsequent\r | |
4631 | calls to LongJump() cause a non-zero value to be returned by SetJump().\r | |
4632 | \r | |
4633 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 4634 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
17f695ed | 4635 | \r |
4636 | NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r | |
4637 | The same structure must never be used for more than one CPU architecture context.\r | |
4638 | For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module. \r | |
4639 | SetJump()/LongJump() is not currently supported for the EBC processor type. \r | |
ac644614 | 4640 | \r |
4641 | @param JumpBuffer A pointer to CPU context buffer.\r | |
4642 | \r | |
4643 | @retval 0 Indicates a return from SetJump().\r | |
4644 | \r | |
4645 | **/\r | |
4646 | UINTN\r | |
4647 | EFIAPI\r | |
4648 | SetJump (\r | |
4649 | OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r | |
4650 | );\r | |
4651 | \r | |
4652 | \r | |
4653 | /**\r | |
4654 | Restores the CPU context that was saved with SetJump().\r | |
4655 | \r | |
4656 | Restores the CPU context from the buffer specified by JumpBuffer. This\r | |
4657 | function never returns to the caller. Instead is resumes execution based on\r | |
4658 | the state of JumpBuffer.\r | |
4659 | \r | |
4660 | If JumpBuffer is NULL, then ASSERT().\r | |
1a2f870c | 4661 | For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r |
ac644614 | 4662 | If Value is 0, then ASSERT().\r |
4663 | \r | |
4664 | @param JumpBuffer A pointer to CPU context buffer.\r | |
4665 | @param Value The value to return when the SetJump() context is\r | |
4666 | restored and must be non-zero.\r | |
4667 | \r | |
4668 | **/\r | |
4669 | VOID\r | |
4670 | EFIAPI\r | |
4671 | LongJump (\r | |
4672 | IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r | |
4673 | IN UINTN Value\r | |
4674 | );\r | |
4675 | \r | |
4676 | \r | |
4677 | /**\r | |
4678 | Enables CPU interrupts.\r | |
4679 | \r | |
ac644614 | 4680 | **/\r |
4681 | VOID\r | |
4682 | EFIAPI\r | |
4683 | EnableInterrupts (\r | |
4684 | VOID\r | |
4685 | );\r | |
4686 | \r | |
4687 | \r | |
4688 | /**\r | |
4689 | Disables CPU interrupts.\r | |
4690 | \r | |
ac644614 | 4691 | **/\r |
4692 | VOID\r | |
4693 | EFIAPI\r | |
4694 | DisableInterrupts (\r | |
4695 | VOID\r | |
4696 | );\r | |
4697 | \r | |
4698 | \r | |
4699 | /**\r | |
4700 | Disables CPU interrupts and returns the interrupt state prior to the disable\r | |
4701 | operation.\r | |
4702 | \r | |
ac644614 | 4703 | @retval TRUE CPU interrupts were enabled on entry to this call.\r |
4704 | @retval FALSE CPU interrupts were disabled on entry to this call.\r | |
4705 | \r | |
4706 | **/\r | |
4707 | BOOLEAN\r | |
4708 | EFIAPI\r | |
4709 | SaveAndDisableInterrupts (\r | |
4710 | VOID\r | |
4711 | );\r | |
4712 | \r | |
4713 | \r | |
4714 | /**\r | |
4715 | Enables CPU interrupts for the smallest window required to capture any\r | |
4716 | pending interrupts.\r | |
4717 | \r | |
ac644614 | 4718 | **/\r |
4719 | VOID\r | |
4720 | EFIAPI\r | |
4721 | EnableDisableInterrupts (\r | |
4722 | VOID\r | |
4723 | );\r | |
4724 | \r | |
4725 | \r | |
4726 | /**\r | |
4727 | Retrieves the current CPU interrupt state.\r | |
4728 | \r | |
af2dc6a7 | 4729 | Returns TRUE if interrupts are currently enabled. Otherwise\r |
38bbd3d9 | 4730 | returns FALSE.\r |
ac644614 | 4731 | \r |
4732 | @retval TRUE CPU interrupts are enabled.\r | |
4733 | @retval FALSE CPU interrupts are disabled.\r | |
4734 | \r | |
4735 | **/\r | |
4736 | BOOLEAN\r | |
4737 | EFIAPI\r | |
4738 | GetInterruptState (\r | |
4739 | VOID\r | |
4740 | );\r | |
4741 | \r | |
4742 | \r | |
4743 | /**\r | |
4744 | Set the current CPU interrupt state.\r | |
4745 | \r | |
4746 | Sets the current CPU interrupt state to the state specified by\r | |
4747 | InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r | |
4748 | InterruptState is FALSE, then interrupts are disabled. InterruptState is\r | |
4749 | returned.\r | |
4750 | \r | |
4751 | @param InterruptState TRUE if interrupts should enabled. FALSE if\r | |
4752 | interrupts should be disabled.\r | |
4753 | \r | |
4754 | @return InterruptState\r | |
4755 | \r | |
4756 | **/\r | |
4757 | BOOLEAN\r | |
4758 | EFIAPI\r | |
4759 | SetInterruptState (\r | |
4760 | IN BOOLEAN InterruptState\r | |
4761 | );\r | |
4762 | \r | |
4763 | \r | |
4764 | /**\r | |
4765 | Requests CPU to pause for a short period of time.\r | |
4766 | \r | |
4767 | Requests CPU to pause for a short period of time. Typically used in MP\r | |
4768 | systems to prevent memory starvation while waiting for a spin lock.\r | |
4769 | \r | |
4770 | **/\r | |
4771 | VOID\r | |
4772 | EFIAPI\r | |
4773 | CpuPause (\r | |
4774 | VOID\r | |
4775 | );\r | |
4776 | \r | |
4777 | \r | |
4778 | /**\r | |
4779 | Transfers control to a function starting with a new stack.\r | |
4780 | \r | |
4781 | Transfers control to the function specified by EntryPoint using the\r | |
4782 | new stack specified by NewStack and passing in the parameters specified\r | |
4783 | by Context1 and Context2. Context1 and Context2 are optional and may\r | |
4784 | be NULL. The function EntryPoint must never return. This function\r | |
4785 | supports a variable number of arguments following the NewStack parameter.\r | |
1a2f870c | 4786 | These additional arguments are ignored on IA-32, x64, and EBC architectures.\r |
4787 | Itanium processors expect one additional parameter of type VOID * that specifies\r | |
ac644614 | 4788 | the new backing store pointer.\r |
4789 | \r | |
4790 | If EntryPoint is NULL, then ASSERT().\r | |
4791 | If NewStack is NULL, then ASSERT().\r | |
4792 | \r | |
4793 | @param EntryPoint A pointer to function to call with the new stack.\r | |
4794 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
4795 | function.\r | |
4796 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
4797 | function.\r | |
4798 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
4799 | function.\r | |
af2dc6a7 | 4800 | @param ... This variable argument list is ignored for IA-32, x64, and \r |
4801 | EBC architectures. For Itanium processors, this variable \r | |
4802 | argument list is expected to contain a single parameter of \r | |
4803 | type VOID * that specifies the new backing store pointer.\r | |
42eedea9 | 4804 | \r |
ac644614 | 4805 | \r |
4806 | **/\r | |
4807 | VOID\r | |
4808 | EFIAPI\r | |
4809 | SwitchStack (\r | |
4810 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
4811 | IN VOID *Context1, OPTIONAL\r | |
4812 | IN VOID *Context2, OPTIONAL\r | |
4813 | IN VOID *NewStack,\r | |
4814 | ...\r | |
4815 | );\r | |
4816 | \r | |
4817 | \r | |
4818 | /**\r | |
4819 | Generates a breakpoint on the CPU.\r | |
4820 | \r | |
4821 | Generates a breakpoint on the CPU. The breakpoint must be implemented such\r | |
4822 | that code can resume normal execution after the breakpoint.\r | |
4823 | \r | |
4824 | **/\r | |
4825 | VOID\r | |
4826 | EFIAPI\r | |
4827 | CpuBreakpoint (\r | |
4828 | VOID\r | |
4829 | );\r | |
4830 | \r | |
4831 | \r | |
4832 | /**\r | |
4833 | Executes an infinite loop.\r | |
4834 | \r | |
4835 | Forces the CPU to execute an infinite loop. A debugger may be used to skip\r | |
4836 | past the loop and the code that follows the loop must execute properly. This\r | |
4837 | implies that the infinite loop must not cause the code that follow it to be\r | |
4838 | optimized away.\r | |
4839 | \r | |
4840 | **/\r | |
4841 | VOID\r | |
4842 | EFIAPI\r | |
4843 | CpuDeadLoop (\r | |
4844 | VOID\r | |
4845 | );\r | |
2fe241a2 | 4846 | \r |
ac644614 | 4847 | #if defined (MDE_CPU_IPF)\r |
4848 | \r | |
4849 | /**\r | |
4850 | Flush a range of cache lines in the cache coherency domain of the calling\r | |
4851 | CPU.\r | |
4852 | \r | |
cc39b88b | 4853 | Flushes the cache lines specified by Address and Length. If Address is not aligned \r |
4854 | on a cache line boundary, then entire cache line containing Address is flushed. \r | |
4855 | If Address + Length is not aligned on a cache line boundary, then the entire cache \r | |
4856 | line containing Address + Length - 1 is flushed. This function may choose to flush \r | |
4857 | the entire cache if that is more efficient than flushing the specified range. If \r | |
4858 | Length is 0, the no cache lines are flushed. Address is returned. \r | |
1a2f870c | 4859 | This function is only available on Itanium processors.\r |
ac644614 | 4860 | \r |
4861 | If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r | |
4862 | \r | |
4863 | @param Address The base address of the instruction lines to invalidate. If\r | |
4864 | the CPU is in a physical addressing mode, then Address is a\r | |
4865 | physical address. If the CPU is in a virtual addressing mode,\r | |
4866 | then Address is a virtual address.\r | |
4867 | \r | |
4868 | @param Length The number of bytes to invalidate from the instruction cache.\r | |
4869 | \r | |
cc39b88b | 4870 | @return Address.\r |
ac644614 | 4871 | \r |
4872 | **/\r | |
4873 | VOID *\r | |
4874 | EFIAPI\r | |
cc39b88b | 4875 | AsmFlushCacheRange (\r |
ac644614 | 4876 | IN VOID *Address,\r |
4877 | IN UINTN Length\r | |
4878 | );\r | |
4879 | \r | |
4880 | \r | |
4881 | /**\r | |
af2dc6a7 | 4882 | Executes an FC instruction.\r |
4883 | Executes an FC instruction on the cache line specified by Address.\r | |
ac644614 | 4884 | The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r |
1a2f870c | 4885 | An implementation may flush a larger region. This function is only available on Itanium processors.\r |
ac644614 | 4886 | \r |
ee6c452c | 4887 | @param Address The Address of cache line to be flushed.\r |
ac644614 | 4888 | \r |
4889 | @return The address of FC instruction executed.\r | |
4890 | \r | |
4891 | **/\r | |
4892 | UINT64\r | |
4893 | EFIAPI\r | |
4894 | AsmFc (\r | |
4895 | IN UINT64 Address\r | |
4896 | );\r | |
4897 | \r | |
4898 | \r | |
4899 | /**\r | |
af2dc6a7 | 4900 | Executes an FC.I instruction.\r |
4901 | Executes an FC.I instruction on the cache line specified by Address.\r | |
ac644614 | 4902 | The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r |
1a2f870c | 4903 | An implementation may flush a larger region. This function is only available on Itanium processors.\r |
ac644614 | 4904 | \r |
ee6c452c | 4905 | @param Address The Address of cache line to be flushed.\r |
ac644614 | 4906 | \r |
af2dc6a7 | 4907 | @return The address of the FC.I instruction executed.\r |
ac644614 | 4908 | \r |
4909 | **/\r | |
4910 | UINT64\r | |
4911 | EFIAPI\r | |
4912 | AsmFci (\r | |
4913 | IN UINT64 Address\r | |
4914 | );\r | |
4915 | \r | |
4916 | \r | |
4917 | /**\r | |
4918 | Reads the current value of a Processor Identifier Register (CPUID).\r | |
17f695ed | 4919 | \r |
4920 | Reads and returns the current value of Processor Identifier Register specified by Index. \r | |
ac644614 | 4921 | The Index of largest implemented CPUID (One less than the number of implemented CPUID\r |
4922 | registers) is determined by CPUID [3] bits {7:0}.\r | |
4923 | No parameter checking is performed on Index. If the Index value is beyond the\r | |
4924 | implemented CPUID register range, a Reserved Register/Field fault may occur. The caller\r | |
4925 | must either guarantee that Index is valid, or the caller must set up fault handlers to\r | |
1a2f870c | 4926 | catch the faults. This function is only available on Itanium processors.\r |
ac644614 | 4927 | \r |
ee6c452c | 4928 | @param Index The 8-bit Processor Identifier Register index to read.\r |
ac644614 | 4929 | \r |
4930 | @return The current value of Processor Identifier Register specified by Index.\r | |
4931 | \r | |
4932 | **/\r | |
4933 | UINT64\r | |
4934 | EFIAPI\r | |
4935 | AsmReadCpuid (\r | |
4936 | IN UINT8 Index\r | |
4937 | );\r | |
4938 | \r | |
4939 | \r | |
4940 | /**\r | |
4941 | Reads the current value of 64-bit Processor Status Register (PSR).\r | |
1a2f870c | 4942 | This function is only available on Itanium processors.\r |
ac644614 | 4943 | \r |
4944 | @return The current value of PSR.\r | |
4945 | \r | |
4946 | **/\r | |
4947 | UINT64\r | |
4948 | EFIAPI\r | |
4949 | AsmReadPsr (\r | |
4950 | VOID\r | |
4951 | );\r | |
4952 | \r | |
4953 | \r | |
4954 | /**\r | |
4955 | Writes the current value of 64-bit Processor Status Register (PSR).\r | |
22388319 | 4956 | \r |
ac644614 | 4957 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
22388319 | 4958 | reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.\r |
4959 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
1a2f870c | 4960 | fault handlers to catch the faults. This function is only available on Itanium processors.\r |
ac644614 | 4961 | \r |
ee6c452c | 4962 | @param Value The 64-bit value to write to PSR.\r |
ac644614 | 4963 | \r |
4964 | @return The 64-bit value written to the PSR.\r | |
4965 | \r | |
4966 | **/\r | |
4967 | UINT64\r | |
4968 | EFIAPI\r | |
4969 | AsmWritePsr (\r | |
4970 | IN UINT64 Value\r | |
4971 | );\r | |
4972 | \r | |
4973 | \r | |
4974 | /**\r | |
4975 | Reads the current value of 64-bit Kernel Register #0 (KR0).\r | |
2fe241a2 | 4976 | \r |
4977 | Reads and returns the current value of KR0. \r | |
1a2f870c | 4978 | This function is only available on Itanium processors.\r |
ac644614 | 4979 | \r |
4980 | @return The current value of KR0.\r | |
4981 | \r | |
4982 | **/\r | |
4983 | UINT64\r | |
4984 | EFIAPI\r | |
4985 | AsmReadKr0 (\r | |
4986 | VOID\r | |
4987 | );\r | |
4988 | \r | |
4989 | \r | |
4990 | /**\r | |
4991 | Reads the current value of 64-bit Kernel Register #1 (KR1).\r | |
2fe241a2 | 4992 | \r |
4993 | Reads and returns the current value of KR1. \r | |
1a2f870c | 4994 | This function is only available on Itanium processors.\r |
ac644614 | 4995 | \r |
4996 | @return The current value of KR1.\r | |
4997 | \r | |
4998 | **/\r | |
4999 | UINT64\r | |
5000 | EFIAPI\r | |
5001 | AsmReadKr1 (\r | |
5002 | VOID\r | |
5003 | );\r | |
5004 | \r | |
5005 | \r | |
5006 | /**\r | |
5007 | Reads the current value of 64-bit Kernel Register #2 (KR2).\r | |
2fe241a2 | 5008 | \r |
5009 | Reads and returns the current value of KR2. \r | |
1a2f870c | 5010 | This function is only available on Itanium processors.\r |
ac644614 | 5011 | \r |
5012 | @return The current value of KR2.\r | |
5013 | \r | |
5014 | **/\r | |
5015 | UINT64\r | |
5016 | EFIAPI\r | |
5017 | AsmReadKr2 (\r | |
5018 | VOID\r | |
5019 | );\r | |
5020 | \r | |
5021 | \r | |
5022 | /**\r | |
5023 | Reads the current value of 64-bit Kernel Register #3 (KR3).\r | |
2fe241a2 | 5024 | \r |
5025 | Reads and returns the current value of KR3. \r | |
1a2f870c | 5026 | This function is only available on Itanium processors.\r |
ac644614 | 5027 | \r |
5028 | @return The current value of KR3.\r | |
5029 | \r | |
5030 | **/\r | |
5031 | UINT64\r | |
5032 | EFIAPI\r | |
5033 | AsmReadKr3 (\r | |
5034 | VOID\r | |
5035 | );\r | |
5036 | \r | |
5037 | \r | |
5038 | /**\r | |
5039 | Reads the current value of 64-bit Kernel Register #4 (KR4).\r | |
ac644614 | 5040 | \r |
2fe241a2 | 5041 | Reads and returns the current value of KR4. \r |
1a2f870c | 5042 | This function is only available on Itanium processors.\r |
2fe241a2 | 5043 | \r |
ac644614 | 5044 | @return The current value of KR4.\r |
5045 | \r | |
5046 | **/\r | |
5047 | UINT64\r | |
5048 | EFIAPI\r | |
5049 | AsmReadKr4 (\r | |
5050 | VOID\r | |
5051 | );\r | |
5052 | \r | |
5053 | \r | |
5054 | /**\r | |
5055 | Reads the current value of 64-bit Kernel Register #5 (KR5).\r | |
2fe241a2 | 5056 | \r |
5057 | Reads and returns the current value of KR5. \r | |
1a2f870c | 5058 | This function is only available on Itanium processors.\r |
ac644614 | 5059 | \r |
5060 | @return The current value of KR5.\r | |
5061 | \r | |
5062 | **/\r | |
5063 | UINT64\r | |
5064 | EFIAPI\r | |
5065 | AsmReadKr5 (\r | |
5066 | VOID\r | |
5067 | );\r | |
5068 | \r | |
5069 | \r | |
5070 | /**\r | |
5071 | Reads the current value of 64-bit Kernel Register #6 (KR6).\r | |
2fe241a2 | 5072 | \r |
5073 | Reads and returns the current value of KR6. \r | |
1a2f870c | 5074 | This function is only available on Itanium processors.\r |
ac644614 | 5075 | \r |
5076 | @return The current value of KR6.\r | |
5077 | \r | |
5078 | **/\r | |
5079 | UINT64\r | |
5080 | EFIAPI\r | |
5081 | AsmReadKr6 (\r | |
5082 | VOID\r | |
5083 | );\r | |
5084 | \r | |
5085 | \r | |
5086 | /**\r | |
5087 | Reads the current value of 64-bit Kernel Register #7 (KR7).\r | |
2fe241a2 | 5088 | \r |
5089 | Reads and returns the current value of KR7. \r | |
1a2f870c | 5090 | This function is only available on Itanium processors.\r |
ac644614 | 5091 | \r |
5092 | @return The current value of KR7.\r | |
5093 | \r | |
5094 | **/\r | |
5095 | UINT64\r | |
5096 | EFIAPI\r | |
5097 | AsmReadKr7 (\r | |
5098 | VOID\r | |
5099 | );\r | |
5100 | \r | |
5101 | \r | |
5102 | /**\r | |
5103 | Write the current value of 64-bit Kernel Register #0 (KR0).\r | |
2fe241a2 | 5104 | \r |
5105 | Writes the current value of KR0. The 64-bit value written to \r | |
1a2f870c | 5106 | the KR0 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5107 | \r |
ee6c452c | 5108 | @param Value The 64-bit value to write to KR0.\r |
ac644614 | 5109 | \r |
5110 | @return The 64-bit value written to the KR0.\r | |
5111 | \r | |
5112 | **/\r | |
5113 | UINT64\r | |
5114 | EFIAPI\r | |
5115 | AsmWriteKr0 (\r | |
5116 | IN UINT64 Value\r | |
5117 | );\r | |
5118 | \r | |
5119 | \r | |
5120 | /**\r | |
5121 | Write the current value of 64-bit Kernel Register #1 (KR1).\r | |
2fe241a2 | 5122 | \r |
5123 | Writes the current value of KR1. The 64-bit value written to \r | |
1a2f870c | 5124 | the KR1 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5125 | \r |
ee6c452c | 5126 | @param Value The 64-bit value to write to KR1.\r |
ac644614 | 5127 | \r |
5128 | @return The 64-bit value written to the KR1.\r | |
5129 | \r | |
5130 | **/\r | |
5131 | UINT64\r | |
5132 | EFIAPI\r | |
5133 | AsmWriteKr1 (\r | |
5134 | IN UINT64 Value\r | |
5135 | );\r | |
5136 | \r | |
5137 | \r | |
5138 | /**\r | |
5139 | Write the current value of 64-bit Kernel Register #2 (KR2).\r | |
2fe241a2 | 5140 | \r |
5141 | Writes the current value of KR2. The 64-bit value written to \r | |
1a2f870c | 5142 | the KR2 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5143 | \r |
ee6c452c | 5144 | @param Value The 64-bit value to write to KR2.\r |
ac644614 | 5145 | \r |
5146 | @return The 64-bit value written to the KR2.\r | |
5147 | \r | |
5148 | **/\r | |
5149 | UINT64\r | |
5150 | EFIAPI\r | |
5151 | AsmWriteKr2 (\r | |
5152 | IN UINT64 Value\r | |
5153 | );\r | |
5154 | \r | |
5155 | \r | |
5156 | /**\r | |
5157 | Write the current value of 64-bit Kernel Register #3 (KR3).\r | |
2fe241a2 | 5158 | \r |
5159 | Writes the current value of KR3. The 64-bit value written to \r | |
1a2f870c | 5160 | the KR3 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5161 | \r |
ee6c452c | 5162 | @param Value The 64-bit value to write to KR3.\r |
ac644614 | 5163 | \r |
5164 | @return The 64-bit value written to the KR3.\r | |
5165 | \r | |
5166 | **/\r | |
5167 | UINT64\r | |
5168 | EFIAPI\r | |
5169 | AsmWriteKr3 (\r | |
5170 | IN UINT64 Value\r | |
5171 | );\r | |
5172 | \r | |
5173 | \r | |
5174 | /**\r | |
5175 | Write the current value of 64-bit Kernel Register #4 (KR4).\r | |
2fe241a2 | 5176 | \r |
5177 | Writes the current value of KR4. The 64-bit value written to \r | |
1a2f870c | 5178 | the KR4 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5179 | \r |
ee6c452c | 5180 | @param Value The 64-bit value to write to KR4.\r |
ac644614 | 5181 | \r |
5182 | @return The 64-bit value written to the KR4.\r | |
5183 | \r | |
5184 | **/\r | |
5185 | UINT64\r | |
5186 | EFIAPI\r | |
5187 | AsmWriteKr4 (\r | |
5188 | IN UINT64 Value\r | |
5189 | );\r | |
5190 | \r | |
5191 | \r | |
5192 | /**\r | |
5193 | Write the current value of 64-bit Kernel Register #5 (KR5).\r | |
2fe241a2 | 5194 | \r |
5195 | Writes the current value of KR5. The 64-bit value written to \r | |
1a2f870c | 5196 | the KR5 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5197 | \r |
ee6c452c | 5198 | @param Value The 64-bit value to write to KR5.\r |
ac644614 | 5199 | \r |
5200 | @return The 64-bit value written to the KR5.\r | |
5201 | \r | |
5202 | **/\r | |
5203 | UINT64\r | |
5204 | EFIAPI\r | |
5205 | AsmWriteKr5 (\r | |
5206 | IN UINT64 Value\r | |
5207 | );\r | |
5208 | \r | |
5209 | \r | |
5210 | /**\r | |
5211 | Write the current value of 64-bit Kernel Register #6 (KR6).\r | |
2fe241a2 | 5212 | \r |
5213 | Writes the current value of KR6. The 64-bit value written to \r | |
1a2f870c | 5214 | the KR6 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5215 | \r |
ee6c452c | 5216 | @param Value The 64-bit value to write to KR6.\r |
ac644614 | 5217 | \r |
5218 | @return The 64-bit value written to the KR6.\r | |
5219 | \r | |
5220 | **/\r | |
5221 | UINT64\r | |
5222 | EFIAPI\r | |
5223 | AsmWriteKr6 (\r | |
5224 | IN UINT64 Value\r | |
5225 | );\r | |
5226 | \r | |
5227 | \r | |
5228 | /**\r | |
5229 | Write the current value of 64-bit Kernel Register #7 (KR7).\r | |
2fe241a2 | 5230 | \r |
5231 | Writes the current value of KR7. The 64-bit value written to \r | |
1a2f870c | 5232 | the KR7 is returned. This function is only available on Itanium processors.\r |
ac644614 | 5233 | \r |
ee6c452c | 5234 | @param Value The 64-bit value to write to KR7.\r |
ac644614 | 5235 | \r |
5236 | @return The 64-bit value written to the KR7.\r | |
5237 | \r | |
5238 | **/\r | |
5239 | UINT64\r | |
5240 | EFIAPI\r | |
5241 | AsmWriteKr7 (\r | |
5242 | IN UINT64 Value\r | |
5243 | );\r | |
5244 | \r | |
5245 | \r | |
5246 | /**\r | |
5247 | Reads the current value of Interval Timer Counter Register (ITC).\r | |
2fe241a2 | 5248 | \r |
5249 | Reads and returns the current value of ITC.\r | |
1a2f870c | 5250 | This function is only available on Itanium processors.\r |
ac644614 | 5251 | \r |
5252 | @return The current value of ITC.\r | |
5253 | \r | |
5254 | **/\r | |
5255 | UINT64\r | |
5256 | EFIAPI\r | |
5257 | AsmReadItc (\r | |
5258 | VOID\r | |
5259 | );\r | |
5260 | \r | |
5261 | \r | |
5262 | /**\r | |
5263 | Reads the current value of Interval Timer Vector Register (ITV).\r | |
2fe241a2 | 5264 | \r |
5265 | Reads and returns the current value of ITV. \r | |
1a2f870c | 5266 | This function is only available on Itanium processors.\r |
ac644614 | 5267 | \r |
5268 | @return The current value of ITV.\r | |
5269 | \r | |
5270 | **/\r | |
5271 | UINT64\r | |
5272 | EFIAPI\r | |
5273 | AsmReadItv (\r | |
5274 | VOID\r | |
5275 | );\r | |
5276 | \r | |
5277 | \r | |
5278 | /**\r | |
5279 | Reads the current value of Interval Timer Match Register (ITM).\r | |
2fe241a2 | 5280 | \r |
5281 | Reads and returns the current value of ITM.\r | |
1a2f870c | 5282 | This function is only available on Itanium processors.\r |
ac644614 | 5283 | \r |
5284 | @return The current value of ITM.\r | |
5285 | **/\r | |
5286 | UINT64\r | |
5287 | EFIAPI\r | |
5288 | AsmReadItm (\r | |
5289 | VOID\r | |
5290 | );\r | |
5291 | \r | |
5292 | \r | |
5293 | /**\r | |
5294 | Writes the current value of 64-bit Interval Timer Counter Register (ITC).\r | |
2fe241a2 | 5295 | \r |
5296 | Writes the current value of ITC. The 64-bit value written to the ITC is returned. \r | |
1a2f870c | 5297 | This function is only available on Itanium processors.\r |
ac644614 | 5298 | \r |
ee6c452c | 5299 | @param Value The 64-bit value to write to ITC.\r |
ac644614 | 5300 | \r |
5301 | @return The 64-bit value written to the ITC.\r | |
5302 | \r | |
5303 | **/\r | |
5304 | UINT64\r | |
5305 | EFIAPI\r | |
5306 | AsmWriteItc (\r | |
5307 | IN UINT64 Value\r | |
5308 | );\r | |
5309 | \r | |
5310 | \r | |
5311 | /**\r | |
5312 | Writes the current value of 64-bit Interval Timer Match Register (ITM).\r | |
2fe241a2 | 5313 | \r |
5314 | Writes the current value of ITM. The 64-bit value written to the ITM is returned. \r | |
1a2f870c | 5315 | This function is only available on Itanium processors.\r |
ac644614 | 5316 | \r |
ee6c452c | 5317 | @param Value The 64-bit value to write to ITM.\r |
ac644614 | 5318 | \r |
5319 | @return The 64-bit value written to the ITM.\r | |
5320 | \r | |
5321 | **/\r | |
5322 | UINT64\r | |
5323 | EFIAPI\r | |
5324 | AsmWriteItm (\r | |
5325 | IN UINT64 Value\r | |
5326 | );\r | |
5327 | \r | |
5328 | \r | |
5329 | /**\r | |
5330 | Writes the current value of 64-bit Interval Timer Vector Register (ITV).\r | |
2fe241a2 | 5331 | \r |
5332 | Writes the current value of ITV. The 64-bit value written to the ITV is returned. \r | |
ac644614 | 5333 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
5334 | reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.\r | |
5335 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5336 | fault handlers to catch the faults.\r | |
1a2f870c | 5337 | This function is only available on Itanium processors.\r |
ac644614 | 5338 | \r |
ee6c452c | 5339 | @param Value The 64-bit value to write to ITV.\r |
ac644614 | 5340 | \r |
5341 | @return The 64-bit value written to the ITV.\r | |
5342 | \r | |
5343 | **/\r | |
5344 | UINT64\r | |
5345 | EFIAPI\r | |
5346 | AsmWriteItv (\r | |
5347 | IN UINT64 Value\r | |
5348 | );\r | |
5349 | \r | |
5350 | \r | |
5351 | /**\r | |
5352 | Reads the current value of Default Control Register (DCR).\r | |
2fe241a2 | 5353 | \r |
1a2f870c | 5354 | Reads and returns the current value of DCR. This function is only available on Itanium processors.\r |
ac644614 | 5355 | \r |
5356 | @return The current value of DCR.\r | |
5357 | \r | |
5358 | **/\r | |
5359 | UINT64\r | |
5360 | EFIAPI\r | |
5361 | AsmReadDcr (\r | |
5362 | VOID\r | |
5363 | );\r | |
5364 | \r | |
5365 | \r | |
5366 | /**\r | |
5367 | Reads the current value of Interruption Vector Address Register (IVA).\r | |
2fe241a2 | 5368 | \r |
1a2f870c | 5369 | Reads and returns the current value of IVA. This function is only available on Itanium processors.\r |
ac644614 | 5370 | \r |
5371 | @return The current value of IVA.\r | |
5372 | **/\r | |
5373 | UINT64\r | |
5374 | EFIAPI\r | |
5375 | AsmReadIva (\r | |
5376 | VOID\r | |
5377 | );\r | |
5378 | \r | |
5379 | \r | |
5380 | /**\r | |
5381 | Reads the current value of Page Table Address Register (PTA).\r | |
2fe241a2 | 5382 | \r |
1a2f870c | 5383 | Reads and returns the current value of PTA. This function is only available on Itanium processors.\r |
ac644614 | 5384 | \r |
5385 | @return The current value of PTA.\r | |
5386 | \r | |
5387 | **/\r | |
5388 | UINT64\r | |
5389 | EFIAPI\r | |
5390 | AsmReadPta (\r | |
5391 | VOID\r | |
5392 | );\r | |
5393 | \r | |
5394 | \r | |
5395 | /**\r | |
5396 | Writes the current value of 64-bit Default Control Register (DCR).\r | |
2fe241a2 | 5397 | \r |
5398 | Writes the current value of DCR. The 64-bit value written to the DCR is returned. \r | |
ac644614 | 5399 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
5400 | reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r | |
5401 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5402 | fault handlers to catch the faults.\r | |
1a2f870c | 5403 | This function is only available on Itanium processors.\r |
ac644614 | 5404 | \r |
ee6c452c | 5405 | @param Value The 64-bit value to write to DCR.\r |
ac644614 | 5406 | \r |
5407 | @return The 64-bit value written to the DCR.\r | |
5408 | \r | |
5409 | **/\r | |
5410 | UINT64\r | |
5411 | EFIAPI\r | |
5412 | AsmWriteDcr (\r | |
5413 | IN UINT64 Value\r | |
5414 | );\r | |
5415 | \r | |
5416 | \r | |
5417 | /**\r | |
5418 | Writes the current value of 64-bit Interruption Vector Address Register (IVA).\r | |
2fe241a2 | 5419 | \r |
5420 | Writes the current value of IVA. The 64-bit value written to the IVA is returned. \r | |
ac644614 | 5421 | The size of vector table is 32 K bytes and is 32 K bytes aligned\r |
5422 | the low 15 bits of Value is ignored when written.\r | |
1a2f870c | 5423 | This function is only available on Itanium processors.\r |
ac644614 | 5424 | \r |
ee6c452c | 5425 | @param Value The 64-bit value to write to IVA.\r |
ac644614 | 5426 | \r |
5427 | @return The 64-bit value written to the IVA.\r | |
5428 | \r | |
5429 | **/\r | |
5430 | UINT64\r | |
5431 | EFIAPI\r | |
5432 | AsmWriteIva (\r | |
5433 | IN UINT64 Value\r | |
5434 | );\r | |
5435 | \r | |
5436 | \r | |
5437 | /**\r | |
5438 | Writes the current value of 64-bit Page Table Address Register (PTA).\r | |
2fe241a2 | 5439 | \r |
5440 | Writes the current value of PTA. The 64-bit value written to the PTA is returned. \r | |
ac644614 | 5441 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
5442 | reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r | |
5443 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5444 | fault handlers to catch the faults.\r | |
1a2f870c | 5445 | This function is only available on Itanium processors.\r |
ac644614 | 5446 | \r |
ee6c452c | 5447 | @param Value The 64-bit value to write to PTA.\r |
ac644614 | 5448 | \r |
5449 | @return The 64-bit value written to the PTA.\r | |
5450 | **/\r | |
5451 | UINT64\r | |
5452 | EFIAPI\r | |
5453 | AsmWritePta (\r | |
5454 | IN UINT64 Value\r | |
5455 | );\r | |
5456 | \r | |
5457 | \r | |
5458 | /**\r | |
5459 | Reads the current value of Local Interrupt ID Register (LID).\r | |
2fe241a2 | 5460 | \r |
1a2f870c | 5461 | Reads and returns the current value of LID. This function is only available on Itanium processors.\r |
ac644614 | 5462 | \r |
5463 | @return The current value of LID.\r | |
5464 | \r | |
5465 | **/\r | |
5466 | UINT64\r | |
5467 | EFIAPI\r | |
5468 | AsmReadLid (\r | |
5469 | VOID\r | |
5470 | );\r | |
5471 | \r | |
5472 | \r | |
5473 | /**\r | |
5474 | Reads the current value of External Interrupt Vector Register (IVR).\r | |
2fe241a2 | 5475 | \r |
1a2f870c | 5476 | Reads and returns the current value of IVR. This function is only available on Itanium processors. \r |
ac644614 | 5477 | \r |
5478 | @return The current value of IVR.\r | |
5479 | \r | |
5480 | **/\r | |
5481 | UINT64\r | |
5482 | EFIAPI\r | |
5483 | AsmReadIvr (\r | |
5484 | VOID\r | |
5485 | );\r | |
5486 | \r | |
5487 | \r | |
5488 | /**\r | |
5489 | Reads the current value of Task Priority Register (TPR).\r | |
2fe241a2 | 5490 | \r |
1a2f870c | 5491 | Reads and returns the current value of TPR. This function is only available on Itanium processors. \r |
ac644614 | 5492 | \r |
5493 | @return The current value of TPR.\r | |
5494 | \r | |
5495 | **/\r | |
5496 | UINT64\r | |
5497 | EFIAPI\r | |
5498 | AsmReadTpr (\r | |
5499 | VOID\r | |
5500 | );\r | |
5501 | \r | |
5502 | \r | |
5503 | /**\r | |
5504 | Reads the current value of External Interrupt Request Register #0 (IRR0).\r | |
2fe241a2 | 5505 | \r |
1a2f870c | 5506 | Reads and returns the current value of IRR0. This function is only available on Itanium processors. \r |
ac644614 | 5507 | \r |
5508 | @return The current value of IRR0.\r | |
5509 | \r | |
5510 | **/\r | |
5511 | UINT64\r | |
5512 | EFIAPI\r | |
5513 | AsmReadIrr0 (\r | |
5514 | VOID\r | |
5515 | );\r | |
5516 | \r | |
5517 | \r | |
5518 | /**\r | |
5519 | Reads the current value of External Interrupt Request Register #1 (IRR1).\r | |
2fe241a2 | 5520 | \r |
1a2f870c | 5521 | Reads and returns the current value of IRR1. This function is only available on Itanium processors. \r |
ac644614 | 5522 | \r |
5523 | @return The current value of IRR1.\r | |
5524 | \r | |
5525 | **/\r | |
5526 | UINT64\r | |
5527 | EFIAPI\r | |
5528 | AsmReadIrr1 (\r | |
5529 | VOID\r | |
5530 | );\r | |
5531 | \r | |
5532 | \r | |
5533 | /**\r | |
5534 | Reads the current value of External Interrupt Request Register #2 (IRR2).\r | |
2fe241a2 | 5535 | \r |
1a2f870c | 5536 | Reads and returns the current value of IRR2. This function is only available on Itanium processors.\r |
ac644614 | 5537 | \r |
5538 | @return The current value of IRR2.\r | |
5539 | \r | |
5540 | **/\r | |
5541 | UINT64\r | |
5542 | EFIAPI\r | |
5543 | AsmReadIrr2 (\r | |
5544 | VOID\r | |
5545 | );\r | |
5546 | \r | |
5547 | \r | |
5548 | /**\r | |
5549 | Reads the current value of External Interrupt Request Register #3 (IRR3).\r | |
2fe241a2 | 5550 | \r |
1a2f870c | 5551 | Reads and returns the current value of IRR3. This function is only available on Itanium processors. \r |
ac644614 | 5552 | \r |
5553 | @return The current value of IRR3.\r | |
5554 | \r | |
5555 | **/\r | |
5556 | UINT64\r | |
5557 | EFIAPI\r | |
5558 | AsmReadIrr3 (\r | |
5559 | VOID\r | |
5560 | );\r | |
5561 | \r | |
5562 | \r | |
5563 | /**\r | |
5564 | Reads the current value of Performance Monitor Vector Register (PMV).\r | |
2fe241a2 | 5565 | \r |
1a2f870c | 5566 | Reads and returns the current value of PMV. This function is only available on Itanium processors. \r |
ac644614 | 5567 | \r |
5568 | @return The current value of PMV.\r | |
5569 | \r | |
5570 | **/\r | |
5571 | UINT64\r | |
5572 | EFIAPI\r | |
5573 | AsmReadPmv (\r | |
5574 | VOID\r | |
5575 | );\r | |
5576 | \r | |
5577 | \r | |
5578 | /**\r | |
5579 | Reads the current value of Corrected Machine Check Vector Register (CMCV).\r | |
2fe241a2 | 5580 | \r |
1a2f870c | 5581 | Reads and returns the current value of CMCV. This function is only available on Itanium processors.\r |
ac644614 | 5582 | \r |
5583 | @return The current value of CMCV.\r | |
5584 | \r | |
5585 | **/\r | |
5586 | UINT64\r | |
5587 | EFIAPI\r | |
5588 | AsmReadCmcv (\r | |
5589 | VOID\r | |
5590 | );\r | |
5591 | \r | |
5592 | \r | |
5593 | /**\r | |
5594 | Reads the current value of Local Redirection Register #0 (LRR0).\r | |
2fe241a2 | 5595 | \r |
1a2f870c | 5596 | Reads and returns the current value of LRR0. This function is only available on Itanium processors. \r |
ac644614 | 5597 | \r |
5598 | @return The current value of LRR0.\r | |
5599 | \r | |
5600 | **/\r | |
5601 | UINT64\r | |
5602 | EFIAPI\r | |
5603 | AsmReadLrr0 (\r | |
5604 | VOID\r | |
5605 | );\r | |
5606 | \r | |
5607 | \r | |
5608 | /**\r | |
5609 | Reads the current value of Local Redirection Register #1 (LRR1).\r | |
2fe241a2 | 5610 | \r |
1a2f870c | 5611 | Reads and returns the current value of LRR1. This function is only available on Itanium processors.\r |
ac644614 | 5612 | \r |
5613 | @return The current value of LRR1.\r | |
5614 | \r | |
5615 | **/\r | |
5616 | UINT64\r | |
5617 | EFIAPI\r | |
5618 | AsmReadLrr1 (\r | |
5619 | VOID\r | |
5620 | );\r | |
5621 | \r | |
5622 | \r | |
5623 | /**\r | |
5624 | Writes the current value of 64-bit Page Local Interrupt ID Register (LID).\r | |
2fe241a2 | 5625 | \r |
5626 | Writes the current value of LID. The 64-bit value written to the LID is returned. \r | |
ac644614 | 5627 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
5628 | reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.\r | |
5629 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5630 | fault handlers to catch the faults.\r | |
1a2f870c | 5631 | This function is only available on Itanium processors.\r |
ac644614 | 5632 | \r |
ee6c452c | 5633 | @param Value The 64-bit value to write to LID.\r |
ac644614 | 5634 | \r |
5635 | @return The 64-bit value written to the LID.\r | |
5636 | \r | |
5637 | **/\r | |
5638 | UINT64\r | |
5639 | EFIAPI\r | |
5640 | AsmWriteLid (\r | |
5641 | IN UINT64 Value\r | |
5642 | );\r | |
5643 | \r | |
5644 | \r | |
5645 | /**\r | |
5646 | Writes the current value of 64-bit Task Priority Register (TPR).\r | |
2fe241a2 | 5647 | \r |
5648 | Writes the current value of TPR. The 64-bit value written to the TPR is returned. \r | |
ac644614 | 5649 | No parameter checking is performed on Value. All bits of Value corresponding to\r |
5650 | reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.\r | |
5651 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5652 | fault handlers to catch the faults.\r | |
1a2f870c | 5653 | This function is only available on Itanium processors.\r |
ac644614 | 5654 | \r |
ee6c452c | 5655 | @param Value The 64-bit value to write to TPR.\r |
ac644614 | 5656 | \r |
5657 | @return The 64-bit value written to the TPR.\r | |
5658 | \r | |
5659 | **/\r | |
5660 | UINT64\r | |
5661 | EFIAPI\r | |
5662 | AsmWriteTpr (\r | |
5663 | IN UINT64 Value\r | |
5664 | );\r | |
5665 | \r | |
5666 | \r | |
5667 | /**\r | |
5668 | Performs a write operation on End OF External Interrupt Register (EOI).\r | |
2fe241a2 | 5669 | \r |
1a2f870c | 5670 | Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.\r |
ac644614 | 5671 | \r |
5672 | **/\r | |
5673 | VOID\r | |
5674 | EFIAPI\r | |
5675 | AsmWriteEoi (\r | |
5676 | VOID\r | |
5677 | );\r | |
5678 | \r | |
5679 | \r | |
5680 | /**\r | |
5681 | Writes the current value of 64-bit Performance Monitor Vector Register (PMV).\r | |
2fe241a2 | 5682 | \r |
5683 | Writes the current value of PMV. The 64-bit value written to the PMV is returned. \r | |
ac644614 | 5684 | No parameter checking is performed on Value. All bits of Value corresponding\r |
5685 | to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.\r | |
5686 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5687 | fault handlers to catch the faults.\r | |
1a2f870c | 5688 | This function is only available on Itanium processors.\r |
ac644614 | 5689 | \r |
ee6c452c | 5690 | @param Value The 64-bit value to write to PMV.\r |
ac644614 | 5691 | \r |
5692 | @return The 64-bit value written to the PMV.\r | |
5693 | \r | |
5694 | **/\r | |
5695 | UINT64\r | |
5696 | EFIAPI\r | |
5697 | AsmWritePmv (\r | |
5698 | IN UINT64 Value\r | |
5699 | );\r | |
5700 | \r | |
5701 | \r | |
5702 | /**\r | |
5703 | Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).\r | |
2fe241a2 | 5704 | \r |
5705 | Writes the current value of CMCV. The 64-bit value written to the CMCV is returned. \r | |
ac644614 | 5706 | No parameter checking is performed on Value. All bits of Value corresponding\r |
5707 | to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.\r | |
5708 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5709 | fault handlers to catch the faults.\r | |
1a2f870c | 5710 | This function is only available on Itanium processors.\r |
ac644614 | 5711 | \r |
ee6c452c | 5712 | @param Value The 64-bit value to write to CMCV.\r |
ac644614 | 5713 | \r |
5714 | @return The 64-bit value written to the CMCV.\r | |
5715 | \r | |
5716 | **/\r | |
5717 | UINT64\r | |
5718 | EFIAPI\r | |
5719 | AsmWriteCmcv (\r | |
5720 | IN UINT64 Value\r | |
5721 | );\r | |
5722 | \r | |
5723 | \r | |
5724 | /**\r | |
5725 | Writes the current value of 64-bit Local Redirection Register #0 (LRR0).\r | |
2fe241a2 | 5726 | \r |
5727 | Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned. \r | |
ac644614 | 5728 | No parameter checking is performed on Value. All bits of Value corresponding\r |
5729 | to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.\r | |
5730 | The caller must either guarantee that Value is valid, or the caller must set up\r | |
5731 | fault handlers to catch the faults.\r | |
1a2f870c | 5732 | This function is only available on Itanium processors.\r |
ac644614 | 5733 | \r |
ee6c452c | 5734 | @param Value The 64-bit value to write to LRR0.\r |
ac644614 | 5735 | \r |
5736 | @return The 64-bit value written to the LRR0.\r | |
5737 | \r | |
5738 | **/\r | |
5739 | UINT64\r | |
5740 | EFIAPI\r | |
5741 | AsmWriteLrr0 (\r | |
5742 | IN UINT64 Value\r | |
5743 | );\r | |
5744 | \r | |
5745 | \r | |
5746 | /**\r | |
5747 | Writes the current value of 64-bit Local Redirection Register #1 (LRR1).\r | |
2fe241a2 | 5748 | \r |
5749 | Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned. \r | |
ac644614 | 5750 | No parameter checking is performed on Value. All bits of Value corresponding\r |
5751 | to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.\r | |
5752 | The caller must either guarantee that Value is valid, or the caller must\r | |
5753 | set up fault handlers to catch the faults.\r | |
1a2f870c | 5754 | This function is only available on Itanium processors.\r |
ac644614 | 5755 | \r |
ee6c452c | 5756 | @param Value The 64-bit value to write to LRR1.\r |
ac644614 | 5757 | \r |
5758 | @return The 64-bit value written to the LRR1.\r | |
5759 | \r | |
5760 | **/\r | |
5761 | UINT64\r | |
5762 | EFIAPI\r | |
5763 | AsmWriteLrr1 (\r | |
5764 | IN UINT64 Value\r | |
5765 | );\r | |
5766 | \r | |
5767 | \r | |
5768 | /**\r | |
5769 | Reads the current value of Instruction Breakpoint Register (IBR).\r | |
5770 | \r | |
5771 | The Instruction Breakpoint Registers are used in pairs. The even numbered\r | |
5772 | registers contain breakpoint addresses, and the odd numbered registers contain\r | |
af2dc6a7 | 5773 | breakpoint mask conditions. At least four instruction registers pairs are implemented\r |
ac644614 | 5774 | on all processor models. Implemented registers are contiguous starting with\r |
5775 | register 0. No parameter checking is performed on Index, and if the Index value\r | |
5776 | is beyond the implemented IBR register range, a Reserved Register/Field fault may\r | |
5777 | occur. The caller must either guarantee that Index is valid, or the caller must\r | |
5778 | set up fault handlers to catch the faults.\r | |
1a2f870c | 5779 | This function is only available on Itanium processors.\r |
ac644614 | 5780 | \r |
ee6c452c | 5781 | @param Index The 8-bit Instruction Breakpoint Register index to read.\r |
ac644614 | 5782 | \r |
5783 | @return The current value of Instruction Breakpoint Register specified by Index.\r | |
5784 | \r | |
5785 | **/\r | |
5786 | UINT64\r | |
5787 | EFIAPI\r | |
5788 | AsmReadIbr (\r | |
5789 | IN UINT8 Index\r | |
5790 | );\r | |
5791 | \r | |
5792 | \r | |
5793 | /**\r | |
5794 | Reads the current value of Data Breakpoint Register (DBR).\r | |
5795 | \r | |
5796 | The Data Breakpoint Registers are used in pairs. The even numbered registers\r | |
5797 | contain breakpoint addresses, and odd numbered registers contain breakpoint\r | |
af2dc6a7 | 5798 | mask conditions. At least four data registers pairs are implemented on all processor\r |
ac644614 | 5799 | models. Implemented registers are contiguous starting with register 0.\r |
5800 | No parameter checking is performed on Index. If the Index value is beyond\r | |
5801 | the implemented DBR register range, a Reserved Register/Field fault may occur.\r | |
5802 | The caller must either guarantee that Index is valid, or the caller must set up\r | |
5803 | fault handlers to catch the faults.\r | |
1a2f870c | 5804 | This function is only available on Itanium processors.\r |
ac644614 | 5805 | \r |
ee6c452c | 5806 | @param Index The 8-bit Data Breakpoint Register index to read.\r |
ac644614 | 5807 | \r |
5808 | @return The current value of Data Breakpoint Register specified by Index.\r | |
5809 | \r | |
5810 | **/\r | |
5811 | UINT64\r | |
5812 | EFIAPI\r | |
5813 | AsmReadDbr (\r | |
5814 | IN UINT8 Index\r | |
5815 | );\r | |
5816 | \r | |
5817 | \r | |
5818 | /**\r | |
5819 | Reads the current value of Performance Monitor Configuration Register (PMC).\r | |
5820 | \r | |
af2dc6a7 | 5821 | All processor implementations provide at least four performance counters\r |
5822 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r | |
ac644614 | 5823 | status registers (PMC [0]... PMC [3]). Processor implementations may provide\r |
5824 | additional implementation-dependent PMC and PMD to increase the number of\r | |
5825 | 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r | |
5826 | register set is implementation dependent. No parameter checking is performed\r | |
5827 | on Index. If the Index value is beyond the implemented PMC register range,\r | |
5828 | zero value will be returned.\r | |
1a2f870c | 5829 | This function is only available on Itanium processors.\r |
ac644614 | 5830 | \r |
ee6c452c | 5831 | @param Index The 8-bit Performance Monitor Configuration Register index to read.\r |
ac644614 | 5832 | \r |
2fe241a2 | 5833 | @return The current value of Performance Monitor Configuration Register\r |
5834 | specified by Index.\r | |
ac644614 | 5835 | \r |
5836 | **/\r | |
5837 | UINT64\r | |
5838 | EFIAPI\r | |
5839 | AsmReadPmc (\r | |
5840 | IN UINT8 Index\r | |
5841 | );\r | |
5842 | \r | |
5843 | \r | |
5844 | /**\r | |
5845 | Reads the current value of Performance Monitor Data Register (PMD).\r | |
5846 | \r | |
5847 | All processor implementations provide at least 4 performance counters\r | |
5848 | (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter\r | |
5849 | overflow status registers (PMC [0]... PMC [3]). Processor implementations may\r | |
5850 | provide additional implementation-dependent PMC and PMD to increase the number\r | |
5851 | of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r | |
5852 | register set is implementation dependent. No parameter checking is performed\r | |
5853 | on Index. If the Index value is beyond the implemented PMD register range,\r | |
5854 | zero value will be returned.\r | |
1a2f870c | 5855 | This function is only available on Itanium processors.\r |
ac644614 | 5856 | \r |
ee6c452c | 5857 | @param Index The 8-bit Performance Monitor Data Register index to read.\r |
ac644614 | 5858 | \r |
5859 | @return The current value of Performance Monitor Data Register specified by Index.\r | |
5860 | \r | |
5861 | **/\r | |
5862 | UINT64\r | |
5863 | EFIAPI\r | |
5864 | AsmReadPmd (\r | |
5865 | IN UINT8 Index\r | |
5866 | );\r | |
5867 | \r | |
5868 | \r | |
5869 | /**\r | |
5870 | Writes the current value of 64-bit Instruction Breakpoint Register (IBR).\r | |
5871 | \r | |
5872 | Writes current value of Instruction Breakpoint Register specified by Index.\r | |
5873 | The Instruction Breakpoint Registers are used in pairs. The even numbered\r | |
5874 | registers contain breakpoint addresses, and odd numbered registers contain\r | |
af2dc6a7 | 5875 | breakpoint mask conditions. At least four instruction registers pairs are implemented\r |
ac644614 | 5876 | on all processor models. Implemented registers are contiguous starting with\r |
5877 | register 0. No parameter checking is performed on Index. If the Index value\r | |
5878 | is beyond the implemented IBR register range, a Reserved Register/Field fault may\r | |
5879 | occur. The caller must either guarantee that Index is valid, or the caller must\r | |
5880 | set up fault handlers to catch the faults.\r | |
1a2f870c | 5881 | This function is only available on Itanium processors.\r |
ac644614 | 5882 | \r |
ee6c452c | 5883 | @param Index The 8-bit Instruction Breakpoint Register index to write.\r |
5884 | @param Value The 64-bit value to write to IBR.\r | |
ac644614 | 5885 | \r |
5886 | @return The 64-bit value written to the IBR.\r | |
5887 | \r | |
5888 | **/\r | |
5889 | UINT64\r | |
5890 | EFIAPI\r | |
5891 | AsmWriteIbr (\r | |
5892 | IN UINT8 Index,\r | |
5893 | IN UINT64 Value\r | |
5894 | );\r | |
5895 | \r | |
5896 | \r | |
5897 | /**\r | |
5898 | Writes the current value of 64-bit Data Breakpoint Register (DBR).\r | |
5899 | \r | |
5900 | Writes current value of Data Breakpoint Register specified by Index.\r | |
5901 | The Data Breakpoint Registers are used in pairs. The even numbered registers\r | |
5902 | contain breakpoint addresses, and odd numbered registers contain breakpoint\r | |
af2dc6a7 | 5903 | mask conditions. At least four data registers pairs are implemented on all processor\r |
ac644614 | 5904 | models. Implemented registers are contiguous starting with register 0. No parameter\r |
5905 | checking is performed on Index. If the Index value is beyond the implemented\r | |
5906 | DBR register range, a Reserved Register/Field fault may occur. The caller must\r | |
5907 | either guarantee that Index is valid, or the caller must set up fault handlers to\r | |
5908 | catch the faults.\r | |
1a2f870c | 5909 | This function is only available on Itanium processors.\r |
ac644614 | 5910 | \r |
ee6c452c | 5911 | @param Index The 8-bit Data Breakpoint Register index to write.\r |
5912 | @param Value The 64-bit value to write to DBR.\r | |
ac644614 | 5913 | \r |
5914 | @return The 64-bit value written to the DBR.\r | |
5915 | \r | |
5916 | **/\r | |
5917 | UINT64\r | |
5918 | EFIAPI\r | |
5919 | AsmWriteDbr (\r | |
5920 | IN UINT8 Index,\r | |
5921 | IN UINT64 Value\r | |
5922 | );\r | |
5923 | \r | |
5924 | \r | |
5925 | /**\r | |
5926 | Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).\r | |
5927 | \r | |
5928 | Writes current value of Performance Monitor Configuration Register specified by Index.\r | |
af2dc6a7 | 5929 | All processor implementations provide at least four performance counters\r |
5930 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status\r | |
ac644614 | 5931 | registers (PMC [0]... PMC [3]). Processor implementations may provide additional\r |
5932 | implementation-dependent PMC and PMD to increase the number of 'generic' performance\r | |
5933 | counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation\r | |
5934 | dependent. No parameter checking is performed on Index. If the Index value is\r | |
5935 | beyond the implemented PMC register range, the write is ignored.\r | |
1a2f870c | 5936 | This function is only available on Itanium processors.\r |
ac644614 | 5937 | \r |
ee6c452c | 5938 | @param Index The 8-bit Performance Monitor Configuration Register index to write.\r |
5939 | @param Value The 64-bit value to write to PMC.\r | |
ac644614 | 5940 | \r |
5941 | @return The 64-bit value written to the PMC.\r | |
5942 | \r | |
5943 | **/\r | |
5944 | UINT64\r | |
5945 | EFIAPI\r | |
5946 | AsmWritePmc (\r | |
5947 | IN UINT8 Index,\r | |
5948 | IN UINT64 Value\r | |
5949 | );\r | |
5950 | \r | |
5951 | \r | |
5952 | /**\r | |
5953 | Writes the current value of 64-bit Performance Monitor Data Register (PMD).\r | |
5954 | \r | |
5955 | Writes current value of Performance Monitor Data Register specified by Index.\r | |
af2dc6a7 | 5956 | All processor implementations provide at least four performance counters\r |
5957 | (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r | |
ac644614 | 5958 | status registers (PMC [0]... PMC [3]). Processor implementations may provide\r |
5959 | additional implementation-dependent PMC and PMD to increase the number of 'generic'\r | |
5960 | performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set\r | |
5961 | is implementation dependent. No parameter checking is performed on Index. If the\r | |
5962 | Index value is beyond the implemented PMD register range, the write is ignored.\r | |
1a2f870c | 5963 | This function is only available on Itanium processors.\r |
ac644614 | 5964 | \r |
ee6c452c | 5965 | @param Index The 8-bit Performance Monitor Data Register index to write.\r |
5966 | @param Value The 64-bit value to write to PMD.\r | |
ac644614 | 5967 | \r |
5968 | @return The 64-bit value written to the PMD.\r | |
5969 | \r | |
5970 | **/\r | |
5971 | UINT64\r | |
5972 | EFIAPI\r | |
5973 | AsmWritePmd (\r | |
5974 | IN UINT8 Index,\r | |
5975 | IN UINT64 Value\r | |
5976 | );\r | |
5977 | \r | |
5978 | \r | |
5979 | /**\r | |
5980 | Reads the current value of 64-bit Global Pointer (GP).\r | |
5981 | \r | |
5982 | Reads and returns the current value of GP.\r | |
1a2f870c | 5983 | This function is only available on Itanium processors.\r |
ac644614 | 5984 | \r |
5985 | @return The current value of GP.\r | |
5986 | \r | |
5987 | **/\r | |
5988 | UINT64\r | |
5989 | EFIAPI\r | |
5990 | AsmReadGp (\r | |
5991 | VOID\r | |
5992 | );\r | |
5993 | \r | |
5994 | \r | |
5995 | /**\r | |
5996 | Write the current value of 64-bit Global Pointer (GP).\r | |
5997 | \r | |
5998 | Writes the current value of GP. The 64-bit value written to the GP is returned.\r | |
5999 | No parameter checking is performed on Value.\r | |
1a2f870c | 6000 | This function is only available on Itanium processors.\r |
ac644614 | 6001 | \r |
6002 | @param Value The 64-bit value to write to GP.\r | |
6003 | \r | |
6004 | @return The 64-bit value written to the GP.\r | |
6005 | \r | |
6006 | **/\r | |
6007 | UINT64\r | |
6008 | EFIAPI\r | |
6009 | AsmWriteGp (\r | |
6010 | IN UINT64 Value\r | |
6011 | );\r | |
6012 | \r | |
6013 | \r | |
6014 | /**\r | |
6015 | Reads the current value of 64-bit Stack Pointer (SP).\r | |
6016 | \r | |
6017 | Reads and returns the current value of SP.\r | |
1a2f870c | 6018 | This function is only available on Itanium processors.\r |
ac644614 | 6019 | \r |
6020 | @return The current value of SP.\r | |
6021 | \r | |
6022 | **/\r | |
6023 | UINT64\r | |
6024 | EFIAPI\r | |
6025 | AsmReadSp (\r | |
6026 | VOID\r | |
6027 | );\r | |
6028 | \r | |
6029 | \r | |
aad6137d | 6030 | ///\r |
af2dc6a7 | 6031 | /// Valid Index value for AsmReadControlRegister().\r |
aad6137d | 6032 | ///\r |
6033 | #define IPF_CONTROL_REGISTER_DCR 0\r | |
6034 | #define IPF_CONTROL_REGISTER_ITM 1\r | |
6035 | #define IPF_CONTROL_REGISTER_IVA 2\r | |
6036 | #define IPF_CONTROL_REGISTER_PTA 8\r | |
6037 | #define IPF_CONTROL_REGISTER_IPSR 16\r | |
6038 | #define IPF_CONTROL_REGISTER_ISR 17\r | |
6039 | #define IPF_CONTROL_REGISTER_IIP 19\r | |
6040 | #define IPF_CONTROL_REGISTER_IFA 20\r | |
6041 | #define IPF_CONTROL_REGISTER_ITIR 21\r | |
6042 | #define IPF_CONTROL_REGISTER_IIPA 22\r | |
6043 | #define IPF_CONTROL_REGISTER_IFS 23\r | |
6044 | #define IPF_CONTROL_REGISTER_IIM 24\r | |
6045 | #define IPF_CONTROL_REGISTER_IHA 25\r | |
6046 | #define IPF_CONTROL_REGISTER_LID 64\r | |
6047 | #define IPF_CONTROL_REGISTER_IVR 65\r | |
6048 | #define IPF_CONTROL_REGISTER_TPR 66\r | |
6049 | #define IPF_CONTROL_REGISTER_EOI 67\r | |
6050 | #define IPF_CONTROL_REGISTER_IRR0 68\r | |
6051 | #define IPF_CONTROL_REGISTER_IRR1 69\r | |
6052 | #define IPF_CONTROL_REGISTER_IRR2 70\r | |
6053 | #define IPF_CONTROL_REGISTER_IRR3 71\r | |
6054 | #define IPF_CONTROL_REGISTER_ITV 72\r | |
6055 | #define IPF_CONTROL_REGISTER_PMV 73\r | |
6056 | #define IPF_CONTROL_REGISTER_CMCV 74\r | |
6057 | #define IPF_CONTROL_REGISTER_LRR0 80\r | |
6058 | #define IPF_CONTROL_REGISTER_LRR1 81\r | |
6059 | \r | |
6060 | /**\r | |
6061 | Reads a 64-bit control register.\r | |
6062 | \r | |
af2dc6a7 | 6063 | Reads and returns the control register specified by Index. The valid Index valued \r |
6064 | are defined above in "Related Definitions".\r | |
6065 | If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r | |
6066 | available on Itanium processors.\r | |
aad6137d | 6067 | \r |
6068 | @param Index The index of the control register to read.\r | |
6069 | \r | |
6070 | @return The control register specified by Index.\r | |
6071 | \r | |
6072 | **/\r | |
6073 | UINT64\r | |
6074 | EFIAPI\r | |
6075 | AsmReadControlRegister (\r | |
6076 | IN UINT64 Index\r | |
6077 | );\r | |
6078 | \r | |
6079 | \r | |
6080 | ///\r | |
af2dc6a7 | 6081 | /// Valid Index value for AsmReadApplicationRegister().\r |
aad6137d | 6082 | ///\r |
6083 | #define IPF_APPLICATION_REGISTER_K0 0\r | |
6084 | #define IPF_APPLICATION_REGISTER_K1 1\r | |
6085 | #define IPF_APPLICATION_REGISTER_K2 2\r | |
6086 | #define IPF_APPLICATION_REGISTER_K3 3\r | |
6087 | #define IPF_APPLICATION_REGISTER_K4 4\r | |
6088 | #define IPF_APPLICATION_REGISTER_K5 5\r | |
6089 | #define IPF_APPLICATION_REGISTER_K6 6\r | |
6090 | #define IPF_APPLICATION_REGISTER_K7 7\r | |
6091 | #define IPF_APPLICATION_REGISTER_RSC 16\r | |
6092 | #define IPF_APPLICATION_REGISTER_BSP 17\r | |
6093 | #define IPF_APPLICATION_REGISTER_BSPSTORE 18\r | |
6094 | #define IPF_APPLICATION_REGISTER_RNAT 19\r | |
6095 | #define IPF_APPLICATION_REGISTER_FCR 21\r | |
6096 | #define IPF_APPLICATION_REGISTER_EFLAG 24\r | |
6097 | #define IPF_APPLICATION_REGISTER_CSD 25\r | |
6098 | #define IPF_APPLICATION_REGISTER_SSD 26\r | |
6099 | #define IPF_APPLICATION_REGISTER_CFLG 27\r | |
6100 | #define IPF_APPLICATION_REGISTER_FSR 28\r | |
6101 | #define IPF_APPLICATION_REGISTER_FIR 29\r | |
6102 | #define IPF_APPLICATION_REGISTER_FDR 30\r | |
6103 | #define IPF_APPLICATION_REGISTER_CCV 32\r | |
6104 | #define IPF_APPLICATION_REGISTER_UNAT 36\r | |
6105 | #define IPF_APPLICATION_REGISTER_FPSR 40\r | |
6106 | #define IPF_APPLICATION_REGISTER_ITC 44\r | |
6107 | #define IPF_APPLICATION_REGISTER_PFS 64\r | |
6108 | #define IPF_APPLICATION_REGISTER_LC 65\r | |
6109 | #define IPF_APPLICATION_REGISTER_EC 66\r | |
6110 | \r | |
6111 | /**\r | |
6112 | Reads a 64-bit application register.\r | |
6113 | \r | |
af2dc6a7 | 6114 | Reads and returns the application register specified by Index. The valid Index \r |
6115 | valued are defined above in "Related Definitions".\r | |
6116 | If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r | |
6117 | available on Itanium processors.\r | |
aad6137d | 6118 | \r |
6119 | @param Index The index of the application register to read.\r | |
6120 | \r | |
6121 | @return The application register specified by Index.\r | |
6122 | \r | |
6123 | **/\r | |
6124 | UINT64\r | |
6125 | EFIAPI\r | |
6126 | AsmReadApplicationRegister (\r | |
6127 | IN UINT64 Index\r | |
6128 | );\r | |
6129 | \r | |
6130 | \r | |
59e0bb0c | 6131 | /**\r |
6132 | Reads the current value of a Machine Specific Register (MSR).\r | |
6133 | \r | |
6134 | Reads and returns the current value of the Machine Specific Register specified by Index. No\r | |
6135 | parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r | |
6136 | register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r | |
6137 | Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r | |
1a2f870c | 6138 | only available on Itanium processors.\r |
59e0bb0c | 6139 | \r |
6140 | @param Index The 8-bit Machine Specific Register index to read.\r | |
6141 | \r | |
6142 | @return The current value of the Machine Specific Register specified by Index. \r | |
6143 | \r | |
6144 | **/\r | |
6145 | UINT64\r | |
6146 | EFIAPI\r | |
6147 | AsmReadMsr (\r | |
6148 | IN UINT8 Index \r | |
6149 | );\r | |
6150 | \r | |
6151 | \r | |
6152 | /**\r | |
6153 | Writes the current value of a Machine Specific Register (MSR).\r | |
6154 | \r | |
6155 | Writes Value to the Machine Specific Register specified by Index. Value is returned. No\r | |
6156 | parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r | |
6157 | register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r | |
6158 | Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r | |
1a2f870c | 6159 | only available on Itanium processors.\r |
59e0bb0c | 6160 | \r |
6161 | @param Index The 8-bit Machine Specific Register index to write.\r | |
6162 | @param Value The 64-bit value to write to the Machine Specific Register.\r | |
6163 | \r | |
6164 | @return The 64-bit value to write to the Machine Specific Register. \r | |
6165 | \r | |
6166 | **/\r | |
6167 | UINT64\r | |
6168 | EFIAPI\r | |
6169 | AsmWriteMsr (\r | |
6170 | IN UINT8 Index, \r | |
6171 | IN UINT64 Value \r | |
6172 | );\r | |
6173 | \r | |
6174 | \r | |
ac644614 | 6175 | /**\r |
6176 | Determines if the CPU is currently executing in virtual, physical, or mixed mode.\r | |
6177 | \r | |
6178 | Determines the current execution mode of the CPU.\r | |
6179 | If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r | |
6180 | If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r | |
6181 | If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r | |
6182 | and -1 is returned.\r | |
1a2f870c | 6183 | This function is only available on Itanium processors.\r |
ac644614 | 6184 | \r |
17f695ed | 6185 | @retval 1 The CPU is in virtual mode.\r |
6186 | @retval 0 The CPU is in physical mode.\r | |
6187 | @retval -1 The CPU is in mixed mode.\r | |
ac644614 | 6188 | \r |
6189 | **/\r | |
6190 | INT64\r | |
6191 | EFIAPI\r | |
6192 | AsmCpuVirtual (\r | |
6193 | VOID\r | |
6194 | );\r | |
6195 | \r | |
6196 | \r | |
6197 | /**\r | |
6198 | Makes a PAL procedure call.\r | |
6199 | \r | |
6200 | This is a wrapper function to make a PAL procedure call. Based on the Index\r | |
6201 | value this API will make static or stacked PAL call. The following table\r | |
6202 | describes the usage of PAL Procedure Index Assignment. Architected procedures\r | |
6203 | may be designated as required or optional. If a PAL procedure is specified\r | |
6204 | as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the\r | |
6205 | Status field of the PAL_CALL_RETURN structure.\r | |
6206 | This indicates that the procedure is not present in this PAL implementation.\r | |
6207 | It is the caller's responsibility to check for this return code after calling\r | |
6208 | any optional PAL procedure.\r | |
6209 | No parameter checking is performed on the 5 input parameters, but there are\r | |
6210 | some common rules that the caller should follow when making a PAL call. Any\r | |
6211 | address passed to PAL as buffers for return parameters must be 8-byte aligned.\r | |
6212 | Unaligned addresses may cause undefined results. For those parameters defined\r | |
6213 | as reserved or some fields defined as reserved must be zero filled or the invalid\r | |
6214 | argument return value may be returned or undefined result may occur during the\r | |
6215 | execution of the procedure. If the PalEntryPoint does not point to a valid\r | |
6216 | PAL entry point then the system behavior is undefined. This function is only\r | |
1a2f870c | 6217 | available on Itanium processors.\r |
ac644614 | 6218 | \r |
ee6c452c | 6219 | @param PalEntryPoint The PAL procedure calls entry point.\r |
6220 | @param Index The PAL procedure Index number.\r | |
6221 | @param Arg2 The 2nd parameter for PAL procedure calls.\r | |
6222 | @param Arg3 The 3rd parameter for PAL procedure calls.\r | |
6223 | @param Arg4 The 4th parameter for PAL procedure calls.\r | |
ac644614 | 6224 | \r |
6225 | @return structure returned from the PAL Call procedure, including the status and return value.\r | |
6226 | \r | |
6227 | **/\r | |
6228 | PAL_CALL_RETURN\r | |
6229 | EFIAPI\r | |
6230 | AsmPalCall (\r | |
6231 | IN UINT64 PalEntryPoint,\r | |
6232 | IN UINT64 Index,\r | |
6233 | IN UINT64 Arg2,\r | |
6234 | IN UINT64 Arg3,\r | |
6235 | IN UINT64 Arg4\r | |
6236 | );\r | |
fd163050 | 6237 | #endif\r |
ac644614 | 6238 | \r |
fd163050 | 6239 | #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r |
1106ffe1 | 6240 | ///\r |
af2dc6a7 | 6241 | /// IA32 and x64 Specific Functions.\r |
6242 | /// Byte packed structure for 16-bit Real Mode EFLAGS.\r | |
1106ffe1 | 6243 | ///\r |
ac644614 | 6244 | typedef union {\r |
6245 | struct {\r | |
af2dc6a7 | 6246 | UINT32 CF:1; ///< Carry Flag.\r |
6247 | UINT32 Reserved_0:1; ///< Reserved.\r | |
6248 | UINT32 PF:1; ///< Parity Flag.\r | |
6249 | UINT32 Reserved_1:1; ///< Reserved.\r | |
6250 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
6251 | UINT32 Reserved_2:1; ///< Reserved.\r | |
6252 | UINT32 ZF:1; ///< Zero Flag.\r | |
6253 | UINT32 SF:1; ///< Sign Flag.\r | |
6254 | UINT32 TF:1; ///< Trap Flag.\r | |
6255 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
6256 | UINT32 DF:1; ///< Direction Flag.\r | |
6257 | UINT32 OF:1; ///< Overflow Flag.\r | |
6258 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
6259 | UINT32 NT:1; ///< Nested Task.\r | |
6260 | UINT32 Reserved_3:1; ///< Reserved.\r | |
ac644614 | 6261 | } Bits;\r |
6262 | UINT16 Uint16;\r | |
6263 | } IA32_FLAGS16;\r | |
6264 | \r | |
1106ffe1 | 6265 | ///\r |
af2dc6a7 | 6266 | /// Byte packed structure for EFLAGS/RFLAGS.\r |
6267 | /// 32-bits on IA-32.\r | |
6268 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 6269 | ///\r |
ac644614 | 6270 | typedef union {\r |
6271 | struct {\r | |
af2dc6a7 | 6272 | UINT32 CF:1; ///< Carry Flag.\r |
6273 | UINT32 Reserved_0:1; ///< Reserved.\r | |
6274 | UINT32 PF:1; ///< Parity Flag.\r | |
6275 | UINT32 Reserved_1:1; ///< Reserved.\r | |
6276 | UINT32 AF:1; ///< Auxiliary Carry Flag.\r | |
6277 | UINT32 Reserved_2:1; ///< Reserved.\r | |
6278 | UINT32 ZF:1; ///< Zero Flag.\r | |
6279 | UINT32 SF:1; ///< Sign Flag.\r | |
6280 | UINT32 TF:1; ///< Trap Flag.\r | |
6281 | UINT32 IF:1; ///< Interrupt Enable Flag.\r | |
6282 | UINT32 DF:1; ///< Direction Flag.\r | |
6283 | UINT32 OF:1; ///< Overflow Flag.\r | |
6284 | UINT32 IOPL:2; ///< I/O Privilege Level.\r | |
6285 | UINT32 NT:1; ///< Nested Task.\r | |
6286 | UINT32 Reserved_3:1; ///< Reserved.\r | |
6287 | UINT32 RF:1; ///< Resume Flag.\r | |
6288 | UINT32 VM:1; ///< Virtual 8086 Mode.\r | |
6289 | UINT32 AC:1; ///< Alignment Check.\r | |
6290 | UINT32 VIF:1; ///< Virtual Interrupt Flag.\r | |
6291 | UINT32 VIP:1; ///< Virtual Interrupt Pending.\r | |
6292 | UINT32 ID:1; ///< ID Flag.\r | |
6293 | UINT32 Reserved_4:10; ///< Reserved.\r | |
ac644614 | 6294 | } Bits;\r |
6295 | UINTN UintN;\r | |
6296 | } IA32_EFLAGS32;\r | |
6297 | \r | |
1106ffe1 | 6298 | ///\r |
af2dc6a7 | 6299 | /// Byte packed structure for Control Register 0 (CR0).\r |
6300 | /// 32-bits on IA-32.\r | |
6301 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 6302 | ///\r |
ac644614 | 6303 | typedef union {\r |
6304 | struct {\r | |
af2dc6a7 | 6305 | UINT32 PE:1; ///< Protection Enable.\r |
6306 | UINT32 MP:1; ///< Monitor Coprocessor.\r | |
6307 | UINT32 EM:1; ///< Emulation.\r | |
6308 | UINT32 TS:1; ///< Task Switched.\r | |
6309 | UINT32 ET:1; ///< Extension Type.\r | |
6310 | UINT32 NE:1; ///< Numeric Error.\r | |
6311 | UINT32 Reserved_0:10; ///< Reserved.\r | |
6312 | UINT32 WP:1; ///< Write Protect.\r | |
6313 | UINT32 Reserved_1:1; ///< Reserved.\r | |
6314 | UINT32 AM:1; ///< Alignment Mask.\r | |
6315 | UINT32 Reserved_2:10; ///< Reserved.\r | |
6316 | UINT32 NW:1; ///< Mot Write-through.\r | |
6317 | UINT32 CD:1; ///< Cache Disable.\r | |
6318 | UINT32 PG:1; ///< Paging.\r | |
ac644614 | 6319 | } Bits;\r |
6320 | UINTN UintN;\r | |
6321 | } IA32_CR0;\r | |
6322 | \r | |
1106ffe1 | 6323 | ///\r |
af2dc6a7 | 6324 | /// Byte packed structure for Control Register 4 (CR4).\r |
6325 | /// 32-bits on IA-32.\r | |
6326 | /// 64-bits on x64. The upper 32-bits on x64 are reserved.\r | |
1106ffe1 | 6327 | ///\r |
ac644614 | 6328 | typedef union {\r |
6329 | struct {\r | |
af2dc6a7 | 6330 | UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r |
6331 | UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r | |
6332 | UINT32 TSD:1; ///< Time Stamp Disable.\r | |
6333 | UINT32 DE:1; ///< Debugging Extensions.\r | |
6334 | UINT32 PSE:1; ///< Page Size Extensions.\r | |
6335 | UINT32 PAE:1; ///< Physical Address Extension.\r | |
6336 | UINT32 MCE:1; ///< Machine Check Enable.\r | |
6337 | UINT32 PGE:1; ///< Page Global Enable.\r | |
2a53dabf | 6338 | UINT32 PCE:1; ///< Performance Monitoring Counter\r |
af2dc6a7 | 6339 | ///< Enable.\r |
2a53dabf LG |
6340 | UINT32 OSFXSR:1; ///< Operating System Support for\r |
6341 | ///< FXSAVE and FXRSTOR instructions\r | |
6342 | UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r | |
6343 | ///< Unmasked SIMD Floating Point\r | |
af2dc6a7 | 6344 | ///< Exceptions.\r |
6345 | UINT32 Reserved_0:2; ///< Reserved.\r | |
2a53dabf | 6346 | UINT32 VMXE:1; ///< VMX Enable\r |
af2dc6a7 | 6347 | UINT32 Reserved_1:18; ///< Reserved.\r |
ac644614 | 6348 | } Bits;\r |
6349 | UINTN UintN;\r | |
6350 | } IA32_CR4;\r | |
6351 | \r | |
6088db38 | 6352 | ///\r |
6353 | /// Byte packed structure for a segment descriptor in a GDT/LDT.\r | |
6354 | ///\r | |
6355 | typedef union {\r | |
6356 | struct {\r | |
6357 | UINT32 LimitLow:16;\r | |
6358 | UINT32 BaseLow:16;\r | |
6359 | UINT32 BaseMid:8;\r | |
6360 | UINT32 Type:4;\r | |
6361 | UINT32 S:1;\r | |
6362 | UINT32 DPL:2;\r | |
6363 | UINT32 P:1;\r | |
6364 | UINT32 LimitHigh:4;\r | |
6365 | UINT32 AVL:1;\r | |
6366 | UINT32 L:1;\r | |
6367 | UINT32 DB:1;\r | |
6368 | UINT32 G:1;\r | |
6369 | UINT32 BaseHigh:8;\r | |
6370 | } Bits;\r | |
6371 | UINT64 Uint64;\r | |
6372 | } IA32_SEGMENT_DESCRIPTOR;\r | |
6373 | \r | |
1106ffe1 | 6374 | ///\r |
af2dc6a7 | 6375 | /// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r |
1106ffe1 | 6376 | ///\r |
ac644614 | 6377 | #pragma pack (1)\r |
6378 | typedef struct {\r | |
6379 | UINT16 Limit;\r | |
6380 | UINTN Base;\r | |
6381 | } IA32_DESCRIPTOR;\r | |
6382 | #pragma pack ()\r | |
6383 | \r | |
6384 | #define IA32_IDT_GATE_TYPE_TASK 0x85\r | |
6385 | #define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r | |
6386 | #define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r | |
6387 | #define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r | |
6388 | #define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r | |
6389 | \r | |
6f4aad3b | 6390 | \r |
6391 | #if defined (MDE_CPU_IA32)\r | |
1106ffe1 | 6392 | ///\r |
af2dc6a7 | 6393 | /// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r |
1106ffe1 | 6394 | ///\r |
dc317713 | 6395 | typedef union {\r |
6396 | struct {\r | |
af2dc6a7 | 6397 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
6398 | UINT32 Selector:16; ///< Selector.\r | |
6399 | UINT32 Reserved_0:8; ///< Reserved.\r | |
6400 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
6401 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
dc317713 | 6402 | } Bits;\r |
6403 | UINT64 Uint64;\r | |
6404 | } IA32_IDT_GATE_DESCRIPTOR;\r | |
6405 | \r | |
6406 | #endif\r | |
6407 | \r | |
6408 | #if defined (MDE_CPU_X64)\r | |
6f4aad3b | 6409 | ///\r |
af2dc6a7 | 6410 | /// Byte packed structure for an x64 Interrupt Gate Descriptor.\r |
6f4aad3b | 6411 | ///\r |
ac644614 | 6412 | typedef union {\r |
6413 | struct {\r | |
af2dc6a7 | 6414 | UINT32 OffsetLow:16; ///< Offset bits 15..0.\r |
6415 | UINT32 Selector:16; ///< Selector.\r | |
6416 | UINT32 Reserved_0:8; ///< Reserved.\r | |
6417 | UINT32 GateType:8; ///< Gate Type. See #defines above.\r | |
6418 | UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r | |
6419 | UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r | |
6420 | UINT32 Reserved_1:32; ///< Reserved.\r | |
ac644614 | 6421 | } Bits;\r |
6f4aad3b | 6422 | struct {\r |
6423 | UINT64 Uint64;\r | |
6424 | UINT64 Uint64_1;\r | |
6425 | } Uint128; \r | |
ac644614 | 6426 | } IA32_IDT_GATE_DESCRIPTOR;\r |
6427 | \r | |
dc317713 | 6428 | #endif\r |
6429 | \r | |
1106ffe1 | 6430 | ///\r |
af2dc6a7 | 6431 | /// Byte packed structure for an FP/SSE/SSE2 context.\r |
1106ffe1 | 6432 | ///\r |
ac644614 | 6433 | typedef struct {\r |
6434 | UINT8 Buffer[512];\r | |
6435 | } IA32_FX_BUFFER;\r | |
6436 | \r | |
1106ffe1 | 6437 | ///\r |
af2dc6a7 | 6438 | /// Structures for the 16-bit real mode thunks.\r |
1106ffe1 | 6439 | ///\r |
ac644614 | 6440 | typedef struct {\r |
6441 | UINT32 Reserved1;\r | |
6442 | UINT32 Reserved2;\r | |
6443 | UINT32 Reserved3;\r | |
6444 | UINT32 Reserved4;\r | |
6445 | UINT8 BL;\r | |
6446 | UINT8 BH;\r | |
6447 | UINT16 Reserved5;\r | |
6448 | UINT8 DL;\r | |
6449 | UINT8 DH;\r | |
6450 | UINT16 Reserved6;\r | |
6451 | UINT8 CL;\r | |
6452 | UINT8 CH;\r | |
6453 | UINT16 Reserved7;\r | |
6454 | UINT8 AL;\r | |
6455 | UINT8 AH;\r | |
6456 | UINT16 Reserved8;\r | |
6457 | } IA32_BYTE_REGS;\r | |
6458 | \r | |
6459 | typedef struct {\r | |
6460 | UINT16 DI;\r | |
6461 | UINT16 Reserved1;\r | |
6462 | UINT16 SI;\r | |
6463 | UINT16 Reserved2;\r | |
6464 | UINT16 BP;\r | |
6465 | UINT16 Reserved3;\r | |
6466 | UINT16 SP;\r | |
6467 | UINT16 Reserved4;\r | |
6468 | UINT16 BX;\r | |
6469 | UINT16 Reserved5;\r | |
6470 | UINT16 DX;\r | |
6471 | UINT16 Reserved6;\r | |
6472 | UINT16 CX;\r | |
6473 | UINT16 Reserved7;\r | |
6474 | UINT16 AX;\r | |
6475 | UINT16 Reserved8;\r | |
6476 | } IA32_WORD_REGS;\r | |
6477 | \r | |
6478 | typedef struct {\r | |
6479 | UINT32 EDI;\r | |
6480 | UINT32 ESI;\r | |
6481 | UINT32 EBP;\r | |
6482 | UINT32 ESP;\r | |
6483 | UINT32 EBX;\r | |
6484 | UINT32 EDX;\r | |
6485 | UINT32 ECX;\r | |
6486 | UINT32 EAX;\r | |
6487 | UINT16 DS;\r | |
6488 | UINT16 ES;\r | |
6489 | UINT16 FS;\r | |
6490 | UINT16 GS;\r | |
6491 | IA32_EFLAGS32 EFLAGS;\r | |
6492 | UINT32 Eip;\r | |
6493 | UINT16 CS;\r | |
6494 | UINT16 SS;\r | |
6495 | } IA32_DWORD_REGS;\r | |
6496 | \r | |
6497 | typedef union {\r | |
6498 | IA32_DWORD_REGS E;\r | |
6499 | IA32_WORD_REGS X;\r | |
6500 | IA32_BYTE_REGS H;\r | |
6501 | } IA32_REGISTER_SET;\r | |
6502 | \r | |
1106ffe1 | 6503 | ///\r |
af2dc6a7 | 6504 | /// Byte packed structure for an 16-bit real mode thunks.\r |
1106ffe1 | 6505 | ///\r |
ac644614 | 6506 | typedef struct {\r |
6507 | IA32_REGISTER_SET *RealModeState;\r | |
6508 | VOID *RealModeBuffer;\r | |
6509 | UINT32 RealModeBufferSize;\r | |
6510 | UINT32 ThunkAttributes;\r | |
6511 | } THUNK_CONTEXT;\r | |
6512 | \r | |
6513 | #define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r | |
6514 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r | |
6515 | #define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r | |
6516 | \r | |
6517 | /**\r | |
6518 | Retrieves CPUID information.\r | |
6519 | \r | |
6520 | Executes the CPUID instruction with EAX set to the value specified by Index.\r | |
6521 | This function always returns Index.\r | |
6522 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
6523 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
6524 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
6525 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
030cd1a2 | 6526 | This function is only available on IA-32 and x64.\r |
ac644614 | 6527 | \r |
6528 | @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r | |
6529 | instruction.\r | |
af2dc6a7 | 6530 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 6531 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 6532 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 6533 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 6534 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 6535 | instruction. This is an optional parameter that may be NULL.\r |
af2dc6a7 | 6536 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 6537 | instruction. This is an optional parameter that may be NULL.\r |
6538 | \r | |
2fe241a2 | 6539 | @return Index.\r |
ac644614 | 6540 | \r |
6541 | **/\r | |
6542 | UINT32\r | |
6543 | EFIAPI\r | |
6544 | AsmCpuid (\r | |
6545 | IN UINT32 Index,\r | |
6546 | OUT UINT32 *Eax, OPTIONAL\r | |
6547 | OUT UINT32 *Ebx, OPTIONAL\r | |
6548 | OUT UINT32 *Ecx, OPTIONAL\r | |
6549 | OUT UINT32 *Edx OPTIONAL\r | |
6550 | );\r | |
6551 | \r | |
6552 | \r | |
6553 | /**\r | |
6554 | Retrieves CPUID information using an extended leaf identifier.\r | |
6555 | \r | |
6556 | Executes the CPUID instruction with EAX set to the value specified by Index\r | |
6557 | and ECX set to the value specified by SubIndex. This function always returns\r | |
6558 | Index. This function is only available on IA-32 and x64.\r | |
6559 | \r | |
6560 | If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r | |
6561 | If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r | |
6562 | If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r | |
6563 | If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r | |
6564 | \r | |
6565 | @param Index The 32-bit value to load into EAX prior to invoking the\r | |
6566 | CPUID instruction.\r | |
6567 | @param SubIndex The 32-bit value to load into ECX prior to invoking the\r | |
6568 | CPUID instruction.\r | |
af2dc6a7 | 6569 | @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r |
ac644614 | 6570 | instruction. This is an optional parameter that may be\r |
6571 | NULL.\r | |
af2dc6a7 | 6572 | @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r |
ac644614 | 6573 | instruction. This is an optional parameter that may be\r |
6574 | NULL.\r | |
af2dc6a7 | 6575 | @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r |
ac644614 | 6576 | instruction. This is an optional parameter that may be\r |
6577 | NULL.\r | |
af2dc6a7 | 6578 | @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r |
ac644614 | 6579 | instruction. This is an optional parameter that may be\r |
6580 | NULL.\r | |
6581 | \r | |
2fe241a2 | 6582 | @return Index.\r |
ac644614 | 6583 | \r |
6584 | **/\r | |
6585 | UINT32\r | |
6586 | EFIAPI\r | |
6587 | AsmCpuidEx (\r | |
6588 | IN UINT32 Index,\r | |
6589 | IN UINT32 SubIndex,\r | |
6590 | OUT UINT32 *Eax, OPTIONAL\r | |
6591 | OUT UINT32 *Ebx, OPTIONAL\r | |
6592 | OUT UINT32 *Ecx, OPTIONAL\r | |
6593 | OUT UINT32 *Edx OPTIONAL\r | |
6594 | );\r | |
6595 | \r | |
6596 | \r | |
be5f1614 | 6597 | /**\r |
6598 | Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r | |
6599 | \r | |
6600 | Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r | |
6601 | and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r | |
6602 | \r | |
6603 | **/\r | |
6604 | VOID\r | |
6605 | EFIAPI\r | |
6606 | AsmDisableCache (\r | |
6607 | VOID\r | |
6608 | );\r | |
6609 | \r | |
6610 | \r | |
6611 | /**\r | |
6612 | Perform a WBINVD and clear both the CD and NW bits of CR0.\r | |
6613 | \r | |
6614 | Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r | |
6615 | bits of CR0 to 0. This function is only available on IA-32 and x64.\r | |
6616 | \r | |
6617 | **/\r | |
6618 | VOID\r | |
6619 | EFIAPI\r | |
6620 | AsmEnableCache (\r | |
6621 | VOID\r | |
6622 | );\r | |
6623 | \r | |
6624 | \r | |
ac644614 | 6625 | /**\r |
6626 | Returns the lower 32-bits of a Machine Specific Register(MSR).\r | |
6627 | \r | |
6628 | Reads and returns the lower 32-bits of the MSR specified by Index.\r | |
6629 | No parameter checking is performed on Index, and some Index values may cause\r | |
6630 | CPU exceptions. The caller must either guarantee that Index is valid, or the\r | |
6631 | caller must set up exception handlers to catch the exceptions. This function\r | |
030cd1a2 | 6632 | is only available on IA-32 and x64.\r |
ac644614 | 6633 | \r |
6634 | @param Index The 32-bit MSR index to read.\r | |
6635 | \r | |
6636 | @return The lower 32 bits of the MSR identified by Index.\r | |
6637 | \r | |
6638 | **/\r | |
6639 | UINT32\r | |
6640 | EFIAPI\r | |
6641 | AsmReadMsr32 (\r | |
6642 | IN UINT32 Index\r | |
6643 | );\r | |
6644 | \r | |
6645 | \r | |
6646 | /**\r | |
17f695ed | 6647 | Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r |
6648 | The upper 32-bits of the MSR are set to zero.\r | |
ac644614 | 6649 | \r |
6650 | Writes the 32-bit value specified by Value to the MSR specified by Index. The\r | |
6651 | upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r | |
6652 | the MSR is returned. No parameter checking is performed on Index or Value,\r | |
6653 | and some of these may cause CPU exceptions. The caller must either guarantee\r | |
6654 | that Index and Value are valid, or the caller must establish proper exception\r | |
030cd1a2 | 6655 | handlers. This function is only available on IA-32 and x64.\r |
ac644614 | 6656 | \r |
6657 | @param Index The 32-bit MSR index to write.\r | |
6658 | @param Value The 32-bit value to write to the MSR.\r | |
6659 | \r | |
6660 | @return Value\r | |
6661 | \r | |
6662 | **/\r | |
6663 | UINT32\r | |
6664 | EFIAPI\r | |
6665 | AsmWriteMsr32 (\r | |
6666 | IN UINT32 Index,\r | |
6667 | IN UINT32 Value\r | |
6668 | );\r | |
6669 | \r | |
6670 | \r | |
6671 | /**\r | |
62991af2 | 6672 | Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r |
ac644614 | 6673 | writes the result back to the 64-bit MSR.\r |
6674 | \r | |
62991af2 | 6675 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6676 | between the lower 32-bits of the read result and the value specified by\r |
6677 | OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r | |
6678 | 32-bits of the value written to the MSR is returned. No parameter checking is\r | |
6679 | performed on Index or OrData, and some of these may cause CPU exceptions. The\r | |
6680 | caller must either guarantee that Index and OrData are valid, or the caller\r | |
6681 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 6682 | IA-32 and x64.\r |
ac644614 | 6683 | \r |
6684 | @param Index The 32-bit MSR index to write.\r | |
6685 | @param OrData The value to OR with the read value from the MSR.\r | |
6686 | \r | |
6687 | @return The lower 32-bit value written to the MSR.\r | |
6688 | \r | |
6689 | **/\r | |
6690 | UINT32\r | |
6691 | EFIAPI\r | |
6692 | AsmMsrOr32 (\r | |
6693 | IN UINT32 Index,\r | |
6694 | IN UINT32 OrData\r | |
6695 | );\r | |
6696 | \r | |
6697 | \r | |
6698 | /**\r | |
6699 | Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r | |
6700 | the result back to the 64-bit MSR.\r | |
6701 | \r | |
6702 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6703 | lower 32-bits of the read result and the value specified by AndData, and\r | |
6704 | writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r | |
6705 | the value written to the MSR is returned. No parameter checking is performed\r | |
6706 | on Index or AndData, and some of these may cause CPU exceptions. The caller\r | |
6707 | must either guarantee that Index and AndData are valid, or the caller must\r | |
6708 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 6709 | and x64.\r |
ac644614 | 6710 | \r |
6711 | @param Index The 32-bit MSR index to write.\r | |
6712 | @param AndData The value to AND with the read value from the MSR.\r | |
6713 | \r | |
6714 | @return The lower 32-bit value written to the MSR.\r | |
6715 | \r | |
6716 | **/\r | |
6717 | UINT32\r | |
6718 | EFIAPI\r | |
6719 | AsmMsrAnd32 (\r | |
6720 | IN UINT32 Index,\r | |
6721 | IN UINT32 AndData\r | |
6722 | );\r | |
6723 | \r | |
6724 | \r | |
6725 | /**\r | |
62991af2 | 6726 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r |
ac644614 | 6727 | on the lower 32-bits, and writes the result back to the 64-bit MSR.\r |
6728 | \r | |
6729 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6730 | lower 32-bits of the read result and the value specified by AndData\r | |
62991af2 | 6731 | preserving the upper 32-bits, performs a bitwise OR between the\r |
ac644614 | 6732 | result of the AND operation and the value specified by OrData, and writes the\r |
6733 | result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r | |
6734 | written to the MSR is returned. No parameter checking is performed on Index,\r | |
6735 | AndData, or OrData, and some of these may cause CPU exceptions. The caller\r | |
6736 | must either guarantee that Index, AndData, and OrData are valid, or the\r | |
6737 | caller must establish proper exception handlers. This function is only\r | |
030cd1a2 | 6738 | available on IA-32 and x64.\r |
ac644614 | 6739 | \r |
6740 | @param Index The 32-bit MSR index to write.\r | |
6741 | @param AndData The value to AND with the read value from the MSR.\r | |
6742 | @param OrData The value to OR with the result of the AND operation.\r | |
6743 | \r | |
6744 | @return The lower 32-bit value written to the MSR.\r | |
6745 | \r | |
6746 | **/\r | |
6747 | UINT32\r | |
6748 | EFIAPI\r | |
6749 | AsmMsrAndThenOr32 (\r | |
6750 | IN UINT32 Index,\r | |
6751 | IN UINT32 AndData,\r | |
6752 | IN UINT32 OrData\r | |
6753 | );\r | |
6754 | \r | |
6755 | \r | |
6756 | /**\r | |
6757 | Reads a bit field of an MSR.\r | |
6758 | \r | |
6759 | Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r | |
6760 | specified by the StartBit and the EndBit. The value of the bit field is\r | |
6761 | returned. The caller must either guarantee that Index is valid, or the caller\r | |
6762 | must set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 6763 | available on IA-32 and x64.\r |
ac644614 | 6764 | \r |
6765 | If StartBit is greater than 31, then ASSERT().\r | |
6766 | If EndBit is greater than 31, then ASSERT().\r | |
6767 | If EndBit is less than StartBit, then ASSERT().\r | |
6768 | \r | |
6769 | @param Index The 32-bit MSR index to read.\r | |
6770 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6771 | Range 0..31.\r | |
6772 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6773 | Range 0..31.\r | |
6774 | \r | |
6775 | @return The bit field read from the MSR.\r | |
6776 | \r | |
6777 | **/\r | |
6778 | UINT32\r | |
6779 | EFIAPI\r | |
6780 | AsmMsrBitFieldRead32 (\r | |
6781 | IN UINT32 Index,\r | |
6782 | IN UINTN StartBit,\r | |
6783 | IN UINTN EndBit\r | |
6784 | );\r | |
6785 | \r | |
6786 | \r | |
6787 | /**\r | |
6788 | Writes a bit field to an MSR.\r | |
6789 | \r | |
2fe241a2 | 6790 | Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r |
ac644614 | 6791 | field is specified by the StartBit and the EndBit. All other bits in the\r |
6792 | destination MSR are preserved. The lower 32-bits of the MSR written is\r | |
62991af2 | 6793 | returned. The caller must either guarantee that Index and the data written \r |
6794 | is valid, or the caller must set up exception handlers to catch the exceptions. \r | |
6795 | This function is only available on IA-32 and x64.\r | |
ac644614 | 6796 | \r |
6797 | If StartBit is greater than 31, then ASSERT().\r | |
6798 | If EndBit is greater than 31, then ASSERT().\r | |
6799 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6800 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6801 | \r |
6802 | @param Index The 32-bit MSR index to write.\r | |
6803 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6804 | Range 0..31.\r | |
6805 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6806 | Range 0..31.\r | |
6807 | @param Value New value of the bit field.\r | |
6808 | \r | |
6809 | @return The lower 32-bit of the value written to the MSR.\r | |
6810 | \r | |
6811 | **/\r | |
6812 | UINT32\r | |
6813 | EFIAPI\r | |
6814 | AsmMsrBitFieldWrite32 (\r | |
6815 | IN UINT32 Index,\r | |
6816 | IN UINTN StartBit,\r | |
6817 | IN UINTN EndBit,\r | |
6818 | IN UINT32 Value\r | |
6819 | );\r | |
6820 | \r | |
6821 | \r | |
6822 | /**\r | |
6823 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r | |
6824 | result back to the bit field in the 64-bit MSR.\r | |
6825 | \r | |
62991af2 | 6826 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6827 | between the read result and the value specified by OrData, and writes the\r |
6828 | result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r | |
6829 | written to the MSR are returned. Extra left bits in OrData are stripped. The\r | |
6830 | caller must either guarantee that Index and the data written is valid, or\r | |
6831 | the caller must set up exception handlers to catch the exceptions. This\r | |
030cd1a2 | 6832 | function is only available on IA-32 and x64.\r |
ac644614 | 6833 | \r |
6834 | If StartBit is greater than 31, then ASSERT().\r | |
6835 | If EndBit is greater than 31, then ASSERT().\r | |
6836 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6837 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6838 | \r |
6839 | @param Index The 32-bit MSR index to write.\r | |
6840 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6841 | Range 0..31.\r | |
6842 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6843 | Range 0..31.\r | |
6844 | @param OrData The value to OR with the read value from the MSR.\r | |
6845 | \r | |
6846 | @return The lower 32-bit of the value written to the MSR.\r | |
6847 | \r | |
6848 | **/\r | |
6849 | UINT32\r | |
6850 | EFIAPI\r | |
6851 | AsmMsrBitFieldOr32 (\r | |
6852 | IN UINT32 Index,\r | |
6853 | IN UINTN StartBit,\r | |
6854 | IN UINTN EndBit,\r | |
6855 | IN UINT32 OrData\r | |
6856 | );\r | |
6857 | \r | |
6858 | \r | |
6859 | /**\r | |
6860 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
6861 | result back to the bit field in the 64-bit MSR.\r | |
6862 | \r | |
6863 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
6864 | read result and the value specified by AndData, and writes the result to the\r | |
6865 | 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r | |
6866 | MSR are returned. Extra left bits in AndData are stripped. The caller must\r | |
6867 | either guarantee that Index and the data written is valid, or the caller must\r | |
6868 | set up exception handlers to catch the exceptions. This function is only\r | |
030cd1a2 | 6869 | available on IA-32 and x64.\r |
ac644614 | 6870 | \r |
6871 | If StartBit is greater than 31, then ASSERT().\r | |
6872 | If EndBit is greater than 31, then ASSERT().\r | |
6873 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 6874 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 6875 | \r |
6876 | @param Index The 32-bit MSR index to write.\r | |
6877 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6878 | Range 0..31.\r | |
6879 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6880 | Range 0..31.\r | |
6881 | @param AndData The value to AND with the read value from the MSR.\r | |
6882 | \r | |
6883 | @return The lower 32-bit of the value written to the MSR.\r | |
6884 | \r | |
6885 | **/\r | |
6886 | UINT32\r | |
6887 | EFIAPI\r | |
6888 | AsmMsrBitFieldAnd32 (\r | |
6889 | IN UINT32 Index,\r | |
6890 | IN UINTN StartBit,\r | |
6891 | IN UINTN EndBit,\r | |
6892 | IN UINT32 AndData\r | |
6893 | );\r | |
6894 | \r | |
6895 | \r | |
6896 | /**\r | |
6897 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 6898 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 6899 | 64-bit MSR.\r |
6900 | \r | |
6901 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r | |
62991af2 | 6902 | bitwise OR between the read result and the value specified by\r |
ac644614 | 6903 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
6904 | lower 32-bits of the value written to the MSR are returned. Extra left bits\r | |
6905 | in both AndData and OrData are stripped. The caller must either guarantee\r | |
6906 | that Index and the data written is valid, or the caller must set up exception\r | |
6907 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 6908 | and x64.\r |
ac644614 | 6909 | \r |
6910 | If StartBit is greater than 31, then ASSERT().\r | |
6911 | If EndBit is greater than 31, then ASSERT().\r | |
6912 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
6913 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
6914 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 6915 | \r |
6916 | @param Index The 32-bit MSR index to write.\r | |
6917 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
6918 | Range 0..31.\r | |
6919 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
6920 | Range 0..31.\r | |
6921 | @param AndData The value to AND with the read value from the MSR.\r | |
6922 | @param OrData The value to OR with the result of the AND operation.\r | |
6923 | \r | |
6924 | @return The lower 32-bit of the value written to the MSR.\r | |
6925 | \r | |
6926 | **/\r | |
6927 | UINT32\r | |
6928 | EFIAPI\r | |
6929 | AsmMsrBitFieldAndThenOr32 (\r | |
6930 | IN UINT32 Index,\r | |
6931 | IN UINTN StartBit,\r | |
6932 | IN UINTN EndBit,\r | |
6933 | IN UINT32 AndData,\r | |
6934 | IN UINT32 OrData\r | |
6935 | );\r | |
6936 | \r | |
6937 | \r | |
6938 | /**\r | |
6939 | Returns a 64-bit Machine Specific Register(MSR).\r | |
6940 | \r | |
6941 | Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r | |
6942 | performed on Index, and some Index values may cause CPU exceptions. The\r | |
6943 | caller must either guarantee that Index is valid, or the caller must set up\r | |
6944 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 6945 | on IA-32 and x64.\r |
ac644614 | 6946 | \r |
6947 | @param Index The 32-bit MSR index to read.\r | |
6948 | \r | |
6949 | @return The value of the MSR identified by Index.\r | |
6950 | \r | |
6951 | **/\r | |
6952 | UINT64\r | |
6953 | EFIAPI\r | |
6954 | AsmReadMsr64 (\r | |
6955 | IN UINT32 Index\r | |
6956 | );\r | |
6957 | \r | |
6958 | \r | |
6959 | /**\r | |
6960 | Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r | |
6961 | value.\r | |
6962 | \r | |
6963 | Writes the 64-bit value specified by Value to the MSR specified by Index. The\r | |
6964 | 64-bit value written to the MSR is returned. No parameter checking is\r | |
6965 | performed on Index or Value, and some of these may cause CPU exceptions. The\r | |
6966 | caller must either guarantee that Index and Value are valid, or the caller\r | |
6967 | must establish proper exception handlers. This function is only available on\r | |
030cd1a2 | 6968 | IA-32 and x64.\r |
ac644614 | 6969 | \r |
6970 | @param Index The 32-bit MSR index to write.\r | |
6971 | @param Value The 64-bit value to write to the MSR.\r | |
6972 | \r | |
6973 | @return Value\r | |
6974 | \r | |
6975 | **/\r | |
6976 | UINT64\r | |
6977 | EFIAPI\r | |
6978 | AsmWriteMsr64 (\r | |
6979 | IN UINT32 Index,\r | |
6980 | IN UINT64 Value\r | |
6981 | );\r | |
6982 | \r | |
6983 | \r | |
6984 | /**\r | |
62991af2 | 6985 | Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r |
ac644614 | 6986 | back to the 64-bit MSR.\r |
6987 | \r | |
62991af2 | 6988 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 6989 | between the read result and the value specified by OrData, and writes the\r |
6990 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
6991 | returned. No parameter checking is performed on Index or OrData, and some of\r | |
6992 | these may cause CPU exceptions. The caller must either guarantee that Index\r | |
6993 | and OrData are valid, or the caller must establish proper exception handlers.\r | |
030cd1a2 | 6994 | This function is only available on IA-32 and x64.\r |
ac644614 | 6995 | \r |
6996 | @param Index The 32-bit MSR index to write.\r | |
6997 | @param OrData The value to OR with the read value from the MSR.\r | |
6998 | \r | |
6999 | @return The value written back to the MSR.\r | |
7000 | \r | |
7001 | **/\r | |
7002 | UINT64\r | |
7003 | EFIAPI\r | |
7004 | AsmMsrOr64 (\r | |
7005 | IN UINT32 Index,\r | |
7006 | IN UINT64 OrData\r | |
7007 | );\r | |
7008 | \r | |
7009 | \r | |
7010 | /**\r | |
7011 | Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r | |
7012 | 64-bit MSR.\r | |
7013 | \r | |
7014 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
7015 | read result and the value specified by OrData, and writes the result to the\r | |
7016 | 64-bit MSR specified by Index. The value written to the MSR is returned. No\r | |
7017 | parameter checking is performed on Index or OrData, and some of these may\r | |
7018 | cause CPU exceptions. The caller must either guarantee that Index and OrData\r | |
7019 | are valid, or the caller must establish proper exception handlers. This\r | |
030cd1a2 | 7020 | function is only available on IA-32 and x64.\r |
ac644614 | 7021 | \r |
7022 | @param Index The 32-bit MSR index to write.\r | |
7023 | @param AndData The value to AND with the read value from the MSR.\r | |
7024 | \r | |
7025 | @return The value written back to the MSR.\r | |
7026 | \r | |
7027 | **/\r | |
7028 | UINT64\r | |
7029 | EFIAPI\r | |
7030 | AsmMsrAnd64 (\r | |
7031 | IN UINT32 Index,\r | |
7032 | IN UINT64 AndData\r | |
7033 | );\r | |
7034 | \r | |
7035 | \r | |
7036 | /**\r | |
62991af2 | 7037 | Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise \r |
ac644614 | 7038 | OR, and writes the result back to the 64-bit MSR.\r |
7039 | \r | |
7040 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r | |
62991af2 | 7041 | result and the value specified by AndData, performs a bitwise OR\r |
ac644614 | 7042 | between the result of the AND operation and the value specified by OrData,\r |
7043 | and writes the result to the 64-bit MSR specified by Index. The value written\r | |
7044 | to the MSR is returned. No parameter checking is performed on Index, AndData,\r | |
7045 | or OrData, and some of these may cause CPU exceptions. The caller must either\r | |
7046 | guarantee that Index, AndData, and OrData are valid, or the caller must\r | |
7047 | establish proper exception handlers. This function is only available on IA-32\r | |
030cd1a2 | 7048 | and x64.\r |
ac644614 | 7049 | \r |
7050 | @param Index The 32-bit MSR index to write.\r | |
7051 | @param AndData The value to AND with the read value from the MSR.\r | |
7052 | @param OrData The value to OR with the result of the AND operation.\r | |
7053 | \r | |
7054 | @return The value written back to the MSR.\r | |
7055 | \r | |
7056 | **/\r | |
7057 | UINT64\r | |
7058 | EFIAPI\r | |
7059 | AsmMsrAndThenOr64 (\r | |
7060 | IN UINT32 Index,\r | |
7061 | IN UINT64 AndData,\r | |
7062 | IN UINT64 OrData\r | |
7063 | );\r | |
7064 | \r | |
7065 | \r | |
7066 | /**\r | |
7067 | Reads a bit field of an MSR.\r | |
7068 | \r | |
7069 | Reads the bit field in the 64-bit MSR. The bit field is specified by the\r | |
7070 | StartBit and the EndBit. The value of the bit field is returned. The caller\r | |
7071 | must either guarantee that Index is valid, or the caller must set up\r | |
7072 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 7073 | on IA-32 and x64.\r |
ac644614 | 7074 | \r |
7075 | If StartBit is greater than 63, then ASSERT().\r | |
7076 | If EndBit is greater than 63, then ASSERT().\r | |
7077 | If EndBit is less than StartBit, then ASSERT().\r | |
7078 | \r | |
7079 | @param Index The 32-bit MSR index to read.\r | |
7080 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
7081 | Range 0..63.\r | |
7082 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
7083 | Range 0..63.\r | |
7084 | \r | |
7085 | @return The value read from the MSR.\r | |
7086 | \r | |
7087 | **/\r | |
7088 | UINT64\r | |
7089 | EFIAPI\r | |
7090 | AsmMsrBitFieldRead64 (\r | |
7091 | IN UINT32 Index,\r | |
7092 | IN UINTN StartBit,\r | |
7093 | IN UINTN EndBit\r | |
7094 | );\r | |
7095 | \r | |
7096 | \r | |
7097 | /**\r | |
7098 | Writes a bit field to an MSR.\r | |
7099 | \r | |
7100 | Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r | |
7101 | the StartBit and the EndBit. All other bits in the destination MSR are\r | |
62991af2 | 7102 | preserved. The MSR written is returned. The caller must either guarantee \r |
7103 | that Index and the data written is valid, or the caller must set up exception \r | |
7104 | handlers to catch the exceptions. This function is only available on IA-32 and x64.\r | |
ac644614 | 7105 | \r |
7106 | If StartBit is greater than 63, then ASSERT().\r | |
7107 | If EndBit is greater than 63, then ASSERT().\r | |
7108 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 7109 | If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 7110 | \r |
7111 | @param Index The 32-bit MSR index to write.\r | |
7112 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
7113 | Range 0..63.\r | |
7114 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
7115 | Range 0..63.\r | |
7116 | @param Value New value of the bit field.\r | |
7117 | \r | |
7118 | @return The value written back to the MSR.\r | |
7119 | \r | |
7120 | **/\r | |
7121 | UINT64\r | |
7122 | EFIAPI\r | |
7123 | AsmMsrBitFieldWrite64 (\r | |
7124 | IN UINT32 Index,\r | |
7125 | IN UINTN StartBit,\r | |
7126 | IN UINTN EndBit,\r | |
7127 | IN UINT64 Value\r | |
7128 | );\r | |
7129 | \r | |
7130 | \r | |
7131 | /**\r | |
62991af2 | 7132 | Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r |
ac644614 | 7133 | writes the result back to the bit field in the 64-bit MSR.\r |
7134 | \r | |
62991af2 | 7135 | Reads the 64-bit MSR specified by Index, performs a bitwise OR\r |
ac644614 | 7136 | between the read result and the value specified by OrData, and writes the\r |
7137 | result to the 64-bit MSR specified by Index. The value written to the MSR is\r | |
7138 | returned. Extra left bits in OrData are stripped. The caller must either\r | |
7139 | guarantee that Index and the data written is valid, or the caller must set up\r | |
7140 | exception handlers to catch the exceptions. This function is only available\r | |
030cd1a2 | 7141 | on IA-32 and x64.\r |
ac644614 | 7142 | \r |
7143 | If StartBit is greater than 63, then ASSERT().\r | |
7144 | If EndBit is greater than 63, then ASSERT().\r | |
7145 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 7146 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 7147 | \r |
7148 | @param Index The 32-bit MSR index to write.\r | |
7149 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
7150 | Range 0..63.\r | |
7151 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
7152 | Range 0..63.\r | |
7153 | @param OrData The value to OR with the read value from the bit field.\r | |
7154 | \r | |
7155 | @return The value written back to the MSR.\r | |
7156 | \r | |
7157 | **/\r | |
7158 | UINT64\r | |
7159 | EFIAPI\r | |
7160 | AsmMsrBitFieldOr64 (\r | |
7161 | IN UINT32 Index,\r | |
7162 | IN UINTN StartBit,\r | |
7163 | IN UINTN EndBit,\r | |
7164 | IN UINT64 OrData\r | |
7165 | );\r | |
7166 | \r | |
7167 | \r | |
7168 | /**\r | |
7169 | Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r | |
7170 | result back to the bit field in the 64-bit MSR.\r | |
7171 | \r | |
7172 | Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r | |
7173 | read result and the value specified by AndData, and writes the result to the\r | |
7174 | 64-bit MSR specified by Index. The value written to the MSR is returned.\r | |
7175 | Extra left bits in AndData are stripped. The caller must either guarantee\r | |
7176 | that Index and the data written is valid, or the caller must set up exception\r | |
7177 | handlers to catch the exceptions. This function is only available on IA-32\r | |
030cd1a2 | 7178 | and x64.\r |
ac644614 | 7179 | \r |
7180 | If StartBit is greater than 63, then ASSERT().\r | |
7181 | If EndBit is greater than 63, then ASSERT().\r | |
7182 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 | 7183 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
ac644614 | 7184 | \r |
7185 | @param Index The 32-bit MSR index to write.\r | |
7186 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
7187 | Range 0..63.\r | |
7188 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
7189 | Range 0..63.\r | |
7190 | @param AndData The value to AND with the read value from the bit field.\r | |
7191 | \r | |
7192 | @return The value written back to the MSR.\r | |
7193 | \r | |
7194 | **/\r | |
7195 | UINT64\r | |
7196 | EFIAPI\r | |
7197 | AsmMsrBitFieldAnd64 (\r | |
7198 | IN UINT32 Index,\r | |
7199 | IN UINTN StartBit,\r | |
7200 | IN UINTN EndBit,\r | |
7201 | IN UINT64 AndData\r | |
7202 | );\r | |
7203 | \r | |
7204 | \r | |
7205 | /**\r | |
7206 | Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r | |
62991af2 | 7207 | bitwise OR, and writes the result back to the bit field in the\r |
ac644614 | 7208 | 64-bit MSR.\r |
7209 | \r | |
7210 | Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r | |
62991af2 | 7211 | a bitwise OR between the read result and the value specified by\r |
ac644614 | 7212 | AndData, and writes the result to the 64-bit MSR specified by Index. The\r |
7213 | value written to the MSR is returned. Extra left bits in both AndData and\r | |
7214 | OrData are stripped. The caller must either guarantee that Index and the data\r | |
7215 | written is valid, or the caller must set up exception handlers to catch the\r | |
030cd1a2 | 7216 | exceptions. This function is only available on IA-32 and x64.\r |
ac644614 | 7217 | \r |
7218 | If StartBit is greater than 63, then ASSERT().\r | |
7219 | If EndBit is greater than 63, then ASSERT().\r | |
7220 | If EndBit is less than StartBit, then ASSERT().\r | |
94952554 LG |
7221 | If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r |
7222 | If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r | |
ac644614 | 7223 | \r |
7224 | @param Index The 32-bit MSR index to write.\r | |
7225 | @param StartBit The ordinal of the least significant bit in the bit field.\r | |
7226 | Range 0..63.\r | |
7227 | @param EndBit The ordinal of the most significant bit in the bit field.\r | |
7228 | Range 0..63.\r | |
7229 | @param AndData The value to AND with the read value from the bit field.\r | |
7230 | @param OrData The value to OR with the result of the AND operation.\r | |
7231 | \r | |
7232 | @return The value written back to the MSR.\r | |
7233 | \r | |
7234 | **/\r | |
7235 | UINT64\r | |
7236 | EFIAPI\r | |
7237 | AsmMsrBitFieldAndThenOr64 (\r | |
7238 | IN UINT32 Index,\r | |
7239 | IN UINTN StartBit,\r | |
7240 | IN UINTN EndBit,\r | |
7241 | IN UINT64 AndData,\r | |
7242 | IN UINT64 OrData\r | |
7243 | );\r | |
7244 | \r | |
7245 | \r | |
7246 | /**\r | |
7247 | Reads the current value of the EFLAGS register.\r | |
7248 | \r | |
7249 | Reads and returns the current value of the EFLAGS register. This function is\r | |
030cd1a2 | 7250 | only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r |
7251 | 64-bit value on x64.\r | |
ac644614 | 7252 | \r |
030cd1a2 | 7253 | @return EFLAGS on IA-32 or RFLAGS on x64.\r |
ac644614 | 7254 | \r |
7255 | **/\r | |
7256 | UINTN\r | |
7257 | EFIAPI\r | |
7258 | AsmReadEflags (\r | |
7259 | VOID\r | |
7260 | );\r | |
7261 | \r | |
7262 | \r | |
7263 | /**\r | |
7264 | Reads the current value of the Control Register 0 (CR0).\r | |
7265 | \r | |
7266 | Reads and returns the current value of CR0. This function is only available\r | |
030cd1a2 | 7267 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7268 | x64.\r | |
ac644614 | 7269 | \r |
7270 | @return The value of the Control Register 0 (CR0).\r | |
7271 | \r | |
7272 | **/\r | |
7273 | UINTN\r | |
7274 | EFIAPI\r | |
7275 | AsmReadCr0 (\r | |
7276 | VOID\r | |
7277 | );\r | |
7278 | \r | |
7279 | \r | |
7280 | /**\r | |
7281 | Reads the current value of the Control Register 2 (CR2).\r | |
7282 | \r | |
7283 | Reads and returns the current value of CR2. This function is only available\r | |
030cd1a2 | 7284 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7285 | x64.\r | |
ac644614 | 7286 | \r |
7287 | @return The value of the Control Register 2 (CR2).\r | |
7288 | \r | |
7289 | **/\r | |
7290 | UINTN\r | |
7291 | EFIAPI\r | |
7292 | AsmReadCr2 (\r | |
7293 | VOID\r | |
7294 | );\r | |
7295 | \r | |
7296 | \r | |
7297 | /**\r | |
7298 | Reads the current value of the Control Register 3 (CR3).\r | |
7299 | \r | |
7300 | Reads and returns the current value of CR3. This function is only available\r | |
030cd1a2 | 7301 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7302 | x64.\r | |
ac644614 | 7303 | \r |
7304 | @return The value of the Control Register 3 (CR3).\r | |
7305 | \r | |
7306 | **/\r | |
7307 | UINTN\r | |
7308 | EFIAPI\r | |
7309 | AsmReadCr3 (\r | |
7310 | VOID\r | |
7311 | );\r | |
7312 | \r | |
7313 | \r | |
7314 | /**\r | |
7315 | Reads the current value of the Control Register 4 (CR4).\r | |
7316 | \r | |
7317 | Reads and returns the current value of CR4. This function is only available\r | |
030cd1a2 | 7318 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7319 | x64.\r | |
ac644614 | 7320 | \r |
7321 | @return The value of the Control Register 4 (CR4).\r | |
7322 | \r | |
7323 | **/\r | |
7324 | UINTN\r | |
7325 | EFIAPI\r | |
7326 | AsmReadCr4 (\r | |
7327 | VOID\r | |
7328 | );\r | |
7329 | \r | |
7330 | \r | |
7331 | /**\r | |
7332 | Writes a value to Control Register 0 (CR0).\r | |
7333 | \r | |
7334 | Writes and returns a new value to CR0. This function is only available on\r | |
030cd1a2 | 7335 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7336 | \r |
7337 | @param Cr0 The value to write to CR0.\r | |
7338 | \r | |
7339 | @return The value written to CR0.\r | |
7340 | \r | |
7341 | **/\r | |
7342 | UINTN\r | |
7343 | EFIAPI\r | |
7344 | AsmWriteCr0 (\r | |
7345 | UINTN Cr0\r | |
7346 | );\r | |
7347 | \r | |
7348 | \r | |
7349 | /**\r | |
7350 | Writes a value to Control Register 2 (CR2).\r | |
7351 | \r | |
7352 | Writes and returns a new value to CR2. This function is only available on\r | |
030cd1a2 | 7353 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7354 | \r |
7355 | @param Cr2 The value to write to CR2.\r | |
7356 | \r | |
7357 | @return The value written to CR2.\r | |
7358 | \r | |
7359 | **/\r | |
7360 | UINTN\r | |
7361 | EFIAPI\r | |
7362 | AsmWriteCr2 (\r | |
7363 | UINTN Cr2\r | |
7364 | );\r | |
7365 | \r | |
7366 | \r | |
7367 | /**\r | |
7368 | Writes a value to Control Register 3 (CR3).\r | |
7369 | \r | |
7370 | Writes and returns a new value to CR3. This function is only available on\r | |
030cd1a2 | 7371 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7372 | \r |
7373 | @param Cr3 The value to write to CR3.\r | |
7374 | \r | |
7375 | @return The value written to CR3.\r | |
7376 | \r | |
7377 | **/\r | |
7378 | UINTN\r | |
7379 | EFIAPI\r | |
7380 | AsmWriteCr3 (\r | |
7381 | UINTN Cr3\r | |
7382 | );\r | |
7383 | \r | |
7384 | \r | |
7385 | /**\r | |
7386 | Writes a value to Control Register 4 (CR4).\r | |
7387 | \r | |
7388 | Writes and returns a new value to CR4. This function is only available on\r | |
030cd1a2 | 7389 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7390 | \r |
7391 | @param Cr4 The value to write to CR4.\r | |
7392 | \r | |
7393 | @return The value written to CR4.\r | |
7394 | \r | |
7395 | **/\r | |
7396 | UINTN\r | |
7397 | EFIAPI\r | |
7398 | AsmWriteCr4 (\r | |
7399 | UINTN Cr4\r | |
7400 | );\r | |
7401 | \r | |
7402 | \r | |
7403 | /**\r | |
7404 | Reads the current value of Debug Register 0 (DR0).\r | |
7405 | \r | |
7406 | Reads and returns the current value of DR0. This function is only available\r | |
030cd1a2 | 7407 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7408 | x64.\r | |
ac644614 | 7409 | \r |
7410 | @return The value of Debug Register 0 (DR0).\r | |
7411 | \r | |
7412 | **/\r | |
7413 | UINTN\r | |
7414 | EFIAPI\r | |
7415 | AsmReadDr0 (\r | |
7416 | VOID\r | |
7417 | );\r | |
7418 | \r | |
7419 | \r | |
7420 | /**\r | |
7421 | Reads the current value of Debug Register 1 (DR1).\r | |
7422 | \r | |
7423 | Reads and returns the current value of DR1. This function is only available\r | |
030cd1a2 | 7424 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7425 | x64.\r | |
ac644614 | 7426 | \r |
7427 | @return The value of Debug Register 1 (DR1).\r | |
7428 | \r | |
7429 | **/\r | |
7430 | UINTN\r | |
7431 | EFIAPI\r | |
7432 | AsmReadDr1 (\r | |
7433 | VOID\r | |
7434 | );\r | |
7435 | \r | |
7436 | \r | |
7437 | /**\r | |
7438 | Reads the current value of Debug Register 2 (DR2).\r | |
7439 | \r | |
7440 | Reads and returns the current value of DR2. This function is only available\r | |
030cd1a2 | 7441 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7442 | x64.\r | |
ac644614 | 7443 | \r |
7444 | @return The value of Debug Register 2 (DR2).\r | |
7445 | \r | |
7446 | **/\r | |
7447 | UINTN\r | |
7448 | EFIAPI\r | |
7449 | AsmReadDr2 (\r | |
7450 | VOID\r | |
7451 | );\r | |
7452 | \r | |
7453 | \r | |
7454 | /**\r | |
7455 | Reads the current value of Debug Register 3 (DR3).\r | |
7456 | \r | |
7457 | Reads and returns the current value of DR3. This function is only available\r | |
030cd1a2 | 7458 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7459 | x64.\r | |
ac644614 | 7460 | \r |
7461 | @return The value of Debug Register 3 (DR3).\r | |
7462 | \r | |
7463 | **/\r | |
7464 | UINTN\r | |
7465 | EFIAPI\r | |
7466 | AsmReadDr3 (\r | |
7467 | VOID\r | |
7468 | );\r | |
7469 | \r | |
7470 | \r | |
7471 | /**\r | |
7472 | Reads the current value of Debug Register 4 (DR4).\r | |
7473 | \r | |
7474 | Reads and returns the current value of DR4. This function is only available\r | |
030cd1a2 | 7475 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7476 | x64.\r | |
ac644614 | 7477 | \r |
7478 | @return The value of Debug Register 4 (DR4).\r | |
7479 | \r | |
7480 | **/\r | |
7481 | UINTN\r | |
7482 | EFIAPI\r | |
7483 | AsmReadDr4 (\r | |
7484 | VOID\r | |
7485 | );\r | |
7486 | \r | |
7487 | \r | |
7488 | /**\r | |
7489 | Reads the current value of Debug Register 5 (DR5).\r | |
7490 | \r | |
7491 | Reads and returns the current value of DR5. This function is only available\r | |
030cd1a2 | 7492 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7493 | x64.\r | |
ac644614 | 7494 | \r |
7495 | @return The value of Debug Register 5 (DR5).\r | |
7496 | \r | |
7497 | **/\r | |
7498 | UINTN\r | |
7499 | EFIAPI\r | |
7500 | AsmReadDr5 (\r | |
7501 | VOID\r | |
7502 | );\r | |
7503 | \r | |
7504 | \r | |
7505 | /**\r | |
7506 | Reads the current value of Debug Register 6 (DR6).\r | |
7507 | \r | |
7508 | Reads and returns the current value of DR6. This function is only available\r | |
030cd1a2 | 7509 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7510 | x64.\r | |
ac644614 | 7511 | \r |
7512 | @return The value of Debug Register 6 (DR6).\r | |
7513 | \r | |
7514 | **/\r | |
7515 | UINTN\r | |
7516 | EFIAPI\r | |
7517 | AsmReadDr6 (\r | |
7518 | VOID\r | |
7519 | );\r | |
7520 | \r | |
7521 | \r | |
7522 | /**\r | |
7523 | Reads the current value of Debug Register 7 (DR7).\r | |
7524 | \r | |
7525 | Reads and returns the current value of DR7. This function is only available\r | |
030cd1a2 | 7526 | on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r |
7527 | x64.\r | |
ac644614 | 7528 | \r |
7529 | @return The value of Debug Register 7 (DR7).\r | |
7530 | \r | |
7531 | **/\r | |
7532 | UINTN\r | |
7533 | EFIAPI\r | |
7534 | AsmReadDr7 (\r | |
7535 | VOID\r | |
7536 | );\r | |
7537 | \r | |
7538 | \r | |
7539 | /**\r | |
7540 | Writes a value to Debug Register 0 (DR0).\r | |
7541 | \r | |
7542 | Writes and returns a new value to DR0. This function is only available on\r | |
030cd1a2 | 7543 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7544 | \r |
7545 | @param Dr0 The value to write to Dr0.\r | |
7546 | \r | |
7547 | @return The value written to Debug Register 0 (DR0).\r | |
7548 | \r | |
7549 | **/\r | |
7550 | UINTN\r | |
7551 | EFIAPI\r | |
7552 | AsmWriteDr0 (\r | |
7553 | UINTN Dr0\r | |
7554 | );\r | |
7555 | \r | |
7556 | \r | |
7557 | /**\r | |
7558 | Writes a value to Debug Register 1 (DR1).\r | |
7559 | \r | |
7560 | Writes and returns a new value to DR1. This function is only available on\r | |
030cd1a2 | 7561 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7562 | \r |
7563 | @param Dr1 The value to write to Dr1.\r | |
7564 | \r | |
7565 | @return The value written to Debug Register 1 (DR1).\r | |
7566 | \r | |
7567 | **/\r | |
7568 | UINTN\r | |
7569 | EFIAPI\r | |
7570 | AsmWriteDr1 (\r | |
7571 | UINTN Dr1\r | |
7572 | );\r | |
7573 | \r | |
7574 | \r | |
7575 | /**\r | |
7576 | Writes a value to Debug Register 2 (DR2).\r | |
7577 | \r | |
7578 | Writes and returns a new value to DR2. This function is only available on\r | |
030cd1a2 | 7579 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7580 | \r |
7581 | @param Dr2 The value to write to Dr2.\r | |
7582 | \r | |
7583 | @return The value written to Debug Register 2 (DR2).\r | |
7584 | \r | |
7585 | **/\r | |
7586 | UINTN\r | |
7587 | EFIAPI\r | |
7588 | AsmWriteDr2 (\r | |
7589 | UINTN Dr2\r | |
7590 | );\r | |
7591 | \r | |
7592 | \r | |
7593 | /**\r | |
7594 | Writes a value to Debug Register 3 (DR3).\r | |
7595 | \r | |
7596 | Writes and returns a new value to DR3. This function is only available on\r | |
030cd1a2 | 7597 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7598 | \r |
7599 | @param Dr3 The value to write to Dr3.\r | |
7600 | \r | |
7601 | @return The value written to Debug Register 3 (DR3).\r | |
7602 | \r | |
7603 | **/\r | |
7604 | UINTN\r | |
7605 | EFIAPI\r | |
7606 | AsmWriteDr3 (\r | |
7607 | UINTN Dr3\r | |
7608 | );\r | |
7609 | \r | |
7610 | \r | |
7611 | /**\r | |
7612 | Writes a value to Debug Register 4 (DR4).\r | |
7613 | \r | |
7614 | Writes and returns a new value to DR4. This function is only available on\r | |
030cd1a2 | 7615 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7616 | \r |
7617 | @param Dr4 The value to write to Dr4.\r | |
7618 | \r | |
7619 | @return The value written to Debug Register 4 (DR4).\r | |
7620 | \r | |
7621 | **/\r | |
7622 | UINTN\r | |
7623 | EFIAPI\r | |
7624 | AsmWriteDr4 (\r | |
7625 | UINTN Dr4\r | |
7626 | );\r | |
7627 | \r | |
7628 | \r | |
7629 | /**\r | |
7630 | Writes a value to Debug Register 5 (DR5).\r | |
7631 | \r | |
7632 | Writes and returns a new value to DR5. This function is only available on\r | |
030cd1a2 | 7633 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7634 | \r |
7635 | @param Dr5 The value to write to Dr5.\r | |
7636 | \r | |
7637 | @return The value written to Debug Register 5 (DR5).\r | |
7638 | \r | |
7639 | **/\r | |
7640 | UINTN\r | |
7641 | EFIAPI\r | |
7642 | AsmWriteDr5 (\r | |
7643 | UINTN Dr5\r | |
7644 | );\r | |
7645 | \r | |
7646 | \r | |
7647 | /**\r | |
7648 | Writes a value to Debug Register 6 (DR6).\r | |
7649 | \r | |
7650 | Writes and returns a new value to DR6. This function is only available on\r | |
030cd1a2 | 7651 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7652 | \r |
7653 | @param Dr6 The value to write to Dr6.\r | |
7654 | \r | |
7655 | @return The value written to Debug Register 6 (DR6).\r | |
7656 | \r | |
7657 | **/\r | |
7658 | UINTN\r | |
7659 | EFIAPI\r | |
7660 | AsmWriteDr6 (\r | |
7661 | UINTN Dr6\r | |
7662 | );\r | |
7663 | \r | |
7664 | \r | |
7665 | /**\r | |
7666 | Writes a value to Debug Register 7 (DR7).\r | |
7667 | \r | |
7668 | Writes and returns a new value to DR7. This function is only available on\r | |
030cd1a2 | 7669 | IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r |
ac644614 | 7670 | \r |
7671 | @param Dr7 The value to write to Dr7.\r | |
7672 | \r | |
7673 | @return The value written to Debug Register 7 (DR7).\r | |
7674 | \r | |
7675 | **/\r | |
7676 | UINTN\r | |
7677 | EFIAPI\r | |
7678 | AsmWriteDr7 (\r | |
7679 | UINTN Dr7\r | |
7680 | );\r | |
7681 | \r | |
7682 | \r | |
7683 | /**\r | |
7684 | Reads the current value of Code Segment Register (CS).\r | |
7685 | \r | |
7686 | Reads and returns the current value of CS. This function is only available on\r | |
030cd1a2 | 7687 | IA-32 and x64.\r |
ac644614 | 7688 | \r |
7689 | @return The current value of CS.\r | |
7690 | \r | |
7691 | **/\r | |
7692 | UINT16\r | |
7693 | EFIAPI\r | |
7694 | AsmReadCs (\r | |
7695 | VOID\r | |
7696 | );\r | |
7697 | \r | |
7698 | \r | |
7699 | /**\r | |
7700 | Reads the current value of Data Segment Register (DS).\r | |
7701 | \r | |
7702 | Reads and returns the current value of DS. This function is only available on\r | |
030cd1a2 | 7703 | IA-32 and x64.\r |
ac644614 | 7704 | \r |
7705 | @return The current value of DS.\r | |
7706 | \r | |
7707 | **/\r | |
7708 | UINT16\r | |
7709 | EFIAPI\r | |
7710 | AsmReadDs (\r | |
7711 | VOID\r | |
7712 | );\r | |
7713 | \r | |
7714 | \r | |
7715 | /**\r | |
7716 | Reads the current value of Extra Segment Register (ES).\r | |
7717 | \r | |
7718 | Reads and returns the current value of ES. This function is only available on\r | |
030cd1a2 | 7719 | IA-32 and x64.\r |
ac644614 | 7720 | \r |
7721 | @return The current value of ES.\r | |
7722 | \r | |
7723 | **/\r | |
7724 | UINT16\r | |
7725 | EFIAPI\r | |
7726 | AsmReadEs (\r | |
7727 | VOID\r | |
7728 | );\r | |
7729 | \r | |
7730 | \r | |
7731 | /**\r | |
7732 | Reads the current value of FS Data Segment Register (FS).\r | |
7733 | \r | |
7734 | Reads and returns the current value of FS. This function is only available on\r | |
030cd1a2 | 7735 | IA-32 and x64.\r |
ac644614 | 7736 | \r |
7737 | @return The current value of FS.\r | |
7738 | \r | |
7739 | **/\r | |
7740 | UINT16\r | |
7741 | EFIAPI\r | |
7742 | AsmReadFs (\r | |
7743 | VOID\r | |
7744 | );\r | |
7745 | \r | |
7746 | \r | |
7747 | /**\r | |
7748 | Reads the current value of GS Data Segment Register (GS).\r | |
7749 | \r | |
7750 | Reads and returns the current value of GS. This function is only available on\r | |
030cd1a2 | 7751 | IA-32 and x64.\r |
ac644614 | 7752 | \r |
7753 | @return The current value of GS.\r | |
7754 | \r | |
7755 | **/\r | |
7756 | UINT16\r | |
7757 | EFIAPI\r | |
7758 | AsmReadGs (\r | |
7759 | VOID\r | |
7760 | );\r | |
7761 | \r | |
7762 | \r | |
7763 | /**\r | |
7764 | Reads the current value of Stack Segment Register (SS).\r | |
7765 | \r | |
7766 | Reads and returns the current value of SS. This function is only available on\r | |
030cd1a2 | 7767 | IA-32 and x64.\r |
ac644614 | 7768 | \r |
7769 | @return The current value of SS.\r | |
7770 | \r | |
7771 | **/\r | |
7772 | UINT16\r | |
7773 | EFIAPI\r | |
7774 | AsmReadSs (\r | |
7775 | VOID\r | |
7776 | );\r | |
7777 | \r | |
7778 | \r | |
7779 | /**\r | |
7780 | Reads the current value of Task Register (TR).\r | |
7781 | \r | |
7782 | Reads and returns the current value of TR. This function is only available on\r | |
030cd1a2 | 7783 | IA-32 and x64.\r |
ac644614 | 7784 | \r |
7785 | @return The current value of TR.\r | |
7786 | \r | |
7787 | **/\r | |
7788 | UINT16\r | |
7789 | EFIAPI\r | |
7790 | AsmReadTr (\r | |
7791 | VOID\r | |
7792 | );\r | |
7793 | \r | |
7794 | \r | |
7795 | /**\r | |
7796 | Reads the current Global Descriptor Table Register(GDTR) descriptor.\r | |
7797 | \r | |
7798 | Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r | |
030cd1a2 | 7799 | function is only available on IA-32 and x64.\r |
ac644614 | 7800 | \r |
7801 | If Gdtr is NULL, then ASSERT().\r | |
7802 | \r | |
af2dc6a7 | 7803 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 7804 | \r |
7805 | **/\r | |
7806 | VOID\r | |
7807 | EFIAPI\r | |
7808 | AsmReadGdtr (\r | |
7809 | OUT IA32_DESCRIPTOR *Gdtr\r | |
7810 | );\r | |
7811 | \r | |
7812 | \r | |
7813 | /**\r | |
7814 | Writes the current Global Descriptor Table Register (GDTR) descriptor.\r | |
7815 | \r | |
7816 | Writes and the current GDTR descriptor specified by Gdtr. This function is\r | |
030cd1a2 | 7817 | only available on IA-32 and x64.\r |
ac644614 | 7818 | \r |
7819 | If Gdtr is NULL, then ASSERT().\r | |
7820 | \r | |
af2dc6a7 | 7821 | @param Gdtr The pointer to a GDTR descriptor.\r |
ac644614 | 7822 | \r |
7823 | **/\r | |
7824 | VOID\r | |
7825 | EFIAPI\r | |
7826 | AsmWriteGdtr (\r | |
7827 | IN CONST IA32_DESCRIPTOR *Gdtr\r | |
7828 | );\r | |
7829 | \r | |
7830 | \r | |
7831 | /**\r | |
17f695ed | 7832 | Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 7833 | \r |
7834 | Reads and returns the current IDTR descriptor and returns it in Idtr. This\r | |
030cd1a2 | 7835 | function is only available on IA-32 and x64.\r |
ac644614 | 7836 | \r |
7837 | If Idtr is NULL, then ASSERT().\r | |
7838 | \r | |
af2dc6a7 | 7839 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 7840 | \r |
7841 | **/\r | |
7842 | VOID\r | |
7843 | EFIAPI\r | |
7844 | AsmReadIdtr (\r | |
7845 | OUT IA32_DESCRIPTOR *Idtr\r | |
7846 | );\r | |
7847 | \r | |
7848 | \r | |
7849 | /**\r | |
17f695ed | 7850 | Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r |
ac644614 | 7851 | \r |
7852 | Writes the current IDTR descriptor and returns it in Idtr. This function is\r | |
030cd1a2 | 7853 | only available on IA-32 and x64.\r |
ac644614 | 7854 | \r |
7855 | If Idtr is NULL, then ASSERT().\r | |
7856 | \r | |
af2dc6a7 | 7857 | @param Idtr The pointer to a IDTR descriptor.\r |
ac644614 | 7858 | \r |
7859 | **/\r | |
7860 | VOID\r | |
7861 | EFIAPI\r | |
7862 | AsmWriteIdtr (\r | |
7863 | IN CONST IA32_DESCRIPTOR *Idtr\r | |
7864 | );\r | |
7865 | \r | |
7866 | \r | |
7867 | /**\r | |
7868 | Reads the current Local Descriptor Table Register(LDTR) selector.\r | |
7869 | \r | |
7870 | Reads and returns the current 16-bit LDTR descriptor value. This function is\r | |
030cd1a2 | 7871 | only available on IA-32 and x64.\r |
ac644614 | 7872 | \r |
7873 | @return The current selector of LDT.\r | |
7874 | \r | |
7875 | **/\r | |
7876 | UINT16\r | |
7877 | EFIAPI\r | |
7878 | AsmReadLdtr (\r | |
7879 | VOID\r | |
7880 | );\r | |
7881 | \r | |
7882 | \r | |
7883 | /**\r | |
17f695ed | 7884 | Writes the current Local Descriptor Table Register (LDTR) selector.\r |
ac644614 | 7885 | \r |
7886 | Writes and the current LDTR descriptor specified by Ldtr. This function is\r | |
030cd1a2 | 7887 | only available on IA-32 and x64.\r |
ac644614 | 7888 | \r |
7889 | @param Ldtr 16-bit LDTR selector value.\r | |
7890 | \r | |
7891 | **/\r | |
7892 | VOID\r | |
7893 | EFIAPI\r | |
7894 | AsmWriteLdtr (\r | |
7895 | IN UINT16 Ldtr\r | |
7896 | );\r | |
7897 | \r | |
7898 | \r | |
7899 | /**\r | |
7900 | Save the current floating point/SSE/SSE2 context to a buffer.\r | |
7901 | \r | |
7902 | Saves the current floating point/SSE/SSE2 state to the buffer specified by\r | |
7903 | Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r | |
030cd1a2 | 7904 | available on IA-32 and x64.\r |
ac644614 | 7905 | \r |
7906 | If Buffer is NULL, then ASSERT().\r | |
7907 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7908 | \r | |
af2dc6a7 | 7909 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7910 | \r |
7911 | **/\r | |
7912 | VOID\r | |
7913 | EFIAPI\r | |
7914 | AsmFxSave (\r | |
7915 | OUT IA32_FX_BUFFER *Buffer\r | |
7916 | );\r | |
7917 | \r | |
7918 | \r | |
7919 | /**\r | |
7920 | Restores the current floating point/SSE/SSE2 context from a buffer.\r | |
7921 | \r | |
7922 | Restores the current floating point/SSE/SSE2 state from the buffer specified\r | |
7923 | by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r | |
030cd1a2 | 7924 | only available on IA-32 and x64.\r |
ac644614 | 7925 | \r |
7926 | If Buffer is NULL, then ASSERT().\r | |
7927 | If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r | |
7928 | If Buffer was not saved with AsmFxSave(), then ASSERT().\r | |
7929 | \r | |
af2dc6a7 | 7930 | @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r |
ac644614 | 7931 | \r |
7932 | **/\r | |
7933 | VOID\r | |
7934 | EFIAPI\r | |
7935 | AsmFxRestore (\r | |
7936 | IN CONST IA32_FX_BUFFER *Buffer\r | |
7937 | );\r | |
7938 | \r | |
7939 | \r | |
7940 | /**\r | |
7941 | Reads the current value of 64-bit MMX Register #0 (MM0).\r | |
7942 | \r | |
7943 | Reads and returns the current value of MM0. This function is only available\r | |
030cd1a2 | 7944 | on IA-32 and x64.\r |
ac644614 | 7945 | \r |
7946 | @return The current value of MM0.\r | |
7947 | \r | |
7948 | **/\r | |
7949 | UINT64\r | |
7950 | EFIAPI\r | |
7951 | AsmReadMm0 (\r | |
7952 | VOID\r | |
7953 | );\r | |
7954 | \r | |
7955 | \r | |
7956 | /**\r | |
7957 | Reads the current value of 64-bit MMX Register #1 (MM1).\r | |
7958 | \r | |
7959 | Reads and returns the current value of MM1. This function is only available\r | |
030cd1a2 | 7960 | on IA-32 and x64.\r |
ac644614 | 7961 | \r |
7962 | @return The current value of MM1.\r | |
7963 | \r | |
7964 | **/\r | |
7965 | UINT64\r | |
7966 | EFIAPI\r | |
7967 | AsmReadMm1 (\r | |
7968 | VOID\r | |
7969 | );\r | |
7970 | \r | |
7971 | \r | |
7972 | /**\r | |
7973 | Reads the current value of 64-bit MMX Register #2 (MM2).\r | |
7974 | \r | |
7975 | Reads and returns the current value of MM2. This function is only available\r | |
030cd1a2 | 7976 | on IA-32 and x64.\r |
ac644614 | 7977 | \r |
7978 | @return The current value of MM2.\r | |
7979 | \r | |
7980 | **/\r | |
7981 | UINT64\r | |
7982 | EFIAPI\r | |
7983 | AsmReadMm2 (\r | |
7984 | VOID\r | |
7985 | );\r | |
7986 | \r | |
7987 | \r | |
7988 | /**\r | |
7989 | Reads the current value of 64-bit MMX Register #3 (MM3).\r | |
7990 | \r | |
7991 | Reads and returns the current value of MM3. This function is only available\r | |
030cd1a2 | 7992 | on IA-32 and x64.\r |
ac644614 | 7993 | \r |
7994 | @return The current value of MM3.\r | |
7995 | \r | |
7996 | **/\r | |
7997 | UINT64\r | |
7998 | EFIAPI\r | |
7999 | AsmReadMm3 (\r | |
8000 | VOID\r | |
8001 | );\r | |
8002 | \r | |
8003 | \r | |
8004 | /**\r | |
8005 | Reads the current value of 64-bit MMX Register #4 (MM4).\r | |
8006 | \r | |
8007 | Reads and returns the current value of MM4. This function is only available\r | |
030cd1a2 | 8008 | on IA-32 and x64.\r |
ac644614 | 8009 | \r |
8010 | @return The current value of MM4.\r | |
8011 | \r | |
8012 | **/\r | |
8013 | UINT64\r | |
8014 | EFIAPI\r | |
8015 | AsmReadMm4 (\r | |
8016 | VOID\r | |
8017 | );\r | |
8018 | \r | |
8019 | \r | |
8020 | /**\r | |
8021 | Reads the current value of 64-bit MMX Register #5 (MM5).\r | |
8022 | \r | |
8023 | Reads and returns the current value of MM5. This function is only available\r | |
030cd1a2 | 8024 | on IA-32 and x64.\r |
ac644614 | 8025 | \r |
8026 | @return The current value of MM5.\r | |
8027 | \r | |
8028 | **/\r | |
8029 | UINT64\r | |
8030 | EFIAPI\r | |
8031 | AsmReadMm5 (\r | |
8032 | VOID\r | |
8033 | );\r | |
8034 | \r | |
8035 | \r | |
8036 | /**\r | |
8037 | Reads the current value of 64-bit MMX Register #6 (MM6).\r | |
8038 | \r | |
8039 | Reads and returns the current value of MM6. This function is only available\r | |
030cd1a2 | 8040 | on IA-32 and x64.\r |
ac644614 | 8041 | \r |
8042 | @return The current value of MM6.\r | |
8043 | \r | |
8044 | **/\r | |
8045 | UINT64\r | |
8046 | EFIAPI\r | |
8047 | AsmReadMm6 (\r | |
8048 | VOID\r | |
8049 | );\r | |
8050 | \r | |
8051 | \r | |
8052 | /**\r | |
8053 | Reads the current value of 64-bit MMX Register #7 (MM7).\r | |
8054 | \r | |
8055 | Reads and returns the current value of MM7. This function is only available\r | |
030cd1a2 | 8056 | on IA-32 and x64.\r |
ac644614 | 8057 | \r |
8058 | @return The current value of MM7.\r | |
8059 | \r | |
8060 | **/\r | |
8061 | UINT64\r | |
8062 | EFIAPI\r | |
8063 | AsmReadMm7 (\r | |
8064 | VOID\r | |
8065 | );\r | |
8066 | \r | |
8067 | \r | |
8068 | /**\r | |
8069 | Writes the current value of 64-bit MMX Register #0 (MM0).\r | |
8070 | \r | |
8071 | Writes the current value of MM0. This function is only available on IA32 and\r | |
030cd1a2 | 8072 | x64.\r |
ac644614 | 8073 | \r |
8074 | @param Value The 64-bit value to write to MM0.\r | |
8075 | \r | |
8076 | **/\r | |
8077 | VOID\r | |
8078 | EFIAPI\r | |
8079 | AsmWriteMm0 (\r | |
8080 | IN UINT64 Value\r | |
8081 | );\r | |
8082 | \r | |
8083 | \r | |
8084 | /**\r | |
8085 | Writes the current value of 64-bit MMX Register #1 (MM1).\r | |
8086 | \r | |
8087 | Writes the current value of MM1. This function is only available on IA32 and\r | |
030cd1a2 | 8088 | x64.\r |
ac644614 | 8089 | \r |
8090 | @param Value The 64-bit value to write to MM1.\r | |
8091 | \r | |
8092 | **/\r | |
8093 | VOID\r | |
8094 | EFIAPI\r | |
8095 | AsmWriteMm1 (\r | |
8096 | IN UINT64 Value\r | |
8097 | );\r | |
8098 | \r | |
8099 | \r | |
8100 | /**\r | |
8101 | Writes the current value of 64-bit MMX Register #2 (MM2).\r | |
8102 | \r | |
8103 | Writes the current value of MM2. This function is only available on IA32 and\r | |
030cd1a2 | 8104 | x64.\r |
ac644614 | 8105 | \r |
8106 | @param Value The 64-bit value to write to MM2.\r | |
8107 | \r | |
8108 | **/\r | |
8109 | VOID\r | |
8110 | EFIAPI\r | |
8111 | AsmWriteMm2 (\r | |
8112 | IN UINT64 Value\r | |
8113 | );\r | |
8114 | \r | |
8115 | \r | |
8116 | /**\r | |
8117 | Writes the current value of 64-bit MMX Register #3 (MM3).\r | |
8118 | \r | |
8119 | Writes the current value of MM3. This function is only available on IA32 and\r | |
030cd1a2 | 8120 | x64.\r |
ac644614 | 8121 | \r |
8122 | @param Value The 64-bit value to write to MM3.\r | |
8123 | \r | |
8124 | **/\r | |
8125 | VOID\r | |
8126 | EFIAPI\r | |
8127 | AsmWriteMm3 (\r | |
8128 | IN UINT64 Value\r | |
8129 | );\r | |
8130 | \r | |
8131 | \r | |
8132 | /**\r | |
8133 | Writes the current value of 64-bit MMX Register #4 (MM4).\r | |
8134 | \r | |
8135 | Writes the current value of MM4. This function is only available on IA32 and\r | |
030cd1a2 | 8136 | x64.\r |
ac644614 | 8137 | \r |
8138 | @param Value The 64-bit value to write to MM4.\r | |
8139 | \r | |
8140 | **/\r | |
8141 | VOID\r | |
8142 | EFIAPI\r | |
8143 | AsmWriteMm4 (\r | |
8144 | IN UINT64 Value\r | |
8145 | );\r | |
8146 | \r | |
8147 | \r | |
8148 | /**\r | |
8149 | Writes the current value of 64-bit MMX Register #5 (MM5).\r | |
8150 | \r | |
8151 | Writes the current value of MM5. This function is only available on IA32 and\r | |
030cd1a2 | 8152 | x64.\r |
ac644614 | 8153 | \r |
8154 | @param Value The 64-bit value to write to MM5.\r | |
8155 | \r | |
8156 | **/\r | |
8157 | VOID\r | |
8158 | EFIAPI\r | |
8159 | AsmWriteMm5 (\r | |
8160 | IN UINT64 Value\r | |
8161 | );\r | |
8162 | \r | |
8163 | \r | |
8164 | /**\r | |
8165 | Writes the current value of 64-bit MMX Register #6 (MM6).\r | |
8166 | \r | |
8167 | Writes the current value of MM6. This function is only available on IA32 and\r | |
030cd1a2 | 8168 | x64.\r |
ac644614 | 8169 | \r |
8170 | @param Value The 64-bit value to write to MM6.\r | |
8171 | \r | |
8172 | **/\r | |
8173 | VOID\r | |
8174 | EFIAPI\r | |
8175 | AsmWriteMm6 (\r | |
8176 | IN UINT64 Value\r | |
8177 | );\r | |
8178 | \r | |
8179 | \r | |
8180 | /**\r | |
8181 | Writes the current value of 64-bit MMX Register #7 (MM7).\r | |
8182 | \r | |
8183 | Writes the current value of MM7. This function is only available on IA32 and\r | |
030cd1a2 | 8184 | x64.\r |
ac644614 | 8185 | \r |
8186 | @param Value The 64-bit value to write to MM7.\r | |
8187 | \r | |
8188 | **/\r | |
8189 | VOID\r | |
8190 | EFIAPI\r | |
8191 | AsmWriteMm7 (\r | |
8192 | IN UINT64 Value\r | |
8193 | );\r | |
8194 | \r | |
8195 | \r | |
8196 | /**\r | |
8197 | Reads the current value of Time Stamp Counter (TSC).\r | |
8198 | \r | |
8199 | Reads and returns the current value of TSC. This function is only available\r | |
030cd1a2 | 8200 | on IA-32 and x64.\r |
ac644614 | 8201 | \r |
8202 | @return The current value of TSC\r | |
8203 | \r | |
8204 | **/\r | |
8205 | UINT64\r | |
8206 | EFIAPI\r | |
8207 | AsmReadTsc (\r | |
8208 | VOID\r | |
8209 | );\r | |
8210 | \r | |
8211 | \r | |
8212 | /**\r | |
8213 | Reads the current value of a Performance Counter (PMC).\r | |
8214 | \r | |
8215 | Reads and returns the current value of performance counter specified by\r | |
030cd1a2 | 8216 | Index. This function is only available on IA-32 and x64.\r |
ac644614 | 8217 | \r |
8218 | @param Index The 32-bit Performance Counter index to read.\r | |
8219 | \r | |
8220 | @return The value of the PMC specified by Index.\r | |
8221 | \r | |
8222 | **/\r | |
8223 | UINT64\r | |
8224 | EFIAPI\r | |
8225 | AsmReadPmc (\r | |
8226 | IN UINT32 Index\r | |
8227 | );\r | |
8228 | \r | |
8229 | \r | |
8230 | /**\r | |
8231 | Sets up a monitor buffer that is used by AsmMwait().\r | |
8232 | \r | |
8233 | Executes a MONITOR instruction with the register state specified by Eax, Ecx\r | |
030cd1a2 | 8234 | and Edx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 8235 | \r |
8236 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
8237 | instruction.\r | |
8238 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
8239 | instruction.\r | |
8240 | @param Edx The value to load into EDX or RDX before executing the MONITOR\r | |
8241 | instruction.\r | |
8242 | \r | |
8243 | @return Eax\r | |
8244 | \r | |
8245 | **/\r | |
8246 | UINTN\r | |
8247 | EFIAPI\r | |
8248 | AsmMonitor (\r | |
8249 | IN UINTN Eax,\r | |
8250 | IN UINTN Ecx,\r | |
8251 | IN UINTN Edx\r | |
8252 | );\r | |
8253 | \r | |
8254 | \r | |
8255 | /**\r | |
8256 | Executes an MWAIT instruction.\r | |
8257 | \r | |
8258 | Executes an MWAIT instruction with the register state specified by Eax and\r | |
030cd1a2 | 8259 | Ecx. Returns Eax. This function is only available on IA-32 and x64.\r |
ac644614 | 8260 | \r |
8261 | @param Eax The value to load into EAX or RAX before executing the MONITOR\r | |
8262 | instruction.\r | |
8263 | @param Ecx The value to load into ECX or RCX before executing the MONITOR\r | |
8264 | instruction.\r | |
8265 | \r | |
8266 | @return Eax\r | |
8267 | \r | |
8268 | **/\r | |
8269 | UINTN\r | |
8270 | EFIAPI\r | |
8271 | AsmMwait (\r | |
8272 | IN UINTN Eax,\r | |
8273 | IN UINTN Ecx\r | |
8274 | );\r | |
8275 | \r | |
8276 | \r | |
8277 | /**\r | |
8278 | Executes a WBINVD instruction.\r | |
8279 | \r | |
8280 | Executes a WBINVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 8281 | x64.\r |
ac644614 | 8282 | \r |
8283 | **/\r | |
8284 | VOID\r | |
8285 | EFIAPI\r | |
8286 | AsmWbinvd (\r | |
8287 | VOID\r | |
8288 | );\r | |
8289 | \r | |
8290 | \r | |
8291 | /**\r | |
8292 | Executes a INVD instruction.\r | |
8293 | \r | |
8294 | Executes a INVD instruction. This function is only available on IA-32 and\r | |
030cd1a2 | 8295 | x64.\r |
ac644614 | 8296 | \r |
8297 | **/\r | |
8298 | VOID\r | |
8299 | EFIAPI\r | |
8300 | AsmInvd (\r | |
8301 | VOID\r | |
8302 | );\r | |
8303 | \r | |
8304 | \r | |
8305 | /**\r | |
8306 | Flushes a cache line from all the instruction and data caches within the\r | |
8307 | coherency domain of the CPU.\r | |
8308 | \r | |
8309 | Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r | |
030cd1a2 | 8310 | This function is only available on IA-32 and x64.\r |
ac644614 | 8311 | \r |
8312 | @param LinearAddress The address of the cache line to flush. If the CPU is\r | |
8313 | in a physical addressing mode, then LinearAddress is a\r | |
8314 | physical address. If the CPU is in a virtual\r | |
8315 | addressing mode, then LinearAddress is a virtual\r | |
8316 | address.\r | |
8317 | \r | |
af2dc6a7 | 8318 | @return LinearAddress.\r |
ac644614 | 8319 | **/\r |
8320 | VOID *\r | |
8321 | EFIAPI\r | |
8322 | AsmFlushCacheLine (\r | |
8323 | IN VOID *LinearAddress\r | |
8324 | );\r | |
8325 | \r | |
8326 | \r | |
8327 | /**\r | |
8328 | Enables the 32-bit paging mode on the CPU.\r | |
8329 | \r | |
8330 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
8331 | must be properly initialized prior to calling this service. This function\r | |
8332 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
8333 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
8334 | transferred to the function specified by EntryPoint using the new stack\r | |
8335 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
8336 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
8337 | EntryPoint must never return.\r | |
8338 | \r | |
8339 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r | |
8340 | If EntryPoint is NULL, then ASSERT().\r | |
8341 | If NewStack is NULL, then ASSERT().\r | |
8342 | \r | |
8343 | There are a number of constraints that must be followed before calling this\r | |
8344 | function:\r | |
8345 | 1) Interrupts must be disabled.\r | |
8346 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
8347 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
8348 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
8349 | descriptors.\r | |
8350 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
8351 | is complete, and those page tables must guarantee that the pages for this\r | |
8352 | function and the stack are identity mapped.\r | |
8353 | \r | |
8354 | @param EntryPoint A pointer to function to call with the new stack after\r | |
8355 | paging is enabled.\r | |
8356 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
8357 | function as the first parameter after paging is enabled.\r | |
8358 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
8359 | function as the second parameter after paging is enabled.\r | |
8360 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
8361 | function after paging is enabled.\r | |
8362 | \r | |
8363 | **/\r | |
8364 | VOID\r | |
8365 | EFIAPI\r | |
8366 | AsmEnablePaging32 (\r | |
8367 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
8368 | IN VOID *Context1, OPTIONAL\r | |
8369 | IN VOID *Context2, OPTIONAL\r | |
8370 | IN VOID *NewStack\r | |
8371 | );\r | |
8372 | \r | |
8373 | \r | |
8374 | /**\r | |
8375 | Disables the 32-bit paging mode on the CPU.\r | |
8376 | \r | |
8377 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
8378 | mode. This function assumes the current execution mode is 32-paged protected\r | |
8379 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
8380 | is disabled, control is transferred to the function specified by EntryPoint\r | |
8381 | using the new stack specified by NewStack and passing in the parameters\r | |
8382 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
8383 | may be NULL. The function EntryPoint must never return.\r | |
8384 | \r | |
8385 | If the current execution mode is not 32-bit paged mode, then ASSERT().\r | |
8386 | If EntryPoint is NULL, then ASSERT().\r | |
8387 | If NewStack is NULL, then ASSERT().\r | |
8388 | \r | |
8389 | There are a number of constraints that must be followed before calling this\r | |
8390 | function:\r | |
8391 | 1) Interrupts must be disabled.\r | |
8392 | 2) The caller must be in 32-bit paged mode.\r | |
8393 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
8394 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
8395 | this function and the stack are identity mapped.\r | |
8396 | \r | |
8397 | @param EntryPoint A pointer to function to call with the new stack after\r | |
8398 | paging is disabled.\r | |
8399 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
8400 | function as the first parameter after paging is disabled.\r | |
8401 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
8402 | function as the second parameter after paging is\r | |
8403 | disabled.\r | |
8404 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
8405 | function after paging is disabled.\r | |
8406 | \r | |
8407 | **/\r | |
8408 | VOID\r | |
8409 | EFIAPI\r | |
8410 | AsmDisablePaging32 (\r | |
8411 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
8412 | IN VOID *Context1, OPTIONAL\r | |
8413 | IN VOID *Context2, OPTIONAL\r | |
8414 | IN VOID *NewStack\r | |
8415 | );\r | |
8416 | \r | |
8417 | \r | |
8418 | /**\r | |
8419 | Enables the 64-bit paging mode on the CPU.\r | |
8420 | \r | |
8421 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
8422 | must be properly initialized prior to calling this service. This function\r | |
8423 | assumes the current execution mode is 32-bit protected mode with flat\r | |
8424 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
8425 | paging mode is enabled, control is transferred to the function specified by\r | |
8426 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
8427 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
8428 | optional and may be 0. The function EntryPoint must never return.\r | |
8429 | \r | |
8430 | If the current execution mode is not 32-bit protected mode with flat\r | |
8431 | descriptors, then ASSERT().\r | |
8432 | If EntryPoint is 0, then ASSERT().\r | |
8433 | If NewStack is 0, then ASSERT().\r | |
8434 | \r | |
17f695ed | 8435 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 8436 | is called. The descriptor in the GDT that this selector\r |
8437 | references must be setup for long mode.\r | |
8438 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
8439 | the new stack after paging is enabled.\r | |
8440 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
8441 | the EntryPoint function as the first parameter after\r | |
8442 | paging is enabled.\r | |
8443 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
8444 | the EntryPoint function as the second parameter after\r | |
8445 | paging is enabled.\r | |
8446 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
8447 | the EntryPoint function after paging is enabled.\r | |
8448 | \r | |
8449 | **/\r | |
8450 | VOID\r | |
8451 | EFIAPI\r | |
8452 | AsmEnablePaging64 (\r | |
17f695ed | 8453 | IN UINT16 Cs,\r |
ac644614 | 8454 | IN UINT64 EntryPoint,\r |
8455 | IN UINT64 Context1, OPTIONAL\r | |
8456 | IN UINT64 Context2, OPTIONAL\r | |
8457 | IN UINT64 NewStack\r | |
8458 | );\r | |
8459 | \r | |
8460 | \r | |
8461 | /**\r | |
8462 | Disables the 64-bit paging mode on the CPU.\r | |
8463 | \r | |
8464 | Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r | |
8465 | mode. This function assumes the current execution mode is 64-paging mode.\r | |
030cd1a2 | 8466 | This function is only available on x64. After the 64-bit paging mode is\r |
ac644614 | 8467 | disabled, control is transferred to the function specified by EntryPoint\r |
8468 | using the new stack specified by NewStack and passing in the parameters\r | |
8469 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
8470 | may be 0. The function EntryPoint must never return.\r | |
8471 | \r | |
8472 | If the current execution mode is not 64-bit paged mode, then ASSERT().\r | |
8473 | If EntryPoint is 0, then ASSERT().\r | |
8474 | If NewStack is 0, then ASSERT().\r | |
8475 | \r | |
17f695ed | 8476 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r |
ac644614 | 8477 | is called. The descriptor in the GDT that this selector\r |
8478 | references must be setup for 32-bit protected mode.\r | |
8479 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
8480 | the new stack after paging is disabled.\r | |
8481 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
8482 | the EntryPoint function as the first parameter after\r | |
8483 | paging is disabled.\r | |
8484 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
8485 | the EntryPoint function as the second parameter after\r | |
8486 | paging is disabled.\r | |
8487 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
8488 | the EntryPoint function after paging is disabled.\r | |
8489 | \r | |
8490 | **/\r | |
8491 | VOID\r | |
8492 | EFIAPI\r | |
8493 | AsmDisablePaging64 (\r | |
17f695ed | 8494 | IN UINT16 Cs,\r |
ac644614 | 8495 | IN UINT32 EntryPoint,\r |
8496 | IN UINT32 Context1, OPTIONAL\r | |
8497 | IN UINT32 Context2, OPTIONAL\r | |
8498 | IN UINT32 NewStack\r | |
8499 | );\r | |
8500 | \r | |
8501 | \r | |
8502 | //\r | |
8503 | // 16-bit thunking services\r | |
8504 | //\r | |
8505 | \r | |
8506 | /**\r | |
8507 | Retrieves the properties for 16-bit thunk functions.\r | |
8508 | \r | |
8509 | Computes the size of the buffer and stack below 1MB required to use the\r | |
8510 | AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r | |
8511 | buffer size is returned in RealModeBufferSize, and the stack size is returned\r | |
8512 | in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r | |
8513 | then the actual minimum stack size is ExtraStackSize plus the maximum number\r | |
8514 | of bytes that need to be passed to the 16-bit real mode code.\r | |
52fa075c | 8515 | \r |
ac644614 | 8516 | If RealModeBufferSize is NULL, then ASSERT().\r |
8517 | If ExtraStackSize is NULL, then ASSERT().\r | |
8518 | \r | |
8519 | @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r | |
8520 | required to use the 16-bit thunk functions.\r | |
8521 | @param ExtraStackSize A pointer to the extra size of stack below 1MB\r | |
8522 | that the 16-bit thunk functions require for\r | |
8523 | temporary storage in the transition to and from\r | |
8524 | 16-bit real mode.\r | |
8525 | \r | |
8526 | **/\r | |
8527 | VOID\r | |
8528 | EFIAPI\r | |
8529 | AsmGetThunk16Properties (\r | |
8530 | OUT UINT32 *RealModeBufferSize,\r | |
8531 | OUT UINT32 *ExtraStackSize\r | |
8532 | );\r | |
8533 | \r | |
8534 | \r | |
8535 | /**\r | |
8536 | Prepares all structures a code required to use AsmThunk16().\r | |
8537 | \r | |
8538 | Prepares all structures and code required to use AsmThunk16().\r | |
52fa075c | 8539 | \r |
8243b089 | 8540 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
8541 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
ac644614 | 8542 | \r |
8543 | If ThunkContext is NULL, then ASSERT().\r | |
8544 | \r | |
8545 | @param ThunkContext A pointer to the context structure that describes the\r | |
8546 | 16-bit real mode code to call.\r | |
8547 | \r | |
8548 | **/\r | |
8549 | VOID\r | |
8550 | EFIAPI\r | |
8551 | AsmPrepareThunk16 (\r | |
1445300f | 8552 | IN OUT THUNK_CONTEXT *ThunkContext\r |
ac644614 | 8553 | );\r |
8554 | \r | |
8555 | \r | |
8556 | /**\r | |
8557 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
8558 | \r | |
8559 | Transfers control to a 16-bit real mode entry point and returns the results.\r | |
17f695ed | 8560 | AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r |
8561 | This function must be called with interrupts disabled.\r | |
8562 | \r | |
8563 | The register state from the RealModeState field of ThunkContext is restored just prior \r | |
8564 | to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, \r | |
8565 | which is used to set the interrupt state when a 16-bit real mode entry point is called.\r | |
8566 | Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r | |
8567 | The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to \r | |
8568 | the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. \r | |
8569 | The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r | |
8570 | so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment \r | |
8571 | and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry \r | |
8572 | point must exit with a RETF instruction. The register state is captured into RealModeState immediately \r | |
8573 | after the RETF instruction is executed.\r | |
8574 | \r | |
8575 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r | |
8576 | or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure \r | |
8577 | the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. \r | |
8578 | \r | |
8579 | If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r | |
8580 | then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. \r | |
8581 | This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r | |
8582 | \r | |
8583 | If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code \r | |
8584 | is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r | |
8585 | \r | |
8586 | If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r | |
8587 | ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to \r | |
8588 | disable the A20 mask.\r | |
8589 | \r | |
8590 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in \r | |
8591 | ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, \r | |
8592 | then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r | |
8593 | \r | |
8594 | If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in \r | |
8595 | ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r | |
8596 | \r | |
ac644614 | 8597 | If ThunkContext is NULL, then ASSERT().\r |
8598 | If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r | |
17f695ed | 8599 | If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r |
8600 | ThunkAttributes, then ASSERT().\r | |
ac644614 | 8601 | \r |
8243b089 | 8602 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
af2dc6a7 | 8603 | virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r |
52fa075c | 8604 | \r |
ac644614 | 8605 | @param ThunkContext A pointer to the context structure that describes the\r |
8606 | 16-bit real mode code to call.\r | |
8607 | \r | |
8608 | **/\r | |
8609 | VOID\r | |
8610 | EFIAPI\r | |
8611 | AsmThunk16 (\r | |
8612 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
8613 | );\r | |
8614 | \r | |
8615 | \r | |
8616 | /**\r | |
8617 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
8618 | control to a 16-bit real mode entry point, and returns the results.\r | |
8619 | \r | |
8620 | Prepares all structures and code for a 16-bit real mode thunk, transfers\r | |
8621 | control to a 16-bit real mode entry point, and returns the results. If the\r | |
8622 | caller only need to perform a single 16-bit real mode thunk, then this\r | |
8623 | service should be used. If the caller intends to make more than one 16-bit\r | |
8624 | real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r | |
8625 | once and AsmThunk16() can be called for each 16-bit real mode thunk.\r | |
8626 | \r | |
8243b089 | 8627 | This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r |
8628 | virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r | |
52fa075c | 8629 | \r |
17f695ed | 8630 | See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r |
ac644614 | 8631 | \r |
8632 | @param ThunkContext A pointer to the context structure that describes the\r | |
8633 | 16-bit real mode code to call.\r | |
8634 | \r | |
8635 | **/\r | |
8636 | VOID\r | |
8637 | EFIAPI\r | |
8638 | AsmPrepareAndThunk16 (\r | |
8639 | IN OUT THUNK_CONTEXT *ThunkContext\r | |
8640 | );\r | |
8641 | \r | |
3cfc7813 QL |
8642 | /**\r |
8643 | Generates a 16-bit random number through RDRAND instruction.\r | |
8644 | \r | |
8645 | if Rand is NULL, then ASSERT().\r | |
8646 | \r | |
8647 | @param[out] Rand Buffer pointer to store the random result.\r | |
8648 | \r | |
8649 | @retval TRUE RDRAND call was successful.\r | |
8650 | @retval FALSE Failed attempts to call RDRAND.\r | |
8651 | \r | |
8652 | **/\r | |
8653 | BOOLEAN\r | |
8654 | EFIAPI\r | |
8655 | AsmRdRand16 (\r | |
8656 | OUT UINT16 *Rand\r | |
8657 | );\r | |
8658 | \r | |
8659 | /**\r | |
8660 | Generates a 32-bit random number through RDRAND instruction.\r | |
8661 | \r | |
8662 | if Rand is NULL, then ASSERT().\r | |
8663 | \r | |
8664 | @param[out] Rand Buffer pointer to store the random result.\r | |
8665 | \r | |
8666 | @retval TRUE RDRAND call was successful.\r | |
8667 | @retval FALSE Failed attempts to call RDRAND.\r | |
8668 | \r | |
8669 | **/\r | |
8670 | BOOLEAN\r | |
8671 | EFIAPI\r | |
8672 | AsmRdRand32 (\r | |
8673 | OUT UINT32 *Rand\r | |
8674 | );\r | |
8675 | \r | |
8676 | /**\r | |
8677 | Generates a 64-bit random number through RDRAND instruction.\r | |
8678 | \r | |
8679 | if Rand is NULL, then ASSERT().\r | |
8680 | \r | |
8681 | @param[out] Rand Buffer pointer to store the random result.\r | |
8682 | \r | |
8683 | @retval TRUE RDRAND call was successful.\r | |
8684 | @retval FALSE Failed attempts to call RDRAND.\r | |
8685 | \r | |
8686 | **/\r | |
8687 | BOOLEAN\r | |
8688 | EFIAPI\r | |
8689 | AsmRdRand64 (\r | |
8690 | OUT UINT64 *Rand\r | |
8691 | );\r | |
8692 | \r | |
ac644614 | 8693 | #endif\r |
e3a7917f | 8694 | #endif\r |
ac644614 | 8695 | \r |
8696 | \r |