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