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