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