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