]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Library/BaseLib.h
MdePkg/ProcessorBind: add defines for page allocation granularity
[mirror_edk2.git] / MdePkg / Include / Library / BaseLib.h
CommitLineData
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 5Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
9df063a0
HT
6Portions copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>\r
7This program and the accompanying materials\r
50a64e5b 8are licensed and made available under the terms and conditions of the BSD License\r
9which accompanies this distribution. The full text of the license may be found at\r
af2dc6a7 10http://opensource.org/licenses/bsd-license.php.\r
ac644614 11\r
50a64e5b 12THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
13WITHOUT 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 27typedef 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 45typedef 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 94typedef 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 117typedef 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
131typedef 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
150typedef 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
203UINTN\r
204EFIAPI\r
205StrnLenS (\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
231UINTN\r
232EFIAPI\r
233StrnSizeS (\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
265RETURN_STATUS\r
266EFIAPI\r
267StrCpyS (\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
303RETURN_STATUS\r
304EFIAPI\r
305StrnCpyS (\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
342RETURN_STATUS\r
343EFIAPI\r
344StrCatS (\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
383RETURN_STATUS\r
384EFIAPI\r
385StrnCatS (\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
440RETURN_STATUS\r
441EFIAPI\r
442StrDecimalToUintnS (\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
496RETURN_STATUS\r
497EFIAPI\r
498StrDecimalToUint64S (\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
557RETURN_STATUS\r
558EFIAPI\r
559StrHexToUintnS (\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
618RETURN_STATUS\r
619EFIAPI\r
620StrHexToUint64S (\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
640UINTN\r
641EFIAPI\r
642AsciiStrnLenS (\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
666UINTN\r
667EFIAPI\r
668AsciiStrnSizeS (\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
698RETURN_STATUS\r
699EFIAPI\r
700AsciiStrCpyS (\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
734RETURN_STATUS\r
735EFIAPI\r
736AsciiStrnCpyS (\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
771RETURN_STATUS\r
772EFIAPI\r
773AsciiStrCatS (\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
810RETURN_STATUS\r
811EFIAPI\r
812AsciiStrnCatS (\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
866RETURN_STATUS\r
867EFIAPI\r
868AsciiStrDecimalToUintnS (\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
921RETURN_STATUS\r
922EFIAPI\r
923AsciiStrDecimalToUint64S (\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
980RETURN_STATUS\r
981EFIAPI\r
982AsciiStrHexToUintnS (\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
1039RETURN_STATUS\r
1040EFIAPI\r
1041AsciiStrHexToUint64S (\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
1075CHAR16 *\r
1076EFIAPI\r
1077StrCpy (\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
1115CHAR16 *\r
1116EFIAPI\r
1117StrnCpy (\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
1141UINTN\r
1142EFIAPI\r
1143StrLen (\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
1166UINTN\r
1167EFIAPI\r
1168StrSize (\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
1201INTN\r
1202EFIAPI\r
1203StrCmp (\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
1241INTN\r
1242EFIAPI\r
1243StrnCmp (\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
1286CHAR16 *\r
1287EFIAPI\r
1288StrCat (\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
1334CHAR16 *\r
1335EFIAPI\r
1336StrnCat (\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
1368CHAR16 *\r
1369EFIAPI\r
1370StrStr (\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
1409UINTN\r
1410EFIAPI\r
1411StrDecimalToUintn (\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
1449UINT64\r
1450EFIAPI\r
1451StrDecimalToUint64 (\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
1491UINTN\r
1492EFIAPI\r
1493StrHexToUintn (\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
1533UINT64\r
1534EFIAPI\r
1535StrHexToUint64 (\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
1597RETURN_STATUS\r
1598EFIAPI\r
1599StrToIpv6Address (\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
1655RETURN_STATUS\r
1656EFIAPI\r
1657StrToIpv4Address (\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
1710RETURN_STATUS\r
1711EFIAPI\r
1712StrToGuid (\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
1761RETURN_STATUS\r
1762EFIAPI\r
1763StrHexToBytes (\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
1807CHAR8 *\r
1808EFIAPI\r
1809UnicodeStrToAsciiStr (\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
1857RETURN_STATUS\r
1858EFIAPI\r
1859UnicodeStrToAsciiStrS (\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
1909RETURN_STATUS\r
1910EFIAPI\r
1911UnicodeStrnToAsciiStrS (\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
1944CHAR8 *\r
1945EFIAPI\r
1946AsciiStrCpy (\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
1981CHAR8 *\r
1982EFIAPI\r
1983AsciiStrnCpy (\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
2007UINTN\r
2008EFIAPI\r
2009AsciiStrLen (\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
2031UINTN\r
2032EFIAPI\r
2033AsciiStrSize (\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
2064INTN\r
2065EFIAPI\r
2066AsciiStrCmp (\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
2101INTN\r
2102EFIAPI\r
2103AsciiStriCmp (\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
2139INTN\r
2140EFIAPI\r
2141AsciiStrnCmp (\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
2179CHAR8 *\r
2180EFIAPI\r
2181AsciiStrCat (\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
2225CHAR8 *\r
2226EFIAPI\r
2227AsciiStrnCat (\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
2258CHAR8 *\r
2259EFIAPI\r
2260AsciiStrStr (\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
2296UINTN\r
2297EFIAPI\r
2298AsciiStrDecimalToUintn (\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
2333UINT64\r
2334EFIAPI\r
2335AsciiStrDecimalToUint64 (\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
2374UINTN\r
2375EFIAPI\r
2376AsciiStrHexToUintn (\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
2415UINT64\r
2416EFIAPI\r
2417AsciiStrHexToUint64 (\r
17f695ed 2418 IN CONST CHAR8 *String\r
ac644614 2419 );\r
2420\r
fb4dd857
RN
2421/**\r
2422 Convert a Null-terminated ASCII string to IPv6 address and prefix length.\r
2423\r
2424 This function outputs a value of type IPv6_ADDRESS and may output a value\r
2425 of type UINT8 by interpreting the contents of the ASCII string specified\r
2426 by String. The format of the input ASCII string String is as follows:\r
2427\r
2428 X:X:X:X:X:X:X:X[/P]\r
2429\r
2430 X contains one to four hexadecimal digit characters in the range [0-9], [a-f] and\r
2431 [A-F]. X is converted to a value of type UINT16, whose low byte is stored in low\r
2432 memory address and high byte is stored in high memory address. P contains decimal\r
2433 digit characters in the range [0-9]. The running zero in the beginning of P will\r
2434 be ignored. /P is optional.\r
2435\r
2436 When /P is not in the String, the function stops at the first character that is\r
2437 not a valid hexadecimal digit character after eight X's are converted.\r
2438\r
2439 When /P is in the String, the function stops at the first character that is not\r
2440 a valid decimal digit character after P is converted.\r
2441\r
2442 "::" can be used to compress one or more groups of X when X contains only 0.\r
2443 The "::" can only appear once in the String.\r
2444\r
2445 If String is NULL, then ASSERT().\r
2446\r
2447 If Address is NULL, then ASSERT().\r
2448\r
2449 If EndPointer is not NULL and Address is translated from String, a pointer\r
2450 to the character that stopped the scan is stored at the location pointed to\r
2451 by EndPointer.\r
2452\r
2453 @param String Pointer to a Null-terminated ASCII string.\r
2454 @param EndPointer Pointer to character that stops scan.\r
2455 @param Address Pointer to the converted IPv6 address.\r
2456 @param PrefixLength Pointer to the converted IPv6 address prefix\r
2457 length. MAX_UINT8 is returned when /P is\r
2458 not in the String.\r
2459\r
2460 @retval RETURN_SUCCESS Address is translated from String.\r
2461 @retval RETURN_INVALID_PARAMETER If String is NULL.\r
2462 If Data is NULL.\r
2463 @retval RETURN_UNSUPPORTED If X contains more than four hexadecimal\r
2464 digit characters.\r
2465 If String contains "::" and number of X\r
2466 is not less than 8.\r
2467 If P starts with character that is not a\r
2468 valid decimal digit character.\r
2469 If the decimal number converted from P\r
2470 exceeds 128.\r
2471\r
2472**/\r
2473RETURN_STATUS\r
2474EFIAPI\r
2475AsciiStrToIpv6Address (\r
2476 IN CONST CHAR8 *String,\r
2477 OUT CHAR8 **EndPointer, OPTIONAL\r
2478 OUT IPv6_ADDRESS *Address,\r
2479 OUT UINT8 *PrefixLength OPTIONAL\r
2480 );\r
2481\r
2482/**\r
2483 Convert a Null-terminated ASCII string to IPv4 address and prefix length.\r
2484\r
2485 This function outputs a value of type IPv4_ADDRESS and may output a value\r
2486 of type UINT8 by interpreting the contents of the ASCII string specified\r
2487 by String. The format of the input ASCII string String is as follows:\r
2488\r
2489 D.D.D.D[/P]\r
2490\r
2491 D and P are decimal digit characters in the range [0-9]. The running zero in\r
2492 the beginning of D and P will be ignored. /P is optional.\r
2493\r
2494 When /P is not in the String, the function stops at the first character that is\r
2495 not a valid decimal digit character after four D's are converted.\r
2496\r
2497 When /P is in the String, the function stops at the first character that is not\r
2498 a valid decimal digit character after P is converted.\r
2499\r
2500 If String is NULL, then ASSERT().\r
2501\r
2502 If Address is NULL, then ASSERT().\r
2503\r
2504 If EndPointer is not NULL and Address is translated from String, a pointer\r
2505 to the character that stopped the scan is stored at the location pointed to\r
2506 by EndPointer.\r
2507\r
2508 @param String Pointer to a Null-terminated ASCII string.\r
2509 @param EndPointer Pointer to character that stops scan.\r
2510 @param Address Pointer to the converted IPv4 address.\r
2511 @param PrefixLength Pointer to the converted IPv4 address prefix\r
2512 length. MAX_UINT8 is returned when /P is\r
2513 not in the String.\r
2514\r
2515 @retval RETURN_SUCCESS Address is translated from String.\r
2516 @retval RETURN_INVALID_PARAMETER If String is NULL.\r
2517 If Data is NULL.\r
2518 @retval RETURN_UNSUPPORTED If String is not in the correct format.\r
2519 If any decimal number converted from D\r
2520 exceeds 255.\r
2521 If the decimal number converted from P\r
2522 exceeds 32.\r
2523\r
2524**/\r
2525RETURN_STATUS\r
2526EFIAPI\r
2527AsciiStrToIpv4Address (\r
2528 IN CONST CHAR8 *String,\r
2529 OUT CHAR8 **EndPointer, OPTIONAL\r
2530 OUT IPv4_ADDRESS *Address,\r
2531 OUT UINT8 *PrefixLength OPTIONAL\r
2532 );\r
2533\r
2534/**\r
2535 Convert a Null-terminated ASCII GUID string to a value of type\r
2536 EFI_GUID.\r
2537\r
2538 This function outputs a GUID value by interpreting the contents of\r
2539 the ASCII string specified by String. The format of the input\r
2540 ASCII string String consists of 36 characters, as follows:\r
2541\r
2542 aabbccdd-eeff-gghh-iijj-kkllmmnnoopp\r
2543\r
2544 The pairs aa - pp are two characters in the range [0-9], [a-f] and\r
2545 [A-F], with each pair representing a single byte hexadecimal value.\r
2546\r
2547 The mapping between String and the EFI_GUID structure is as follows:\r
2548 aa Data1[24:31]\r
2549 bb Data1[16:23]\r
2550 cc Data1[8:15]\r
2551 dd Data1[0:7]\r
2552 ee Data2[8:15]\r
2553 ff Data2[0:7]\r
2554 gg Data3[8:15]\r
2555 hh Data3[0:7]\r
2556 ii Data4[0:7]\r
2557 jj Data4[8:15]\r
2558 kk Data4[16:23]\r
2559 ll Data4[24:31]\r
2560 mm Data4[32:39]\r
2561 nn Data4[40:47]\r
2562 oo Data4[48:55]\r
2563 pp Data4[56:63]\r
2564\r
2565 If String is NULL, then ASSERT().\r
2566 If Guid is NULL, then ASSERT().\r
2567\r
2568 @param String Pointer to a Null-terminated ASCII string.\r
2569 @param Guid Pointer to the converted GUID.\r
2570\r
2571 @retval RETURN_SUCCESS Guid is translated from String.\r
2572 @retval RETURN_INVALID_PARAMETER If String is NULL.\r
2573 If Data is NULL.\r
2574 @retval RETURN_UNSUPPORTED If String is not as the above format.\r
2575\r
2576**/\r
2577RETURN_STATUS\r
2578EFIAPI\r
2579AsciiStrToGuid (\r
2580 IN CONST CHAR8 *String,\r
2581 OUT GUID *Guid\r
2582 );\r
2583\r
2584/**\r
2585 Convert a Null-terminated ASCII hexadecimal string to a byte array.\r
2586\r
2587 This function outputs a byte array by interpreting the contents of\r
2588 the ASCII string specified by String in hexadecimal format. The format of\r
2589 the input ASCII string String is:\r
2590\r
2591 [XX]*\r
2592\r
2593 X is a hexadecimal digit character in the range [0-9], [a-f] and [A-F].\r
2594 The function decodes every two hexadecimal digit characters as one byte. The\r
2595 decoding stops after Length of characters and outputs Buffer containing\r
2596 (Length / 2) bytes.\r
2597\r
2598 If String is NULL, then ASSERT().\r
2599\r
2600 If Buffer is NULL, then ASSERT().\r
2601\r
2602 If Length is not multiple of 2, then ASSERT().\r
2603\r
2604 If PcdMaximumAsciiStringLength is not zero and Length is greater than\r
2605 PcdMaximumAsciiStringLength, then ASSERT().\r
2606\r
2607 If MaxBufferSize is less than (Length / 2), then ASSERT().\r
2608\r
2609 @param String Pointer to a Null-terminated ASCII string.\r
2610 @param Length The number of ASCII characters to decode.\r
2611 @param Buffer Pointer to the converted bytes array.\r
2612 @param MaxBufferSize The maximum size of Buffer.\r
2613\r
2614 @retval RETURN_SUCCESS Buffer is translated from String.\r
2615 @retval RETURN_INVALID_PARAMETER If String is NULL.\r
2616 If Data is NULL.\r
2617 If Length is not multiple of 2.\r
2618 If PcdMaximumAsciiStringLength is not zero,\r
2619 and Length is greater than\r
2620 PcdMaximumAsciiStringLength.\r
2621 @retval RETURN_UNSUPPORTED If Length of characters from String contain\r
2622 a character that is not valid hexadecimal\r
2623 digit characters, or a Null-terminator.\r
2624 @retval RETURN_BUFFER_TOO_SMALL If MaxBufferSize is less than (Length / 2).\r
2625**/\r
2626RETURN_STATUS\r
2627EFIAPI\r
2628AsciiStrHexToBytes (\r
2629 IN CONST CHAR8 *String,\r
2630 IN UINTN Length,\r
2631 OUT UINT8 *Buffer,\r
2632 IN UINTN MaxBufferSize\r
2633 );\r
2634\r
415aa2f1 2635#ifndef DISABLE_NEW_DEPRECATED_INTERFACES\r
ac644614 2636\r
2637/**\r
415aa2f1
SZ
2638 [ATTENTION] This function is deprecated for security reason.\r
2639\r
ac644614 2640 Convert one Null-terminated ASCII string to a Null-terminated\r
2641 Unicode string and returns the Unicode string.\r
2642\r
2643 This function converts the contents of the ASCII string Source to the Unicode\r
2644 string Destination, and returns Destination. The function terminates the\r
2645 Unicode string Destination by appending a Null-terminator character at the end.\r
2646 The caller is responsible to make sure Destination points to a buffer with size\r
2647 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
2648\r
2649 If Destination is NULL, then ASSERT().\r
2650 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
2651 If Source is NULL, then ASSERT().\r
2652 If Source and Destination overlap, then ASSERT().\r
2653 If PcdMaximumAsciiStringLength is not zero, and Source contains more than\r
2654 PcdMaximumAsciiStringLength ASCII characters not including the Null-terminator,\r
2655 then ASSERT().\r
2656 If PcdMaximumUnicodeStringLength is not zero, and Source contains more than\r
2657 PcdMaximumUnicodeStringLength ASCII characters not including the\r
2658 Null-terminator, then ASSERT().\r
2659\r
af2dc6a7 2660 @param Source The pointer to a Null-terminated ASCII string.\r
2661 @param Destination The pointer to a Null-terminated Unicode string.\r
ac644614 2662\r
9aa049d9 2663 @return Destination.\r
ac644614 2664\r
2665**/\r
2666CHAR16 *\r
2667EFIAPI\r
2668AsciiStrToUnicodeStr (\r
17f695ed 2669 IN CONST CHAR8 *Source,\r
2670 OUT CHAR16 *Destination\r
ac644614 2671 );\r
2672\r
415aa2f1
SZ
2673#endif\r
2674\r
3ab41b7a
JY
2675/**\r
2676 Convert one Null-terminated ASCII string to a Null-terminated\r
2677 Unicode string.\r
2678\r
2679 This function is similar to StrCpyS.\r
2680\r
2681 This function converts the contents of the ASCII string Source to the Unicode\r
2682 string Destination. The function terminates the Unicode string Destination by\r
2683 appending a Null-terminator character at the end.\r
2684\r
2685 The caller is responsible to make sure Destination points to a buffer with size\r
2686 equal or greater than ((AsciiStrLen (Source) + 1) * sizeof (CHAR16)) in bytes.\r
2687\r
2688 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
2689 If an error would be returned, then the function will also ASSERT().\r
2690\r
2691 If an error is returned, then the Destination is unmodified.\r
2692\r
2693 @param Source The pointer to a Null-terminated ASCII string.\r
2694 @param Destination The pointer to a Null-terminated Unicode string.\r
2695 @param DestMax The maximum number of Destination Unicode\r
2696 char, including terminating null char.\r
2697\r
2698 @retval RETURN_SUCCESS String is converted.\r
2699 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than StrLen(Source).\r
2700 @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
2701 If Source is NULL.\r
2702 If PcdMaximumUnicodeStringLength is not zero,\r
2703 and DestMax is greater than\r
2704 PcdMaximumUnicodeStringLength.\r
2705 If PcdMaximumAsciiStringLength is not zero,\r
2706 and DestMax is greater than\r
2707 PcdMaximumAsciiStringLength.\r
2708 If DestMax is 0.\r
2709 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r
2710\r
2711**/\r
2712RETURN_STATUS\r
2713EFIAPI\r
2714AsciiStrToUnicodeStrS (\r
2715 IN CONST CHAR8 *Source,\r
2716 OUT CHAR16 *Destination,\r
2717 IN UINTN DestMax\r
2718 );\r
ac644614 2719\r
02263214
HW
2720/**\r
2721 Convert not more than Length successive characters from a Null-terminated\r
2722 Ascii string to a Null-terminated Unicode string. If no null char is copied\r
2723 from Source, then Destination[Length] is always set to null.\r
2724\r
2725 This function converts not more than Length successive characters from the\r
2726 Ascii string Source to the Unicode string Destination. The function\r
2727 terminates the Unicode string Destination by appending a Null-terminator\r
2728 character at the end.\r
2729\r
2730 The caller is responsible to make sure Destination points to a buffer with\r
2731 size not smaller than\r
2732 ((MIN(AsciiStrLen(Source), Length) + 1) * sizeof (CHAR8)) in bytes.\r
2733\r
2734 If Destination is not aligned on a 16-bit boundary, then ASSERT().\r
2735 If an error would be returned, then the function will also ASSERT().\r
2736\r
2737 If an error is returned, then Destination and DestinationLength are\r
2738 unmodified.\r
2739\r
2740 @param Source The pointer to a Null-terminated Ascii string.\r
2741 @param Length The maximum number of Ascii characters to convert.\r
2742 @param Destination The pointer to a Null-terminated Unicode string.\r
2743 @param DestMax The maximum number of Destination Unicode char,\r
2744 including terminating null char.\r
2745 @param DestinationLength The number of Ascii characters converted.\r
2746\r
2747 @retval RETURN_SUCCESS String is converted.\r
2748 @retval RETURN_INVALID_PARAMETER If Destination is NULL.\r
2749 If Source is NULL.\r
2750 If DestinationLength is NULL.\r
2751 If PcdMaximumUnicodeStringLength is not\r
2752 zero, and Length or DestMax is greater than\r
2753 PcdMaximumUnicodeStringLength.\r
2754 If PcdMaximumAsciiStringLength is not zero,\r
2755 and Length or DestMax is greater than\r
2756 PcdMaximumAsciiStringLength.\r
2757 If DestMax is 0.\r
2758 @retval RETURN_BUFFER_TOO_SMALL If DestMax is NOT greater than\r
2759 MIN(AsciiStrLen(Source), Length).\r
2760 @retval RETURN_ACCESS_DENIED If Source and Destination overlap.\r
2761\r
2762**/\r
2763RETURN_STATUS\r
2764EFIAPI\r
2765AsciiStrnToUnicodeStrS (\r
2766 IN CONST CHAR8 *Source,\r
2767 IN UINTN Length,\r
2768 OUT CHAR16 *Destination,\r
2769 IN UINTN DestMax,\r
2770 OUT UINTN *DestinationLength\r
2771 );\r
2772\r
ac644614 2773/**\r
2774 Converts an 8-bit value to an 8-bit BCD value.\r
2775\r
2776 Converts the 8-bit value specified by Value to BCD. The BCD value is\r
2777 returned.\r
2778\r
2779 If Value >= 100, then ASSERT().\r
2780\r
2781 @param Value The 8-bit value to convert to BCD. Range 0..99.\r
2782\r
9aa049d9 2783 @return The BCD value.\r
ac644614 2784\r
2785**/\r
2786UINT8\r
2787EFIAPI\r
2788DecimalToBcd8 (\r
2789 IN UINT8 Value\r
2790 );\r
2791\r
2792\r
2793/**\r
2794 Converts an 8-bit BCD value to an 8-bit value.\r
2795\r
2796 Converts the 8-bit BCD value specified by Value to an 8-bit value. The 8-bit\r
2797 value is returned.\r
2798\r
2799 If Value >= 0xA0, then ASSERT().\r
2800 If (Value & 0x0F) >= 0x0A, then ASSERT().\r
2801\r
2802 @param Value The 8-bit BCD value to convert to an 8-bit value.\r
2803\r
2804 @return The 8-bit value is returned.\r
2805\r
2806**/\r
2807UINT8\r
2808EFIAPI\r
2809BcdToDecimal8 (\r
2810 IN UINT8 Value\r
2811 );\r
2812\r
ae591c14
DM
2813//\r
2814// File Path Manipulation Functions\r
2815//\r
2816\r
2817/**\r
6a623094 2818 Removes the last directory or file entry in a path.\r
ae591c14
DM
2819\r
2820 @param[in, out] Path The pointer to the path to modify.\r
2821\r
2822 @retval FALSE Nothing was found to remove.\r
2823 @retval TRUE A directory or file was removed.\r
2824**/\r
2825BOOLEAN\r
2826EFIAPI\r
2827PathRemoveLastItem(\r
2828 IN OUT CHAR16 *Path\r
2829 );\r
2830\r
2831/**\r
2832 Function to clean up paths.\r
2833 - Single periods in the path are removed.\r
2834 - Double periods in the path are removed along with a single parent directory.\r
2835 - Forward slashes L'/' are converted to backward slashes L'\'.\r
2836\r
2837 This will be done inline and the existing buffer may be larger than required\r
2838 upon completion.\r
2839\r
2840 @param[in] Path The pointer to the string containing the path.\r
2841\r
00b7cc0f 2842 @return Returns Path, otherwise returns NULL to indicate that an error has occurred.\r
ae591c14
DM
2843**/\r
2844CHAR16*\r
2845EFIAPI\r
2846PathCleanUpDirectories(\r
2847 IN CHAR16 *Path\r
909ac47b 2848 );\r
ac644614 2849\r
2850//\r
2851// Linked List Functions and Macros\r
2852//\r
2853\r
2854/**\r
2855 Initializes the head node of a doubly linked list that is declared as a\r
2856 global variable in a module.\r
2857\r
2858 Initializes the forward and backward links of a new linked list. After\r
2859 initializing a linked list with this macro, the other linked list functions\r
2860 may be used to add and remove nodes from the linked list. This macro results\r
2861 in smaller executables by initializing the linked list in the data section,\r
2862 instead if calling the InitializeListHead() function to perform the\r
2863 equivalent operation.\r
2864\r
77f863ee 2865 @param ListHead The head note of a list to initialize.\r
ac644614 2866\r
2867**/\r
17f695ed 2868#define INITIALIZE_LIST_HEAD_VARIABLE(ListHead) {&(ListHead), &(ListHead)}\r
ac644614 2869\r
2870\r
2871/**\r
2872 Initializes the head node of a doubly linked list, and returns the pointer to\r
2873 the head node of the doubly linked list.\r
2874\r
2875 Initializes the forward and backward links of a new linked list. After\r
2876 initializing a linked list with this function, the other linked list\r
2877 functions may be used to add and remove nodes from the linked list. It is up\r
2878 to the caller of this function to allocate the memory for ListHead.\r
2879\r
2880 If ListHead is NULL, then ASSERT().\r
2881\r
2882 @param ListHead A pointer to the head node of a new doubly linked list.\r
2883\r
2884 @return ListHead\r
2885\r
2886**/\r
2887LIST_ENTRY *\r
2888EFIAPI\r
2889InitializeListHead (\r
aa0583c7 2890 IN OUT LIST_ENTRY *ListHead\r
ac644614 2891 );\r
2892\r
2893\r
2894/**\r
2895 Adds a node to the beginning of a doubly linked list, and returns the pointer\r
2896 to the head node of the doubly linked list.\r
2897\r
2898 Adds the node Entry at the beginning of the doubly linked list denoted by\r
2899 ListHead, and returns ListHead.\r
2900\r
2901 If ListHead is NULL, then ASSERT().\r
2902 If Entry is NULL, then ASSERT().\r
17f695ed 2903 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
2904 InitializeListHead(), then ASSERT().\r
a71865b1 2905 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r
ac644614 2906 of nodes in ListHead, including the ListHead node, is greater than or\r
2907 equal to PcdMaximumLinkedListLength, then ASSERT().\r
2908\r
2909 @param ListHead A pointer to the head node of a doubly linked list.\r
2910 @param Entry A pointer to a node that is to be inserted at the beginning\r
2911 of a doubly linked list.\r
2912\r
2913 @return ListHead\r
2914\r
2915**/\r
2916LIST_ENTRY *\r
2917EFIAPI\r
2918InsertHeadList (\r
aa0583c7 2919 IN OUT LIST_ENTRY *ListHead,\r
2920 IN OUT LIST_ENTRY *Entry\r
ac644614 2921 );\r
2922\r
2923\r
2924/**\r
2925 Adds a node to the end of a doubly linked list, and returns the pointer to\r
2926 the head node of the doubly linked list.\r
2927\r
2928 Adds the node Entry to the end of the doubly linked list denoted by ListHead,\r
2929 and returns ListHead.\r
2930\r
2931 If ListHead is NULL, then ASSERT().\r
2932 If Entry is NULL, then ASSERT().\r
17f695ed 2933 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
2934 InitializeListHead(), then ASSERT().\r
a71865b1 2935 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r
ac644614 2936 of nodes in ListHead, including the ListHead node, is greater than or\r
2937 equal to PcdMaximumLinkedListLength, then ASSERT().\r
2938\r
2939 @param ListHead A pointer to the head node of a doubly linked list.\r
2940 @param Entry A pointer to a node that is to be added at the end of the\r
2941 doubly linked list.\r
2942\r
2943 @return ListHead\r
2944\r
2945**/\r
2946LIST_ENTRY *\r
2947EFIAPI\r
2948InsertTailList (\r
aa0583c7 2949 IN OUT LIST_ENTRY *ListHead,\r
2950 IN OUT LIST_ENTRY *Entry\r
ac644614 2951 );\r
2952\r
2953\r
2954/**\r
2955 Retrieves the first node of a doubly linked list.\r
2956\r
17f695ed 2957 Returns the first node of a doubly linked list. List must have been \r
2958 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
2959 If List is empty, then List is returned.\r
ac644614 2960\r
2961 If List is NULL, then ASSERT().\r
17f695ed 2962 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
2963 InitializeListHead(), then ASSERT().\r
a71865b1 2964 If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
ac644614 2965 in List, including the List node, is greater than or equal to\r
2966 PcdMaximumLinkedListLength, then ASSERT().\r
2967\r
2968 @param List A pointer to the head node of a doubly linked list.\r
2969\r
2970 @return The first node of a doubly linked list.\r
e01a125f 2971 @retval List The list is empty.\r
ac644614 2972\r
2973**/\r
2974LIST_ENTRY *\r
2975EFIAPI\r
2976GetFirstNode (\r
2977 IN CONST LIST_ENTRY *List\r
2978 );\r
2979\r
2980\r
2981/**\r
2982 Retrieves the next node of a doubly linked list.\r
2983\r
17f695ed 2984 Returns the node of a doubly linked list that follows Node. \r
2985 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
2986 or InitializeListHead(). If List is empty, then List is returned.\r
ac644614 2987\r
2988 If List is NULL, then ASSERT().\r
2989 If Node is NULL, then ASSERT().\r
17f695ed 2990 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
2991 InitializeListHead(), then ASSERT().\r
a71865b1
LG
2992 If PcdMaximumLinkedListLength is not zero, and List contains more than\r
2993 PcdMaximumLinkedListLength nodes, then ASSERT().\r
1081f624 2994 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
ac644614 2995\r
2996 @param List A pointer to the head node of a doubly linked list.\r
2997 @param Node A pointer to a node in the doubly linked list.\r
2998\r
af2dc6a7 2999 @return The pointer to the next node if one exists. Otherwise List is returned.\r
ac644614 3000\r
3001**/\r
3002LIST_ENTRY *\r
3003EFIAPI\r
3004GetNextNode (\r
3005 IN CONST LIST_ENTRY *List,\r
3006 IN CONST LIST_ENTRY *Node\r
3007 );\r
3008\r
cbca8de5 3009 \r
3010/**\r
3011 Retrieves the previous node of a doubly linked list.\r
3012 \r
3013 Returns the node of a doubly linked list that precedes Node. \r
3014 List must have been initialized with INTIALIZE_LIST_HEAD_VARIABLE()\r
3015 or InitializeListHead(). If List is empty, then List is returned.\r
3016 \r
3017 If List is NULL, then ASSERT().\r
3018 If Node is NULL, then ASSERT().\r
3019 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
3020 InitializeListHead(), then ASSERT().\r
a71865b1
LG
3021 If PcdMaximumLinkedListLength is not zero, and List contains more than\r
3022 PcdMaximumLinkedListLength nodes, then ASSERT().\r
cbca8de5 3023 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
3024 \r
3025 @param List A pointer to the head node of a doubly linked list.\r
3026 @param Node A pointer to a node in the doubly linked list.\r
3027 \r
af2dc6a7 3028 @return The pointer to the previous node if one exists. Otherwise List is returned.\r
cbca8de5 3029 \r
3030**/\r
3031LIST_ENTRY *\r
3032EFIAPI\r
3033GetPreviousNode (\r
3034 IN CONST LIST_ENTRY *List,\r
3035 IN CONST LIST_ENTRY *Node\r
3036 );\r
ac644614 3037\r
cbca8de5 3038 \r
ac644614 3039/**\r
3040 Checks to see if a doubly linked list is empty or not.\r
3041\r
3042 Checks to see if the doubly linked list is empty. If the linked list contains\r
3043 zero nodes, this function returns TRUE. Otherwise, it returns FALSE.\r
3044\r
3045 If ListHead is NULL, then ASSERT().\r
17f695ed 3046 If ListHead was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or \r
3047 InitializeListHead(), then ASSERT().\r
a71865b1 3048 If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
ac644614 3049 in List, including the List node, is greater than or equal to\r
3050 PcdMaximumLinkedListLength, then ASSERT().\r
3051\r
3052 @param ListHead A pointer to the head node of a doubly linked list.\r
3053\r
3054 @retval TRUE The linked list is empty.\r
3055 @retval FALSE The linked list is not empty.\r
3056\r
3057**/\r
3058BOOLEAN\r
3059EFIAPI\r
3060IsListEmpty (\r
3061 IN CONST LIST_ENTRY *ListHead\r
3062 );\r
3063\r
3064\r
3065/**\r
aa0583c7 3066 Determines if a node in a doubly linked list is the head node of a the same\r
3067 doubly linked list. This function is typically used to terminate a loop that\r
3068 traverses all the nodes in a doubly linked list starting with the head node.\r
ac644614 3069\r
aa0583c7 3070 Returns TRUE if Node is equal to List. Returns FALSE if Node is one of the\r
3071 nodes in the doubly linked list specified by List. List must have been\r
17f695ed 3072 initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
ac644614 3073\r
3074 If List is NULL, then ASSERT().\r
3075 If Node is NULL, then ASSERT().\r
17f695ed 3076 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(), \r
3077 then ASSERT().\r
a71865b1 3078 If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
ac644614 3079 in List, including the List node, is greater than or equal to\r
3080 PcdMaximumLinkedListLength, then ASSERT().\r
1081f624 3081 If PcdVerifyNodeInList is TRUE and Node is not a node in List the and Node is not equal \r
3082 to List, then ASSERT().\r
ac644614 3083\r
3084 @param List A pointer to the head node of a doubly linked list.\r
3085 @param Node A pointer to a node in the doubly linked list.\r
3086\r
1955808d
LG
3087 @retval TRUE Node is the head of the doubly-linked list pointed by List.\r
3088 @retval FALSE Node is not the head of the doubly-linked list pointed by List.\r
ac644614 3089\r
3090**/\r
3091BOOLEAN\r
3092EFIAPI\r
3093IsNull (\r
3094 IN CONST LIST_ENTRY *List,\r
3095 IN CONST LIST_ENTRY *Node\r
3096 );\r
3097\r
3098\r
3099/**\r
3100 Determines if a node the last node in a doubly linked list.\r
3101\r
3102 Returns TRUE if Node is the last node in the doubly linked list specified by\r
3103 List. Otherwise, FALSE is returned. List must have been initialized with\r
17f695ed 3104 INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead().\r
ac644614 3105\r
3106 If List is NULL, then ASSERT().\r
3107 If Node is NULL, then ASSERT().\r
17f695ed 3108 If List was not initialized with INTIALIZE_LIST_HEAD_VARIABLE() or\r
3109 InitializeListHead(), then ASSERT().\r
a71865b1 3110 If PcdMaximumLinkedListLength is not zero, and the number of nodes\r
ac644614 3111 in List, including the List node, is greater than or equal to\r
3112 PcdMaximumLinkedListLength, then ASSERT().\r
1081f624 3113 If PcdVerifyNodeInList is TRUE and Node is not a node in List, then ASSERT().\r
ac644614 3114\r
3115 @param List A pointer to the head node of a doubly linked list.\r
3116 @param Node A pointer to a node in the doubly linked list.\r
3117\r
3118 @retval TRUE Node is the last node in the linked list.\r
3119 @retval FALSE Node is not the last node in the linked list.\r
3120\r
3121**/\r
3122BOOLEAN\r
3123EFIAPI\r
3124IsNodeAtEnd (\r
3125 IN CONST LIST_ENTRY *List,\r
3126 IN CONST LIST_ENTRY *Node\r
3127 );\r
3128\r
3129\r
3130/**\r
3131 Swaps the location of two nodes in a doubly linked list, and returns the\r
3132 first node after the swap.\r
3133\r
3134 If FirstEntry is identical to SecondEntry, then SecondEntry is returned.\r
3135 Otherwise, the location of the FirstEntry node is swapped with the location\r
3136 of the SecondEntry node in a doubly linked list. SecondEntry must be in the\r
3137 same double linked list as FirstEntry and that double linked list must have\r
17f695ed 3138 been initialized with INTIALIZE_LIST_HEAD_VARIABLE() or InitializeListHead(). \r
3139 SecondEntry is returned after the nodes are swapped.\r
ac644614 3140\r
3141 If FirstEntry is NULL, then ASSERT().\r
3142 If SecondEntry is NULL, then ASSERT().\r
1081f624 3143 If PcdVerifyNodeInList is TRUE and SecondEntry and FirstEntry are not in the \r
3144 same linked list, then ASSERT().\r
ac644614 3145 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
3146 linked list containing the FirstEntry and SecondEntry nodes, including\r
3147 the FirstEntry and SecondEntry nodes, is greater than or equal to\r
3148 PcdMaximumLinkedListLength, then ASSERT().\r
3149\r
3150 @param FirstEntry A pointer to a node in a linked list.\r
3151 @param SecondEntry A pointer to another node in the same linked list.\r
38bbd3d9 3152 \r
9aa049d9 3153 @return SecondEntry.\r
ac644614 3154\r
3155**/\r
3156LIST_ENTRY *\r
3157EFIAPI\r
3158SwapListEntries (\r
aa0583c7 3159 IN OUT LIST_ENTRY *FirstEntry,\r
3160 IN OUT LIST_ENTRY *SecondEntry\r
ac644614 3161 );\r
3162\r
3163\r
3164/**\r
3165 Removes a node from a doubly linked list, and returns the node that follows\r
3166 the removed node.\r
3167\r
3168 Removes the node Entry from a doubly linked list. It is up to the caller of\r
3169 this function to release the memory used by this node if that is required. On\r
3170 exit, the node following Entry in the doubly linked list is returned. If\r
3171 Entry is the only node in the linked list, then the head node of the linked\r
3172 list is returned.\r
3173\r
3174 If Entry is NULL, then ASSERT().\r
3175 If Entry is the head node of an empty list, then ASSERT().\r
3176 If PcdMaximumLinkedListLength is not zero, and the number of nodes in the\r
3177 linked list containing Entry, including the Entry node, is greater than\r
3178 or equal to PcdMaximumLinkedListLength, then ASSERT().\r
3179\r
9aa049d9 3180 @param Entry A pointer to a node in a linked list.\r
ac644614 3181\r
9aa049d9 3182 @return Entry.\r
ac644614 3183\r
3184**/\r
3185LIST_ENTRY *\r
3186EFIAPI\r
3187RemoveEntryList (\r
3188 IN CONST LIST_ENTRY *Entry\r
3189 );\r
3190\r
3191//\r
3192// Math Services\r
3193//\r
3194\r
3195/**\r
3196 Shifts a 64-bit integer left between 0 and 63 bits. The low bits are filled\r
3197 with zeros. The shifted value is returned.\r
3198\r
3199 This function shifts the 64-bit value Operand to the left by Count bits. The\r
3200 low Count bits are set to zero. The shifted value is returned.\r
3201\r
3202 If Count is greater than 63, then ASSERT().\r
3203\r
3204 @param Operand The 64-bit operand to shift left.\r
3205 @param Count The number of bits to shift left.\r
3206\r
9aa049d9 3207 @return Operand << Count.\r
ac644614 3208\r
3209**/\r
3210UINT64\r
3211EFIAPI\r
3212LShiftU64 (\r
3213 IN UINT64 Operand,\r
3214 IN UINTN Count\r
3215 );\r
3216\r
3217\r
3218/**\r
3219 Shifts a 64-bit integer right between 0 and 63 bits. This high bits are\r
3220 filled with zeros. The shifted value is returned.\r
3221\r
3222 This function shifts the 64-bit value Operand to the right by Count bits. The\r
3223 high Count bits are set to zero. The shifted value is returned.\r
3224\r
3225 If Count is greater than 63, then ASSERT().\r
3226\r
3227 @param Operand The 64-bit operand to shift right.\r
3228 @param Count The number of bits to shift right.\r
3229\r
3230 @return Operand >> Count\r
3231\r
3232**/\r
3233UINT64\r
3234EFIAPI\r
3235RShiftU64 (\r
3236 IN UINT64 Operand,\r
3237 IN UINTN Count\r
3238 );\r
3239\r
3240\r
3241/**\r
3242 Shifts a 64-bit integer right between 0 and 63 bits. The high bits are filled\r
3243 with original integer's bit 63. The shifted value is returned.\r
3244\r
3245 This function shifts the 64-bit value Operand to the right by Count bits. The\r
3246 high Count bits are set to bit 63 of Operand. The shifted value is returned.\r
3247\r
3248 If Count is greater than 63, then ASSERT().\r
3249\r
3250 @param Operand The 64-bit operand to shift right.\r
3251 @param Count The number of bits to shift right.\r
3252\r
3253 @return Operand >> Count\r
3254\r
3255**/\r
3256UINT64\r
3257EFIAPI\r
3258ARShiftU64 (\r
3259 IN UINT64 Operand,\r
3260 IN UINTN Count\r
3261 );\r
3262\r
3263\r
3264/**\r
3265 Rotates a 32-bit integer left between 0 and 31 bits, filling the low bits\r
3266 with the high bits that were rotated.\r
3267\r
3268 This function rotates the 32-bit value Operand to the left by Count bits. The\r
3269 low Count bits are fill with the high Count bits of Operand. The rotated\r
3270 value is returned.\r
3271\r
3272 If Count is greater than 31, then ASSERT().\r
3273\r
3274 @param Operand The 32-bit operand to rotate left.\r
3275 @param Count The number of bits to rotate left.\r
3276\r
17f695ed 3277 @return Operand << Count\r
ac644614 3278\r
3279**/\r
3280UINT32\r
3281EFIAPI\r
3282LRotU32 (\r
3283 IN UINT32 Operand,\r
3284 IN UINTN Count\r
3285 );\r
3286\r
3287\r
3288/**\r
3289 Rotates a 32-bit integer right between 0 and 31 bits, filling the high bits\r
3290 with the low bits that were rotated.\r
3291\r
3292 This function rotates the 32-bit value Operand to the right by Count bits.\r
3293 The high Count bits are fill with the low Count bits of Operand. The rotated\r
3294 value is returned.\r
3295\r
3296 If Count is greater than 31, then ASSERT().\r
3297\r
3298 @param Operand The 32-bit operand to rotate right.\r
3299 @param Count The number of bits to rotate right.\r
3300\r
2fe241a2 3301 @return Operand >> Count\r
ac644614 3302\r
3303**/\r
3304UINT32\r
3305EFIAPI\r
3306RRotU32 (\r
3307 IN UINT32 Operand,\r
3308 IN UINTN Count\r
3309 );\r
3310\r
3311\r
3312/**\r
3313 Rotates a 64-bit integer left between 0 and 63 bits, filling the low bits\r
3314 with the high bits that were rotated.\r
3315\r
3316 This function rotates the 64-bit value Operand to the left by Count bits. The\r
3317 low Count bits are fill with the high Count bits of Operand. The rotated\r
3318 value is returned.\r
3319\r
3320 If Count is greater than 63, then ASSERT().\r
3321\r
3322 @param Operand The 64-bit operand to rotate left.\r
3323 @param Count The number of bits to rotate left.\r
3324\r
17f695ed 3325 @return Operand << Count\r
ac644614 3326\r
3327**/\r
3328UINT64\r
3329EFIAPI\r
3330LRotU64 (\r
3331 IN UINT64 Operand,\r
3332 IN UINTN Count\r
3333 );\r
3334\r
3335\r
3336/**\r
3337 Rotates a 64-bit integer right between 0 and 63 bits, filling the high bits\r
3338 with the high low bits that were rotated.\r
3339\r
3340 This function rotates the 64-bit value Operand to the right by Count bits.\r
3341 The high Count bits are fill with the low Count bits of Operand. The rotated\r
3342 value is returned.\r
3343\r
3344 If Count is greater than 63, then ASSERT().\r
3345\r
3346 @param Operand The 64-bit operand to rotate right.\r
3347 @param Count The number of bits to rotate right.\r
3348\r
17f695ed 3349 @return Operand >> Count\r
ac644614 3350\r
3351**/\r
3352UINT64\r
3353EFIAPI\r
3354RRotU64 (\r
3355 IN UINT64 Operand,\r
3356 IN UINTN Count\r
3357 );\r
3358\r
3359\r
3360/**\r
3361 Returns the bit position of the lowest bit set in a 32-bit value.\r
3362\r
3363 This function computes the bit position of the lowest bit set in the 32-bit\r
3364 value specified by Operand. If Operand is zero, then -1 is returned.\r
3365 Otherwise, a value between 0 and 31 is returned.\r
3366\r
3367 @param Operand The 32-bit operand to evaluate.\r
3368\r
9aa049d9 3369 @retval 0..31 The lowest bit set in Operand was found.\r
17f695ed 3370 @retval -1 Operand is zero.\r
ac644614 3371\r
3372**/\r
3373INTN\r
3374EFIAPI\r
3375LowBitSet32 (\r
3376 IN UINT32 Operand\r
3377 );\r
3378\r
3379\r
3380/**\r
3381 Returns the bit position of the lowest bit set in a 64-bit value.\r
3382\r
3383 This function computes the bit position of the lowest bit set in the 64-bit\r
3384 value specified by Operand. If Operand is zero, then -1 is returned.\r
3385 Otherwise, a value between 0 and 63 is returned.\r
3386\r
3387 @param Operand The 64-bit operand to evaluate.\r
3388\r
9aa049d9 3389 @retval 0..63 The lowest bit set in Operand was found.\r
17f695ed 3390 @retval -1 Operand is zero.\r
3391\r
ac644614 3392\r
3393**/\r
3394INTN\r
3395EFIAPI\r
3396LowBitSet64 (\r
3397 IN UINT64 Operand\r
3398 );\r
3399\r
3400\r
3401/**\r
3402 Returns the bit position of the highest bit set in a 32-bit value. Equivalent\r
3403 to log2(x).\r
3404\r
3405 This function computes the bit position of the highest bit set in the 32-bit\r
3406 value specified by Operand. If Operand is zero, then -1 is returned.\r
3407 Otherwise, a value between 0 and 31 is returned.\r
3408\r
3409 @param Operand The 32-bit operand to evaluate.\r
3410\r
9aa049d9 3411 @retval 0..31 Position of the highest bit set in Operand if found.\r
17f695ed 3412 @retval -1 Operand is zero.\r
ac644614 3413\r
3414**/\r
3415INTN\r
3416EFIAPI\r
3417HighBitSet32 (\r
3418 IN UINT32 Operand\r
3419 );\r
3420\r
3421\r
3422/**\r
3423 Returns the bit position of the highest bit set in a 64-bit value. Equivalent\r
3424 to log2(x).\r
3425\r
3426 This function computes the bit position of the highest bit set in the 64-bit\r
3427 value specified by Operand. If Operand is zero, then -1 is returned.\r
3428 Otherwise, a value between 0 and 63 is returned.\r
3429\r
3430 @param Operand The 64-bit operand to evaluate.\r
3431\r
9aa049d9 3432 @retval 0..63 Position of the highest bit set in Operand if found.\r
17f695ed 3433 @retval -1 Operand is zero.\r
ac644614 3434\r
3435**/\r
3436INTN\r
3437EFIAPI\r
3438HighBitSet64 (\r
3439 IN UINT64 Operand\r
3440 );\r
3441\r
3442\r
3443/**\r
3444 Returns the value of the highest bit set in a 32-bit value. Equivalent to\r
17f695ed 3445 1 << log2(x).\r
ac644614 3446\r
3447 This function computes the value of the highest bit set in the 32-bit value\r
3448 specified by Operand. If Operand is zero, then zero is returned.\r
3449\r
3450 @param Operand The 32-bit operand to evaluate.\r
3451\r
3452 @return 1 << HighBitSet32(Operand)\r
3453 @retval 0 Operand is zero.\r
3454\r
3455**/\r
3456UINT32\r
3457EFIAPI\r
3458GetPowerOfTwo32 (\r
3459 IN UINT32 Operand\r
3460 );\r
3461\r
3462\r
3463/**\r
3464 Returns the value of the highest bit set in a 64-bit value. Equivalent to\r
17f695ed 3465 1 << log2(x).\r
ac644614 3466\r
3467 This function computes the value of the highest bit set in the 64-bit value\r
3468 specified by Operand. If Operand is zero, then zero is returned.\r
3469\r
3470 @param Operand The 64-bit operand to evaluate.\r
3471\r
3472 @return 1 << HighBitSet64(Operand)\r
3473 @retval 0 Operand is zero.\r
3474\r
3475**/\r
3476UINT64\r
3477EFIAPI\r
3478GetPowerOfTwo64 (\r
3479 IN UINT64 Operand\r
3480 );\r
3481\r
3482\r
3483/**\r
af2dc6a7 3484 Switches the endianness of a 16-bit integer.\r
ac644614 3485\r
3486 This function swaps the bytes in a 16-bit unsigned value to switch the value\r
3487 from little endian to big endian or vice versa. The byte swapped value is\r
3488 returned.\r
3489\r
2a53dabf 3490 @param Value A 16-bit unsigned value.\r
ac644614 3491\r
efb23117 3492 @return The byte swapped Value.\r
ac644614 3493\r
3494**/\r
3495UINT16\r
3496EFIAPI\r
3497SwapBytes16 (\r
3498 IN UINT16 Value\r
3499 );\r
3500\r
3501\r
3502/**\r
af2dc6a7 3503 Switches the endianness of a 32-bit integer.\r
ac644614 3504\r
3505 This function swaps the bytes in a 32-bit unsigned value to switch the value\r
3506 from little endian to big endian or vice versa. The byte swapped value is\r
3507 returned.\r
3508\r
2a53dabf 3509 @param Value A 32-bit unsigned value.\r
ac644614 3510\r
efb23117 3511 @return The byte swapped Value.\r
ac644614 3512\r
3513**/\r
3514UINT32\r
3515EFIAPI\r
3516SwapBytes32 (\r
3517 IN UINT32 Value\r
3518 );\r
3519\r
3520\r
3521/**\r
af2dc6a7 3522 Switches the endianness of a 64-bit integer.\r
ac644614 3523\r
3524 This function swaps the bytes in a 64-bit unsigned value to switch the value\r
3525 from little endian to big endian or vice versa. The byte swapped value is\r
3526 returned.\r
3527\r
2a53dabf 3528 @param Value A 64-bit unsigned value.\r
ac644614 3529\r
efb23117 3530 @return The byte swapped Value.\r
ac644614 3531\r
3532**/\r
3533UINT64\r
3534EFIAPI\r
3535SwapBytes64 (\r
3536 IN UINT64 Value\r
3537 );\r
3538\r
3539\r
3540/**\r
3541 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer and\r
3542 generates a 64-bit unsigned result.\r
3543\r
3544 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit\r
3545 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
3546 bit unsigned result is returned.\r
3547\r
ac644614 3548 @param Multiplicand A 64-bit unsigned value.\r
3549 @param Multiplier A 32-bit unsigned value.\r
3550\r
3551 @return Multiplicand * Multiplier\r
3552\r
3553**/\r
3554UINT64\r
3555EFIAPI\r
3556MultU64x32 (\r
3557 IN UINT64 Multiplicand,\r
3558 IN UINT32 Multiplier\r
3559 );\r
3560\r
3561\r
3562/**\r
3563 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer and\r
3564 generates a 64-bit unsigned result.\r
3565\r
3566 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
3567 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
3568 bit unsigned result is returned.\r
3569\r
ac644614 3570 @param Multiplicand A 64-bit unsigned value.\r
3571 @param Multiplier A 64-bit unsigned value.\r
3572\r
af2dc6a7 3573 @return Multiplicand * Multiplier.\r
ac644614 3574\r
3575**/\r
3576UINT64\r
3577EFIAPI\r
3578MultU64x64 (\r
3579 IN UINT64 Multiplicand,\r
3580 IN UINT64 Multiplier\r
3581 );\r
3582\r
3583\r
3584/**\r
3585 Multiples a 64-bit signed integer by a 64-bit signed integer and generates a\r
3586 64-bit signed result.\r
3587\r
3588 This function multiples the 64-bit signed value Multiplicand by the 64-bit\r
3589 signed value Multiplier and generates a 64-bit signed result. This 64-bit\r
3590 signed result is returned.\r
3591\r
ac644614 3592 @param Multiplicand A 64-bit signed value.\r
3593 @param Multiplier A 64-bit signed value.\r
3594\r
3595 @return Multiplicand * Multiplier\r
3596\r
3597**/\r
3598INT64\r
3599EFIAPI\r
3600MultS64x64 (\r
3601 IN INT64 Multiplicand,\r
3602 IN INT64 Multiplier\r
3603 );\r
3604\r
3605\r
3606/**\r
3607 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
3608 a 64-bit unsigned result.\r
3609\r
3610 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
3611 unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
3612 function returns the 64-bit unsigned quotient.\r
3613\r
3614 If Divisor is 0, then ASSERT().\r
3615\r
3616 @param Dividend A 64-bit unsigned value.\r
3617 @param Divisor A 32-bit unsigned value.\r
3618\r
af2dc6a7 3619 @return Dividend / Divisor.\r
ac644614 3620\r
3621**/\r
3622UINT64\r
3623EFIAPI\r
3624DivU64x32 (\r
3625 IN UINT64 Dividend,\r
3626 IN UINT32 Divisor\r
3627 );\r
3628\r
3629\r
3630/**\r
3631 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
3632 a 32-bit unsigned remainder.\r
3633\r
3634 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
3635 unsigned value Divisor and generates a 32-bit remainder. This function\r
3636 returns the 32-bit unsigned remainder.\r
3637\r
3638 If Divisor is 0, then ASSERT().\r
3639\r
3640 @param Dividend A 64-bit unsigned value.\r
3641 @param Divisor A 32-bit unsigned value.\r
3642\r
af2dc6a7 3643 @return Dividend % Divisor.\r
ac644614 3644\r
3645**/\r
3646UINT32\r
3647EFIAPI\r
3648ModU64x32 (\r
3649 IN UINT64 Dividend,\r
3650 IN UINT32 Divisor\r
3651 );\r
3652\r
3653\r
3654/**\r
3655 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and generates\r
3656 a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
3657\r
3658 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
3659 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
3660 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
3661 This function returns the 64-bit unsigned quotient.\r
3662\r
3663 If Divisor is 0, then ASSERT().\r
3664\r
3665 @param Dividend A 64-bit unsigned value.\r
3666 @param Divisor A 32-bit unsigned value.\r
3667 @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r
3668 optional and may be NULL.\r
3669\r
af2dc6a7 3670 @return Dividend / Divisor.\r
ac644614 3671\r
3672**/\r
3673UINT64\r
3674EFIAPI\r
3675DivU64x32Remainder (\r
3676 IN UINT64 Dividend,\r
3677 IN UINT32 Divisor,\r
3678 OUT UINT32 *Remainder OPTIONAL\r
3679 );\r
3680\r
3681\r
3682/**\r
3683 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and generates\r
3684 a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
3685\r
3686 This function divides the 64-bit unsigned value Dividend by the 64-bit\r
3687 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
3688 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
3689 This function returns the 64-bit unsigned quotient.\r
3690\r
3691 If Divisor is 0, then ASSERT().\r
3692\r
3693 @param Dividend A 64-bit unsigned value.\r
3694 @param Divisor A 64-bit unsigned value.\r
3695 @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r
3696 optional and may be NULL.\r
3697\r
af2dc6a7 3698 @return Dividend / Divisor.\r
ac644614 3699\r
3700**/\r
3701UINT64\r
3702EFIAPI\r
3703DivU64x64Remainder (\r
3704 IN UINT64 Dividend,\r
3705 IN UINT64 Divisor,\r
3706 OUT UINT64 *Remainder OPTIONAL\r
3707 );\r
3708\r
3709\r
3710/**\r
3711 Divides a 64-bit signed integer by a 64-bit signed integer and generates a\r
3712 64-bit signed result and a optional 64-bit signed remainder.\r
3713\r
3714 This function divides the 64-bit signed value Dividend by the 64-bit signed\r
3715 value Divisor and generates a 64-bit signed quotient. If Remainder is not\r
3716 NULL, then the 64-bit signed remainder is returned in Remainder. This\r
3717 function returns the 64-bit signed quotient.\r
3718\r
9aa049d9 3719 It is the caller's responsibility to not call this function with a Divisor of 0.\r
17f695ed 3720 If Divisor is 0, then the quotient and remainder should be assumed to be \r
3721 the largest negative integer.\r
3722\r
ac644614 3723 If Divisor is 0, then ASSERT().\r
3724\r
3725 @param Dividend A 64-bit signed value.\r
3726 @param Divisor A 64-bit signed value.\r
3727 @param Remainder A pointer to a 64-bit signed value. This parameter is\r
3728 optional and may be NULL.\r
3729\r
af2dc6a7 3730 @return Dividend / Divisor.\r
ac644614 3731\r
3732**/\r
3733INT64\r
3734EFIAPI\r
3735DivS64x64Remainder (\r
3736 IN INT64 Dividend,\r
3737 IN INT64 Divisor,\r
3738 OUT INT64 *Remainder OPTIONAL\r
3739 );\r
3740\r
3741\r
3742/**\r
3743 Reads a 16-bit value from memory that may be unaligned.\r
3744\r
3745 This function returns the 16-bit value pointed to by Buffer. The function\r
3746 guarantees that the read operation does not produce an alignment fault.\r
3747\r
3748 If the Buffer is NULL, then ASSERT().\r
3749\r
af2dc6a7 3750 @param Buffer The pointer to a 16-bit value that may be unaligned.\r
ac644614 3751\r
5385a579 3752 @return The 16-bit value read from Buffer.\r
ac644614 3753\r
3754**/\r
3755UINT16\r
3756EFIAPI\r
3757ReadUnaligned16 (\r
5385a579 3758 IN CONST UINT16 *Buffer\r
ac644614 3759 );\r
3760\r
3761\r
3762/**\r
3763 Writes a 16-bit value to memory that may be unaligned.\r
3764\r
3765 This function writes the 16-bit value specified by Value to Buffer. Value is\r
3766 returned. The function guarantees that the write operation does not produce\r
3767 an alignment fault.\r
3768\r
3769 If the Buffer is NULL, then ASSERT().\r
3770\r
af2dc6a7 3771 @param Buffer The pointer to a 16-bit value that may be unaligned.\r
ac644614 3772 @param Value 16-bit value to write to Buffer.\r
3773\r
5385a579 3774 @return The 16-bit value to write to Buffer.\r
ac644614 3775\r
3776**/\r
3777UINT16\r
3778EFIAPI\r
3779WriteUnaligned16 (\r
5385a579 3780 OUT UINT16 *Buffer,\r
3781 IN UINT16 Value\r
ac644614 3782 );\r
3783\r
3784\r
3785/**\r
3786 Reads a 24-bit value from memory that may be unaligned.\r
3787\r
3788 This function returns the 24-bit value pointed to by Buffer. The function\r
3789 guarantees that the read operation does not produce an alignment fault.\r
3790\r
3791 If the Buffer is NULL, then ASSERT().\r
3792\r
af2dc6a7 3793 @param Buffer The pointer to a 24-bit value that may be unaligned.\r
ac644614 3794\r
5385a579 3795 @return The 24-bit value read from Buffer.\r
ac644614 3796\r
3797**/\r
3798UINT32\r
3799EFIAPI\r
3800ReadUnaligned24 (\r
5385a579 3801 IN CONST UINT32 *Buffer\r
ac644614 3802 );\r
3803\r
3804\r
3805/**\r
3806 Writes a 24-bit value to memory that may be unaligned.\r
3807\r
3808 This function writes the 24-bit value specified by Value to Buffer. Value is\r
3809 returned. The function guarantees that the write operation does not produce\r
3810 an alignment fault.\r
3811\r
3812 If the Buffer is NULL, then ASSERT().\r
3813\r
af2dc6a7 3814 @param Buffer The pointer to a 24-bit value that may be unaligned.\r
ac644614 3815 @param Value 24-bit value to write to Buffer.\r
3816\r
5385a579 3817 @return The 24-bit value to write to Buffer.\r
ac644614 3818\r
3819**/\r
3820UINT32\r
3821EFIAPI\r
3822WriteUnaligned24 (\r
5385a579 3823 OUT UINT32 *Buffer,\r
3824 IN UINT32 Value\r
ac644614 3825 );\r
3826\r
3827\r
3828/**\r
3829 Reads a 32-bit value from memory that may be unaligned.\r
3830\r
3831 This function returns the 32-bit value pointed to by Buffer. The function\r
3832 guarantees that the read operation does not produce an alignment fault.\r
3833\r
3834 If the Buffer is NULL, then ASSERT().\r
3835\r
af2dc6a7 3836 @param Buffer The pointer to a 32-bit value that may be unaligned.\r
ac644614 3837\r
5385a579 3838 @return The 32-bit value read from Buffer.\r
ac644614 3839\r
3840**/\r
3841UINT32\r
3842EFIAPI\r
3843ReadUnaligned32 (\r
5385a579 3844 IN CONST UINT32 *Buffer\r
ac644614 3845 );\r
3846\r
3847\r
3848/**\r
3849 Writes a 32-bit value to memory that may be unaligned.\r
3850\r
3851 This function writes the 32-bit value specified by Value to Buffer. Value is\r
3852 returned. The function guarantees that the write operation does not produce\r
3853 an alignment fault.\r
3854\r
3855 If the Buffer is NULL, then ASSERT().\r
3856\r
af2dc6a7 3857 @param Buffer The pointer to a 32-bit value that may be unaligned.\r
ac644614 3858 @param Value 32-bit value to write to Buffer.\r
3859\r
5385a579 3860 @return The 32-bit value to write to Buffer.\r
ac644614 3861\r
3862**/\r
3863UINT32\r
3864EFIAPI\r
3865WriteUnaligned32 (\r
5385a579 3866 OUT UINT32 *Buffer,\r
3867 IN UINT32 Value\r
ac644614 3868 );\r
3869\r
3870\r
3871/**\r
3872 Reads a 64-bit value from memory that may be unaligned.\r
3873\r
3874 This function returns the 64-bit value pointed to by Buffer. The function\r
3875 guarantees that the read operation does not produce an alignment fault.\r
3876\r
3877 If the Buffer is NULL, then ASSERT().\r
3878\r
af2dc6a7 3879 @param Buffer The pointer to a 64-bit value that may be unaligned.\r
ac644614 3880\r
5385a579 3881 @return The 64-bit value read from Buffer.\r
ac644614 3882\r
3883**/\r
3884UINT64\r
3885EFIAPI\r
3886ReadUnaligned64 (\r
5385a579 3887 IN CONST UINT64 *Buffer\r
ac644614 3888 );\r
3889\r
3890\r
3891/**\r
3892 Writes a 64-bit value to memory that may be unaligned.\r
3893\r
3894 This function writes the 64-bit value specified by Value to Buffer. Value is\r
3895 returned. The function guarantees that the write operation does not produce\r
3896 an alignment fault.\r
3897\r
3898 If the Buffer is NULL, then ASSERT().\r
3899\r
af2dc6a7 3900 @param Buffer The pointer to a 64-bit value that may be unaligned.\r
ac644614 3901 @param Value 64-bit value to write to Buffer.\r
3902\r
5385a579 3903 @return The 64-bit value to write to Buffer.\r
ac644614 3904\r
3905**/\r
3906UINT64\r
3907EFIAPI\r
3908WriteUnaligned64 (\r
5385a579 3909 OUT UINT64 *Buffer,\r
3910 IN UINT64 Value\r
ac644614 3911 );\r
3912\r
3913\r
3914//\r
3915// Bit Field Functions\r
3916//\r
3917\r
3918/**\r
3919 Returns a bit field from an 8-bit value.\r
3920\r
3921 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
3922\r
3923 If 8-bit operations are not supported, then ASSERT().\r
3924 If StartBit is greater than 7, then ASSERT().\r
3925 If EndBit is greater than 7, then ASSERT().\r
3926 If EndBit is less than StartBit, then ASSERT().\r
3927\r
3928 @param Operand Operand on which to perform the bitfield operation.\r
3929 @param StartBit The ordinal of the least significant bit in the bit field.\r
3930 Range 0..7.\r
3931 @param EndBit The ordinal of the most significant bit in the bit field.\r
3932 Range 0..7.\r
3933\r
3934 @return The bit field read.\r
3935\r
3936**/\r
3937UINT8\r
3938EFIAPI\r
3939BitFieldRead8 (\r
3940 IN UINT8 Operand,\r
3941 IN UINTN StartBit,\r
3942 IN UINTN EndBit\r
3943 );\r
3944\r
3945\r
3946/**\r
3947 Writes a bit field to an 8-bit value, and returns the result.\r
3948\r
3949 Writes Value to the bit field specified by the StartBit and the EndBit in\r
3950 Operand. All other bits in Operand are preserved. The new 8-bit value is\r
3951 returned.\r
3952\r
3953 If 8-bit operations are not supported, then ASSERT().\r
3954 If StartBit is greater than 7, then ASSERT().\r
3955 If EndBit is greater than 7, then ASSERT().\r
3956 If EndBit is less than StartBit, then ASSERT().\r
94952554 3957 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 3958\r
3959 @param Operand Operand on which to perform the bitfield operation.\r
3960 @param StartBit The ordinal of the least significant bit in the bit field.\r
3961 Range 0..7.\r
3962 @param EndBit The ordinal of the most significant bit in the bit field.\r
3963 Range 0..7.\r
3964 @param Value New value of the bit field.\r
3965\r
3966 @return The new 8-bit value.\r
3967\r
3968**/\r
3969UINT8\r
3970EFIAPI\r
3971BitFieldWrite8 (\r
3972 IN UINT8 Operand,\r
3973 IN UINTN StartBit,\r
3974 IN UINTN EndBit,\r
3975 IN UINT8 Value\r
3976 );\r
3977\r
3978\r
3979/**\r
3980 Reads a bit field from an 8-bit value, performs a bitwise OR, and returns the\r
3981 result.\r
3982\r
62991af2 3983 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 3984 and EndBit in Operand and the value specified by OrData. All other bits in\r
3985 Operand are preserved. The new 8-bit value is returned.\r
3986\r
3987 If 8-bit operations are not supported, then ASSERT().\r
3988 If StartBit is greater than 7, then ASSERT().\r
3989 If EndBit is greater than 7, then ASSERT().\r
3990 If EndBit is less than StartBit, then ASSERT().\r
94952554 3991 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 3992\r
3993 @param Operand Operand on which to perform the bitfield operation.\r
3994 @param StartBit The ordinal of the least significant bit in the bit field.\r
3995 Range 0..7.\r
3996 @param EndBit The ordinal of the most significant bit in the bit field.\r
3997 Range 0..7.\r
3998 @param OrData The value to OR with the read value from the value\r
3999\r
4000 @return The new 8-bit value.\r
4001\r
4002**/\r
4003UINT8\r
4004EFIAPI\r
4005BitFieldOr8 (\r
4006 IN UINT8 Operand,\r
4007 IN UINTN StartBit,\r
4008 IN UINTN EndBit,\r
4009 IN UINT8 OrData\r
4010 );\r
4011\r
4012\r
4013/**\r
4014 Reads a bit field from an 8-bit value, performs a bitwise AND, and returns\r
4015 the result.\r
4016\r
4017 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
4018 in Operand and the value specified by AndData. All other bits in Operand are\r
4019 preserved. The new 8-bit value is returned.\r
4020\r
4021 If 8-bit operations are not supported, then ASSERT().\r
4022 If StartBit is greater than 7, then ASSERT().\r
4023 If EndBit is greater than 7, then ASSERT().\r
4024 If EndBit is less than StartBit, then ASSERT().\r
94952554 4025 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4026\r
4027 @param Operand Operand on which to perform the bitfield operation.\r
4028 @param StartBit The ordinal of the least significant bit in the bit field.\r
4029 Range 0..7.\r
4030 @param EndBit The ordinal of the most significant bit in the bit field.\r
4031 Range 0..7.\r
4032 @param AndData The value to AND with the read value from the value.\r
4033\r
4034 @return The new 8-bit value.\r
4035\r
4036**/\r
4037UINT8\r
4038EFIAPI\r
4039BitFieldAnd8 (\r
4040 IN UINT8 Operand,\r
4041 IN UINTN StartBit,\r
4042 IN UINTN EndBit,\r
4043 IN UINT8 AndData\r
4044 );\r
4045\r
4046\r
4047/**\r
4048 Reads a bit field from an 8-bit value, performs a bitwise AND followed by a\r
4049 bitwise OR, and returns the result.\r
4050\r
4051 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 4052 in Operand and the value specified by AndData, followed by a bitwise \r
4053 OR with value specified by OrData. All other bits in Operand are\r
ac644614 4054 preserved. The new 8-bit value is returned.\r
4055\r
4056 If 8-bit operations are not supported, then ASSERT().\r
4057 If StartBit is greater than 7, then ASSERT().\r
4058 If EndBit is greater than 7, then ASSERT().\r
4059 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
4060 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
4061 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4062\r
4063 @param Operand Operand on which to perform the bitfield operation.\r
4064 @param StartBit The ordinal of the least significant bit in the bit field.\r
4065 Range 0..7.\r
4066 @param EndBit The ordinal of the most significant bit in the bit field.\r
4067 Range 0..7.\r
4068 @param AndData The value to AND with the read value from the value.\r
4069 @param OrData The value to OR with the result of the AND operation.\r
4070\r
4071 @return The new 8-bit value.\r
4072\r
4073**/\r
4074UINT8\r
4075EFIAPI\r
4076BitFieldAndThenOr8 (\r
4077 IN UINT8 Operand,\r
4078 IN UINTN StartBit,\r
4079 IN UINTN EndBit,\r
4080 IN UINT8 AndData,\r
4081 IN UINT8 OrData\r
4082 );\r
4083\r
4084\r
4085/**\r
4086 Returns a bit field from a 16-bit value.\r
4087\r
4088 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
4089\r
4090 If 16-bit operations are not supported, then ASSERT().\r
4091 If StartBit is greater than 15, then ASSERT().\r
4092 If EndBit is greater than 15, then ASSERT().\r
4093 If EndBit is less than StartBit, then ASSERT().\r
4094\r
4095 @param Operand Operand on which to perform the bitfield operation.\r
4096 @param StartBit The ordinal of the least significant bit in the bit field.\r
4097 Range 0..15.\r
4098 @param EndBit The ordinal of the most significant bit in the bit field.\r
4099 Range 0..15.\r
4100\r
4101 @return The bit field read.\r
4102\r
4103**/\r
4104UINT16\r
4105EFIAPI\r
4106BitFieldRead16 (\r
4107 IN UINT16 Operand,\r
4108 IN UINTN StartBit,\r
4109 IN UINTN EndBit\r
4110 );\r
4111\r
4112\r
4113/**\r
4114 Writes a bit field to a 16-bit value, and returns the result.\r
4115\r
4116 Writes Value to the bit field specified by the StartBit and the EndBit in\r
4117 Operand. All other bits in Operand are preserved. The new 16-bit value is\r
4118 returned.\r
4119\r
4120 If 16-bit operations are not supported, then ASSERT().\r
4121 If StartBit is greater than 15, then ASSERT().\r
4122 If EndBit is greater than 15, then ASSERT().\r
4123 If EndBit is less than StartBit, then ASSERT().\r
94952554 4124 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4125\r
4126 @param Operand Operand on which to perform the bitfield operation.\r
4127 @param StartBit The ordinal of the least significant bit in the bit field.\r
4128 Range 0..15.\r
4129 @param EndBit The ordinal of the most significant bit in the bit field.\r
4130 Range 0..15.\r
4131 @param Value New value of the bit field.\r
4132\r
4133 @return The new 16-bit value.\r
4134\r
4135**/\r
4136UINT16\r
4137EFIAPI\r
4138BitFieldWrite16 (\r
4139 IN UINT16 Operand,\r
4140 IN UINTN StartBit,\r
4141 IN UINTN EndBit,\r
4142 IN UINT16 Value\r
4143 );\r
4144\r
4145\r
4146/**\r
4147 Reads a bit field from a 16-bit value, performs a bitwise OR, and returns the\r
4148 result.\r
4149\r
62991af2 4150 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 4151 and EndBit in Operand and the value specified by OrData. All other bits in\r
4152 Operand are preserved. The new 16-bit value is returned.\r
4153\r
4154 If 16-bit operations are not supported, then ASSERT().\r
4155 If StartBit is greater than 15, then ASSERT().\r
4156 If EndBit is greater than 15, then ASSERT().\r
4157 If EndBit is less than StartBit, then ASSERT().\r
94952554 4158 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4159\r
4160 @param Operand Operand on which to perform the bitfield operation.\r
4161 @param StartBit The ordinal of the least significant bit in the bit field.\r
4162 Range 0..15.\r
4163 @param EndBit The ordinal of the most significant bit in the bit field.\r
4164 Range 0..15.\r
4165 @param OrData The value to OR with the read value from the value\r
4166\r
4167 @return The new 16-bit value.\r
4168\r
4169**/\r
4170UINT16\r
4171EFIAPI\r
4172BitFieldOr16 (\r
4173 IN UINT16 Operand,\r
4174 IN UINTN StartBit,\r
4175 IN UINTN EndBit,\r
4176 IN UINT16 OrData\r
4177 );\r
4178\r
4179\r
4180/**\r
4181 Reads a bit field from a 16-bit value, performs a bitwise AND, and returns\r
4182 the result.\r
4183\r
4184 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
4185 in Operand and the value specified by AndData. All other bits in Operand are\r
4186 preserved. The new 16-bit value is returned.\r
4187\r
4188 If 16-bit operations are not supported, then ASSERT().\r
4189 If StartBit is greater than 15, then ASSERT().\r
4190 If EndBit is greater than 15, then ASSERT().\r
4191 If EndBit is less than StartBit, then ASSERT().\r
94952554 4192 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4193\r
4194 @param Operand Operand on which to perform the bitfield operation.\r
4195 @param StartBit The ordinal of the least significant bit in the bit field.\r
4196 Range 0..15.\r
4197 @param EndBit The ordinal of the most significant bit in the bit field.\r
4198 Range 0..15.\r
4199 @param AndData The value to AND with the read value from the value\r
4200\r
4201 @return The new 16-bit value.\r
4202\r
4203**/\r
4204UINT16\r
4205EFIAPI\r
4206BitFieldAnd16 (\r
4207 IN UINT16 Operand,\r
4208 IN UINTN StartBit,\r
4209 IN UINTN EndBit,\r
4210 IN UINT16 AndData\r
4211 );\r
4212\r
4213\r
4214/**\r
4215 Reads a bit field from a 16-bit value, performs a bitwise AND followed by a\r
4216 bitwise OR, and returns the result.\r
4217\r
4218 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 4219 in Operand and the value specified by AndData, followed by a bitwise \r
4220 OR with value specified by OrData. All other bits in Operand are\r
ac644614 4221 preserved. The new 16-bit value is returned.\r
4222\r
4223 If 16-bit operations are not supported, then ASSERT().\r
4224 If StartBit is greater than 15, then ASSERT().\r
4225 If EndBit is greater than 15, then ASSERT().\r
4226 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
4227 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
4228 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4229\r
4230 @param Operand Operand on which to perform the bitfield operation.\r
4231 @param StartBit The ordinal of the least significant bit in the bit field.\r
4232 Range 0..15.\r
4233 @param EndBit The ordinal of the most significant bit in the bit field.\r
4234 Range 0..15.\r
4235 @param AndData The value to AND with the read value from the value.\r
4236 @param OrData The value to OR with the result of the AND operation.\r
4237\r
4238 @return The new 16-bit value.\r
4239\r
4240**/\r
4241UINT16\r
4242EFIAPI\r
4243BitFieldAndThenOr16 (\r
4244 IN UINT16 Operand,\r
4245 IN UINTN StartBit,\r
4246 IN UINTN EndBit,\r
4247 IN UINT16 AndData,\r
4248 IN UINT16 OrData\r
4249 );\r
4250\r
4251\r
4252/**\r
4253 Returns a bit field from a 32-bit value.\r
4254\r
4255 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
4256\r
4257 If 32-bit operations are not supported, then ASSERT().\r
4258 If StartBit is greater than 31, then ASSERT().\r
4259 If EndBit is greater than 31, then ASSERT().\r
4260 If EndBit is less than StartBit, then ASSERT().\r
4261\r
4262 @param Operand Operand on which to perform the bitfield operation.\r
4263 @param StartBit The ordinal of the least significant bit in the bit field.\r
4264 Range 0..31.\r
4265 @param EndBit The ordinal of the most significant bit in the bit field.\r
4266 Range 0..31.\r
4267\r
4268 @return The bit field read.\r
4269\r
4270**/\r
4271UINT32\r
4272EFIAPI\r
4273BitFieldRead32 (\r
4274 IN UINT32 Operand,\r
4275 IN UINTN StartBit,\r
4276 IN UINTN EndBit\r
4277 );\r
4278\r
4279\r
4280/**\r
4281 Writes a bit field to a 32-bit value, and returns the result.\r
4282\r
4283 Writes Value to the bit field specified by the StartBit and the EndBit in\r
4284 Operand. All other bits in Operand are preserved. The new 32-bit value is\r
4285 returned.\r
4286\r
4287 If 32-bit operations are not supported, then ASSERT().\r
4288 If StartBit is greater than 31, then ASSERT().\r
4289 If EndBit is greater than 31, then ASSERT().\r
4290 If EndBit is less than StartBit, then ASSERT().\r
94952554 4291 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4292\r
4293 @param Operand Operand on which to perform the bitfield operation.\r
4294 @param StartBit The ordinal of the least significant bit in the bit field.\r
4295 Range 0..31.\r
4296 @param EndBit The ordinal of the most significant bit in the bit field.\r
4297 Range 0..31.\r
4298 @param Value New value of the bit field.\r
4299\r
4300 @return The new 32-bit value.\r
4301\r
4302**/\r
4303UINT32\r
4304EFIAPI\r
4305BitFieldWrite32 (\r
4306 IN UINT32 Operand,\r
4307 IN UINTN StartBit,\r
4308 IN UINTN EndBit,\r
4309 IN UINT32 Value\r
4310 );\r
4311\r
4312\r
4313/**\r
4314 Reads a bit field from a 32-bit value, performs a bitwise OR, and returns the\r
4315 result.\r
4316\r
62991af2 4317 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 4318 and EndBit in Operand and the value specified by OrData. All other bits in\r
4319 Operand are preserved. The new 32-bit value is returned.\r
4320\r
4321 If 32-bit operations are not supported, then ASSERT().\r
4322 If StartBit is greater than 31, then ASSERT().\r
4323 If EndBit is greater than 31, then ASSERT().\r
4324 If EndBit is less than StartBit, then ASSERT().\r
94952554 4325 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4326\r
4327 @param Operand Operand on which to perform the bitfield operation.\r
4328 @param StartBit The ordinal of the least significant bit in the bit field.\r
4329 Range 0..31.\r
4330 @param EndBit The ordinal of the most significant bit in the bit field.\r
4331 Range 0..31.\r
af2dc6a7 4332 @param OrData The value to OR with the read value from the value.\r
ac644614 4333\r
4334 @return The new 32-bit value.\r
4335\r
4336**/\r
4337UINT32\r
4338EFIAPI\r
4339BitFieldOr32 (\r
4340 IN UINT32 Operand,\r
4341 IN UINTN StartBit,\r
4342 IN UINTN EndBit,\r
4343 IN UINT32 OrData\r
4344 );\r
4345\r
4346\r
4347/**\r
4348 Reads a bit field from a 32-bit value, performs a bitwise AND, and returns\r
4349 the result.\r
4350\r
4351 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
4352 in Operand and the value specified by AndData. All other bits in Operand are\r
4353 preserved. The new 32-bit value is returned.\r
4354\r
4355 If 32-bit operations are not supported, then ASSERT().\r
4356 If StartBit is greater than 31, then ASSERT().\r
4357 If EndBit is greater than 31, then ASSERT().\r
4358 If EndBit is less than StartBit, then ASSERT().\r
94952554 4359 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4360\r
4361 @param Operand Operand on which to perform the bitfield operation.\r
4362 @param StartBit The ordinal of the least significant bit in the bit field.\r
4363 Range 0..31.\r
4364 @param EndBit The ordinal of the most significant bit in the bit field.\r
4365 Range 0..31.\r
4366 @param AndData The value to AND with the read value from the value\r
4367\r
4368 @return The new 32-bit value.\r
4369\r
4370**/\r
4371UINT32\r
4372EFIAPI\r
4373BitFieldAnd32 (\r
4374 IN UINT32 Operand,\r
4375 IN UINTN StartBit,\r
4376 IN UINTN EndBit,\r
4377 IN UINT32 AndData\r
4378 );\r
4379\r
4380\r
4381/**\r
4382 Reads a bit field from a 32-bit value, performs a bitwise AND followed by a\r
4383 bitwise OR, and returns the result.\r
4384\r
4385 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 4386 in Operand and the value specified by AndData, followed by a bitwise \r
4387 OR with value specified by OrData. All other bits in Operand are\r
ac644614 4388 preserved. The new 32-bit value is returned.\r
4389\r
4390 If 32-bit operations are not supported, then ASSERT().\r
4391 If StartBit is greater than 31, then ASSERT().\r
4392 If EndBit is greater than 31, then ASSERT().\r
4393 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
4394 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
4395 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4396\r
4397 @param Operand Operand on which to perform the bitfield operation.\r
4398 @param StartBit The ordinal of the least significant bit in the bit field.\r
4399 Range 0..31.\r
4400 @param EndBit The ordinal of the most significant bit in the bit field.\r
4401 Range 0..31.\r
4402 @param AndData The value to AND with the read value from the value.\r
4403 @param OrData The value to OR with the result of the AND operation.\r
4404\r
4405 @return The new 32-bit value.\r
4406\r
4407**/\r
4408UINT32\r
4409EFIAPI\r
4410BitFieldAndThenOr32 (\r
4411 IN UINT32 Operand,\r
4412 IN UINTN StartBit,\r
4413 IN UINTN EndBit,\r
4414 IN UINT32 AndData,\r
4415 IN UINT32 OrData\r
4416 );\r
4417\r
4418\r
4419/**\r
4420 Returns a bit field from a 64-bit value.\r
4421\r
4422 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
4423\r
4424 If 64-bit operations are not supported, then ASSERT().\r
4425 If StartBit is greater than 63, then ASSERT().\r
4426 If EndBit is greater than 63, then ASSERT().\r
4427 If EndBit is less than StartBit, then ASSERT().\r
4428\r
4429 @param Operand Operand on which to perform the bitfield operation.\r
4430 @param StartBit The ordinal of the least significant bit in the bit field.\r
4431 Range 0..63.\r
4432 @param EndBit The ordinal of the most significant bit in the bit field.\r
4433 Range 0..63.\r
4434\r
4435 @return The bit field read.\r
4436\r
4437**/\r
4438UINT64\r
4439EFIAPI\r
4440BitFieldRead64 (\r
4441 IN UINT64 Operand,\r
4442 IN UINTN StartBit,\r
4443 IN UINTN EndBit\r
4444 );\r
4445\r
4446\r
4447/**\r
4448 Writes a bit field to a 64-bit value, and returns the result.\r
4449\r
4450 Writes Value to the bit field specified by the StartBit and the EndBit in\r
4451 Operand. All other bits in Operand are preserved. The new 64-bit value is\r
4452 returned.\r
4453\r
4454 If 64-bit operations are not supported, then ASSERT().\r
4455 If StartBit is greater than 63, then ASSERT().\r
4456 If EndBit is greater than 63, then ASSERT().\r
4457 If EndBit is less than StartBit, then ASSERT().\r
94952554 4458 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4459\r
4460 @param Operand Operand on which to perform the bitfield operation.\r
4461 @param StartBit The ordinal of the least significant bit in the bit field.\r
4462 Range 0..63.\r
4463 @param EndBit The ordinal of the most significant bit in the bit field.\r
4464 Range 0..63.\r
4465 @param Value New value of the bit field.\r
4466\r
4467 @return The new 64-bit value.\r
4468\r
4469**/\r
4470UINT64\r
4471EFIAPI\r
4472BitFieldWrite64 (\r
4473 IN UINT64 Operand,\r
4474 IN UINTN StartBit,\r
4475 IN UINTN EndBit,\r
4476 IN UINT64 Value\r
4477 );\r
4478\r
4479\r
4480/**\r
4481 Reads a bit field from a 64-bit value, performs a bitwise OR, and returns the\r
4482 result.\r
4483\r
62991af2 4484 Performs a bitwise OR between the bit field specified by StartBit\r
ac644614 4485 and EndBit in Operand and the value specified by OrData. All other bits in\r
4486 Operand are preserved. The new 64-bit value is returned.\r
4487\r
4488 If 64-bit operations are not supported, then ASSERT().\r
4489 If StartBit is greater than 63, then ASSERT().\r
4490 If EndBit is greater than 63, then ASSERT().\r
4491 If EndBit is less than StartBit, then ASSERT().\r
94952554 4492 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4493\r
4494 @param Operand Operand on which to perform the bitfield operation.\r
4495 @param StartBit The ordinal of the least significant bit in the bit field.\r
4496 Range 0..63.\r
4497 @param EndBit The ordinal of the most significant bit in the bit field.\r
4498 Range 0..63.\r
4499 @param OrData The value to OR with the read value from the value\r
4500\r
4501 @return The new 64-bit value.\r
4502\r
4503**/\r
4504UINT64\r
4505EFIAPI\r
4506BitFieldOr64 (\r
4507 IN UINT64 Operand,\r
4508 IN UINTN StartBit,\r
4509 IN UINTN EndBit,\r
4510 IN UINT64 OrData\r
4511 );\r
4512\r
4513\r
4514/**\r
4515 Reads a bit field from a 64-bit value, performs a bitwise AND, and returns\r
4516 the result.\r
4517\r
4518 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
4519 in Operand and the value specified by AndData. All other bits in Operand are\r
4520 preserved. The new 64-bit value is returned.\r
4521\r
4522 If 64-bit operations are not supported, then ASSERT().\r
4523 If StartBit is greater than 63, then ASSERT().\r
4524 If EndBit is greater than 63, then ASSERT().\r
4525 If EndBit is less than StartBit, then ASSERT().\r
94952554 4526 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4527\r
4528 @param Operand Operand on which to perform the bitfield operation.\r
4529 @param StartBit The ordinal of the least significant bit in the bit field.\r
4530 Range 0..63.\r
4531 @param EndBit The ordinal of the most significant bit in the bit field.\r
4532 Range 0..63.\r
4533 @param AndData The value to AND with the read value from the value\r
4534\r
4535 @return The new 64-bit value.\r
4536\r
4537**/\r
4538UINT64\r
4539EFIAPI\r
4540BitFieldAnd64 (\r
4541 IN UINT64 Operand,\r
4542 IN UINTN StartBit,\r
4543 IN UINTN EndBit,\r
4544 IN UINT64 AndData\r
4545 );\r
4546\r
4547\r
4548/**\r
4549 Reads a bit field from a 64-bit value, performs a bitwise AND followed by a\r
4550 bitwise OR, and returns the result.\r
4551\r
4552 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
62991af2 4553 in Operand and the value specified by AndData, followed by a bitwise \r
4554 OR with value specified by OrData. All other bits in Operand are\r
ac644614 4555 preserved. The new 64-bit value is returned.\r
4556\r
4557 If 64-bit operations are not supported, then ASSERT().\r
4558 If StartBit is greater than 63, then ASSERT().\r
4559 If EndBit is greater than 63, then ASSERT().\r
4560 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
4561 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
4562 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 4563\r
4564 @param Operand Operand on which to perform the bitfield operation.\r
4565 @param StartBit The ordinal of the least significant bit in the bit field.\r
4566 Range 0..63.\r
4567 @param EndBit The ordinal of the most significant bit in the bit field.\r
4568 Range 0..63.\r
4569 @param AndData The value to AND with the read value from the value.\r
4570 @param OrData The value to OR with the result of the AND operation.\r
4571\r
4572 @return The new 64-bit value.\r
4573\r
4574**/\r
4575UINT64\r
4576EFIAPI\r
4577BitFieldAndThenOr64 (\r
4578 IN UINT64 Operand,\r
4579 IN UINTN StartBit,\r
4580 IN UINTN EndBit,\r
4581 IN UINT64 AndData,\r
4582 IN UINT64 OrData\r
4583 );\r
4584\r
ac644614 4585//\r
4586// Base Library Checksum Functions\r
4587//\r
4588\r
4589/**\r
17f695ed 4590 Returns the sum of all elements in a buffer in unit of UINT8.\r
ac644614 4591 During calculation, the carry bits are dropped.\r
4592\r
4593 This function calculates the sum of all elements in a buffer\r
4594 in unit of UINT8. The carry bits in result of addition are dropped.\r
4595 The result is returned as UINT8. If Length is Zero, then Zero is\r
4596 returned.\r
4597\r
4598 If Buffer is NULL, then ASSERT().\r
4599 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4600\r
af2dc6a7 4601 @param Buffer The pointer to the buffer to carry out the sum operation.\r
17f695ed 4602 @param Length The size, in bytes, of Buffer.\r
ac644614 4603\r
4604 @return Sum The sum of Buffer with carry bits dropped during additions.\r
4605\r
4606**/\r
4607UINT8\r
4608EFIAPI\r
4609CalculateSum8 (\r
ee6c452c 4610 IN CONST UINT8 *Buffer,\r
4611 IN UINTN Length\r
ac644614 4612 );\r
4613\r
4614\r
4615/**\r
4616 Returns the two's complement checksum of all elements in a buffer\r
4617 of 8-bit values.\r
4618\r
4619 This function first calculates the sum of the 8-bit values in the\r
4620 buffer specified by Buffer and Length. The carry bits in the result\r
4621 of addition are dropped. Then, the two's complement of the sum is\r
4622 returned. If Length is 0, then 0 is returned.\r
4623\r
4624 If Buffer is NULL, then ASSERT().\r
4625 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4626\r
af2dc6a7 4627 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 4628 @param Length The size, in bytes, of Buffer.\r
ac644614 4629\r
af2dc6a7 4630 @return Checksum The two's complement checksum of Buffer.\r
ac644614 4631\r
4632**/\r
4633UINT8\r
4634EFIAPI\r
4635CalculateCheckSum8 (\r
ee6c452c 4636 IN CONST UINT8 *Buffer,\r
4637 IN UINTN Length\r
ac644614 4638 );\r
4639\r
4640\r
4641/**\r
4642 Returns the sum of all elements in a buffer of 16-bit values. During\r
4643 calculation, the carry bits are dropped.\r
4644\r
4645 This function calculates the sum of the 16-bit values in the buffer\r
4646 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
4647 The 16-bit result is returned. If Length is 0, then 0 is returned.\r
4648\r
4649 If Buffer is NULL, then ASSERT().\r
4650 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
4651 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
4652 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4653\r
af2dc6a7 4654 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 4655 @param Length The size, in bytes, of Buffer.\r
ac644614 4656\r
4657 @return Sum The sum of Buffer with carry bits dropped during additions.\r
4658\r
4659**/\r
4660UINT16\r
4661EFIAPI\r
4662CalculateSum16 (\r
ee6c452c 4663 IN CONST UINT16 *Buffer,\r
4664 IN UINTN Length\r
ac644614 4665 );\r
4666\r
4667\r
4668/**\r
4669 Returns the two's complement checksum of all elements in a buffer of\r
4670 16-bit values.\r
4671\r
4672 This function first calculates the sum of the 16-bit values in the buffer\r
4673 specified by Buffer and Length. The carry bits in the result of addition\r
4674 are dropped. Then, the two's complement of the sum is returned. If Length\r
4675 is 0, then 0 is returned.\r
4676\r
4677 If Buffer is NULL, then ASSERT().\r
4678 If Buffer is not aligned on a 16-bit boundary, then ASSERT().\r
4679 If Length is not aligned on a 16-bit boundary, then ASSERT().\r
4680 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4681\r
af2dc6a7 4682 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 4683 @param Length The size, in bytes, of Buffer.\r
ac644614 4684\r
af2dc6a7 4685 @return Checksum The two's complement checksum of Buffer.\r
ac644614 4686\r
4687**/\r
4688UINT16\r
4689EFIAPI\r
4690CalculateCheckSum16 (\r
ee6c452c 4691 IN CONST UINT16 *Buffer,\r
4692 IN UINTN Length\r
ac644614 4693 );\r
4694\r
4695\r
4696/**\r
17f695ed 4697 Returns the sum of all elements in a buffer of 32-bit values. During\r
ac644614 4698 calculation, the carry bits are dropped.\r
4699\r
4700 This function calculates the sum of the 32-bit values in the buffer\r
4701 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
17f695ed 4702 The 32-bit result is returned. If Length is 0, then 0 is returned.\r
ac644614 4703\r
4704 If Buffer is NULL, then ASSERT().\r
4705 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
4706 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
4707 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4708\r
af2dc6a7 4709 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 4710 @param Length The size, in bytes, of Buffer.\r
ac644614 4711\r
4712 @return Sum The sum of Buffer with carry bits dropped during additions.\r
4713\r
4714**/\r
4715UINT32\r
4716EFIAPI\r
4717CalculateSum32 (\r
ee6c452c 4718 IN CONST UINT32 *Buffer,\r
4719 IN UINTN Length\r
ac644614 4720 );\r
4721\r
4722\r
4723/**\r
4724 Returns the two's complement checksum of all elements in a buffer of\r
4725 32-bit values.\r
4726\r
4727 This function first calculates the sum of the 32-bit values in the buffer\r
4728 specified by Buffer and Length. The carry bits in the result of addition\r
4729 are dropped. Then, the two's complement of the sum is returned. If Length\r
4730 is 0, then 0 is returned.\r
4731\r
4732 If Buffer is NULL, then ASSERT().\r
4733 If Buffer is not aligned on a 32-bit boundary, then ASSERT().\r
4734 If Length is not aligned on a 32-bit boundary, then ASSERT().\r
4735 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4736\r
af2dc6a7 4737 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 4738 @param Length The size, in bytes, of Buffer.\r
ac644614 4739\r
af2dc6a7 4740 @return Checksum The two's complement checksum of Buffer.\r
ac644614 4741\r
4742**/\r
4743UINT32\r
4744EFIAPI\r
4745CalculateCheckSum32 (\r
ee6c452c 4746 IN CONST UINT32 *Buffer,\r
4747 IN UINTN Length\r
ac644614 4748 );\r
4749\r
4750\r
4751/**\r
4752 Returns the sum of all elements in a buffer of 64-bit values. During\r
4753 calculation, the carry bits are dropped.\r
4754\r
4755 This function calculates the sum of the 64-bit values in the buffer\r
4756 specified by Buffer and Length. The carry bits in result of addition are dropped.\r
4757 The 64-bit result is returned. If Length is 0, then 0 is returned.\r
4758\r
4759 If Buffer is NULL, then ASSERT().\r
4760 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
4761 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
4762 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4763\r
af2dc6a7 4764 @param Buffer The pointer to the buffer to carry out the sum operation.\r
1106ffe1 4765 @param Length The size, in bytes, of Buffer.\r
ac644614 4766\r
4767 @return Sum The sum of Buffer with carry bits dropped during additions.\r
4768\r
4769**/\r
4770UINT64\r
4771EFIAPI\r
4772CalculateSum64 (\r
ee6c452c 4773 IN CONST UINT64 *Buffer,\r
4774 IN UINTN Length\r
ac644614 4775 );\r
4776\r
4777\r
4778/**\r
4779 Returns the two's complement checksum of all elements in a buffer of\r
4780 64-bit values.\r
4781\r
4782 This function first calculates the sum of the 64-bit values in the buffer\r
4783 specified by Buffer and Length. The carry bits in the result of addition\r
4784 are dropped. Then, the two's complement of the sum is returned. If Length\r
4785 is 0, then 0 is returned.\r
4786\r
4787 If Buffer is NULL, then ASSERT().\r
4788 If Buffer is not aligned on a 64-bit boundary, then ASSERT().\r
4789 If Length is not aligned on a 64-bit boundary, then ASSERT().\r
4790 If Length is greater than (MAX_ADDRESS - Buffer + 1), then ASSERT().\r
4791\r
af2dc6a7 4792 @param Buffer The pointer to the buffer to carry out the checksum operation.\r
1106ffe1 4793 @param Length The size, in bytes, of Buffer.\r
ac644614 4794\r
af2dc6a7 4795 @return Checksum The two's complement checksum of Buffer.\r
ac644614 4796\r
4797**/\r
4798UINT64\r
4799EFIAPI\r
4800CalculateCheckSum64 (\r
ee6c452c 4801 IN CONST UINT64 *Buffer,\r
4802 IN UINTN Length\r
ac644614 4803 );\r
4804\r
4805\r
d75f9fc2 4806//\r
4807// Base Library CPU Functions\r
4808//\r
4809\r
4810/**\r
4811 Function entry point used when a stack switch is requested with SwitchStack()\r
4812\r
4813 @param Context1 Context1 parameter passed into SwitchStack().\r
4814 @param Context2 Context2 parameter passed into SwitchStack().\r
4815\r
4816**/\r
ac644614 4817typedef\r
4818VOID\r
9810cdd8 4819(EFIAPI *SWITCH_STACK_ENTRY_POINT)(\r
ac644614 4820 IN VOID *Context1, OPTIONAL\r
4821 IN VOID *Context2 OPTIONAL\r
4822 );\r
4823\r
4824\r
4825/**\r
4826 Used to serialize load and store operations.\r
4827\r
4828 All loads and stores that proceed calls to this function are guaranteed to be\r
4829 globally visible when this function returns.\r
4830\r
4831**/\r
4832VOID\r
4833EFIAPI\r
4834MemoryFence (\r
4835 VOID\r
4836 );\r
4837\r
4838\r
4839/**\r
4840 Saves the current CPU context that can be restored with a call to LongJump()\r
4841 and returns 0.\r
4842\r
4843 Saves the current CPU context in the buffer specified by JumpBuffer and\r
4844 returns 0. The initial call to SetJump() must always return 0. Subsequent\r
4845 calls to LongJump() cause a non-zero value to be returned by SetJump().\r
4846\r
4847 If JumpBuffer is NULL, then ASSERT().\r
1a2f870c 4848 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
17f695ed 4849 \r
4850 NOTE: The structure BASE_LIBRARY_JUMP_BUFFER is CPU architecture specific.\r
4851 The same structure must never be used for more than one CPU architecture context.\r
4852 For example, a BASE_LIBRARY_JUMP_BUFFER allocated by an IA-32 module must never be used from an x64 module. \r
4853 SetJump()/LongJump() is not currently supported for the EBC processor type. \r
ac644614 4854\r
4855 @param JumpBuffer A pointer to CPU context buffer.\r
4856\r
4857 @retval 0 Indicates a return from SetJump().\r
4858\r
4859**/\r
4860UINTN\r
4861EFIAPI\r
4862SetJump (\r
4863 OUT BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
4864 );\r
4865\r
4866\r
4867/**\r
4868 Restores the CPU context that was saved with SetJump().\r
4869\r
4870 Restores the CPU context from the buffer specified by JumpBuffer. This\r
4871 function never returns to the caller. Instead is resumes execution based on\r
4872 the state of JumpBuffer.\r
4873\r
4874 If JumpBuffer is NULL, then ASSERT().\r
1a2f870c 4875 For Itanium processors, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
ac644614 4876 If Value is 0, then ASSERT().\r
4877\r
4878 @param JumpBuffer A pointer to CPU context buffer.\r
4879 @param Value The value to return when the SetJump() context is\r
4880 restored and must be non-zero.\r
4881\r
4882**/\r
4883VOID\r
4884EFIAPI\r
4885LongJump (\r
4886 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
4887 IN UINTN Value\r
4888 );\r
4889\r
4890\r
4891/**\r
4892 Enables CPU interrupts.\r
4893\r
ac644614 4894**/\r
4895VOID\r
4896EFIAPI\r
4897EnableInterrupts (\r
4898 VOID\r
4899 );\r
4900\r
4901\r
4902/**\r
4903 Disables CPU interrupts.\r
4904\r
ac644614 4905**/\r
4906VOID\r
4907EFIAPI\r
4908DisableInterrupts (\r
4909 VOID\r
4910 );\r
4911\r
4912\r
4913/**\r
4914 Disables CPU interrupts and returns the interrupt state prior to the disable\r
4915 operation.\r
4916\r
ac644614 4917 @retval TRUE CPU interrupts were enabled on entry to this call.\r
4918 @retval FALSE CPU interrupts were disabled on entry to this call.\r
4919\r
4920**/\r
4921BOOLEAN\r
4922EFIAPI\r
4923SaveAndDisableInterrupts (\r
4924 VOID\r
4925 );\r
4926\r
4927\r
4928/**\r
4929 Enables CPU interrupts for the smallest window required to capture any\r
4930 pending interrupts.\r
4931\r
ac644614 4932**/\r
4933VOID\r
4934EFIAPI\r
4935EnableDisableInterrupts (\r
4936 VOID\r
4937 );\r
4938\r
4939\r
4940/**\r
4941 Retrieves the current CPU interrupt state.\r
4942\r
af2dc6a7 4943 Returns TRUE if interrupts are currently enabled. Otherwise\r
38bbd3d9 4944 returns FALSE.\r
ac644614 4945\r
4946 @retval TRUE CPU interrupts are enabled.\r
4947 @retval FALSE CPU interrupts are disabled.\r
4948\r
4949**/\r
4950BOOLEAN\r
4951EFIAPI\r
4952GetInterruptState (\r
4953 VOID\r
4954 );\r
4955\r
4956\r
4957/**\r
4958 Set the current CPU interrupt state.\r
4959\r
4960 Sets the current CPU interrupt state to the state specified by\r
4961 InterruptState. If InterruptState is TRUE, then interrupts are enabled. If\r
4962 InterruptState is FALSE, then interrupts are disabled. InterruptState is\r
4963 returned.\r
4964\r
4965 @param InterruptState TRUE if interrupts should enabled. FALSE if\r
4966 interrupts should be disabled.\r
4967\r
4968 @return InterruptState\r
4969\r
4970**/\r
4971BOOLEAN\r
4972EFIAPI\r
4973SetInterruptState (\r
4974 IN BOOLEAN InterruptState\r
4975 );\r
4976\r
4977\r
4978/**\r
4979 Requests CPU to pause for a short period of time.\r
4980\r
4981 Requests CPU to pause for a short period of time. Typically used in MP\r
4982 systems to prevent memory starvation while waiting for a spin lock.\r
4983\r
4984**/\r
4985VOID\r
4986EFIAPI\r
4987CpuPause (\r
4988 VOID\r
4989 );\r
4990\r
4991\r
4992/**\r
4993 Transfers control to a function starting with a new stack.\r
4994\r
4995 Transfers control to the function specified by EntryPoint using the\r
4996 new stack specified by NewStack and passing in the parameters specified\r
4997 by Context1 and Context2. Context1 and Context2 are optional and may\r
4998 be NULL. The function EntryPoint must never return. This function\r
4999 supports a variable number of arguments following the NewStack parameter.\r
1a2f870c 5000 These additional arguments are ignored on IA-32, x64, and EBC architectures.\r
5001 Itanium processors expect one additional parameter of type VOID * that specifies\r
ac644614 5002 the new backing store pointer.\r
5003\r
5004 If EntryPoint is NULL, then ASSERT().\r
5005 If NewStack is NULL, then ASSERT().\r
5006\r
5007 @param EntryPoint A pointer to function to call with the new stack.\r
5008 @param Context1 A pointer to the context to pass into the EntryPoint\r
5009 function.\r
5010 @param Context2 A pointer to the context to pass into the EntryPoint\r
5011 function.\r
5012 @param NewStack A pointer to the new stack to use for the EntryPoint\r
5013 function.\r
af2dc6a7 5014 @param ... This variable argument list is ignored for IA-32, x64, and \r
5015 EBC architectures. For Itanium processors, this variable \r
5016 argument list is expected to contain a single parameter of \r
5017 type VOID * that specifies the new backing store pointer.\r
42eedea9 5018\r
ac644614 5019\r
5020**/\r
5021VOID\r
5022EFIAPI\r
5023SwitchStack (\r
5024 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
5025 IN VOID *Context1, OPTIONAL\r
5026 IN VOID *Context2, OPTIONAL\r
5027 IN VOID *NewStack,\r
5028 ...\r
5029 );\r
5030\r
5031\r
5032/**\r
5033 Generates a breakpoint on the CPU.\r
5034\r
5035 Generates a breakpoint on the CPU. The breakpoint must be implemented such\r
5036 that code can resume normal execution after the breakpoint.\r
5037\r
5038**/\r
5039VOID\r
5040EFIAPI\r
5041CpuBreakpoint (\r
5042 VOID\r
5043 );\r
5044\r
5045\r
5046/**\r
5047 Executes an infinite loop.\r
5048\r
5049 Forces the CPU to execute an infinite loop. A debugger may be used to skip\r
5050 past the loop and the code that follows the loop must execute properly. This\r
5051 implies that the infinite loop must not cause the code that follow it to be\r
5052 optimized away.\r
5053\r
5054**/\r
5055VOID\r
5056EFIAPI\r
5057CpuDeadLoop (\r
5058 VOID\r
5059 );\r
2fe241a2 5060 \r
ac644614 5061#if defined (MDE_CPU_IPF)\r
5062\r
5063/**\r
5064 Flush a range of cache lines in the cache coherency domain of the calling\r
5065 CPU.\r
5066\r
cc39b88b 5067 Flushes the cache lines specified by Address and Length. If Address is not aligned \r
5068 on a cache line boundary, then entire cache line containing Address is flushed. \r
5069 If Address + Length is not aligned on a cache line boundary, then the entire cache \r
5070 line containing Address + Length - 1 is flushed. This function may choose to flush \r
5071 the entire cache if that is more efficient than flushing the specified range. If \r
5072 Length is 0, the no cache lines are flushed. Address is returned. \r
1a2f870c 5073 This function is only available on Itanium processors.\r
ac644614 5074\r
5075 If Length is greater than (MAX_ADDRESS - Address + 1), then ASSERT().\r
5076\r
5077 @param Address The base address of the instruction lines to invalidate. If\r
5078 the CPU is in a physical addressing mode, then Address is a\r
5079 physical address. If the CPU is in a virtual addressing mode,\r
5080 then Address is a virtual address.\r
5081\r
5082 @param Length The number of bytes to invalidate from the instruction cache.\r
5083\r
cc39b88b 5084 @return Address.\r
ac644614 5085\r
5086**/\r
5087VOID *\r
5088EFIAPI\r
cc39b88b 5089AsmFlushCacheRange (\r
ac644614 5090 IN VOID *Address,\r
5091 IN UINTN Length\r
5092 );\r
5093\r
5094\r
5095/**\r
af2dc6a7 5096 Executes an FC instruction.\r
5097 Executes an FC instruction on the cache line specified by Address.\r
ac644614 5098 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
1a2f870c 5099 An implementation may flush a larger region. This function is only available on Itanium processors.\r
ac644614 5100\r
ee6c452c 5101 @param Address The Address of cache line to be flushed.\r
ac644614 5102\r
5103 @return The address of FC instruction executed.\r
5104\r
5105**/\r
5106UINT64\r
5107EFIAPI\r
5108AsmFc (\r
5109 IN UINT64 Address\r
5110 );\r
5111\r
5112\r
5113/**\r
af2dc6a7 5114 Executes an FC.I instruction.\r
5115 Executes an FC.I instruction on the cache line specified by Address.\r
ac644614 5116 The cache line size affected is at least 32-bytes (aligned on a 32-byte boundary).\r
1a2f870c 5117 An implementation may flush a larger region. This function is only available on Itanium processors.\r
ac644614 5118\r
ee6c452c 5119 @param Address The Address of cache line to be flushed.\r
ac644614 5120\r
af2dc6a7 5121 @return The address of the FC.I instruction executed.\r
ac644614 5122\r
5123**/\r
5124UINT64\r
5125EFIAPI\r
5126AsmFci (\r
5127 IN UINT64 Address\r
5128 );\r
5129\r
5130\r
5131/**\r
5132 Reads the current value of a Processor Identifier Register (CPUID).\r
17f695ed 5133 \r
5134 Reads and returns the current value of Processor Identifier Register specified by Index. \r
ac644614 5135 The Index of largest implemented CPUID (One less than the number of implemented CPUID\r
5136 registers) is determined by CPUID [3] bits {7:0}.\r
5137 No parameter checking is performed on Index. If the Index value is beyond the\r
5138 implemented CPUID register range, a Reserved Register/Field fault may occur. The caller\r
5139 must either guarantee that Index is valid, or the caller must set up fault handlers to\r
1a2f870c 5140 catch the faults. This function is only available on Itanium processors.\r
ac644614 5141\r
ee6c452c 5142 @param Index The 8-bit Processor Identifier Register index to read.\r
ac644614 5143\r
5144 @return The current value of Processor Identifier Register specified by Index.\r
5145\r
5146**/\r
5147UINT64\r
5148EFIAPI\r
5149AsmReadCpuid (\r
5150 IN UINT8 Index\r
5151 );\r
5152\r
5153\r
5154/**\r
5155 Reads the current value of 64-bit Processor Status Register (PSR).\r
1a2f870c 5156 This function is only available on Itanium processors.\r
ac644614 5157\r
5158 @return The current value of PSR.\r
5159\r
5160**/\r
5161UINT64\r
5162EFIAPI\r
5163AsmReadPsr (\r
5164 VOID\r
5165 );\r
5166\r
5167\r
5168/**\r
5169 Writes the current value of 64-bit Processor Status Register (PSR).\r
22388319 5170\r
ac644614 5171 No parameter checking is performed on Value. All bits of Value corresponding to\r
22388319 5172 reserved fields of PSR must be 0 or a Reserved Register/Field fault may occur.\r
5173 The caller must either guarantee that Value is valid, or the caller must set up\r
1a2f870c 5174 fault handlers to catch the faults. This function is only available on Itanium processors.\r
ac644614 5175\r
ee6c452c 5176 @param Value The 64-bit value to write to PSR.\r
ac644614 5177\r
5178 @return The 64-bit value written to the PSR.\r
5179\r
5180**/\r
5181UINT64\r
5182EFIAPI\r
5183AsmWritePsr (\r
5184 IN UINT64 Value\r
5185 );\r
5186\r
5187\r
5188/**\r
5189 Reads the current value of 64-bit Kernel Register #0 (KR0).\r
2fe241a2 5190 \r
5191 Reads and returns the current value of KR0. \r
1a2f870c 5192 This function is only available on Itanium processors.\r
ac644614 5193\r
5194 @return The current value of KR0.\r
5195\r
5196**/\r
5197UINT64\r
5198EFIAPI\r
5199AsmReadKr0 (\r
5200 VOID\r
5201 );\r
5202\r
5203\r
5204/**\r
5205 Reads the current value of 64-bit Kernel Register #1 (KR1).\r
2fe241a2 5206\r
5207 Reads and returns the current value of KR1. \r
1a2f870c 5208 This function is only available on Itanium processors.\r
ac644614 5209\r
5210 @return The current value of KR1.\r
5211\r
5212**/\r
5213UINT64\r
5214EFIAPI\r
5215AsmReadKr1 (\r
5216 VOID\r
5217 );\r
5218\r
5219\r
5220/**\r
5221 Reads the current value of 64-bit Kernel Register #2 (KR2).\r
2fe241a2 5222\r
5223 Reads and returns the current value of KR2. \r
1a2f870c 5224 This function is only available on Itanium processors.\r
ac644614 5225\r
5226 @return The current value of KR2.\r
5227\r
5228**/\r
5229UINT64\r
5230EFIAPI\r
5231AsmReadKr2 (\r
5232 VOID\r
5233 );\r
5234\r
5235\r
5236/**\r
5237 Reads the current value of 64-bit Kernel Register #3 (KR3).\r
2fe241a2 5238\r
5239 Reads and returns the current value of KR3. \r
1a2f870c 5240 This function is only available on Itanium processors.\r
ac644614 5241\r
5242 @return The current value of KR3.\r
5243\r
5244**/\r
5245UINT64\r
5246EFIAPI\r
5247AsmReadKr3 (\r
5248 VOID\r
5249 );\r
5250\r
5251\r
5252/**\r
5253 Reads the current value of 64-bit Kernel Register #4 (KR4).\r
ac644614 5254\r
2fe241a2 5255 Reads and returns the current value of KR4. \r
1a2f870c 5256 This function is only available on Itanium processors.\r
2fe241a2 5257 \r
ac644614 5258 @return The current value of KR4.\r
5259\r
5260**/\r
5261UINT64\r
5262EFIAPI\r
5263AsmReadKr4 (\r
5264 VOID\r
5265 );\r
5266\r
5267\r
5268/**\r
5269 Reads the current value of 64-bit Kernel Register #5 (KR5).\r
2fe241a2 5270\r
5271 Reads and returns the current value of KR5. \r
1a2f870c 5272 This function is only available on Itanium processors.\r
ac644614 5273\r
5274 @return The current value of KR5.\r
5275\r
5276**/\r
5277UINT64\r
5278EFIAPI\r
5279AsmReadKr5 (\r
5280 VOID\r
5281 );\r
5282\r
5283\r
5284/**\r
5285 Reads the current value of 64-bit Kernel Register #6 (KR6).\r
2fe241a2 5286\r
5287 Reads and returns the current value of KR6. \r
1a2f870c 5288 This function is only available on Itanium processors.\r
ac644614 5289\r
5290 @return The current value of KR6.\r
5291\r
5292**/\r
5293UINT64\r
5294EFIAPI\r
5295AsmReadKr6 (\r
5296 VOID\r
5297 );\r
5298\r
5299\r
5300/**\r
5301 Reads the current value of 64-bit Kernel Register #7 (KR7).\r
2fe241a2 5302\r
5303 Reads and returns the current value of KR7. \r
1a2f870c 5304 This function is only available on Itanium processors.\r
ac644614 5305\r
5306 @return The current value of KR7.\r
5307\r
5308**/\r
5309UINT64\r
5310EFIAPI\r
5311AsmReadKr7 (\r
5312 VOID\r
5313 );\r
5314\r
5315\r
5316/**\r
5317 Write the current value of 64-bit Kernel Register #0 (KR0).\r
2fe241a2 5318 \r
5319 Writes the current value of KR0. The 64-bit value written to \r
1a2f870c 5320 the KR0 is returned. This function is only available on Itanium processors.\r
ac644614 5321\r
ee6c452c 5322 @param Value The 64-bit value to write to KR0.\r
ac644614 5323\r
5324 @return The 64-bit value written to the KR0.\r
5325\r
5326**/\r
5327UINT64\r
5328EFIAPI\r
5329AsmWriteKr0 (\r
5330 IN UINT64 Value\r
5331 );\r
5332\r
5333\r
5334/**\r
5335 Write the current value of 64-bit Kernel Register #1 (KR1).\r
2fe241a2 5336\r
5337 Writes the current value of KR1. The 64-bit value written to \r
1a2f870c 5338 the KR1 is returned. This function is only available on Itanium processors.\r
ac644614 5339\r
ee6c452c 5340 @param Value The 64-bit value to write to KR1.\r
ac644614 5341\r
5342 @return The 64-bit value written to the KR1.\r
5343\r
5344**/\r
5345UINT64\r
5346EFIAPI\r
5347AsmWriteKr1 (\r
5348 IN UINT64 Value\r
5349 );\r
5350\r
5351\r
5352/**\r
5353 Write the current value of 64-bit Kernel Register #2 (KR2).\r
2fe241a2 5354\r
5355 Writes the current value of KR2. The 64-bit value written to \r
1a2f870c 5356 the KR2 is returned. This function is only available on Itanium processors.\r
ac644614 5357\r
ee6c452c 5358 @param Value The 64-bit value to write to KR2.\r
ac644614 5359\r
5360 @return The 64-bit value written to the KR2.\r
5361\r
5362**/\r
5363UINT64\r
5364EFIAPI\r
5365AsmWriteKr2 (\r
5366 IN UINT64 Value\r
5367 );\r
5368\r
5369\r
5370/**\r
5371 Write the current value of 64-bit Kernel Register #3 (KR3).\r
2fe241a2 5372\r
5373 Writes the current value of KR3. The 64-bit value written to \r
1a2f870c 5374 the KR3 is returned. This function is only available on Itanium processors.\r
ac644614 5375\r
ee6c452c 5376 @param Value The 64-bit value to write to KR3.\r
ac644614 5377\r
5378 @return The 64-bit value written to the KR3.\r
5379\r
5380**/\r
5381UINT64\r
5382EFIAPI\r
5383AsmWriteKr3 (\r
5384 IN UINT64 Value\r
5385 );\r
5386\r
5387\r
5388/**\r
5389 Write the current value of 64-bit Kernel Register #4 (KR4).\r
2fe241a2 5390\r
5391 Writes the current value of KR4. The 64-bit value written to \r
1a2f870c 5392 the KR4 is returned. This function is only available on Itanium processors.\r
ac644614 5393\r
ee6c452c 5394 @param Value The 64-bit value to write to KR4.\r
ac644614 5395\r
5396 @return The 64-bit value written to the KR4.\r
5397\r
5398**/\r
5399UINT64\r
5400EFIAPI\r
5401AsmWriteKr4 (\r
5402 IN UINT64 Value\r
5403 );\r
5404\r
5405\r
5406/**\r
5407 Write the current value of 64-bit Kernel Register #5 (KR5).\r
2fe241a2 5408\r
5409 Writes the current value of KR5. The 64-bit value written to \r
1a2f870c 5410 the KR5 is returned. This function is only available on Itanium processors.\r
ac644614 5411\r
ee6c452c 5412 @param Value The 64-bit value to write to KR5.\r
ac644614 5413\r
5414 @return The 64-bit value written to the KR5.\r
5415\r
5416**/\r
5417UINT64\r
5418EFIAPI\r
5419AsmWriteKr5 (\r
5420 IN UINT64 Value\r
5421 );\r
5422\r
5423\r
5424/**\r
5425 Write the current value of 64-bit Kernel Register #6 (KR6).\r
2fe241a2 5426\r
5427 Writes the current value of KR6. The 64-bit value written to \r
1a2f870c 5428 the KR6 is returned. This function is only available on Itanium processors.\r
ac644614 5429\r
ee6c452c 5430 @param Value The 64-bit value to write to KR6.\r
ac644614 5431\r
5432 @return The 64-bit value written to the KR6.\r
5433\r
5434**/\r
5435UINT64\r
5436EFIAPI\r
5437AsmWriteKr6 (\r
5438 IN UINT64 Value\r
5439 );\r
5440\r
5441\r
5442/**\r
5443 Write the current value of 64-bit Kernel Register #7 (KR7).\r
2fe241a2 5444\r
5445 Writes the current value of KR7. The 64-bit value written to \r
1a2f870c 5446 the KR7 is returned. This function is only available on Itanium processors.\r
ac644614 5447\r
ee6c452c 5448 @param Value The 64-bit value to write to KR7.\r
ac644614 5449\r
5450 @return The 64-bit value written to the KR7.\r
5451\r
5452**/\r
5453UINT64\r
5454EFIAPI\r
5455AsmWriteKr7 (\r
5456 IN UINT64 Value\r
5457 );\r
5458\r
5459\r
5460/**\r
5461 Reads the current value of Interval Timer Counter Register (ITC).\r
2fe241a2 5462 \r
5463 Reads and returns the current value of ITC.\r
1a2f870c 5464 This function is only available on Itanium processors.\r
ac644614 5465\r
5466 @return The current value of ITC.\r
5467\r
5468**/\r
5469UINT64\r
5470EFIAPI\r
5471AsmReadItc (\r
5472 VOID\r
5473 );\r
5474\r
5475\r
5476/**\r
5477 Reads the current value of Interval Timer Vector Register (ITV).\r
2fe241a2 5478 \r
5479 Reads and returns the current value of ITV. \r
1a2f870c 5480 This function is only available on Itanium processors.\r
ac644614 5481\r
5482 @return The current value of ITV.\r
5483\r
5484**/\r
5485UINT64\r
5486EFIAPI\r
5487AsmReadItv (\r
5488 VOID\r
5489 );\r
5490\r
5491\r
5492/**\r
5493 Reads the current value of Interval Timer Match Register (ITM).\r
2fe241a2 5494 \r
5495 Reads and returns the current value of ITM.\r
1a2f870c 5496 This function is only available on Itanium processors.\r
ac644614 5497\r
5498 @return The current value of ITM.\r
5499**/\r
5500UINT64\r
5501EFIAPI\r
5502AsmReadItm (\r
5503 VOID\r
5504 );\r
5505\r
5506\r
5507/**\r
5508 Writes the current value of 64-bit Interval Timer Counter Register (ITC).\r
2fe241a2 5509 \r
5510 Writes the current value of ITC. The 64-bit value written to the ITC is returned. \r
1a2f870c 5511 This function is only available on Itanium processors.\r
ac644614 5512\r
ee6c452c 5513 @param Value The 64-bit value to write to ITC.\r
ac644614 5514\r
5515 @return The 64-bit value written to the ITC.\r
5516\r
5517**/\r
5518UINT64\r
5519EFIAPI\r
5520AsmWriteItc (\r
5521 IN UINT64 Value\r
5522 );\r
5523\r
5524\r
5525/**\r
5526 Writes the current value of 64-bit Interval Timer Match Register (ITM).\r
2fe241a2 5527 \r
5528 Writes the current value of ITM. The 64-bit value written to the ITM is returned. \r
1a2f870c 5529 This function is only available on Itanium processors.\r
ac644614 5530\r
ee6c452c 5531 @param Value The 64-bit value to write to ITM.\r
ac644614 5532\r
5533 @return The 64-bit value written to the ITM.\r
5534\r
5535**/\r
5536UINT64\r
5537EFIAPI\r
5538AsmWriteItm (\r
5539 IN UINT64 Value\r
5540 );\r
5541\r
5542\r
5543/**\r
5544 Writes the current value of 64-bit Interval Timer Vector Register (ITV).\r
2fe241a2 5545 \r
5546 Writes the current value of ITV. The 64-bit value written to the ITV is returned. \r
ac644614 5547 No parameter checking is performed on Value. All bits of Value corresponding to\r
5548 reserved fields of ITV must be 0 or a Reserved Register/Field fault may occur.\r
5549 The caller must either guarantee that Value is valid, or the caller must set up\r
5550 fault handlers to catch the faults.\r
1a2f870c 5551 This function is only available on Itanium processors.\r
ac644614 5552\r
ee6c452c 5553 @param Value The 64-bit value to write to ITV.\r
ac644614 5554\r
5555 @return The 64-bit value written to the ITV.\r
5556\r
5557**/\r
5558UINT64\r
5559EFIAPI\r
5560AsmWriteItv (\r
5561 IN UINT64 Value\r
5562 );\r
5563\r
5564\r
5565/**\r
5566 Reads the current value of Default Control Register (DCR).\r
2fe241a2 5567 \r
1a2f870c 5568 Reads and returns the current value of DCR. This function is only available on Itanium processors.\r
ac644614 5569\r
5570 @return The current value of DCR.\r
5571\r
5572**/\r
5573UINT64\r
5574EFIAPI\r
5575AsmReadDcr (\r
5576 VOID\r
5577 );\r
5578\r
5579\r
5580/**\r
5581 Reads the current value of Interruption Vector Address Register (IVA).\r
2fe241a2 5582 \r
1a2f870c 5583 Reads and returns the current value of IVA. This function is only available on Itanium processors.\r
ac644614 5584\r
5585 @return The current value of IVA.\r
5586**/\r
5587UINT64\r
5588EFIAPI\r
5589AsmReadIva (\r
5590 VOID\r
5591 );\r
5592\r
5593\r
5594/**\r
5595 Reads the current value of Page Table Address Register (PTA).\r
2fe241a2 5596 \r
1a2f870c 5597 Reads and returns the current value of PTA. This function is only available on Itanium processors.\r
ac644614 5598\r
5599 @return The current value of PTA.\r
5600\r
5601**/\r
5602UINT64\r
5603EFIAPI\r
5604AsmReadPta (\r
5605 VOID\r
5606 );\r
5607\r
5608\r
5609/**\r
5610 Writes the current value of 64-bit Default Control Register (DCR).\r
2fe241a2 5611 \r
5612 Writes the current value of DCR. The 64-bit value written to the DCR is returned. \r
ac644614 5613 No parameter checking is performed on Value. All bits of Value corresponding to\r
5614 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
5615 The caller must either guarantee that Value is valid, or the caller must set up\r
5616 fault handlers to catch the faults.\r
1a2f870c 5617 This function is only available on Itanium processors.\r
ac644614 5618\r
ee6c452c 5619 @param Value The 64-bit value to write to DCR.\r
ac644614 5620\r
5621 @return The 64-bit value written to the DCR.\r
5622\r
5623**/\r
5624UINT64\r
5625EFIAPI\r
5626AsmWriteDcr (\r
5627 IN UINT64 Value\r
5628 );\r
5629\r
5630\r
5631/**\r
5632 Writes the current value of 64-bit Interruption Vector Address Register (IVA).\r
2fe241a2 5633 \r
5634 Writes the current value of IVA. The 64-bit value written to the IVA is returned. \r
ac644614 5635 The size of vector table is 32 K bytes and is 32 K bytes aligned\r
5636 the low 15 bits of Value is ignored when written.\r
1a2f870c 5637 This function is only available on Itanium processors.\r
ac644614 5638\r
ee6c452c 5639 @param Value The 64-bit value to write to IVA.\r
ac644614 5640\r
5641 @return The 64-bit value written to the IVA.\r
5642\r
5643**/\r
5644UINT64\r
5645EFIAPI\r
5646AsmWriteIva (\r
5647 IN UINT64 Value\r
5648 );\r
5649\r
5650\r
5651/**\r
5652 Writes the current value of 64-bit Page Table Address Register (PTA).\r
2fe241a2 5653 \r
5654 Writes the current value of PTA. The 64-bit value written to the PTA is returned. \r
ac644614 5655 No parameter checking is performed on Value. All bits of Value corresponding to\r
5656 reserved fields of DCR must be 0 or a Reserved Register/Field fault may occur.\r
5657 The caller must either guarantee that Value is valid, or the caller must set up\r
5658 fault handlers to catch the faults.\r
1a2f870c 5659 This function is only available on Itanium processors.\r
ac644614 5660\r
ee6c452c 5661 @param Value The 64-bit value to write to PTA.\r
ac644614 5662\r
5663 @return The 64-bit value written to the PTA.\r
5664**/\r
5665UINT64\r
5666EFIAPI\r
5667AsmWritePta (\r
5668 IN UINT64 Value\r
5669 );\r
5670\r
5671\r
5672/**\r
5673 Reads the current value of Local Interrupt ID Register (LID).\r
2fe241a2 5674 \r
1a2f870c 5675 Reads and returns the current value of LID. This function is only available on Itanium processors.\r
ac644614 5676\r
5677 @return The current value of LID.\r
5678\r
5679**/\r
5680UINT64\r
5681EFIAPI\r
5682AsmReadLid (\r
5683 VOID\r
5684 );\r
5685\r
5686\r
5687/**\r
5688 Reads the current value of External Interrupt Vector Register (IVR).\r
2fe241a2 5689 \r
1a2f870c 5690 Reads and returns the current value of IVR. This function is only available on Itanium processors. \r
ac644614 5691\r
5692 @return The current value of IVR.\r
5693\r
5694**/\r
5695UINT64\r
5696EFIAPI\r
5697AsmReadIvr (\r
5698 VOID\r
5699 );\r
5700\r
5701\r
5702/**\r
5703 Reads the current value of Task Priority Register (TPR).\r
2fe241a2 5704 \r
1a2f870c 5705 Reads and returns the current value of TPR. This function is only available on Itanium processors. \r
ac644614 5706\r
5707 @return The current value of TPR.\r
5708\r
5709**/\r
5710UINT64\r
5711EFIAPI\r
5712AsmReadTpr (\r
5713 VOID\r
5714 );\r
5715\r
5716\r
5717/**\r
5718 Reads the current value of External Interrupt Request Register #0 (IRR0).\r
2fe241a2 5719 \r
1a2f870c 5720 Reads and returns the current value of IRR0. This function is only available on Itanium processors. \r
ac644614 5721\r
5722 @return The current value of IRR0.\r
5723\r
5724**/\r
5725UINT64\r
5726EFIAPI\r
5727AsmReadIrr0 (\r
5728 VOID\r
5729 );\r
5730\r
5731\r
5732/**\r
5733 Reads the current value of External Interrupt Request Register #1 (IRR1).\r
2fe241a2 5734 \r
1a2f870c 5735 Reads and returns the current value of IRR1. This function is only available on Itanium processors. \r
ac644614 5736\r
5737 @return The current value of IRR1.\r
5738\r
5739**/\r
5740UINT64\r
5741EFIAPI\r
5742AsmReadIrr1 (\r
5743 VOID\r
5744 );\r
5745\r
5746\r
5747/**\r
5748 Reads the current value of External Interrupt Request Register #2 (IRR2).\r
2fe241a2 5749 \r
1a2f870c 5750 Reads and returns the current value of IRR2. This function is only available on Itanium processors.\r
ac644614 5751\r
5752 @return The current value of IRR2.\r
5753\r
5754**/\r
5755UINT64\r
5756EFIAPI\r
5757AsmReadIrr2 (\r
5758 VOID\r
5759 );\r
5760\r
5761\r
5762/**\r
5763 Reads the current value of External Interrupt Request Register #3 (IRR3).\r
2fe241a2 5764 \r
1a2f870c 5765 Reads and returns the current value of IRR3. This function is only available on Itanium processors. \r
ac644614 5766\r
5767 @return The current value of IRR3.\r
5768\r
5769**/\r
5770UINT64\r
5771EFIAPI\r
5772AsmReadIrr3 (\r
5773 VOID\r
5774 );\r
5775\r
5776\r
5777/**\r
5778 Reads the current value of Performance Monitor Vector Register (PMV).\r
2fe241a2 5779 \r
1a2f870c 5780 Reads and returns the current value of PMV. This function is only available on Itanium processors. \r
ac644614 5781\r
5782 @return The current value of PMV.\r
5783\r
5784**/\r
5785UINT64\r
5786EFIAPI\r
5787AsmReadPmv (\r
5788 VOID\r
5789 );\r
5790\r
5791\r
5792/**\r
5793 Reads the current value of Corrected Machine Check Vector Register (CMCV).\r
2fe241a2 5794 \r
1a2f870c 5795 Reads and returns the current value of CMCV. This function is only available on Itanium processors.\r
ac644614 5796\r
5797 @return The current value of CMCV.\r
5798\r
5799**/\r
5800UINT64\r
5801EFIAPI\r
5802AsmReadCmcv (\r
5803 VOID\r
5804 );\r
5805\r
5806\r
5807/**\r
5808 Reads the current value of Local Redirection Register #0 (LRR0).\r
2fe241a2 5809 \r
1a2f870c 5810 Reads and returns the current value of LRR0. This function is only available on Itanium processors. \r
ac644614 5811\r
5812 @return The current value of LRR0.\r
5813\r
5814**/\r
5815UINT64\r
5816EFIAPI\r
5817AsmReadLrr0 (\r
5818 VOID\r
5819 );\r
5820\r
5821\r
5822/**\r
5823 Reads the current value of Local Redirection Register #1 (LRR1).\r
2fe241a2 5824 \r
1a2f870c 5825 Reads and returns the current value of LRR1. This function is only available on Itanium processors.\r
ac644614 5826\r
5827 @return The current value of LRR1.\r
5828\r
5829**/\r
5830UINT64\r
5831EFIAPI\r
5832AsmReadLrr1 (\r
5833 VOID\r
5834 );\r
5835\r
5836\r
5837/**\r
5838 Writes the current value of 64-bit Page Local Interrupt ID Register (LID).\r
2fe241a2 5839 \r
5840 Writes the current value of LID. The 64-bit value written to the LID is returned. \r
ac644614 5841 No parameter checking is performed on Value. All bits of Value corresponding to\r
5842 reserved fields of LID must be 0 or a Reserved Register/Field fault may occur.\r
5843 The caller must either guarantee that Value is valid, or the caller must set up\r
5844 fault handlers to catch the faults.\r
1a2f870c 5845 This function is only available on Itanium processors.\r
ac644614 5846\r
ee6c452c 5847 @param Value The 64-bit value to write to LID.\r
ac644614 5848\r
5849 @return The 64-bit value written to the LID.\r
5850\r
5851**/\r
5852UINT64\r
5853EFIAPI\r
5854AsmWriteLid (\r
5855 IN UINT64 Value\r
5856 );\r
5857\r
5858\r
5859/**\r
5860 Writes the current value of 64-bit Task Priority Register (TPR).\r
2fe241a2 5861 \r
5862 Writes the current value of TPR. The 64-bit value written to the TPR is returned. \r
ac644614 5863 No parameter checking is performed on Value. All bits of Value corresponding to\r
5864 reserved fields of TPR must be 0 or a Reserved Register/Field fault may occur.\r
5865 The caller must either guarantee that Value is valid, or the caller must set up\r
5866 fault handlers to catch the faults.\r
1a2f870c 5867 This function is only available on Itanium processors.\r
ac644614 5868\r
ee6c452c 5869 @param Value The 64-bit value to write to TPR.\r
ac644614 5870\r
5871 @return The 64-bit value written to the TPR.\r
5872\r
5873**/\r
5874UINT64\r
5875EFIAPI\r
5876AsmWriteTpr (\r
5877 IN UINT64 Value\r
5878 );\r
5879\r
5880\r
5881/**\r
5882 Performs a write operation on End OF External Interrupt Register (EOI).\r
2fe241a2 5883 \r
1a2f870c 5884 Writes a value of 0 to the EOI Register. This function is only available on Itanium processors.\r
ac644614 5885\r
5886**/\r
5887VOID\r
5888EFIAPI\r
5889AsmWriteEoi (\r
5890 VOID\r
5891 );\r
5892\r
5893\r
5894/**\r
5895 Writes the current value of 64-bit Performance Monitor Vector Register (PMV).\r
2fe241a2 5896 \r
5897 Writes the current value of PMV. The 64-bit value written to the PMV is returned. \r
ac644614 5898 No parameter checking is performed on Value. All bits of Value corresponding\r
5899 to reserved fields of PMV must be 0 or a Reserved Register/Field fault may occur.\r
5900 The caller must either guarantee that Value is valid, or the caller must set up\r
5901 fault handlers to catch the faults.\r
1a2f870c 5902 This function is only available on Itanium processors.\r
ac644614 5903\r
ee6c452c 5904 @param Value The 64-bit value to write to PMV.\r
ac644614 5905\r
5906 @return The 64-bit value written to the PMV.\r
5907\r
5908**/\r
5909UINT64\r
5910EFIAPI\r
5911AsmWritePmv (\r
5912 IN UINT64 Value\r
5913 );\r
5914\r
5915\r
5916/**\r
5917 Writes the current value of 64-bit Corrected Machine Check Vector Register (CMCV).\r
2fe241a2 5918 \r
5919 Writes the current value of CMCV. The 64-bit value written to the CMCV is returned. \r
ac644614 5920 No parameter checking is performed on Value. All bits of Value corresponding\r
5921 to reserved fields of CMCV must be 0 or a Reserved Register/Field fault may occur.\r
5922 The caller must either guarantee that Value is valid, or the caller must set up\r
5923 fault handlers to catch the faults.\r
1a2f870c 5924 This function is only available on Itanium processors.\r
ac644614 5925\r
ee6c452c 5926 @param Value The 64-bit value to write to CMCV.\r
ac644614 5927\r
5928 @return The 64-bit value written to the CMCV.\r
5929\r
5930**/\r
5931UINT64\r
5932EFIAPI\r
5933AsmWriteCmcv (\r
5934 IN UINT64 Value\r
5935 );\r
5936\r
5937\r
5938/**\r
5939 Writes the current value of 64-bit Local Redirection Register #0 (LRR0).\r
2fe241a2 5940 \r
5941 Writes the current value of LRR0. The 64-bit value written to the LRR0 is returned. \r
ac644614 5942 No parameter checking is performed on Value. All bits of Value corresponding\r
5943 to reserved fields of LRR0 must be 0 or a Reserved Register/Field fault may occur.\r
5944 The caller must either guarantee that Value is valid, or the caller must set up\r
5945 fault handlers to catch the faults.\r
1a2f870c 5946 This function is only available on Itanium processors.\r
ac644614 5947\r
ee6c452c 5948 @param Value The 64-bit value to write to LRR0.\r
ac644614 5949\r
5950 @return The 64-bit value written to the LRR0.\r
5951\r
5952**/\r
5953UINT64\r
5954EFIAPI\r
5955AsmWriteLrr0 (\r
5956 IN UINT64 Value\r
5957 );\r
5958\r
5959\r
5960/**\r
5961 Writes the current value of 64-bit Local Redirection Register #1 (LRR1).\r
2fe241a2 5962 \r
5963 Writes the current value of LRR1. The 64-bit value written to the LRR1 is returned. \r
ac644614 5964 No parameter checking is performed on Value. All bits of Value corresponding\r
5965 to reserved fields of LRR1 must be 0 or a Reserved Register/Field fault may occur.\r
5966 The caller must either guarantee that Value is valid, or the caller must\r
5967 set up fault handlers to catch the faults.\r
1a2f870c 5968 This function is only available on Itanium processors.\r
ac644614 5969\r
ee6c452c 5970 @param Value The 64-bit value to write to LRR1.\r
ac644614 5971\r
5972 @return The 64-bit value written to the LRR1.\r
5973\r
5974**/\r
5975UINT64\r
5976EFIAPI\r
5977AsmWriteLrr1 (\r
5978 IN UINT64 Value\r
5979 );\r
5980\r
5981\r
5982/**\r
5983 Reads the current value of Instruction Breakpoint Register (IBR).\r
5984 \r
5985 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
5986 registers contain breakpoint addresses, and the odd numbered registers contain\r
af2dc6a7 5987 breakpoint mask conditions. At least four instruction registers pairs are implemented\r
ac644614 5988 on all processor models. Implemented registers are contiguous starting with\r
5989 register 0. No parameter checking is performed on Index, and if the Index value\r
5990 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
5991 occur. The caller must either guarantee that Index is valid, or the caller must\r
5992 set up fault handlers to catch the faults.\r
1a2f870c 5993 This function is only available on Itanium processors.\r
ac644614 5994\r
ee6c452c 5995 @param Index The 8-bit Instruction Breakpoint Register index to read.\r
ac644614 5996\r
5997 @return The current value of Instruction Breakpoint Register specified by Index.\r
5998\r
5999**/\r
6000UINT64\r
6001EFIAPI\r
6002AsmReadIbr (\r
6003 IN UINT8 Index\r
6004 );\r
6005\r
6006\r
6007/**\r
6008 Reads the current value of Data Breakpoint Register (DBR).\r
6009\r
6010 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
6011 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
af2dc6a7 6012 mask conditions. At least four data registers pairs are implemented on all processor\r
ac644614 6013 models. Implemented registers are contiguous starting with register 0.\r
6014 No parameter checking is performed on Index. If the Index value is beyond\r
6015 the implemented DBR register range, a Reserved Register/Field fault may occur.\r
6016 The caller must either guarantee that Index is valid, or the caller must set up\r
6017 fault handlers to catch the faults.\r
1a2f870c 6018 This function is only available on Itanium processors.\r
ac644614 6019\r
ee6c452c 6020 @param Index The 8-bit Data Breakpoint Register index to read.\r
ac644614 6021\r
6022 @return The current value of Data Breakpoint Register specified by Index.\r
6023\r
6024**/\r
6025UINT64\r
6026EFIAPI\r
6027AsmReadDbr (\r
6028 IN UINT8 Index\r
6029 );\r
6030\r
6031\r
6032/**\r
6033 Reads the current value of Performance Monitor Configuration Register (PMC).\r
6034\r
af2dc6a7 6035 All processor implementations provide at least four performance counters\r
6036 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r
ac644614 6037 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
6038 additional implementation-dependent PMC and PMD to increase the number of\r
6039 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
6040 register set is implementation dependent. No parameter checking is performed\r
6041 on Index. If the Index value is beyond the implemented PMC register range,\r
6042 zero value will be returned.\r
1a2f870c 6043 This function is only available on Itanium processors.\r
ac644614 6044\r
ee6c452c 6045 @param Index The 8-bit Performance Monitor Configuration Register index to read.\r
ac644614 6046\r
2fe241a2 6047 @return The current value of Performance Monitor Configuration Register\r
6048 specified by Index.\r
ac644614 6049\r
6050**/\r
6051UINT64\r
6052EFIAPI\r
6053AsmReadPmc (\r
6054 IN UINT8 Index\r
6055 );\r
6056\r
6057\r
6058/**\r
6059 Reads the current value of Performance Monitor Data Register (PMD).\r
6060\r
6061 All processor implementations provide at least 4 performance counters\r
6062 (PMC/PMD [4]...PMC/PMD [7] pairs), and 4 performance monitor counter\r
6063 overflow status registers (PMC [0]... PMC [3]). Processor implementations may\r
6064 provide additional implementation-dependent PMC and PMD to increase the number\r
6065 of 'generic' performance counters (PMC/PMD pairs). The remainder of PMC and PMD\r
6066 register set is implementation dependent. No parameter checking is performed\r
6067 on Index. If the Index value is beyond the implemented PMD register range,\r
6068 zero value will be returned.\r
1a2f870c 6069 This function is only available on Itanium processors.\r
ac644614 6070\r
ee6c452c 6071 @param Index The 8-bit Performance Monitor Data Register index to read.\r
ac644614 6072\r
6073 @return The current value of Performance Monitor Data Register specified by Index.\r
6074\r
6075**/\r
6076UINT64\r
6077EFIAPI\r
6078AsmReadPmd (\r
6079 IN UINT8 Index\r
6080 );\r
6081\r
6082\r
6083/**\r
6084 Writes the current value of 64-bit Instruction Breakpoint Register (IBR).\r
6085\r
6086 Writes current value of Instruction Breakpoint Register specified by Index.\r
6087 The Instruction Breakpoint Registers are used in pairs. The even numbered\r
6088 registers contain breakpoint addresses, and odd numbered registers contain\r
af2dc6a7 6089 breakpoint mask conditions. At least four instruction registers pairs are implemented\r
ac644614 6090 on all processor models. Implemented registers are contiguous starting with\r
6091 register 0. No parameter checking is performed on Index. If the Index value\r
6092 is beyond the implemented IBR register range, a Reserved Register/Field fault may\r
6093 occur. The caller must either guarantee that Index is valid, or the caller must\r
6094 set up fault handlers to catch the faults.\r
1a2f870c 6095 This function is only available on Itanium processors.\r
ac644614 6096\r
ee6c452c 6097 @param Index The 8-bit Instruction Breakpoint Register index to write.\r
6098 @param Value The 64-bit value to write to IBR.\r
ac644614 6099\r
6100 @return The 64-bit value written to the IBR.\r
6101\r
6102**/\r
6103UINT64\r
6104EFIAPI\r
6105AsmWriteIbr (\r
6106 IN UINT8 Index,\r
6107 IN UINT64 Value\r
6108 );\r
6109\r
6110\r
6111/**\r
6112 Writes the current value of 64-bit Data Breakpoint Register (DBR).\r
6113\r
6114 Writes current value of Data Breakpoint Register specified by Index.\r
6115 The Data Breakpoint Registers are used in pairs. The even numbered registers\r
6116 contain breakpoint addresses, and odd numbered registers contain breakpoint\r
af2dc6a7 6117 mask conditions. At least four data registers pairs are implemented on all processor\r
ac644614 6118 models. Implemented registers are contiguous starting with register 0. No parameter\r
6119 checking is performed on Index. If the Index value is beyond the implemented\r
6120 DBR register range, a Reserved Register/Field fault may occur. The caller must\r
6121 either guarantee that Index is valid, or the caller must set up fault handlers to\r
6122 catch the faults.\r
1a2f870c 6123 This function is only available on Itanium processors.\r
ac644614 6124\r
ee6c452c 6125 @param Index The 8-bit Data Breakpoint Register index to write.\r
6126 @param Value The 64-bit value to write to DBR.\r
ac644614 6127\r
6128 @return The 64-bit value written to the DBR.\r
6129\r
6130**/\r
6131UINT64\r
6132EFIAPI\r
6133AsmWriteDbr (\r
6134 IN UINT8 Index,\r
6135 IN UINT64 Value\r
6136 );\r
6137\r
6138\r
6139/**\r
6140 Writes the current value of 64-bit Performance Monitor Configuration Register (PMC).\r
6141\r
6142 Writes current value of Performance Monitor Configuration Register specified by Index.\r
af2dc6a7 6143 All processor implementations provide at least four performance counters\r
6144 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow status\r
ac644614 6145 registers (PMC [0]... PMC [3]). Processor implementations may provide additional\r
6146 implementation-dependent PMC and PMD to increase the number of 'generic' performance\r
6147 counters (PMC/PMD pairs). The remainder of PMC and PMD register set is implementation\r
6148 dependent. No parameter checking is performed on Index. If the Index value is\r
6149 beyond the implemented PMC register range, the write is ignored.\r
1a2f870c 6150 This function is only available on Itanium processors.\r
ac644614 6151\r
ee6c452c 6152 @param Index The 8-bit Performance Monitor Configuration Register index to write.\r
6153 @param Value The 64-bit value to write to PMC.\r
ac644614 6154\r
6155 @return The 64-bit value written to the PMC.\r
6156\r
6157**/\r
6158UINT64\r
6159EFIAPI\r
6160AsmWritePmc (\r
6161 IN UINT8 Index,\r
6162 IN UINT64 Value\r
6163 );\r
6164\r
6165\r
6166/**\r
6167 Writes the current value of 64-bit Performance Monitor Data Register (PMD).\r
6168\r
6169 Writes current value of Performance Monitor Data Register specified by Index.\r
af2dc6a7 6170 All processor implementations provide at least four performance counters\r
6171 (PMC/PMD [4]...PMC/PMD [7] pairs), and four performance monitor counter overflow\r
ac644614 6172 status registers (PMC [0]... PMC [3]). Processor implementations may provide\r
6173 additional implementation-dependent PMC and PMD to increase the number of 'generic'\r
6174 performance counters (PMC/PMD pairs). The remainder of PMC and PMD register set\r
6175 is implementation dependent. No parameter checking is performed on Index. If the\r
6176 Index value is beyond the implemented PMD register range, the write is ignored.\r
1a2f870c 6177 This function is only available on Itanium processors.\r
ac644614 6178\r
ee6c452c 6179 @param Index The 8-bit Performance Monitor Data Register index to write.\r
6180 @param Value The 64-bit value to write to PMD.\r
ac644614 6181\r
6182 @return The 64-bit value written to the PMD.\r
6183\r
6184**/\r
6185UINT64\r
6186EFIAPI\r
6187AsmWritePmd (\r
6188 IN UINT8 Index,\r
6189 IN UINT64 Value\r
6190 );\r
6191\r
6192\r
6193/**\r
6194 Reads the current value of 64-bit Global Pointer (GP).\r
6195\r
6196 Reads and returns the current value of GP.\r
1a2f870c 6197 This function is only available on Itanium processors.\r
ac644614 6198\r
6199 @return The current value of GP.\r
6200\r
6201**/\r
6202UINT64\r
6203EFIAPI\r
6204AsmReadGp (\r
6205 VOID\r
6206 );\r
6207\r
6208\r
6209/**\r
6210 Write the current value of 64-bit Global Pointer (GP).\r
6211\r
6212 Writes the current value of GP. The 64-bit value written to the GP is returned.\r
6213 No parameter checking is performed on Value.\r
1a2f870c 6214 This function is only available on Itanium processors.\r
ac644614 6215\r
6216 @param Value The 64-bit value to write to GP.\r
6217\r
6218 @return The 64-bit value written to the GP.\r
6219\r
6220**/\r
6221UINT64\r
6222EFIAPI\r
6223AsmWriteGp (\r
6224 IN UINT64 Value\r
6225 );\r
6226\r
6227\r
6228/**\r
6229 Reads the current value of 64-bit Stack Pointer (SP).\r
6230\r
6231 Reads and returns the current value of SP.\r
1a2f870c 6232 This function is only available on Itanium processors.\r
ac644614 6233\r
6234 @return The current value of SP.\r
6235\r
6236**/\r
6237UINT64\r
6238EFIAPI\r
6239AsmReadSp (\r
6240 VOID\r
6241 );\r
6242\r
6243\r
aad6137d 6244///\r
af2dc6a7 6245/// Valid Index value for AsmReadControlRegister().\r
aad6137d 6246///\r
6247#define IPF_CONTROL_REGISTER_DCR 0\r
6248#define IPF_CONTROL_REGISTER_ITM 1\r
6249#define IPF_CONTROL_REGISTER_IVA 2\r
6250#define IPF_CONTROL_REGISTER_PTA 8\r
6251#define IPF_CONTROL_REGISTER_IPSR 16\r
6252#define IPF_CONTROL_REGISTER_ISR 17\r
6253#define IPF_CONTROL_REGISTER_IIP 19\r
6254#define IPF_CONTROL_REGISTER_IFA 20\r
6255#define IPF_CONTROL_REGISTER_ITIR 21\r
6256#define IPF_CONTROL_REGISTER_IIPA 22\r
6257#define IPF_CONTROL_REGISTER_IFS 23\r
6258#define IPF_CONTROL_REGISTER_IIM 24\r
6259#define IPF_CONTROL_REGISTER_IHA 25\r
6260#define IPF_CONTROL_REGISTER_LID 64\r
6261#define IPF_CONTROL_REGISTER_IVR 65\r
6262#define IPF_CONTROL_REGISTER_TPR 66\r
6263#define IPF_CONTROL_REGISTER_EOI 67\r
6264#define IPF_CONTROL_REGISTER_IRR0 68\r
6265#define IPF_CONTROL_REGISTER_IRR1 69\r
6266#define IPF_CONTROL_REGISTER_IRR2 70\r
6267#define IPF_CONTROL_REGISTER_IRR3 71\r
6268#define IPF_CONTROL_REGISTER_ITV 72\r
6269#define IPF_CONTROL_REGISTER_PMV 73\r
6270#define IPF_CONTROL_REGISTER_CMCV 74\r
6271#define IPF_CONTROL_REGISTER_LRR0 80\r
6272#define IPF_CONTROL_REGISTER_LRR1 81\r
6273\r
6274/**\r
6275 Reads a 64-bit control register.\r
6276\r
af2dc6a7 6277 Reads and returns the control register specified by Index. The valid Index valued \r
6278 are defined above in "Related Definitions".\r
6279 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r
6280 available on Itanium processors.\r
aad6137d 6281\r
6282 @param Index The index of the control register to read.\r
6283\r
6284 @return The control register specified by Index.\r
6285\r
6286**/\r
6287UINT64\r
6288EFIAPI\r
6289AsmReadControlRegister (\r
6290 IN UINT64 Index\r
6291 );\r
6292\r
6293\r
6294///\r
af2dc6a7 6295/// Valid Index value for AsmReadApplicationRegister().\r
aad6137d 6296///\r
6297#define IPF_APPLICATION_REGISTER_K0 0\r
6298#define IPF_APPLICATION_REGISTER_K1 1\r
6299#define IPF_APPLICATION_REGISTER_K2 2\r
6300#define IPF_APPLICATION_REGISTER_K3 3\r
6301#define IPF_APPLICATION_REGISTER_K4 4\r
6302#define IPF_APPLICATION_REGISTER_K5 5\r
6303#define IPF_APPLICATION_REGISTER_K6 6\r
6304#define IPF_APPLICATION_REGISTER_K7 7\r
6305#define IPF_APPLICATION_REGISTER_RSC 16\r
6306#define IPF_APPLICATION_REGISTER_BSP 17\r
6307#define IPF_APPLICATION_REGISTER_BSPSTORE 18\r
6308#define IPF_APPLICATION_REGISTER_RNAT 19\r
6309#define IPF_APPLICATION_REGISTER_FCR 21\r
6310#define IPF_APPLICATION_REGISTER_EFLAG 24\r
6311#define IPF_APPLICATION_REGISTER_CSD 25\r
6312#define IPF_APPLICATION_REGISTER_SSD 26\r
6313#define IPF_APPLICATION_REGISTER_CFLG 27\r
6314#define IPF_APPLICATION_REGISTER_FSR 28\r
6315#define IPF_APPLICATION_REGISTER_FIR 29\r
6316#define IPF_APPLICATION_REGISTER_FDR 30\r
6317#define IPF_APPLICATION_REGISTER_CCV 32\r
6318#define IPF_APPLICATION_REGISTER_UNAT 36\r
6319#define IPF_APPLICATION_REGISTER_FPSR 40\r
6320#define IPF_APPLICATION_REGISTER_ITC 44\r
6321#define IPF_APPLICATION_REGISTER_PFS 64\r
6322#define IPF_APPLICATION_REGISTER_LC 65\r
6323#define IPF_APPLICATION_REGISTER_EC 66\r
6324\r
6325/**\r
6326 Reads a 64-bit application register.\r
6327\r
af2dc6a7 6328 Reads and returns the application register specified by Index. The valid Index \r
6329 valued are defined above in "Related Definitions".\r
6330 If Index is invalid then 0xFFFFFFFFFFFFFFFF is returned. This function is only \r
6331 available on Itanium processors.\r
aad6137d 6332\r
6333 @param Index The index of the application register to read.\r
6334\r
6335 @return The application register specified by Index.\r
6336\r
6337**/\r
6338UINT64\r
6339EFIAPI\r
6340AsmReadApplicationRegister (\r
6341 IN UINT64 Index\r
6342 );\r
6343\r
6344\r
59e0bb0c 6345/**\r
6346 Reads the current value of a Machine Specific Register (MSR).\r
6347\r
6348 Reads and returns the current value of the Machine Specific Register specified by Index. No\r
6349 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r
6350 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r
6351 Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r
1a2f870c 6352 only available on Itanium processors.\r
59e0bb0c 6353\r
6354 @param Index The 8-bit Machine Specific Register index to read.\r
6355\r
6356 @return The current value of the Machine Specific Register specified by Index. \r
6357\r
6358**/\r
6359UINT64\r
6360EFIAPI\r
6361AsmReadMsr (\r
6362 IN UINT8 Index \r
6363 );\r
6364\r
6365\r
6366/**\r
6367 Writes the current value of a Machine Specific Register (MSR).\r
6368\r
6369 Writes Value to the Machine Specific Register specified by Index. Value is returned. No\r
6370 parameter checking is performed on Index, and if the Index value is beyond the implemented MSR\r
6371 register range, a Reserved Register/Field fault may occur. The caller must either guarantee that\r
6372 Index is valid, or the caller must set up fault handlers to catch the faults. This function is\r
1a2f870c 6373 only available on Itanium processors.\r
59e0bb0c 6374\r
6375 @param Index The 8-bit Machine Specific Register index to write.\r
6376 @param Value The 64-bit value to write to the Machine Specific Register.\r
6377\r
6378 @return The 64-bit value to write to the Machine Specific Register. \r
6379\r
6380**/\r
6381UINT64\r
6382EFIAPI\r
6383AsmWriteMsr (\r
6384 IN UINT8 Index, \r
6385 IN UINT64 Value \r
6386 );\r
6387\r
6388\r
ac644614 6389/**\r
6390 Determines if the CPU is currently executing in virtual, physical, or mixed mode.\r
6391\r
6392 Determines the current execution mode of the CPU.\r
6393 If the CPU is in virtual mode(PSR.RT=1, PSR.DT=1, PSR.IT=1), then 1 is returned.\r
6394 If the CPU is in physical mode(PSR.RT=0, PSR.DT=0, PSR.IT=0), then 0 is returned.\r
6395 If the CPU is not in physical mode or virtual mode, then it is in mixed mode,\r
6396 and -1 is returned.\r
1a2f870c 6397 This function is only available on Itanium processors.\r
ac644614 6398\r
17f695ed 6399 @retval 1 The CPU is in virtual mode.\r
6400 @retval 0 The CPU is in physical mode.\r
6401 @retval -1 The CPU is in mixed mode.\r
ac644614 6402\r
6403**/\r
6404INT64\r
6405EFIAPI\r
6406AsmCpuVirtual (\r
6407 VOID\r
6408 );\r
6409\r
6410\r
6411/**\r
6412 Makes a PAL procedure call.\r
6413\r
6414 This is a wrapper function to make a PAL procedure call. Based on the Index\r
6415 value this API will make static or stacked PAL call. The following table\r
6416 describes the usage of PAL Procedure Index Assignment. Architected procedures\r
6417 may be designated as required or optional. If a PAL procedure is specified\r
6418 as optional, a unique return code of 0xFFFFFFFFFFFFFFFF is returned in the\r
6419 Status field of the PAL_CALL_RETURN structure.\r
6420 This indicates that the procedure is not present in this PAL implementation.\r
6421 It is the caller's responsibility to check for this return code after calling\r
6422 any optional PAL procedure.\r
6423 No parameter checking is performed on the 5 input parameters, but there are\r
6424 some common rules that the caller should follow when making a PAL call. Any\r
6425 address passed to PAL as buffers for return parameters must be 8-byte aligned.\r
6426 Unaligned addresses may cause undefined results. For those parameters defined\r
6427 as reserved or some fields defined as reserved must be zero filled or the invalid\r
6428 argument return value may be returned or undefined result may occur during the\r
6429 execution of the procedure. If the PalEntryPoint does not point to a valid\r
6430 PAL entry point then the system behavior is undefined. This function is only\r
1a2f870c 6431 available on Itanium processors.\r
ac644614 6432\r
ee6c452c 6433 @param PalEntryPoint The PAL procedure calls entry point.\r
6434 @param Index The PAL procedure Index number.\r
6435 @param Arg2 The 2nd parameter for PAL procedure calls.\r
6436 @param Arg3 The 3rd parameter for PAL procedure calls.\r
6437 @param Arg4 The 4th parameter for PAL procedure calls.\r
ac644614 6438\r
6439 @return structure returned from the PAL Call procedure, including the status and return value.\r
6440\r
6441**/\r
6442PAL_CALL_RETURN\r
6443EFIAPI\r
6444AsmPalCall (\r
6445 IN UINT64 PalEntryPoint,\r
6446 IN UINT64 Index,\r
6447 IN UINT64 Arg2,\r
6448 IN UINT64 Arg3,\r
6449 IN UINT64 Arg4\r
6450 );\r
fd163050 6451#endif\r
ac644614 6452\r
fd163050 6453#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
1106ffe1 6454///\r
af2dc6a7 6455/// IA32 and x64 Specific Functions.\r
6456/// Byte packed structure for 16-bit Real Mode EFLAGS.\r
1106ffe1 6457///\r
ac644614 6458typedef union {\r
6459 struct {\r
af2dc6a7 6460 UINT32 CF:1; ///< Carry Flag.\r
6461 UINT32 Reserved_0:1; ///< Reserved.\r
6462 UINT32 PF:1; ///< Parity Flag.\r
6463 UINT32 Reserved_1:1; ///< Reserved.\r
6464 UINT32 AF:1; ///< Auxiliary Carry Flag.\r
6465 UINT32 Reserved_2:1; ///< Reserved.\r
6466 UINT32 ZF:1; ///< Zero Flag.\r
6467 UINT32 SF:1; ///< Sign Flag.\r
6468 UINT32 TF:1; ///< Trap Flag.\r
6469 UINT32 IF:1; ///< Interrupt Enable Flag.\r
6470 UINT32 DF:1; ///< Direction Flag.\r
6471 UINT32 OF:1; ///< Overflow Flag.\r
6472 UINT32 IOPL:2; ///< I/O Privilege Level.\r
6473 UINT32 NT:1; ///< Nested Task.\r
6474 UINT32 Reserved_3:1; ///< Reserved.\r
ac644614 6475 } Bits;\r
6476 UINT16 Uint16;\r
6477} IA32_FLAGS16;\r
6478\r
1106ffe1 6479///\r
af2dc6a7 6480/// Byte packed structure for EFLAGS/RFLAGS.\r
6481/// 32-bits on IA-32.\r
6482/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 6483///\r
ac644614 6484typedef union {\r
6485 struct {\r
af2dc6a7 6486 UINT32 CF:1; ///< Carry Flag.\r
6487 UINT32 Reserved_0:1; ///< Reserved.\r
6488 UINT32 PF:1; ///< Parity Flag.\r
6489 UINT32 Reserved_1:1; ///< Reserved.\r
6490 UINT32 AF:1; ///< Auxiliary Carry Flag.\r
6491 UINT32 Reserved_2:1; ///< Reserved.\r
6492 UINT32 ZF:1; ///< Zero Flag.\r
6493 UINT32 SF:1; ///< Sign Flag.\r
6494 UINT32 TF:1; ///< Trap Flag.\r
6495 UINT32 IF:1; ///< Interrupt Enable Flag.\r
6496 UINT32 DF:1; ///< Direction Flag.\r
6497 UINT32 OF:1; ///< Overflow Flag.\r
6498 UINT32 IOPL:2; ///< I/O Privilege Level.\r
6499 UINT32 NT:1; ///< Nested Task.\r
6500 UINT32 Reserved_3:1; ///< Reserved.\r
6501 UINT32 RF:1; ///< Resume Flag.\r
6502 UINT32 VM:1; ///< Virtual 8086 Mode.\r
6503 UINT32 AC:1; ///< Alignment Check.\r
6504 UINT32 VIF:1; ///< Virtual Interrupt Flag.\r
6505 UINT32 VIP:1; ///< Virtual Interrupt Pending.\r
6506 UINT32 ID:1; ///< ID Flag.\r
6507 UINT32 Reserved_4:10; ///< Reserved.\r
ac644614 6508 } Bits;\r
6509 UINTN UintN;\r
6510} IA32_EFLAGS32;\r
6511\r
1106ffe1 6512///\r
af2dc6a7 6513/// Byte packed structure for Control Register 0 (CR0).\r
6514/// 32-bits on IA-32.\r
6515/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 6516///\r
ac644614 6517typedef union {\r
6518 struct {\r
af2dc6a7 6519 UINT32 PE:1; ///< Protection Enable.\r
6520 UINT32 MP:1; ///< Monitor Coprocessor.\r
6521 UINT32 EM:1; ///< Emulation.\r
6522 UINT32 TS:1; ///< Task Switched.\r
6523 UINT32 ET:1; ///< Extension Type.\r
6524 UINT32 NE:1; ///< Numeric Error.\r
6525 UINT32 Reserved_0:10; ///< Reserved.\r
6526 UINT32 WP:1; ///< Write Protect.\r
6527 UINT32 Reserved_1:1; ///< Reserved.\r
6528 UINT32 AM:1; ///< Alignment Mask.\r
6529 UINT32 Reserved_2:10; ///< Reserved.\r
6530 UINT32 NW:1; ///< Mot Write-through.\r
6531 UINT32 CD:1; ///< Cache Disable.\r
6532 UINT32 PG:1; ///< Paging.\r
ac644614 6533 } Bits;\r
6534 UINTN UintN;\r
6535} IA32_CR0;\r
6536\r
1106ffe1 6537///\r
af2dc6a7 6538/// Byte packed structure for Control Register 4 (CR4).\r
6539/// 32-bits on IA-32.\r
6540/// 64-bits on x64. The upper 32-bits on x64 are reserved.\r
1106ffe1 6541///\r
ac644614 6542typedef union {\r
6543 struct {\r
af2dc6a7 6544 UINT32 VME:1; ///< Virtual-8086 Mode Extensions.\r
6545 UINT32 PVI:1; ///< Protected-Mode Virtual Interrupts.\r
6546 UINT32 TSD:1; ///< Time Stamp Disable.\r
6547 UINT32 DE:1; ///< Debugging Extensions.\r
6548 UINT32 PSE:1; ///< Page Size Extensions.\r
6549 UINT32 PAE:1; ///< Physical Address Extension.\r
6550 UINT32 MCE:1; ///< Machine Check Enable.\r
6551 UINT32 PGE:1; ///< Page Global Enable.\r
2a53dabf 6552 UINT32 PCE:1; ///< Performance Monitoring Counter\r
af2dc6a7 6553 ///< Enable.\r
2a53dabf
LG
6554 UINT32 OSFXSR:1; ///< Operating System Support for\r
6555 ///< FXSAVE and FXRSTOR instructions\r
6556 UINT32 OSXMMEXCPT:1; ///< Operating System Support for\r
6557 ///< Unmasked SIMD Floating Point\r
af2dc6a7 6558 ///< Exceptions.\r
6559 UINT32 Reserved_0:2; ///< Reserved.\r
2a53dabf 6560 UINT32 VMXE:1; ///< VMX Enable\r
af2dc6a7 6561 UINT32 Reserved_1:18; ///< Reserved.\r
ac644614 6562 } Bits;\r
6563 UINTN UintN;\r
6564} IA32_CR4;\r
6565\r
6088db38 6566///\r
6567/// Byte packed structure for a segment descriptor in a GDT/LDT.\r
6568///\r
6569typedef union {\r
6570 struct {\r
6571 UINT32 LimitLow:16;\r
6572 UINT32 BaseLow:16;\r
6573 UINT32 BaseMid:8;\r
6574 UINT32 Type:4;\r
6575 UINT32 S:1;\r
6576 UINT32 DPL:2;\r
6577 UINT32 P:1;\r
6578 UINT32 LimitHigh:4;\r
6579 UINT32 AVL:1;\r
6580 UINT32 L:1;\r
6581 UINT32 DB:1;\r
6582 UINT32 G:1;\r
6583 UINT32 BaseHigh:8;\r
6584 } Bits;\r
6585 UINT64 Uint64;\r
6586} IA32_SEGMENT_DESCRIPTOR;\r
6587\r
1106ffe1 6588///\r
af2dc6a7 6589/// Byte packed structure for an IDTR, GDTR, LDTR descriptor.\r
1106ffe1 6590///\r
ac644614 6591#pragma pack (1)\r
6592typedef struct {\r
6593 UINT16 Limit;\r
6594 UINTN Base;\r
6595} IA32_DESCRIPTOR;\r
6596#pragma pack ()\r
6597\r
6598#define IA32_IDT_GATE_TYPE_TASK 0x85\r
6599#define IA32_IDT_GATE_TYPE_INTERRUPT_16 0x86\r
6600#define IA32_IDT_GATE_TYPE_TRAP_16 0x87\r
6601#define IA32_IDT_GATE_TYPE_INTERRUPT_32 0x8E\r
6602#define IA32_IDT_GATE_TYPE_TRAP_32 0x8F\r
6603\r
6f4aad3b 6604\r
6605#if defined (MDE_CPU_IA32)\r
1106ffe1 6606///\r
af2dc6a7 6607/// Byte packed structure for an IA-32 Interrupt Gate Descriptor.\r
1106ffe1 6608///\r
dc317713 6609typedef union {\r
6610 struct {\r
af2dc6a7 6611 UINT32 OffsetLow:16; ///< Offset bits 15..0.\r
6612 UINT32 Selector:16; ///< Selector.\r
6613 UINT32 Reserved_0:8; ///< Reserved.\r
6614 UINT32 GateType:8; ///< Gate Type. See #defines above.\r
6615 UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r
dc317713 6616 } Bits;\r
6617 UINT64 Uint64;\r
6618} IA32_IDT_GATE_DESCRIPTOR;\r
6619\r
6620#endif\r
6621\r
6622#if defined (MDE_CPU_X64)\r
6f4aad3b 6623///\r
af2dc6a7 6624/// Byte packed structure for an x64 Interrupt Gate Descriptor.\r
6f4aad3b 6625///\r
ac644614 6626typedef union {\r
6627 struct {\r
af2dc6a7 6628 UINT32 OffsetLow:16; ///< Offset bits 15..0.\r
6629 UINT32 Selector:16; ///< Selector.\r
6630 UINT32 Reserved_0:8; ///< Reserved.\r
6631 UINT32 GateType:8; ///< Gate Type. See #defines above.\r
6632 UINT32 OffsetHigh:16; ///< Offset bits 31..16.\r
6633 UINT32 OffsetUpper:32; ///< Offset bits 63..32.\r
6634 UINT32 Reserved_1:32; ///< Reserved.\r
ac644614 6635 } Bits;\r
6f4aad3b 6636 struct {\r
6637 UINT64 Uint64;\r
6638 UINT64 Uint64_1;\r
6639 } Uint128; \r
ac644614 6640} IA32_IDT_GATE_DESCRIPTOR;\r
6641\r
dc317713 6642#endif\r
6643\r
1106ffe1 6644///\r
af2dc6a7 6645/// Byte packed structure for an FP/SSE/SSE2 context.\r
1106ffe1 6646///\r
ac644614 6647typedef struct {\r
6648 UINT8 Buffer[512];\r
6649} IA32_FX_BUFFER;\r
6650\r
1106ffe1 6651///\r
af2dc6a7 6652/// Structures for the 16-bit real mode thunks.\r
1106ffe1 6653///\r
ac644614 6654typedef struct {\r
6655 UINT32 Reserved1;\r
6656 UINT32 Reserved2;\r
6657 UINT32 Reserved3;\r
6658 UINT32 Reserved4;\r
6659 UINT8 BL;\r
6660 UINT8 BH;\r
6661 UINT16 Reserved5;\r
6662 UINT8 DL;\r
6663 UINT8 DH;\r
6664 UINT16 Reserved6;\r
6665 UINT8 CL;\r
6666 UINT8 CH;\r
6667 UINT16 Reserved7;\r
6668 UINT8 AL;\r
6669 UINT8 AH;\r
6670 UINT16 Reserved8;\r
6671} IA32_BYTE_REGS;\r
6672\r
6673typedef struct {\r
6674 UINT16 DI;\r
6675 UINT16 Reserved1;\r
6676 UINT16 SI;\r
6677 UINT16 Reserved2;\r
6678 UINT16 BP;\r
6679 UINT16 Reserved3;\r
6680 UINT16 SP;\r
6681 UINT16 Reserved4;\r
6682 UINT16 BX;\r
6683 UINT16 Reserved5;\r
6684 UINT16 DX;\r
6685 UINT16 Reserved6;\r
6686 UINT16 CX;\r
6687 UINT16 Reserved7;\r
6688 UINT16 AX;\r
6689 UINT16 Reserved8;\r
6690} IA32_WORD_REGS;\r
6691\r
6692typedef struct {\r
6693 UINT32 EDI;\r
6694 UINT32 ESI;\r
6695 UINT32 EBP;\r
6696 UINT32 ESP;\r
6697 UINT32 EBX;\r
6698 UINT32 EDX;\r
6699 UINT32 ECX;\r
6700 UINT32 EAX;\r
6701 UINT16 DS;\r
6702 UINT16 ES;\r
6703 UINT16 FS;\r
6704 UINT16 GS;\r
6705 IA32_EFLAGS32 EFLAGS;\r
6706 UINT32 Eip;\r
6707 UINT16 CS;\r
6708 UINT16 SS;\r
6709} IA32_DWORD_REGS;\r
6710\r
6711typedef union {\r
6712 IA32_DWORD_REGS E;\r
6713 IA32_WORD_REGS X;\r
6714 IA32_BYTE_REGS H;\r
6715} IA32_REGISTER_SET;\r
6716\r
1106ffe1 6717///\r
af2dc6a7 6718/// Byte packed structure for an 16-bit real mode thunks.\r
1106ffe1 6719///\r
ac644614 6720typedef struct {\r
6721 IA32_REGISTER_SET *RealModeState;\r
6722 VOID *RealModeBuffer;\r
6723 UINT32 RealModeBufferSize;\r
6724 UINT32 ThunkAttributes;\r
6725} THUNK_CONTEXT;\r
6726\r
6727#define THUNK_ATTRIBUTE_BIG_REAL_MODE 0x00000001\r
6728#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 0x00000002\r
6729#define THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL 0x00000004\r
6730\r
6731/**\r
6732 Retrieves CPUID information.\r
6733\r
6734 Executes the CPUID instruction with EAX set to the value specified by Index.\r
6735 This function always returns Index.\r
6736 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
6737 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
6738 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
6739 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
030cd1a2 6740 This function is only available on IA-32 and x64.\r
ac644614 6741\r
6742 @param Index The 32-bit value to load into EAX prior to invoking the CPUID\r
6743 instruction.\r
af2dc6a7 6744 @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r
ac644614 6745 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 6746 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r
ac644614 6747 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 6748 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r
ac644614 6749 instruction. This is an optional parameter that may be NULL.\r
af2dc6a7 6750 @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r
ac644614 6751 instruction. This is an optional parameter that may be NULL.\r
6752\r
2fe241a2 6753 @return Index.\r
ac644614 6754\r
6755**/\r
6756UINT32\r
6757EFIAPI\r
6758AsmCpuid (\r
6759 IN UINT32 Index,\r
6760 OUT UINT32 *Eax, OPTIONAL\r
6761 OUT UINT32 *Ebx, OPTIONAL\r
6762 OUT UINT32 *Ecx, OPTIONAL\r
6763 OUT UINT32 *Edx OPTIONAL\r
6764 );\r
6765\r
6766\r
6767/**\r
6768 Retrieves CPUID information using an extended leaf identifier.\r
6769\r
6770 Executes the CPUID instruction with EAX set to the value specified by Index\r
6771 and ECX set to the value specified by SubIndex. This function always returns\r
6772 Index. This function is only available on IA-32 and x64.\r
6773\r
6774 If Eax is not NULL, then the value of EAX after CPUID is returned in Eax.\r
6775 If Ebx is not NULL, then the value of EBX after CPUID is returned in Ebx.\r
6776 If Ecx is not NULL, then the value of ECX after CPUID is returned in Ecx.\r
6777 If Edx is not NULL, then the value of EDX after CPUID is returned in Edx.\r
6778\r
6779 @param Index The 32-bit value to load into EAX prior to invoking the\r
6780 CPUID instruction.\r
6781 @param SubIndex The 32-bit value to load into ECX prior to invoking the\r
6782 CPUID instruction.\r
af2dc6a7 6783 @param Eax The pointer to the 32-bit EAX value returned by the CPUID\r
ac644614 6784 instruction. This is an optional parameter that may be\r
6785 NULL.\r
af2dc6a7 6786 @param Ebx The pointer to the 32-bit EBX value returned by the CPUID\r
ac644614 6787 instruction. This is an optional parameter that may be\r
6788 NULL.\r
af2dc6a7 6789 @param Ecx The pointer to the 32-bit ECX value returned by the CPUID\r
ac644614 6790 instruction. This is an optional parameter that may be\r
6791 NULL.\r
af2dc6a7 6792 @param Edx The pointer to the 32-bit EDX value returned by the CPUID\r
ac644614 6793 instruction. This is an optional parameter that may be\r
6794 NULL.\r
6795\r
2fe241a2 6796 @return Index.\r
ac644614 6797\r
6798**/\r
6799UINT32\r
6800EFIAPI\r
6801AsmCpuidEx (\r
6802 IN UINT32 Index,\r
6803 IN UINT32 SubIndex,\r
6804 OUT UINT32 *Eax, OPTIONAL\r
6805 OUT UINT32 *Ebx, OPTIONAL\r
6806 OUT UINT32 *Ecx, OPTIONAL\r
6807 OUT UINT32 *Edx OPTIONAL\r
6808 );\r
6809\r
6810\r
be5f1614 6811/**\r
6812 Set CD bit and clear NW bit of CR0 followed by a WBINVD.\r
6813\r
6814 Disables the caches by setting the CD bit of CR0 to 1, clearing the NW bit of CR0 to 0,\r
6815 and executing a WBINVD instruction. This function is only available on IA-32 and x64.\r
6816\r
6817**/\r
6818VOID\r
6819EFIAPI\r
6820AsmDisableCache (\r
6821 VOID\r
6822 );\r
6823\r
6824\r
6825/**\r
6826 Perform a WBINVD and clear both the CD and NW bits of CR0.\r
6827\r
6828 Enables the caches by executing a WBINVD instruction and then clear both the CD and NW\r
6829 bits of CR0 to 0. This function is only available on IA-32 and x64.\r
6830\r
6831**/\r
6832VOID\r
6833EFIAPI\r
6834AsmEnableCache (\r
6835 VOID\r
6836 );\r
6837\r
6838\r
ac644614 6839/**\r
6840 Returns the lower 32-bits of a Machine Specific Register(MSR).\r
6841\r
6842 Reads and returns the lower 32-bits of the MSR specified by Index.\r
6843 No parameter checking is performed on Index, and some Index values may cause\r
6844 CPU exceptions. The caller must either guarantee that Index is valid, or the\r
6845 caller must set up exception handlers to catch the exceptions. This function\r
030cd1a2 6846 is only available on IA-32 and x64.\r
ac644614 6847\r
6848 @param Index The 32-bit MSR index to read.\r
6849\r
6850 @return The lower 32 bits of the MSR identified by Index.\r
6851\r
6852**/\r
6853UINT32\r
6854EFIAPI\r
6855AsmReadMsr32 (\r
6856 IN UINT32 Index\r
6857 );\r
6858\r
6859\r
6860/**\r
17f695ed 6861 Writes a 32-bit value to a Machine Specific Register(MSR), and returns the value.\r
6862 The upper 32-bits of the MSR are set to zero.\r
ac644614 6863\r
6864 Writes the 32-bit value specified by Value to the MSR specified by Index. The\r
6865 upper 32-bits of the MSR write are set to zero. The 32-bit value written to\r
6866 the MSR is returned. No parameter checking is performed on Index or Value,\r
6867 and some of these may cause CPU exceptions. The caller must either guarantee\r
6868 that Index and Value are valid, or the caller must establish proper exception\r
030cd1a2 6869 handlers. This function is only available on IA-32 and x64.\r
ac644614 6870\r
6871 @param Index The 32-bit MSR index to write.\r
6872 @param Value The 32-bit value to write to the MSR.\r
6873\r
6874 @return Value\r
6875\r
6876**/\r
6877UINT32\r
6878EFIAPI\r
6879AsmWriteMsr32 (\r
6880 IN UINT32 Index,\r
6881 IN UINT32 Value\r
6882 );\r
6883\r
6884\r
6885/**\r
62991af2 6886 Reads a 64-bit MSR, performs a bitwise OR on the lower 32-bits, and\r
ac644614 6887 writes the result back to the 64-bit MSR.\r
6888\r
62991af2 6889 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 6890 between the lower 32-bits of the read result and the value specified by\r
6891 OrData, and writes the result to the 64-bit MSR specified by Index. The lower\r
6892 32-bits of the value written to the MSR is returned. No parameter checking is\r
6893 performed on Index or OrData, and some of these may cause CPU exceptions. The\r
6894 caller must either guarantee that Index and OrData are valid, or the caller\r
6895 must establish proper exception handlers. This function is only available on\r
030cd1a2 6896 IA-32 and x64.\r
ac644614 6897\r
6898 @param Index The 32-bit MSR index to write.\r
6899 @param OrData The value to OR with the read value from the MSR.\r
6900\r
6901 @return The lower 32-bit value written to the MSR.\r
6902\r
6903**/\r
6904UINT32\r
6905EFIAPI\r
6906AsmMsrOr32 (\r
6907 IN UINT32 Index,\r
6908 IN UINT32 OrData\r
6909 );\r
6910\r
6911\r
6912/**\r
6913 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes\r
6914 the result back to the 64-bit MSR.\r
6915\r
6916 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
6917 lower 32-bits of the read result and the value specified by AndData, and\r
6918 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of\r
6919 the value written to the MSR is returned. No parameter checking is performed\r
6920 on Index or AndData, and some of these may cause CPU exceptions. The caller\r
6921 must either guarantee that Index and AndData are valid, or the caller must\r
6922 establish proper exception handlers. This function is only available on IA-32\r
030cd1a2 6923 and x64.\r
ac644614 6924\r
6925 @param Index The 32-bit MSR index to write.\r
6926 @param AndData The value to AND with the read value from the MSR.\r
6927\r
6928 @return The lower 32-bit value written to the MSR.\r
6929\r
6930**/\r
6931UINT32\r
6932EFIAPI\r
6933AsmMsrAnd32 (\r
6934 IN UINT32 Index,\r
6935 IN UINT32 AndData\r
6936 );\r
6937\r
6938\r
6939/**\r
62991af2 6940 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise OR\r
ac644614 6941 on the lower 32-bits, and writes the result back to the 64-bit MSR.\r
6942\r
6943 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
6944 lower 32-bits of the read result and the value specified by AndData\r
62991af2 6945 preserving the upper 32-bits, performs a bitwise OR between the\r
ac644614 6946 result of the AND operation and the value specified by OrData, and writes the\r
6947 result to the 64-bit MSR specified by Address. The lower 32-bits of the value\r
6948 written to the MSR is returned. No parameter checking is performed on Index,\r
6949 AndData, or OrData, and some of these may cause CPU exceptions. The caller\r
6950 must either guarantee that Index, AndData, and OrData are valid, or the\r
6951 caller must establish proper exception handlers. This function is only\r
030cd1a2 6952 available on IA-32 and x64.\r
ac644614 6953\r
6954 @param Index The 32-bit MSR index to write.\r
6955 @param AndData The value to AND with the read value from the MSR.\r
6956 @param OrData The value to OR with the result of the AND operation.\r
6957\r
6958 @return The lower 32-bit value written to the MSR.\r
6959\r
6960**/\r
6961UINT32\r
6962EFIAPI\r
6963AsmMsrAndThenOr32 (\r
6964 IN UINT32 Index,\r
6965 IN UINT32 AndData,\r
6966 IN UINT32 OrData\r
6967 );\r
6968\r
6969\r
6970/**\r
6971 Reads a bit field of an MSR.\r
6972\r
6973 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is\r
6974 specified by the StartBit and the EndBit. The value of the bit field is\r
6975 returned. The caller must either guarantee that Index is valid, or the caller\r
6976 must set up exception handlers to catch the exceptions. This function is only\r
030cd1a2 6977 available on IA-32 and x64.\r
ac644614 6978\r
6979 If StartBit is greater than 31, then ASSERT().\r
6980 If EndBit is greater than 31, then ASSERT().\r
6981 If EndBit is less than StartBit, then ASSERT().\r
6982\r
6983 @param Index The 32-bit MSR index to read.\r
6984 @param StartBit The ordinal of the least significant bit in the bit field.\r
6985 Range 0..31.\r
6986 @param EndBit The ordinal of the most significant bit in the bit field.\r
6987 Range 0..31.\r
6988\r
6989 @return The bit field read from the MSR.\r
6990\r
6991**/\r
6992UINT32\r
6993EFIAPI\r
6994AsmMsrBitFieldRead32 (\r
6995 IN UINT32 Index,\r
6996 IN UINTN StartBit,\r
6997 IN UINTN EndBit\r
6998 );\r
6999\r
7000\r
7001/**\r
7002 Writes a bit field to an MSR.\r
7003\r
2fe241a2 7004 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit\r
ac644614 7005 field is specified by the StartBit and the EndBit. All other bits in the\r
7006 destination MSR are preserved. The lower 32-bits of the MSR written is\r
62991af2 7007 returned. The caller must either guarantee that Index and the data written \r
7008 is valid, or the caller must set up exception handlers to catch the exceptions. \r
7009 This function is only available on IA-32 and x64.\r
ac644614 7010\r
7011 If StartBit is greater than 31, then ASSERT().\r
7012 If EndBit is greater than 31, then ASSERT().\r
7013 If EndBit is less than StartBit, then ASSERT().\r
94952554 7014 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7015\r
7016 @param Index The 32-bit MSR index to write.\r
7017 @param StartBit The ordinal of the least significant bit in the bit field.\r
7018 Range 0..31.\r
7019 @param EndBit The ordinal of the most significant bit in the bit field.\r
7020 Range 0..31.\r
7021 @param Value New value of the bit field.\r
7022\r
7023 @return The lower 32-bit of the value written to the MSR.\r
7024\r
7025**/\r
7026UINT32\r
7027EFIAPI\r
7028AsmMsrBitFieldWrite32 (\r
7029 IN UINT32 Index,\r
7030 IN UINTN StartBit,\r
7031 IN UINTN EndBit,\r
7032 IN UINT32 Value\r
7033 );\r
7034\r
7035\r
7036/**\r
7037 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the\r
7038 result back to the bit field in the 64-bit MSR.\r
7039\r
62991af2 7040 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 7041 between the read result and the value specified by OrData, and writes the\r
7042 result to the 64-bit MSR specified by Index. The lower 32-bits of the value\r
7043 written to the MSR are returned. Extra left bits in OrData are stripped. The\r
7044 caller must either guarantee that Index and the data written is valid, or\r
7045 the caller must set up exception handlers to catch the exceptions. This\r
030cd1a2 7046 function is only available on IA-32 and x64.\r
ac644614 7047\r
7048 If StartBit is greater than 31, then ASSERT().\r
7049 If EndBit is greater than 31, then ASSERT().\r
7050 If EndBit is less than StartBit, then ASSERT().\r
94952554 7051 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7052\r
7053 @param Index The 32-bit MSR index to write.\r
7054 @param StartBit The ordinal of the least significant bit in the bit field.\r
7055 Range 0..31.\r
7056 @param EndBit The ordinal of the most significant bit in the bit field.\r
7057 Range 0..31.\r
7058 @param OrData The value to OR with the read value from the MSR.\r
7059\r
7060 @return The lower 32-bit of the value written to the MSR.\r
7061\r
7062**/\r
7063UINT32\r
7064EFIAPI\r
7065AsmMsrBitFieldOr32 (\r
7066 IN UINT32 Index,\r
7067 IN UINTN StartBit,\r
7068 IN UINTN EndBit,\r
7069 IN UINT32 OrData\r
7070 );\r
7071\r
7072\r
7073/**\r
7074 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
7075 result back to the bit field in the 64-bit MSR.\r
7076\r
7077 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
7078 read result and the value specified by AndData, and writes the result to the\r
7079 64-bit MSR specified by Index. The lower 32-bits of the value written to the\r
7080 MSR are returned. Extra left bits in AndData are stripped. The caller must\r
7081 either guarantee that Index and the data written is valid, or the caller must\r
7082 set up exception handlers to catch the exceptions. This function is only\r
030cd1a2 7083 available on IA-32 and x64.\r
ac644614 7084\r
7085 If StartBit is greater than 31, then ASSERT().\r
7086 If EndBit is greater than 31, then ASSERT().\r
7087 If EndBit is less than StartBit, then ASSERT().\r
94952554 7088 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7089\r
7090 @param Index The 32-bit MSR index to write.\r
7091 @param StartBit The ordinal of the least significant bit in the bit field.\r
7092 Range 0..31.\r
7093 @param EndBit The ordinal of the most significant bit in the bit field.\r
7094 Range 0..31.\r
7095 @param AndData The value to AND with the read value from the MSR.\r
7096\r
7097 @return The lower 32-bit of the value written to the MSR.\r
7098\r
7099**/\r
7100UINT32\r
7101EFIAPI\r
7102AsmMsrBitFieldAnd32 (\r
7103 IN UINT32 Index,\r
7104 IN UINTN StartBit,\r
7105 IN UINTN EndBit,\r
7106 IN UINT32 AndData\r
7107 );\r
7108\r
7109\r
7110/**\r
7111 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
62991af2 7112 bitwise OR, and writes the result back to the bit field in the\r
ac644614 7113 64-bit MSR.\r
7114\r
7115 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a\r
62991af2 7116 bitwise OR between the read result and the value specified by\r
ac644614 7117 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
7118 lower 32-bits of the value written to the MSR are returned. Extra left bits\r
7119 in both AndData and OrData are stripped. The caller must either guarantee\r
7120 that Index and the data written is valid, or the caller must set up exception\r
7121 handlers to catch the exceptions. This function is only available on IA-32\r
030cd1a2 7122 and x64.\r
ac644614 7123\r
7124 If StartBit is greater than 31, then ASSERT().\r
7125 If EndBit is greater than 31, then ASSERT().\r
7126 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
7127 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
7128 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7129\r
7130 @param Index The 32-bit MSR index to write.\r
7131 @param StartBit The ordinal of the least significant bit in the bit field.\r
7132 Range 0..31.\r
7133 @param EndBit The ordinal of the most significant bit in the bit field.\r
7134 Range 0..31.\r
7135 @param AndData The value to AND with the read value from the MSR.\r
7136 @param OrData The value to OR with the result of the AND operation.\r
7137\r
7138 @return The lower 32-bit of the value written to the MSR.\r
7139\r
7140**/\r
7141UINT32\r
7142EFIAPI\r
7143AsmMsrBitFieldAndThenOr32 (\r
7144 IN UINT32 Index,\r
7145 IN UINTN StartBit,\r
7146 IN UINTN EndBit,\r
7147 IN UINT32 AndData,\r
7148 IN UINT32 OrData\r
7149 );\r
7150\r
7151\r
7152/**\r
7153 Returns a 64-bit Machine Specific Register(MSR).\r
7154\r
7155 Reads and returns the 64-bit MSR specified by Index. No parameter checking is\r
7156 performed on Index, and some Index values may cause CPU exceptions. The\r
7157 caller must either guarantee that Index is valid, or the caller must set up\r
7158 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 7159 on IA-32 and x64.\r
ac644614 7160\r
7161 @param Index The 32-bit MSR index to read.\r
7162\r
7163 @return The value of the MSR identified by Index.\r
7164\r
7165**/\r
7166UINT64\r
7167EFIAPI\r
7168AsmReadMsr64 (\r
7169 IN UINT32 Index\r
7170 );\r
7171\r
7172\r
7173/**\r
7174 Writes a 64-bit value to a Machine Specific Register(MSR), and returns the\r
7175 value.\r
7176\r
7177 Writes the 64-bit value specified by Value to the MSR specified by Index. The\r
7178 64-bit value written to the MSR is returned. No parameter checking is\r
7179 performed on Index or Value, and some of these may cause CPU exceptions. The\r
7180 caller must either guarantee that Index and Value are valid, or the caller\r
7181 must establish proper exception handlers. This function is only available on\r
030cd1a2 7182 IA-32 and x64.\r
ac644614 7183\r
7184 @param Index The 32-bit MSR index to write.\r
7185 @param Value The 64-bit value to write to the MSR.\r
7186\r
7187 @return Value\r
7188\r
7189**/\r
7190UINT64\r
7191EFIAPI\r
7192AsmWriteMsr64 (\r
7193 IN UINT32 Index,\r
7194 IN UINT64 Value\r
7195 );\r
7196\r
7197\r
7198/**\r
62991af2 7199 Reads a 64-bit MSR, performs a bitwise OR, and writes the result\r
ac644614 7200 back to the 64-bit MSR.\r
7201\r
62991af2 7202 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 7203 between the read result and the value specified by OrData, and writes the\r
7204 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
7205 returned. No parameter checking is performed on Index or OrData, and some of\r
7206 these may cause CPU exceptions. The caller must either guarantee that Index\r
7207 and OrData are valid, or the caller must establish proper exception handlers.\r
030cd1a2 7208 This function is only available on IA-32 and x64.\r
ac644614 7209\r
7210 @param Index The 32-bit MSR index to write.\r
7211 @param OrData The value to OR with the read value from the MSR.\r
7212\r
7213 @return The value written back to the MSR.\r
7214\r
7215**/\r
7216UINT64\r
7217EFIAPI\r
7218AsmMsrOr64 (\r
7219 IN UINT32 Index,\r
7220 IN UINT64 OrData\r
7221 );\r
7222\r
7223\r
7224/**\r
7225 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the\r
7226 64-bit MSR.\r
7227\r
7228 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
7229 read result and the value specified by OrData, and writes the result to the\r
7230 64-bit MSR specified by Index. The value written to the MSR is returned. No\r
7231 parameter checking is performed on Index or OrData, and some of these may\r
7232 cause CPU exceptions. The caller must either guarantee that Index and OrData\r
7233 are valid, or the caller must establish proper exception handlers. This\r
030cd1a2 7234 function is only available on IA-32 and x64.\r
ac644614 7235\r
7236 @param Index The 32-bit MSR index to write.\r
7237 @param AndData The value to AND with the read value from the MSR.\r
7238\r
7239 @return The value written back to the MSR.\r
7240\r
7241**/\r
7242UINT64\r
7243EFIAPI\r
7244AsmMsrAnd64 (\r
7245 IN UINT32 Index,\r
7246 IN UINT64 AndData\r
7247 );\r
7248\r
7249\r
7250/**\r
62991af2 7251 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise \r
ac644614 7252 OR, and writes the result back to the 64-bit MSR.\r
7253\r
7254 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read\r
62991af2 7255 result and the value specified by AndData, performs a bitwise OR\r
ac644614 7256 between the result of the AND operation and the value specified by OrData,\r
7257 and writes the result to the 64-bit MSR specified by Index. The value written\r
7258 to the MSR is returned. No parameter checking is performed on Index, AndData,\r
7259 or OrData, and some of these may cause CPU exceptions. The caller must either\r
7260 guarantee that Index, AndData, and OrData are valid, or the caller must\r
7261 establish proper exception handlers. This function is only available on IA-32\r
030cd1a2 7262 and x64.\r
ac644614 7263\r
7264 @param Index The 32-bit MSR index to write.\r
7265 @param AndData The value to AND with the read value from the MSR.\r
7266 @param OrData The value to OR with the result of the AND operation.\r
7267\r
7268 @return The value written back to the MSR.\r
7269\r
7270**/\r
7271UINT64\r
7272EFIAPI\r
7273AsmMsrAndThenOr64 (\r
7274 IN UINT32 Index,\r
7275 IN UINT64 AndData,\r
7276 IN UINT64 OrData\r
7277 );\r
7278\r
7279\r
7280/**\r
7281 Reads a bit field of an MSR.\r
7282\r
7283 Reads the bit field in the 64-bit MSR. The bit field is specified by the\r
7284 StartBit and the EndBit. The value of the bit field is returned. The caller\r
7285 must either guarantee that Index is valid, or the caller must set up\r
7286 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 7287 on IA-32 and x64.\r
ac644614 7288\r
7289 If StartBit is greater than 63, then ASSERT().\r
7290 If EndBit is greater than 63, then ASSERT().\r
7291 If EndBit is less than StartBit, then ASSERT().\r
7292\r
7293 @param Index The 32-bit MSR index to read.\r
7294 @param StartBit The ordinal of the least significant bit in the bit field.\r
7295 Range 0..63.\r
7296 @param EndBit The ordinal of the most significant bit in the bit field.\r
7297 Range 0..63.\r
7298\r
7299 @return The value read from the MSR.\r
7300\r
7301**/\r
7302UINT64\r
7303EFIAPI\r
7304AsmMsrBitFieldRead64 (\r
7305 IN UINT32 Index,\r
7306 IN UINTN StartBit,\r
7307 IN UINTN EndBit\r
7308 );\r
7309\r
7310\r
7311/**\r
7312 Writes a bit field to an MSR.\r
7313\r
7314 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by\r
7315 the StartBit and the EndBit. All other bits in the destination MSR are\r
62991af2 7316 preserved. The MSR written is returned. The caller must either guarantee \r
7317 that Index and the data written is valid, or the caller must set up exception \r
7318 handlers to catch the exceptions. This function is only available on IA-32 and x64.\r
ac644614 7319\r
7320 If StartBit is greater than 63, then ASSERT().\r
7321 If EndBit is greater than 63, then ASSERT().\r
7322 If EndBit is less than StartBit, then ASSERT().\r
94952554 7323 If Value is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7324\r
7325 @param Index The 32-bit MSR index to write.\r
7326 @param StartBit The ordinal of the least significant bit in the bit field.\r
7327 Range 0..63.\r
7328 @param EndBit The ordinal of the most significant bit in the bit field.\r
7329 Range 0..63.\r
7330 @param Value New value of the bit field.\r
7331\r
7332 @return The value written back to the MSR.\r
7333\r
7334**/\r
7335UINT64\r
7336EFIAPI\r
7337AsmMsrBitFieldWrite64 (\r
7338 IN UINT32 Index,\r
7339 IN UINTN StartBit,\r
7340 IN UINTN EndBit,\r
7341 IN UINT64 Value\r
7342 );\r
7343\r
7344\r
7345/**\r
62991af2 7346 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and\r
ac644614 7347 writes the result back to the bit field in the 64-bit MSR.\r
7348\r
62991af2 7349 Reads the 64-bit MSR specified by Index, performs a bitwise OR\r
ac644614 7350 between the read result and the value specified by OrData, and writes the\r
7351 result to the 64-bit MSR specified by Index. The value written to the MSR is\r
7352 returned. Extra left bits in OrData are stripped. The caller must either\r
7353 guarantee that Index and the data written is valid, or the caller must set up\r
7354 exception handlers to catch the exceptions. This function is only available\r
030cd1a2 7355 on IA-32 and x64.\r
ac644614 7356\r
7357 If StartBit is greater than 63, then ASSERT().\r
7358 If EndBit is greater than 63, then ASSERT().\r
7359 If EndBit is less than StartBit, then ASSERT().\r
94952554 7360 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7361\r
7362 @param Index The 32-bit MSR index to write.\r
7363 @param StartBit The ordinal of the least significant bit in the bit field.\r
7364 Range 0..63.\r
7365 @param EndBit The ordinal of the most significant bit in the bit field.\r
7366 Range 0..63.\r
7367 @param OrData The value to OR with the read value from the bit field.\r
7368\r
7369 @return The value written back to the MSR.\r
7370\r
7371**/\r
7372UINT64\r
7373EFIAPI\r
7374AsmMsrBitFieldOr64 (\r
7375 IN UINT32 Index,\r
7376 IN UINTN StartBit,\r
7377 IN UINTN EndBit,\r
7378 IN UINT64 OrData\r
7379 );\r
7380\r
7381\r
7382/**\r
7383 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the\r
7384 result back to the bit field in the 64-bit MSR.\r
7385\r
7386 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the\r
7387 read result and the value specified by AndData, and writes the result to the\r
7388 64-bit MSR specified by Index. The value written to the MSR is returned.\r
7389 Extra left bits in AndData are stripped. The caller must either guarantee\r
7390 that Index and the data written is valid, or the caller must set up exception\r
7391 handlers to catch the exceptions. This function is only available on IA-32\r
030cd1a2 7392 and x64.\r
ac644614 7393\r
7394 If StartBit is greater than 63, then ASSERT().\r
7395 If EndBit is greater than 63, then ASSERT().\r
7396 If EndBit is less than StartBit, then ASSERT().\r
94952554 7397 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7398\r
7399 @param Index The 32-bit MSR index to write.\r
7400 @param StartBit The ordinal of the least significant bit in the bit field.\r
7401 Range 0..63.\r
7402 @param EndBit The ordinal of the most significant bit in the bit field.\r
7403 Range 0..63.\r
7404 @param AndData The value to AND with the read value from the bit field.\r
7405\r
7406 @return The value written back to the MSR.\r
7407\r
7408**/\r
7409UINT64\r
7410EFIAPI\r
7411AsmMsrBitFieldAnd64 (\r
7412 IN UINT32 Index,\r
7413 IN UINTN StartBit,\r
7414 IN UINTN EndBit,\r
7415 IN UINT64 AndData\r
7416 );\r
7417\r
7418\r
7419/**\r
7420 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a\r
62991af2 7421 bitwise OR, and writes the result back to the bit field in the\r
ac644614 7422 64-bit MSR.\r
7423\r
7424 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by\r
62991af2 7425 a bitwise OR between the read result and the value specified by\r
ac644614 7426 AndData, and writes the result to the 64-bit MSR specified by Index. The\r
7427 value written to the MSR is returned. Extra left bits in both AndData and\r
7428 OrData are stripped. The caller must either guarantee that Index and the data\r
7429 written is valid, or the caller must set up exception handlers to catch the\r
030cd1a2 7430 exceptions. This function is only available on IA-32 and x64.\r
ac644614 7431\r
7432 If StartBit is greater than 63, then ASSERT().\r
7433 If EndBit is greater than 63, then ASSERT().\r
7434 If EndBit is less than StartBit, then ASSERT().\r
94952554
LG
7435 If AndData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
7436 If OrData is larger than the bitmask value range specified by StartBit and EndBit, then ASSERT().\r
ac644614 7437\r
7438 @param Index The 32-bit MSR index to write.\r
7439 @param StartBit The ordinal of the least significant bit in the bit field.\r
7440 Range 0..63.\r
7441 @param EndBit The ordinal of the most significant bit in the bit field.\r
7442 Range 0..63.\r
7443 @param AndData The value to AND with the read value from the bit field.\r
7444 @param OrData The value to OR with the result of the AND operation.\r
7445\r
7446 @return The value written back to the MSR.\r
7447\r
7448**/\r
7449UINT64\r
7450EFIAPI\r
7451AsmMsrBitFieldAndThenOr64 (\r
7452 IN UINT32 Index,\r
7453 IN UINTN StartBit,\r
7454 IN UINTN EndBit,\r
7455 IN UINT64 AndData,\r
7456 IN UINT64 OrData\r
7457 );\r
7458\r
7459\r
7460/**\r
7461 Reads the current value of the EFLAGS register.\r
7462\r
7463 Reads and returns the current value of the EFLAGS register. This function is\r
030cd1a2 7464 only available on IA-32 and x64. This returns a 32-bit value on IA-32 and a\r
7465 64-bit value on x64.\r
ac644614 7466\r
030cd1a2 7467 @return EFLAGS on IA-32 or RFLAGS on x64.\r
ac644614 7468\r
7469**/\r
7470UINTN\r
7471EFIAPI\r
7472AsmReadEflags (\r
7473 VOID\r
7474 );\r
7475\r
7476\r
7477/**\r
7478 Reads the current value of the Control Register 0 (CR0).\r
7479\r
7480 Reads and returns the current value of CR0. This function is only available\r
030cd1a2 7481 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7482 x64.\r
ac644614 7483\r
7484 @return The value of the Control Register 0 (CR0).\r
7485\r
7486**/\r
7487UINTN\r
7488EFIAPI\r
7489AsmReadCr0 (\r
7490 VOID\r
7491 );\r
7492\r
7493\r
7494/**\r
7495 Reads the current value of the Control Register 2 (CR2).\r
7496\r
7497 Reads and returns the current value of CR2. This function is only available\r
030cd1a2 7498 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7499 x64.\r
ac644614 7500\r
7501 @return The value of the Control Register 2 (CR2).\r
7502\r
7503**/\r
7504UINTN\r
7505EFIAPI\r
7506AsmReadCr2 (\r
7507 VOID\r
7508 );\r
7509\r
7510\r
7511/**\r
7512 Reads the current value of the Control Register 3 (CR3).\r
7513\r
7514 Reads and returns the current value of CR3. This function is only available\r
030cd1a2 7515 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7516 x64.\r
ac644614 7517\r
7518 @return The value of the Control Register 3 (CR3).\r
7519\r
7520**/\r
7521UINTN\r
7522EFIAPI\r
7523AsmReadCr3 (\r
7524 VOID\r
7525 );\r
7526\r
7527\r
7528/**\r
7529 Reads the current value of the Control Register 4 (CR4).\r
7530\r
7531 Reads and returns the current value of CR4. This function is only available\r
030cd1a2 7532 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7533 x64.\r
ac644614 7534\r
7535 @return The value of the Control Register 4 (CR4).\r
7536\r
7537**/\r
7538UINTN\r
7539EFIAPI\r
7540AsmReadCr4 (\r
7541 VOID\r
7542 );\r
7543\r
7544\r
7545/**\r
7546 Writes a value to Control Register 0 (CR0).\r
7547\r
7548 Writes and returns a new value to CR0. This function is only available on\r
030cd1a2 7549 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7550\r
7551 @param Cr0 The value to write to CR0.\r
7552\r
7553 @return The value written to CR0.\r
7554\r
7555**/\r
7556UINTN\r
7557EFIAPI\r
7558AsmWriteCr0 (\r
7559 UINTN Cr0\r
7560 );\r
7561\r
7562\r
7563/**\r
7564 Writes a value to Control Register 2 (CR2).\r
7565\r
7566 Writes and returns a new value to CR2. This function is only available on\r
030cd1a2 7567 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7568\r
7569 @param Cr2 The value to write to CR2.\r
7570\r
7571 @return The value written to CR2.\r
7572\r
7573**/\r
7574UINTN\r
7575EFIAPI\r
7576AsmWriteCr2 (\r
7577 UINTN Cr2\r
7578 );\r
7579\r
7580\r
7581/**\r
7582 Writes a value to Control Register 3 (CR3).\r
7583\r
7584 Writes and returns a new value to CR3. This function is only available on\r
030cd1a2 7585 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7586\r
7587 @param Cr3 The value to write to CR3.\r
7588\r
7589 @return The value written to CR3.\r
7590\r
7591**/\r
7592UINTN\r
7593EFIAPI\r
7594AsmWriteCr3 (\r
7595 UINTN Cr3\r
7596 );\r
7597\r
7598\r
7599/**\r
7600 Writes a value to Control Register 4 (CR4).\r
7601\r
7602 Writes and returns a new value to CR4. This function is only available on\r
030cd1a2 7603 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7604\r
7605 @param Cr4 The value to write to CR4.\r
7606\r
7607 @return The value written to CR4.\r
7608\r
7609**/\r
7610UINTN\r
7611EFIAPI\r
7612AsmWriteCr4 (\r
7613 UINTN Cr4\r
7614 );\r
7615\r
7616\r
7617/**\r
7618 Reads the current value of Debug Register 0 (DR0).\r
7619\r
7620 Reads and returns the current value of DR0. This function is only available\r
030cd1a2 7621 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7622 x64.\r
ac644614 7623\r
7624 @return The value of Debug Register 0 (DR0).\r
7625\r
7626**/\r
7627UINTN\r
7628EFIAPI\r
7629AsmReadDr0 (\r
7630 VOID\r
7631 );\r
7632\r
7633\r
7634/**\r
7635 Reads the current value of Debug Register 1 (DR1).\r
7636\r
7637 Reads and returns the current value of DR1. This function is only available\r
030cd1a2 7638 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7639 x64.\r
ac644614 7640\r
7641 @return The value of Debug Register 1 (DR1).\r
7642\r
7643**/\r
7644UINTN\r
7645EFIAPI\r
7646AsmReadDr1 (\r
7647 VOID\r
7648 );\r
7649\r
7650\r
7651/**\r
7652 Reads the current value of Debug Register 2 (DR2).\r
7653\r
7654 Reads and returns the current value of DR2. This function is only available\r
030cd1a2 7655 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7656 x64.\r
ac644614 7657\r
7658 @return The value of Debug Register 2 (DR2).\r
7659\r
7660**/\r
7661UINTN\r
7662EFIAPI\r
7663AsmReadDr2 (\r
7664 VOID\r
7665 );\r
7666\r
7667\r
7668/**\r
7669 Reads the current value of Debug Register 3 (DR3).\r
7670\r
7671 Reads and returns the current value of DR3. This function is only available\r
030cd1a2 7672 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7673 x64.\r
ac644614 7674\r
7675 @return The value of Debug Register 3 (DR3).\r
7676\r
7677**/\r
7678UINTN\r
7679EFIAPI\r
7680AsmReadDr3 (\r
7681 VOID\r
7682 );\r
7683\r
7684\r
7685/**\r
7686 Reads the current value of Debug Register 4 (DR4).\r
7687\r
7688 Reads and returns the current value of DR4. This function is only available\r
030cd1a2 7689 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7690 x64.\r
ac644614 7691\r
7692 @return The value of Debug Register 4 (DR4).\r
7693\r
7694**/\r
7695UINTN\r
7696EFIAPI\r
7697AsmReadDr4 (\r
7698 VOID\r
7699 );\r
7700\r
7701\r
7702/**\r
7703 Reads the current value of Debug Register 5 (DR5).\r
7704\r
7705 Reads and returns the current value of DR5. This function is only available\r
030cd1a2 7706 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7707 x64.\r
ac644614 7708\r
7709 @return The value of Debug Register 5 (DR5).\r
7710\r
7711**/\r
7712UINTN\r
7713EFIAPI\r
7714AsmReadDr5 (\r
7715 VOID\r
7716 );\r
7717\r
7718\r
7719/**\r
7720 Reads the current value of Debug Register 6 (DR6).\r
7721\r
7722 Reads and returns the current value of DR6. This function is only available\r
030cd1a2 7723 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7724 x64.\r
ac644614 7725\r
7726 @return The value of Debug Register 6 (DR6).\r
7727\r
7728**/\r
7729UINTN\r
7730EFIAPI\r
7731AsmReadDr6 (\r
7732 VOID\r
7733 );\r
7734\r
7735\r
7736/**\r
7737 Reads the current value of Debug Register 7 (DR7).\r
7738\r
7739 Reads and returns the current value of DR7. This function is only available\r
030cd1a2 7740 on IA-32 and x64. This returns a 32-bit value on IA-32 and a 64-bit value on\r
7741 x64.\r
ac644614 7742\r
7743 @return The value of Debug Register 7 (DR7).\r
7744\r
7745**/\r
7746UINTN\r
7747EFIAPI\r
7748AsmReadDr7 (\r
7749 VOID\r
7750 );\r
7751\r
7752\r
7753/**\r
7754 Writes a value to Debug Register 0 (DR0).\r
7755\r
7756 Writes and returns a new value to DR0. This function is only available on\r
030cd1a2 7757 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7758\r
7759 @param Dr0 The value to write to Dr0.\r
7760\r
7761 @return The value written to Debug Register 0 (DR0).\r
7762\r
7763**/\r
7764UINTN\r
7765EFIAPI\r
7766AsmWriteDr0 (\r
7767 UINTN Dr0\r
7768 );\r
7769\r
7770\r
7771/**\r
7772 Writes a value to Debug Register 1 (DR1).\r
7773\r
7774 Writes and returns a new value to DR1. This function is only available on\r
030cd1a2 7775 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7776\r
7777 @param Dr1 The value to write to Dr1.\r
7778\r
7779 @return The value written to Debug Register 1 (DR1).\r
7780\r
7781**/\r
7782UINTN\r
7783EFIAPI\r
7784AsmWriteDr1 (\r
7785 UINTN Dr1\r
7786 );\r
7787\r
7788\r
7789/**\r
7790 Writes a value to Debug Register 2 (DR2).\r
7791\r
7792 Writes and returns a new value to DR2. This function is only available on\r
030cd1a2 7793 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7794\r
7795 @param Dr2 The value to write to Dr2.\r
7796\r
7797 @return The value written to Debug Register 2 (DR2).\r
7798\r
7799**/\r
7800UINTN\r
7801EFIAPI\r
7802AsmWriteDr2 (\r
7803 UINTN Dr2\r
7804 );\r
7805\r
7806\r
7807/**\r
7808 Writes a value to Debug Register 3 (DR3).\r
7809\r
7810 Writes and returns a new value to DR3. This function is only available on\r
030cd1a2 7811 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7812\r
7813 @param Dr3 The value to write to Dr3.\r
7814\r
7815 @return The value written to Debug Register 3 (DR3).\r
7816\r
7817**/\r
7818UINTN\r
7819EFIAPI\r
7820AsmWriteDr3 (\r
7821 UINTN Dr3\r
7822 );\r
7823\r
7824\r
7825/**\r
7826 Writes a value to Debug Register 4 (DR4).\r
7827\r
7828 Writes and returns a new value to DR4. This function is only available on\r
030cd1a2 7829 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7830\r
7831 @param Dr4 The value to write to Dr4.\r
7832\r
7833 @return The value written to Debug Register 4 (DR4).\r
7834\r
7835**/\r
7836UINTN\r
7837EFIAPI\r
7838AsmWriteDr4 (\r
7839 UINTN Dr4\r
7840 );\r
7841\r
7842\r
7843/**\r
7844 Writes a value to Debug Register 5 (DR5).\r
7845\r
7846 Writes and returns a new value to DR5. This function is only available on\r
030cd1a2 7847 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7848\r
7849 @param Dr5 The value to write to Dr5.\r
7850\r
7851 @return The value written to Debug Register 5 (DR5).\r
7852\r
7853**/\r
7854UINTN\r
7855EFIAPI\r
7856AsmWriteDr5 (\r
7857 UINTN Dr5\r
7858 );\r
7859\r
7860\r
7861/**\r
7862 Writes a value to Debug Register 6 (DR6).\r
7863\r
7864 Writes and returns a new value to DR6. This function is only available on\r
030cd1a2 7865 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7866\r
7867 @param Dr6 The value to write to Dr6.\r
7868\r
7869 @return The value written to Debug Register 6 (DR6).\r
7870\r
7871**/\r
7872UINTN\r
7873EFIAPI\r
7874AsmWriteDr6 (\r
7875 UINTN Dr6\r
7876 );\r
7877\r
7878\r
7879/**\r
7880 Writes a value to Debug Register 7 (DR7).\r
7881\r
7882 Writes and returns a new value to DR7. This function is only available on\r
030cd1a2 7883 IA-32 and x64. This writes a 32-bit value on IA-32 and a 64-bit value on x64.\r
ac644614 7884\r
7885 @param Dr7 The value to write to Dr7.\r
7886\r
7887 @return The value written to Debug Register 7 (DR7).\r
7888\r
7889**/\r
7890UINTN\r
7891EFIAPI\r
7892AsmWriteDr7 (\r
7893 UINTN Dr7\r
7894 );\r
7895\r
7896\r
7897/**\r
7898 Reads the current value of Code Segment Register (CS).\r
7899\r
7900 Reads and returns the current value of CS. This function is only available on\r
030cd1a2 7901 IA-32 and x64.\r
ac644614 7902\r
7903 @return The current value of CS.\r
7904\r
7905**/\r
7906UINT16\r
7907EFIAPI\r
7908AsmReadCs (\r
7909 VOID\r
7910 );\r
7911\r
7912\r
7913/**\r
7914 Reads the current value of Data Segment Register (DS).\r
7915\r
7916 Reads and returns the current value of DS. This function is only available on\r
030cd1a2 7917 IA-32 and x64.\r
ac644614 7918\r
7919 @return The current value of DS.\r
7920\r
7921**/\r
7922UINT16\r
7923EFIAPI\r
7924AsmReadDs (\r
7925 VOID\r
7926 );\r
7927\r
7928\r
7929/**\r
7930 Reads the current value of Extra Segment Register (ES).\r
7931\r
7932 Reads and returns the current value of ES. This function is only available on\r
030cd1a2 7933 IA-32 and x64.\r
ac644614 7934\r
7935 @return The current value of ES.\r
7936\r
7937**/\r
7938UINT16\r
7939EFIAPI\r
7940AsmReadEs (\r
7941 VOID\r
7942 );\r
7943\r
7944\r
7945/**\r
7946 Reads the current value of FS Data Segment Register (FS).\r
7947\r
7948 Reads and returns the current value of FS. This function is only available on\r
030cd1a2 7949 IA-32 and x64.\r
ac644614 7950\r
7951 @return The current value of FS.\r
7952\r
7953**/\r
7954UINT16\r
7955EFIAPI\r
7956AsmReadFs (\r
7957 VOID\r
7958 );\r
7959\r
7960\r
7961/**\r
7962 Reads the current value of GS Data Segment Register (GS).\r
7963\r
7964 Reads and returns the current value of GS. This function is only available on\r
030cd1a2 7965 IA-32 and x64.\r
ac644614 7966\r
7967 @return The current value of GS.\r
7968\r
7969**/\r
7970UINT16\r
7971EFIAPI\r
7972AsmReadGs (\r
7973 VOID\r
7974 );\r
7975\r
7976\r
7977/**\r
7978 Reads the current value of Stack Segment Register (SS).\r
7979\r
7980 Reads and returns the current value of SS. This function is only available on\r
030cd1a2 7981 IA-32 and x64.\r
ac644614 7982\r
7983 @return The current value of SS.\r
7984\r
7985**/\r
7986UINT16\r
7987EFIAPI\r
7988AsmReadSs (\r
7989 VOID\r
7990 );\r
7991\r
7992\r
7993/**\r
7994 Reads the current value of Task Register (TR).\r
7995\r
7996 Reads and returns the current value of TR. This function is only available on\r
030cd1a2 7997 IA-32 and x64.\r
ac644614 7998\r
7999 @return The current value of TR.\r
8000\r
8001**/\r
8002UINT16\r
8003EFIAPI\r
8004AsmReadTr (\r
8005 VOID\r
8006 );\r
8007\r
8008\r
8009/**\r
8010 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
8011\r
8012 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
030cd1a2 8013 function is only available on IA-32 and x64.\r
ac644614 8014\r
8015 If Gdtr is NULL, then ASSERT().\r
8016\r
af2dc6a7 8017 @param Gdtr The pointer to a GDTR descriptor.\r
ac644614 8018\r
8019**/\r
8020VOID\r
8021EFIAPI\r
8022AsmReadGdtr (\r
8023 OUT IA32_DESCRIPTOR *Gdtr\r
8024 );\r
8025\r
8026\r
8027/**\r
8028 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
8029\r
8030 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
030cd1a2 8031 only available on IA-32 and x64.\r
ac644614 8032\r
8033 If Gdtr is NULL, then ASSERT().\r
8034\r
af2dc6a7 8035 @param Gdtr The pointer to a GDTR descriptor.\r
ac644614 8036\r
8037**/\r
8038VOID\r
8039EFIAPI\r
8040AsmWriteGdtr (\r
8041 IN CONST IA32_DESCRIPTOR *Gdtr\r
8042 );\r
8043\r
8044\r
8045/**\r
17f695ed 8046 Reads the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
ac644614 8047\r
8048 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
030cd1a2 8049 function is only available on IA-32 and x64.\r
ac644614 8050\r
8051 If Idtr is NULL, then ASSERT().\r
8052\r
af2dc6a7 8053 @param Idtr The pointer to a IDTR descriptor.\r
ac644614 8054\r
8055**/\r
8056VOID\r
8057EFIAPI\r
8058AsmReadIdtr (\r
8059 OUT IA32_DESCRIPTOR *Idtr\r
8060 );\r
8061\r
8062\r
8063/**\r
17f695ed 8064 Writes the current Interrupt Descriptor Table Register(IDTR) descriptor.\r
ac644614 8065\r
8066 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
030cd1a2 8067 only available on IA-32 and x64.\r
ac644614 8068\r
8069 If Idtr is NULL, then ASSERT().\r
8070\r
af2dc6a7 8071 @param Idtr The pointer to a IDTR descriptor.\r
ac644614 8072\r
8073**/\r
8074VOID\r
8075EFIAPI\r
8076AsmWriteIdtr (\r
8077 IN CONST IA32_DESCRIPTOR *Idtr\r
8078 );\r
8079\r
8080\r
8081/**\r
8082 Reads the current Local Descriptor Table Register(LDTR) selector.\r
8083\r
8084 Reads and returns the current 16-bit LDTR descriptor value. This function is\r
030cd1a2 8085 only available on IA-32 and x64.\r
ac644614 8086\r
8087 @return The current selector of LDT.\r
8088\r
8089**/\r
8090UINT16\r
8091EFIAPI\r
8092AsmReadLdtr (\r
8093 VOID\r
8094 );\r
8095\r
8096\r
8097/**\r
17f695ed 8098 Writes the current Local Descriptor Table Register (LDTR) selector.\r
ac644614 8099\r
8100 Writes and the current LDTR descriptor specified by Ldtr. This function is\r
030cd1a2 8101 only available on IA-32 and x64.\r
ac644614 8102\r
8103 @param Ldtr 16-bit LDTR selector value.\r
8104\r
8105**/\r
8106VOID\r
8107EFIAPI\r
8108AsmWriteLdtr (\r
8109 IN UINT16 Ldtr\r
8110 );\r
8111\r
8112\r
8113/**\r
8114 Save the current floating point/SSE/SSE2 context to a buffer.\r
8115\r
8116 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
8117 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
030cd1a2 8118 available on IA-32 and x64.\r
ac644614 8119\r
8120 If Buffer is NULL, then ASSERT().\r
8121 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
8122\r
af2dc6a7 8123 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
ac644614 8124\r
8125**/\r
8126VOID\r
8127EFIAPI\r
8128AsmFxSave (\r
8129 OUT IA32_FX_BUFFER *Buffer\r
8130 );\r
8131\r
8132\r
8133/**\r
8134 Restores the current floating point/SSE/SSE2 context from a buffer.\r
8135\r
8136 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
8137 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
030cd1a2 8138 only available on IA-32 and x64.\r
ac644614 8139\r
8140 If Buffer is NULL, then ASSERT().\r
8141 If Buffer is not aligned on a 16-byte boundary, then ASSERT().\r
8142 If Buffer was not saved with AsmFxSave(), then ASSERT().\r
8143\r
af2dc6a7 8144 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
ac644614 8145\r
8146**/\r
8147VOID\r
8148EFIAPI\r
8149AsmFxRestore (\r
8150 IN CONST IA32_FX_BUFFER *Buffer\r
8151 );\r
8152\r
8153\r
8154/**\r
8155 Reads the current value of 64-bit MMX Register #0 (MM0).\r
8156\r
8157 Reads and returns the current value of MM0. This function is only available\r
030cd1a2 8158 on IA-32 and x64.\r
ac644614 8159\r
8160 @return The current value of MM0.\r
8161\r
8162**/\r
8163UINT64\r
8164EFIAPI\r
8165AsmReadMm0 (\r
8166 VOID\r
8167 );\r
8168\r
8169\r
8170/**\r
8171 Reads the current value of 64-bit MMX Register #1 (MM1).\r
8172\r
8173 Reads and returns the current value of MM1. This function is only available\r
030cd1a2 8174 on IA-32 and x64.\r
ac644614 8175\r
8176 @return The current value of MM1.\r
8177\r
8178**/\r
8179UINT64\r
8180EFIAPI\r
8181AsmReadMm1 (\r
8182 VOID\r
8183 );\r
8184\r
8185\r
8186/**\r
8187 Reads the current value of 64-bit MMX Register #2 (MM2).\r
8188\r
8189 Reads and returns the current value of MM2. This function is only available\r
030cd1a2 8190 on IA-32 and x64.\r
ac644614 8191\r
8192 @return The current value of MM2.\r
8193\r
8194**/\r
8195UINT64\r
8196EFIAPI\r
8197AsmReadMm2 (\r
8198 VOID\r
8199 );\r
8200\r
8201\r
8202/**\r
8203 Reads the current value of 64-bit MMX Register #3 (MM3).\r
8204\r
8205 Reads and returns the current value of MM3. This function is only available\r
030cd1a2 8206 on IA-32 and x64.\r
ac644614 8207\r
8208 @return The current value of MM3.\r
8209\r
8210**/\r
8211UINT64\r
8212EFIAPI\r
8213AsmReadMm3 (\r
8214 VOID\r
8215 );\r
8216\r
8217\r
8218/**\r
8219 Reads the current value of 64-bit MMX Register #4 (MM4).\r
8220\r
8221 Reads and returns the current value of MM4. This function is only available\r
030cd1a2 8222 on IA-32 and x64.\r
ac644614 8223\r
8224 @return The current value of MM4.\r
8225\r
8226**/\r
8227UINT64\r
8228EFIAPI\r
8229AsmReadMm4 (\r
8230 VOID\r
8231 );\r
8232\r
8233\r
8234/**\r
8235 Reads the current value of 64-bit MMX Register #5 (MM5).\r
8236\r
8237 Reads and returns the current value of MM5. This function is only available\r
030cd1a2 8238 on IA-32 and x64.\r
ac644614 8239\r
8240 @return The current value of MM5.\r
8241\r
8242**/\r
8243UINT64\r
8244EFIAPI\r
8245AsmReadMm5 (\r
8246 VOID\r
8247 );\r
8248\r
8249\r
8250/**\r
8251 Reads the current value of 64-bit MMX Register #6 (MM6).\r
8252\r
8253 Reads and returns the current value of MM6. This function is only available\r
030cd1a2 8254 on IA-32 and x64.\r
ac644614 8255\r
8256 @return The current value of MM6.\r
8257\r
8258**/\r
8259UINT64\r
8260EFIAPI\r
8261AsmReadMm6 (\r
8262 VOID\r
8263 );\r
8264\r
8265\r
8266/**\r
8267 Reads the current value of 64-bit MMX Register #7 (MM7).\r
8268\r
8269 Reads and returns the current value of MM7. This function is only available\r
030cd1a2 8270 on IA-32 and x64.\r
ac644614 8271\r
8272 @return The current value of MM7.\r
8273\r
8274**/\r
8275UINT64\r
8276EFIAPI\r
8277AsmReadMm7 (\r
8278 VOID\r
8279 );\r
8280\r
8281\r
8282/**\r
8283 Writes the current value of 64-bit MMX Register #0 (MM0).\r
8284\r
8285 Writes the current value of MM0. This function is only available on IA32 and\r
030cd1a2 8286 x64.\r
ac644614 8287\r
8288 @param Value The 64-bit value to write to MM0.\r
8289\r
8290**/\r
8291VOID\r
8292EFIAPI\r
8293AsmWriteMm0 (\r
8294 IN UINT64 Value\r
8295 );\r
8296\r
8297\r
8298/**\r
8299 Writes the current value of 64-bit MMX Register #1 (MM1).\r
8300\r
8301 Writes the current value of MM1. This function is only available on IA32 and\r
030cd1a2 8302 x64.\r
ac644614 8303\r
8304 @param Value The 64-bit value to write to MM1.\r
8305\r
8306**/\r
8307VOID\r
8308EFIAPI\r
8309AsmWriteMm1 (\r
8310 IN UINT64 Value\r
8311 );\r
8312\r
8313\r
8314/**\r
8315 Writes the current value of 64-bit MMX Register #2 (MM2).\r
8316\r
8317 Writes the current value of MM2. This function is only available on IA32 and\r
030cd1a2 8318 x64.\r
ac644614 8319\r
8320 @param Value The 64-bit value to write to MM2.\r
8321\r
8322**/\r
8323VOID\r
8324EFIAPI\r
8325AsmWriteMm2 (\r
8326 IN UINT64 Value\r
8327 );\r
8328\r
8329\r
8330/**\r
8331 Writes the current value of 64-bit MMX Register #3 (MM3).\r
8332\r
8333 Writes the current value of MM3. This function is only available on IA32 and\r
030cd1a2 8334 x64.\r
ac644614 8335\r
8336 @param Value The 64-bit value to write to MM3.\r
8337\r
8338**/\r
8339VOID\r
8340EFIAPI\r
8341AsmWriteMm3 (\r
8342 IN UINT64 Value\r
8343 );\r
8344\r
8345\r
8346/**\r
8347 Writes the current value of 64-bit MMX Register #4 (MM4).\r
8348\r
8349 Writes the current value of MM4. This function is only available on IA32 and\r
030cd1a2 8350 x64.\r
ac644614 8351\r
8352 @param Value The 64-bit value to write to MM4.\r
8353\r
8354**/\r
8355VOID\r
8356EFIAPI\r
8357AsmWriteMm4 (\r
8358 IN UINT64 Value\r
8359 );\r
8360\r
8361\r
8362/**\r
8363 Writes the current value of 64-bit MMX Register #5 (MM5).\r
8364\r
8365 Writes the current value of MM5. This function is only available on IA32 and\r
030cd1a2 8366 x64.\r
ac644614 8367\r
8368 @param Value The 64-bit value to write to MM5.\r
8369\r
8370**/\r
8371VOID\r
8372EFIAPI\r
8373AsmWriteMm5 (\r
8374 IN UINT64 Value\r
8375 );\r
8376\r
8377\r
8378/**\r
8379 Writes the current value of 64-bit MMX Register #6 (MM6).\r
8380\r
8381 Writes the current value of MM6. This function is only available on IA32 and\r
030cd1a2 8382 x64.\r
ac644614 8383\r
8384 @param Value The 64-bit value to write to MM6.\r
8385\r
8386**/\r
8387VOID\r
8388EFIAPI\r
8389AsmWriteMm6 (\r
8390 IN UINT64 Value\r
8391 );\r
8392\r
8393\r
8394/**\r
8395 Writes the current value of 64-bit MMX Register #7 (MM7).\r
8396\r
8397 Writes the current value of MM7. This function is only available on IA32 and\r
030cd1a2 8398 x64.\r
ac644614 8399\r
8400 @param Value The 64-bit value to write to MM7.\r
8401\r
8402**/\r
8403VOID\r
8404EFIAPI\r
8405AsmWriteMm7 (\r
8406 IN UINT64 Value\r
8407 );\r
8408\r
8409\r
8410/**\r
8411 Reads the current value of Time Stamp Counter (TSC).\r
8412\r
8413 Reads and returns the current value of TSC. This function is only available\r
030cd1a2 8414 on IA-32 and x64.\r
ac644614 8415\r
8416 @return The current value of TSC\r
8417\r
8418**/\r
8419UINT64\r
8420EFIAPI\r
8421AsmReadTsc (\r
8422 VOID\r
8423 );\r
8424\r
8425\r
8426/**\r
8427 Reads the current value of a Performance Counter (PMC).\r
8428\r
8429 Reads and returns the current value of performance counter specified by\r
030cd1a2 8430 Index. This function is only available on IA-32 and x64.\r
ac644614 8431\r
8432 @param Index The 32-bit Performance Counter index to read.\r
8433\r
8434 @return The value of the PMC specified by Index.\r
8435\r
8436**/\r
8437UINT64\r
8438EFIAPI\r
8439AsmReadPmc (\r
8440 IN UINT32 Index\r
8441 );\r
8442\r
8443\r
8444/**\r
8445 Sets up a monitor buffer that is used by AsmMwait().\r
8446\r
8447 Executes a MONITOR instruction with the register state specified by Eax, Ecx\r
030cd1a2 8448 and Edx. Returns Eax. This function is only available on IA-32 and x64.\r
ac644614 8449\r
8450 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
8451 instruction.\r
8452 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
8453 instruction.\r
8454 @param Edx The value to load into EDX or RDX before executing the MONITOR\r
8455 instruction.\r
8456\r
8457 @return Eax\r
8458\r
8459**/\r
8460UINTN\r
8461EFIAPI\r
8462AsmMonitor (\r
8463 IN UINTN Eax,\r
8464 IN UINTN Ecx,\r
8465 IN UINTN Edx\r
8466 );\r
8467\r
8468\r
8469/**\r
8470 Executes an MWAIT instruction.\r
8471\r
8472 Executes an MWAIT instruction with the register state specified by Eax and\r
030cd1a2 8473 Ecx. Returns Eax. This function is only available on IA-32 and x64.\r
ac644614 8474\r
8475 @param Eax The value to load into EAX or RAX before executing the MONITOR\r
8476 instruction.\r
8477 @param Ecx The value to load into ECX or RCX before executing the MONITOR\r
8478 instruction.\r
8479\r
8480 @return Eax\r
8481\r
8482**/\r
8483UINTN\r
8484EFIAPI\r
8485AsmMwait (\r
8486 IN UINTN Eax,\r
8487 IN UINTN Ecx\r
8488 );\r
8489\r
8490\r
8491/**\r
8492 Executes a WBINVD instruction.\r
8493\r
8494 Executes a WBINVD instruction. This function is only available on IA-32 and\r
030cd1a2 8495 x64.\r
ac644614 8496\r
8497**/\r
8498VOID\r
8499EFIAPI\r
8500AsmWbinvd (\r
8501 VOID\r
8502 );\r
8503\r
8504\r
8505/**\r
8506 Executes a INVD instruction.\r
8507\r
8508 Executes a INVD instruction. This function is only available on IA-32 and\r
030cd1a2 8509 x64.\r
ac644614 8510\r
8511**/\r
8512VOID\r
8513EFIAPI\r
8514AsmInvd (\r
8515 VOID\r
8516 );\r
8517\r
8518\r
8519/**\r
8520 Flushes a cache line from all the instruction and data caches within the\r
8521 coherency domain of the CPU.\r
8522\r
8523 Flushed the cache line specified by LinearAddress, and returns LinearAddress.\r
030cd1a2 8524 This function is only available on IA-32 and x64.\r
ac644614 8525\r
8526 @param LinearAddress The address of the cache line to flush. If the CPU is\r
8527 in a physical addressing mode, then LinearAddress is a\r
8528 physical address. If the CPU is in a virtual\r
8529 addressing mode, then LinearAddress is a virtual\r
8530 address.\r
8531\r
af2dc6a7 8532 @return LinearAddress.\r
ac644614 8533**/\r
8534VOID *\r
8535EFIAPI\r
8536AsmFlushCacheLine (\r
8537 IN VOID *LinearAddress\r
8538 );\r
8539\r
8540\r
8541/**\r
8542 Enables the 32-bit paging mode on the CPU.\r
8543\r
8544 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
8545 must be properly initialized prior to calling this service. This function\r
8546 assumes the current execution mode is 32-bit protected mode. This function is\r
8547 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
8548 transferred to the function specified by EntryPoint using the new stack\r
8549 specified by NewStack and passing in the parameters specified by Context1 and\r
8550 Context2. Context1 and Context2 are optional and may be NULL. The function\r
8551 EntryPoint must never return.\r
8552\r
8553 If the current execution mode is not 32-bit protected mode, then ASSERT().\r
8554 If EntryPoint is NULL, then ASSERT().\r
8555 If NewStack is NULL, then ASSERT().\r
8556\r
8557 There are a number of constraints that must be followed before calling this\r
8558 function:\r
8559 1) Interrupts must be disabled.\r
8560 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
8561 means all descriptors must have a base of 0 and a limit of 4GB.\r
8562 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
8563 descriptors.\r
8564 4) CR3 must point to valid page tables that will be used once the transition\r
8565 is complete, and those page tables must guarantee that the pages for this\r
8566 function and the stack are identity mapped.\r
8567\r
8568 @param EntryPoint A pointer to function to call with the new stack after\r
8569 paging is enabled.\r
8570 @param Context1 A pointer to the context to pass into the EntryPoint\r
8571 function as the first parameter after paging is enabled.\r
8572 @param Context2 A pointer to the context to pass into the EntryPoint\r
8573 function as the second parameter after paging is enabled.\r
8574 @param NewStack A pointer to the new stack to use for the EntryPoint\r
8575 function after paging is enabled.\r
8576\r
8577**/\r
8578VOID\r
8579EFIAPI\r
8580AsmEnablePaging32 (\r
8581 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
8582 IN VOID *Context1, OPTIONAL\r
8583 IN VOID *Context2, OPTIONAL\r
8584 IN VOID *NewStack\r
8585 );\r
8586\r
8587\r
8588/**\r
8589 Disables the 32-bit paging mode on the CPU.\r
8590\r
8591 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
8592 mode. This function assumes the current execution mode is 32-paged protected\r
8593 mode. This function is only available on IA-32. After the 32-bit paging mode\r
8594 is disabled, control is transferred to the function specified by EntryPoint\r
8595 using the new stack specified by NewStack and passing in the parameters\r
8596 specified by Context1 and Context2. Context1 and Context2 are optional and\r
8597 may be NULL. The function EntryPoint must never return.\r
8598\r
8599 If the current execution mode is not 32-bit paged mode, then ASSERT().\r
8600 If EntryPoint is NULL, then ASSERT().\r
8601 If NewStack is NULL, then ASSERT().\r
8602\r
8603 There are a number of constraints that must be followed before calling this\r
8604 function:\r
8605 1) Interrupts must be disabled.\r
8606 2) The caller must be in 32-bit paged mode.\r
8607 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
8608 4) CR3 must point to valid page tables that guarantee that the pages for\r
8609 this function and the stack are identity mapped.\r
8610\r
8611 @param EntryPoint A pointer to function to call with the new stack after\r
8612 paging is disabled.\r
8613 @param Context1 A pointer to the context to pass into the EntryPoint\r
8614 function as the first parameter after paging is disabled.\r
8615 @param Context2 A pointer to the context to pass into the EntryPoint\r
8616 function as the second parameter after paging is\r
8617 disabled.\r
8618 @param NewStack A pointer to the new stack to use for the EntryPoint\r
8619 function after paging is disabled.\r
8620\r
8621**/\r
8622VOID\r
8623EFIAPI\r
8624AsmDisablePaging32 (\r
8625 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
8626 IN VOID *Context1, OPTIONAL\r
8627 IN VOID *Context2, OPTIONAL\r
8628 IN VOID *NewStack\r
8629 );\r
8630\r
8631\r
8632/**\r
8633 Enables the 64-bit paging mode on the CPU.\r
8634\r
8635 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
8636 must be properly initialized prior to calling this service. This function\r
8637 assumes the current execution mode is 32-bit protected mode with flat\r
8638 descriptors. This function is only available on IA-32. After the 64-bit\r
8639 paging mode is enabled, control is transferred to the function specified by\r
8640 EntryPoint using the new stack specified by NewStack and passing in the\r
8641 parameters specified by Context1 and Context2. Context1 and Context2 are\r
8642 optional and may be 0. The function EntryPoint must never return.\r
8643\r
8644 If the current execution mode is not 32-bit protected mode with flat\r
8645 descriptors, then ASSERT().\r
8646 If EntryPoint is 0, then ASSERT().\r
8647 If NewStack is 0, then ASSERT().\r
8648\r
17f695ed 8649 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
ac644614 8650 is called. The descriptor in the GDT that this selector\r
8651 references must be setup for long mode.\r
8652 @param EntryPoint The 64-bit virtual address of the function to call with\r
8653 the new stack after paging is enabled.\r
8654 @param Context1 The 64-bit virtual address of the context to pass into\r
8655 the EntryPoint function as the first parameter after\r
8656 paging is enabled.\r
8657 @param Context2 The 64-bit virtual address of the context to pass into\r
8658 the EntryPoint function as the second parameter after\r
8659 paging is enabled.\r
8660 @param NewStack The 64-bit virtual address of the new stack to use for\r
8661 the EntryPoint function after paging is enabled.\r
8662\r
8663**/\r
8664VOID\r
8665EFIAPI\r
8666AsmEnablePaging64 (\r
17f695ed 8667 IN UINT16 Cs,\r
ac644614 8668 IN UINT64 EntryPoint,\r
8669 IN UINT64 Context1, OPTIONAL\r
8670 IN UINT64 Context2, OPTIONAL\r
8671 IN UINT64 NewStack\r
8672 );\r
8673\r
8674\r
8675/**\r
8676 Disables the 64-bit paging mode on the CPU.\r
8677\r
8678 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
8679 mode. This function assumes the current execution mode is 64-paging mode.\r
030cd1a2 8680 This function is only available on x64. After the 64-bit paging mode is\r
ac644614 8681 disabled, control is transferred to the function specified by EntryPoint\r
8682 using the new stack specified by NewStack and passing in the parameters\r
8683 specified by Context1 and Context2. Context1 and Context2 are optional and\r
8684 may be 0. The function EntryPoint must never return.\r
8685\r
8686 If the current execution mode is not 64-bit paged mode, then ASSERT().\r
8687 If EntryPoint is 0, then ASSERT().\r
8688 If NewStack is 0, then ASSERT().\r
8689\r
17f695ed 8690 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
ac644614 8691 is called. The descriptor in the GDT that this selector\r
8692 references must be setup for 32-bit protected mode.\r
8693 @param EntryPoint The 64-bit virtual address of the function to call with\r
8694 the new stack after paging is disabled.\r
8695 @param Context1 The 64-bit virtual address of the context to pass into\r
8696 the EntryPoint function as the first parameter after\r
8697 paging is disabled.\r
8698 @param Context2 The 64-bit virtual address of the context to pass into\r
8699 the EntryPoint function as the second parameter after\r
8700 paging is disabled.\r
8701 @param NewStack The 64-bit virtual address of the new stack to use for\r
8702 the EntryPoint function after paging is disabled.\r
8703\r
8704**/\r
8705VOID\r
8706EFIAPI\r
8707AsmDisablePaging64 (\r
17f695ed 8708 IN UINT16 Cs,\r
ac644614 8709 IN UINT32 EntryPoint,\r
8710 IN UINT32 Context1, OPTIONAL\r
8711 IN UINT32 Context2, OPTIONAL\r
8712 IN UINT32 NewStack\r
8713 );\r
8714\r
8715\r
8716//\r
8717// 16-bit thunking services\r
8718//\r
8719\r
8720/**\r
8721 Retrieves the properties for 16-bit thunk functions.\r
8722\r
8723 Computes the size of the buffer and stack below 1MB required to use the\r
8724 AsmPrepareThunk16(), AsmThunk16() and AsmPrepareAndThunk16() functions. This\r
8725 buffer size is returned in RealModeBufferSize, and the stack size is returned\r
8726 in ExtraStackSize. If parameters are passed to the 16-bit real mode code,\r
8727 then the actual minimum stack size is ExtraStackSize plus the maximum number\r
8728 of bytes that need to be passed to the 16-bit real mode code.\r
52fa075c 8729 \r
ac644614 8730 If RealModeBufferSize is NULL, then ASSERT().\r
8731 If ExtraStackSize is NULL, then ASSERT().\r
8732\r
8733 @param RealModeBufferSize A pointer to the size of the buffer below 1MB\r
8734 required to use the 16-bit thunk functions.\r
8735 @param ExtraStackSize A pointer to the extra size of stack below 1MB\r
8736 that the 16-bit thunk functions require for\r
8737 temporary storage in the transition to and from\r
8738 16-bit real mode.\r
8739\r
8740**/\r
8741VOID\r
8742EFIAPI\r
8743AsmGetThunk16Properties (\r
8744 OUT UINT32 *RealModeBufferSize,\r
8745 OUT UINT32 *ExtraStackSize\r
8746 );\r
8747\r
8748\r
8749/**\r
8750 Prepares all structures a code required to use AsmThunk16().\r
8751\r
8752 Prepares all structures and code required to use AsmThunk16().\r
52fa075c 8753 \r
8243b089 8754 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
8755 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
ac644614 8756\r
8757 If ThunkContext is NULL, then ASSERT().\r
8758\r
8759 @param ThunkContext A pointer to the context structure that describes the\r
8760 16-bit real mode code to call.\r
8761\r
8762**/\r
8763VOID\r
8764EFIAPI\r
8765AsmPrepareThunk16 (\r
1445300f 8766 IN OUT THUNK_CONTEXT *ThunkContext\r
ac644614 8767 );\r
8768\r
8769\r
8770/**\r
8771 Transfers control to a 16-bit real mode entry point and returns the results.\r
8772\r
8773 Transfers control to a 16-bit real mode entry point and returns the results.\r
17f695ed 8774 AsmPrepareThunk16() must be called with ThunkContext before this function is used.\r
8775 This function must be called with interrupts disabled.\r
8776\r
8777 The register state from the RealModeState field of ThunkContext is restored just prior \r
8778 to calling the 16-bit real mode entry point. This includes the EFLAGS field of RealModeState, \r
8779 which is used to set the interrupt state when a 16-bit real mode entry point is called.\r
8780 Control is transferred to the 16-bit real mode entry point specified by the CS and Eip fields of RealModeState.\r
8781 The stack is initialized to the SS and ESP fields of RealModeState. Any parameters passed to \r
8782 the 16-bit real mode code must be populated by the caller at SS:ESP prior to calling this function. \r
8783 The 16-bit real mode entry point is invoked with a 16-bit CALL FAR instruction,\r
8784 so when accessing stack contents, the 16-bit real mode code must account for the 16-bit segment \r
8785 and 16-bit offset of the return address that were pushed onto the stack. The 16-bit real mode entry \r
8786 point must exit with a RETF instruction. The register state is captured into RealModeState immediately \r
8787 after the RETF instruction is executed.\r
8788 \r
8789 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
8790 or any of the 16-bit real mode code makes a SW interrupt, then the caller is responsible for making sure \r
8791 the IDT at address 0 is initialized to handle any HW or SW interrupts that may occur while in 16-bit real mode. \r
8792 \r
8793 If EFLAGS specifies interrupts enabled, or any of the 16-bit real mode code enables interrupts, \r
8794 then the caller is responsible for making sure the 8259 PIC is in a state compatible with 16-bit real mode. \r
8795 This includes the base vectors, the interrupt masks, and the edge/level trigger mode.\r
8796 \r
8797 If THUNK_ATTRIBUTE_BIG_REAL_MODE is set in the ThunkAttributes field of ThunkContext, then the user code \r
8798 is invoked in big real mode. Otherwise, the user code is invoked in 16-bit real mode with 64KB segment limits.\r
8799 \r
8800 If neither THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 nor THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
8801 ThunkAttributes, then it is assumed that the user code did not enable the A20 mask, and no attempt is made to \r
8802 disable the A20 mask.\r
8803 \r
8804 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is set and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is clear in \r
8805 ThunkAttributes, then attempt to use the INT 15 service to disable the A20 mask. If this INT 15 call fails, \r
8806 then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
8807 \r
8808 If THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 is clear and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL is set in \r
8809 ThunkAttributes, then attempt to disable the A20 mask by directly accessing the 8042 keyboard controller I/O ports.\r
8810 \r
ac644614 8811 If ThunkContext is NULL, then ASSERT().\r
8812 If AsmPrepareThunk16() was not previously called with ThunkContext, then ASSERT().\r
17f695ed 8813 If both THUNK_ATTRIBUTE_DISABLE_A20_MASK_INT_15 and THUNK_ATTRIBUTE_DISABLE_A20_MASK_KBD_CTRL are set in \r
8814 ThunkAttributes, then ASSERT().\r
ac644614 8815\r
8243b089 8816 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
af2dc6a7 8817 virtual to physical mappings for ThunkContext.RealModeBuffer are mapped 1:1.\r
52fa075c 8818\r
ac644614 8819 @param ThunkContext A pointer to the context structure that describes the\r
8820 16-bit real mode code to call.\r
8821\r
8822**/\r
8823VOID\r
8824EFIAPI\r
8825AsmThunk16 (\r
8826 IN OUT THUNK_CONTEXT *ThunkContext\r
8827 );\r
8828\r
8829\r
8830/**\r
8831 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
8832 control to a 16-bit real mode entry point, and returns the results.\r
8833\r
8834 Prepares all structures and code for a 16-bit real mode thunk, transfers\r
8835 control to a 16-bit real mode entry point, and returns the results. If the\r
8836 caller only need to perform a single 16-bit real mode thunk, then this\r
8837 service should be used. If the caller intends to make more than one 16-bit\r
8838 real mode thunk, then it is more efficient if AsmPrepareThunk16() is called\r
8839 once and AsmThunk16() can be called for each 16-bit real mode thunk.\r
8840\r
8243b089 8841 This interface is limited to be used in either physical mode or virtual modes with paging enabled where the\r
8842 virtual to physical mappings for ThunkContext.RealModeBuffer is mapped 1:1.\r
52fa075c 8843\r
17f695ed 8844 See AsmPrepareThunk16() and AsmThunk16() for the detailed description and ASSERT() conditions.\r
ac644614 8845\r
8846 @param ThunkContext A pointer to the context structure that describes the\r
8847 16-bit real mode code to call.\r
8848\r
8849**/\r
8850VOID\r
8851EFIAPI\r
8852AsmPrepareAndThunk16 (\r
8853 IN OUT THUNK_CONTEXT *ThunkContext\r
8854 );\r
8855\r
3cfc7813
QL
8856/**\r
8857 Generates a 16-bit random number through RDRAND instruction.\r
8858\r
8859 if Rand is NULL, then ASSERT().\r
8860\r
8861 @param[out] Rand Buffer pointer to store the random result.\r
8862\r
8863 @retval TRUE RDRAND call was successful.\r
8864 @retval FALSE Failed attempts to call RDRAND.\r
8865\r
8866 **/\r
8867BOOLEAN\r
8868EFIAPI\r
8869AsmRdRand16 (\r
8870 OUT UINT16 *Rand\r
8871 );\r
8872\r
8873/**\r
8874 Generates a 32-bit random number through RDRAND instruction.\r
8875\r
8876 if Rand is NULL, then ASSERT().\r
8877\r
8878 @param[out] Rand Buffer pointer to store the random result.\r
8879\r
8880 @retval TRUE RDRAND call was successful.\r
8881 @retval FALSE Failed attempts to call RDRAND.\r
8882\r
8883**/\r
8884BOOLEAN\r
8885EFIAPI\r
8886AsmRdRand32 (\r
8887 OUT UINT32 *Rand\r
8888 );\r
8889\r
8890/**\r
8891 Generates a 64-bit random number through RDRAND instruction.\r
8892\r
8893 if Rand is NULL, then ASSERT().\r
8894\r
8895 @param[out] Rand Buffer pointer to store the random result.\r
8896\r
8897 @retval TRUE RDRAND call was successful.\r
8898 @retval FALSE Failed attempts to call RDRAND.\r
8899\r
8900**/\r
8901BOOLEAN\r
8902EFIAPI\r
8903AsmRdRand64 (\r
8904 OUT UINT64 *Rand\r
8905 );\r
8906\r
ac644614 8907#endif\r
e3a7917f 8908#endif\r
ac644614 8909\r
8910\r