]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/BaseLibInternals.h
MdePkg/DevicePathLib: Reverse the byte order of BD_ADDR for Bluetooth
[mirror_edk2.git] / MdePkg / Library / BaseLib / BaseLibInternals.h
CommitLineData
e1f414b6 1/** @file\r
2 Declaration of internal functions in BaseLib.\r
3\r
d8af3301 4 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>\r
bb817c56 5 This program and the accompanying materials\r
e1f414b6 6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
127010dd 8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
e1f414b6 13**/\r
14\r
15#ifndef __BASE_LIB_INTERNALS__\r
16#define __BASE_LIB_INTERNALS__\r
17\r
f734a10a
A
18#include <Base.h>\r
19#include <Library/BaseLib.h>\r
20#include <Library/BaseMemoryLib.h>\r
21#include <Library/DebugLib.h>\r
f734a10a
A
22#include <Library/PcdLib.h>\r
23\r
e1f414b6 24//\r
25// Math functions\r
26//\r
27\r
28/**\r
29 Shifts a 64-bit integer left between 0 and 63 bits. The low bits\r
30 are filled with zeros. The shifted value is returned.\r
31\r
32 This function shifts the 64-bit value Operand to the left by Count bits. The\r
33 low Count bits are set to zero. The shifted value is returned.\r
34\r
35 @param Operand The 64-bit operand to shift left.\r
36 @param Count The number of bits to shift left.\r
37\r
38 @return Operand << Count\r
39\r
40**/\r
41UINT64\r
42EFIAPI\r
43InternalMathLShiftU64 (\r
44 IN UINT64 Operand,\r
45 IN UINTN Count\r
46 );\r
47\r
48/**\r
127010dd 49 Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
e1f414b6 50 are filled with zeros. The shifted value is returned.\r
51\r
52 This function shifts the 64-bit value Operand to the right by Count bits. The\r
53 high Count bits are set to zero. The shifted value is returned.\r
54\r
55 @param Operand The 64-bit operand to shift right.\r
56 @param Count The number of bits to shift right.\r
57\r
58 @return Operand >> Count\r
59\r
60**/\r
61UINT64\r
62EFIAPI\r
63InternalMathRShiftU64 (\r
64 IN UINT64 Operand,\r
65 IN UINTN Count\r
66 );\r
67\r
68/**\r
69 Shifts a 64-bit integer right between 0 and 63 bits. The high bits\r
70 are filled with original integer's bit 63. The shifted value is returned.\r
71\r
72 This function shifts the 64-bit value Operand to the right by Count bits. The\r
73 high Count bits are set to bit 63 of Operand. The shifted value is returned.\r
74\r
75 @param Operand The 64-bit operand to shift right.\r
76 @param Count The number of bits to shift right.\r
77\r
78 @return Operand arithmetically shifted right by Count\r
79\r
80**/\r
81UINT64\r
82EFIAPI\r
83InternalMathARShiftU64 (\r
84 IN UINT64 Operand,\r
85 IN UINTN Count\r
86 );\r
87\r
88/**\r
89 Rotates a 64-bit integer left between 0 and 63 bits, filling\r
90 the low bits with the high bits that were rotated.\r
91\r
92 This function rotates the 64-bit value Operand to the left by Count bits. The\r
127010dd 93 low Count bits are filled with the high Count bits of Operand. The rotated\r
e1f414b6 94 value is returned.\r
95\r
96 @param Operand The 64-bit operand to rotate left.\r
97 @param Count The number of bits to rotate left.\r
98\r
99 @return Operand <<< Count\r
100\r
101**/\r
102UINT64\r
103EFIAPI\r
104InternalMathLRotU64 (\r
105 IN UINT64 Operand,\r
106 IN UINTN Count\r
107 );\r
108\r
109/**\r
110 Rotates a 64-bit integer right between 0 and 63 bits, filling\r
111 the high bits with the high low bits that were rotated.\r
112\r
113 This function rotates the 64-bit value Operand to the right by Count bits.\r
127010dd 114 The high Count bits are filled with the low Count bits of Operand. The rotated\r
e1f414b6 115 value is returned.\r
116\r
117 @param Operand The 64-bit operand to rotate right.\r
118 @param Count The number of bits to rotate right.\r
119\r
120 @return Operand >>> Count\r
121\r
122**/\r
123UINT64\r
124EFIAPI\r
125InternalMathRRotU64 (\r
126 IN UINT64 Operand,\r
127 IN UINTN Count\r
128 );\r
129\r
130/**\r
131 Switches the endianess of a 64-bit integer.\r
132\r
133 This function swaps the bytes in a 64-bit unsigned value to switch the value\r
134 from little endian to big endian or vice versa. The byte swapped value is\r
135 returned.\r
136\r
137 @param Operand A 64-bit unsigned value.\r
138\r
24dcb5e5 139 @return The byte swapped Operand.\r
e1f414b6 140\r
141**/\r
142UINT64\r
143EFIAPI\r
144InternalMathSwapBytes64 (\r
145 IN UINT64 Operand\r
146 );\r
147\r
148/**\r
127010dd 149 Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer\r
e1f414b6 150 and generates a 64-bit unsigned result.\r
151\r
127010dd 152 This function multiplies the 64-bit unsigned value Multiplicand by the 32-bit\r
e1f414b6 153 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
154 bit unsigned result is returned.\r
155\r
156 @param Multiplicand A 64-bit unsigned value.\r
157 @param Multiplier A 32-bit unsigned value.\r
158\r
159 @return Multiplicand * Multiplier\r
160\r
161**/\r
162UINT64\r
163EFIAPI\r
164InternalMathMultU64x32 (\r
165 IN UINT64 Multiplicand,\r
166 IN UINT32 Multiplier\r
167 );\r
168\r
169/**\r
127010dd 170 Multiplies a 64-bit unsigned integer by a 64-bit unsigned integer\r
e1f414b6 171 and generates a 64-bit unsigned result.\r
172\r
173 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit\r
174 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-\r
175 bit unsigned result is returned.\r
176\r
177 @param Multiplicand A 64-bit unsigned value.\r
178 @param Multiplier A 64-bit unsigned value.\r
179\r
180 @return Multiplicand * Multiplier\r
181\r
182**/\r
183UINT64\r
184EFIAPI\r
185InternalMathMultU64x64 (\r
186 IN UINT64 Multiplicand,\r
187 IN UINT64 Multiplier\r
188 );\r
189\r
190/**\r
191 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
192 generates a 64-bit unsigned result.\r
193\r
194 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
195 unsigned value Divisor and generates a 64-bit unsigned quotient. This\r
196 function returns the 64-bit unsigned quotient.\r
197\r
24dcb5e5 198 @param Dividend A 64-bit unsigned value.\r
e1f414b6 199 @param Divisor A 32-bit unsigned value.\r
200\r
201 @return Dividend / Divisor\r
202\r
203**/\r
204UINT64\r
205EFIAPI\r
206InternalMathDivU64x32 (\r
207 IN UINT64 Dividend,\r
208 IN UINT32 Divisor\r
209 );\r
210\r
211/**\r
212 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
213 generates a 32-bit unsigned remainder.\r
214\r
215 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
216 unsigned value Divisor and generates a 32-bit remainder. This function\r
217 returns the 32-bit unsigned remainder.\r
218\r
219 @param Dividend A 64-bit unsigned value.\r
220 @param Divisor A 32-bit unsigned value.\r
221\r
222 @return Dividend % Divisor\r
223\r
224**/\r
225UINT32\r
226EFIAPI\r
227InternalMathModU64x32 (\r
228 IN UINT64 Dividend,\r
229 IN UINT32 Divisor\r
230 );\r
231\r
232/**\r
233 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and\r
234 generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.\r
235\r
236 This function divides the 64-bit unsigned value Dividend by the 32-bit\r
237 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
238 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.\r
239 This function returns the 64-bit unsigned quotient.\r
240\r
241 @param Dividend A 64-bit unsigned value.\r
242 @param Divisor A 32-bit unsigned value.\r
243 @param Remainder A pointer to a 32-bit unsigned value. This parameter is\r
244 optional and may be NULL.\r
245\r
246 @return Dividend / Divisor\r
247\r
248**/\r
249UINT64\r
250EFIAPI\r
251InternalMathDivRemU64x32 (\r
252 IN UINT64 Dividend,\r
253 IN UINT32 Divisor,\r
42eedea9 254 OUT UINT32 *Remainder OPTIONAL\r
e1f414b6 255 );\r
256\r
257/**\r
258 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and\r
259 generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.\r
260\r
261 This function divides the 64-bit unsigned value Dividend by the 64-bit\r
262 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder\r
263 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.\r
264 This function returns the 64-bit unsigned quotient.\r
265\r
266 @param Dividend A 64-bit unsigned value.\r
267 @param Divisor A 64-bit unsigned value.\r
268 @param Remainder A pointer to a 64-bit unsigned value. This parameter is\r
269 optional and may be NULL.\r
270\r
271 @return Dividend / Divisor\r
272\r
273**/\r
274UINT64\r
275EFIAPI\r
276InternalMathDivRemU64x64 (\r
277 IN UINT64 Dividend,\r
278 IN UINT64 Divisor,\r
42eedea9 279 OUT UINT64 *Remainder OPTIONAL\r
e1f414b6 280 );\r
281\r
282/**\r
283 Divides a 64-bit signed integer by a 64-bit signed integer and\r
24dcb5e5 284 generates a 64-bit signed result and an optional 64-bit signed remainder.\r
e1f414b6 285\r
24dcb5e5 286 This function divides the 64-bit signed value Dividend by the 64-bit\r
287 signed value Divisor and generates a 64-bit signed quotient. If Remainder\r
288 is not NULL, then the 64-bit signed remainder is returned in Remainder.\r
289 This function returns the 64-bit signed quotient.\r
e1f414b6 290\r
291 @param Dividend A 64-bit signed value.\r
292 @param Divisor A 64-bit signed value.\r
293 @param Remainder A pointer to a 64-bit signed value. This parameter is\r
294 optional and may be NULL.\r
295\r
296 @return Dividend / Divisor\r
297\r
298**/\r
299INT64\r
38bbd3d9 300EFIAPI\r
e1f414b6 301InternalMathDivRemS64x64 (\r
302 IN INT64 Dividend,\r
303 IN INT64 Divisor,\r
304 OUT INT64 *Remainder OPTIONAL\r
7e43ed89 305 );\r
e1f414b6 306\r
307/**\r
308 Transfers control to a function starting with a new stack.\r
309\r
310 Transfers control to the function specified by EntryPoint using the\r
311 new stack specified by NewStack and passing in the parameters specified\r
312 by Context1 and Context2. Context1 and Context2 are optional and may\r
313 be NULL. The function EntryPoint must never return.\r
314 Marker will be ignored on IA-32, x64, and EBC.\r
315 IPF CPUs expect one additional parameter of type VOID * that specifies\r
316 the new backing store pointer.\r
317\r
318 If EntryPoint is NULL, then ASSERT().\r
319 If NewStack is NULL, then ASSERT().\r
320\r
321 @param EntryPoint A pointer to function to call with the new stack.\r
322 @param Context1 A pointer to the context to pass into the EntryPoint\r
323 function.\r
324 @param Context2 A pointer to the context to pass into the EntryPoint\r
325 function.\r
326 @param NewStack A pointer to the new stack to use for the EntryPoint\r
327 function.\r
328 @param Marker VA_LIST marker for the variable argument list.\r
329\r
330**/\r
331VOID\r
332EFIAPI\r
333InternalSwitchStack (\r
334 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
335 IN VOID *Context1, OPTIONAL\r
336 IN VOID *Context2, OPTIONAL\r
337 IN VOID *NewStack,\r
338 IN VA_LIST Marker\r
339 );\r
340\r
341\r
342/**\r
24dcb5e5 343 Worker function that locates the Node in the List.\r
e1f414b6 344\r
345 By searching the List, finds the location of the Node in List. At the same time,\r
346 verifies the validity of this list.\r
347\r
348 If List is NULL, then ASSERT().\r
349 If List->ForwardLink is NULL, then ASSERT().\r
350 If List->backLink is NULL, then ASSERT().\r
351 If Node is NULL, then ASSERT();\r
a71865b1 352 If PcdMaximumLinkedListLength is not zero, and prior to insertion the number\r
e1f414b6 353 of nodes in ListHead, including the ListHead node, is greater than or\r
354 equal to PcdMaximumLinkedListLength, then ASSERT().\r
355\r
356 @param List A pointer to a node in a linked list.\r
357 @param Node A pointer to one nod.\r
358\r
127010dd 359 @retval TRUE Node is in List.\r
360 @retval FALSE Node isn't in List, or List is invalid.\r
e1f414b6 361\r
362**/\r
363BOOLEAN\r
38bbd3d9 364EFIAPI\r
e1f414b6 365IsNodeInList (\r
366 IN CONST LIST_ENTRY *List,\r
367 IN CONST LIST_ENTRY *Node\r
368 );\r
369\r
e1f414b6 370/**\r
24dcb5e5 371 Worker function that returns a bit field from Operand.\r
e1f414b6 372\r
373 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
374\r
375 @param Operand Operand on which to perform the bitfield operation.\r
376 @param StartBit The ordinal of the least significant bit in the bit field.\r
377 @param EndBit The ordinal of the most significant bit in the bit field.\r
378\r
379 @return The bit field read.\r
380\r
381**/\r
28ca72bc 382UINTN\r
38bbd3d9 383EFIAPI\r
e1f414b6 384BitFieldReadUint (\r
28ca72bc 385 IN UINTN Operand,\r
e1f414b6 386 IN UINTN StartBit,\r
387 IN UINTN EndBit\r
388 );\r
389\r
390\r
391/**\r
392 Worker function that reads a bit field from Operand, performs a bitwise OR,\r
393 and returns the result.\r
394\r
395 Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
396 in Operand and the value specified by AndData. All other bits in Operand are\r
397 preserved. The new value is returned.\r
398\r
399 @param Operand Operand on which to perform the bitfield operation.\r
400 @param StartBit The ordinal of the least significant bit in the bit field.\r
401 @param EndBit The ordinal of the most significant bit in the bit field.\r
402 @param OrData The value to OR with the read value from the value\r
403\r
404 @return The new value.\r
405\r
406**/\r
28ca72bc 407UINTN\r
38bbd3d9 408EFIAPI\r
e1f414b6 409BitFieldOrUint (\r
28ca72bc 410 IN UINTN Operand,\r
e1f414b6 411 IN UINTN StartBit,\r
412 IN UINTN EndBit,\r
28ca72bc 413 IN UINTN OrData\r
e1f414b6 414 );\r
415\r
416\r
417/**\r
418 Worker function that reads a bit field from Operand, performs a bitwise AND,\r
419 and returns the result.\r
420\r
421 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
422 in Operand and the value specified by AndData. All other bits in Operand are\r
423 preserved. The new value is returned.\r
424\r
425 @param Operand Operand on which to perform the bitfield operation.\r
426 @param StartBit The ordinal of the least significant bit in the bit field.\r
427 @param EndBit The ordinal of the most significant bit in the bit field.\r
428 @param AndData The value to And with the read value from the value\r
429\r
430 @return The new value.\r
431\r
432**/\r
28ca72bc 433UINTN\r
38bbd3d9 434EFIAPI\r
e1f414b6 435BitFieldAndUint (\r
28ca72bc 436 IN UINTN Operand,\r
e1f414b6 437 IN UINTN StartBit,\r
438 IN UINTN EndBit,\r
28ca72bc 439 IN UINTN AndData\r
e1f414b6 440 );\r
441\r
442\r
443/**\r
444 Worker function that checks ASSERT condition for JumpBuffer\r
445\r
446 Checks ASSERT condition for JumpBuffer.\r
447\r
448 If JumpBuffer is NULL, then ASSERT().\r
449 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
450\r
451 @param JumpBuffer A pointer to CPU context buffer.\r
452\r
453**/\r
454VOID\r
38bbd3d9 455EFIAPI\r
e1f414b6 456InternalAssertJumpBuffer (\r
457 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
458 );\r
459\r
460\r
461/**\r
462 Restores the CPU context that was saved with SetJump().\r
463\r
464 Restores the CPU context from the buffer specified by JumpBuffer.\r
465 This function never returns to the caller.\r
466 Instead is resumes execution based on the state of JumpBuffer.\r
467\r
468 @param JumpBuffer A pointer to CPU context buffer.\r
469 @param Value The value to return when the SetJump() context is restored.\r
470\r
471**/\r
472VOID\r
473EFIAPI\r
474InternalLongJump (\r
475 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
476 IN UINTN Value\r
477 );\r
478\r
479\r
d8af3301
HW
480/**\r
481 Check if a Unicode character is a decimal character.\r
482\r
483 This internal function checks if a Unicode character is a\r
484 decimal character. The valid decimal character is from\r
485 L'0' to L'9'.\r
486\r
487 @param Char The character to check against.\r
488\r
489 @retval TRUE If the Char is a decmial character.\r
490 @retval FALSE If the Char is not a decmial character.\r
491\r
492**/\r
493BOOLEAN\r
494EFIAPI\r
495InternalIsDecimalDigitCharacter (\r
496 IN CHAR16 Char\r
497 );\r
498\r
499\r
500/**\r
501 Convert a Unicode character to upper case only if\r
502 it maps to a valid small-case ASCII character.\r
503\r
504 This internal function only deal with Unicode character\r
505 which maps to a valid small-case ASCII character, i.e.\r
506 L'a' to L'z'. For other Unicode character, the input character\r
507 is returned directly.\r
508\r
509 @param Char The character to convert.\r
510\r
511 @retval LowerCharacter If the Char is with range L'a' to L'z'.\r
512 @retval Unchanged Otherwise.\r
513\r
514**/\r
515CHAR16\r
516EFIAPI\r
517InternalCharToUpper (\r
518 IN CHAR16 Char\r
519 );\r
520\r
521\r
522/**\r
523 Convert a Unicode character to numerical value.\r
524\r
525 This internal function only deal with Unicode character\r
526 which maps to a valid hexadecimal ASII character, i.e.\r
527 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other\r
528 Unicode character, the value returned does not make sense.\r
529\r
530 @param Char The character to convert.\r
531\r
532 @return The numerical value converted.\r
533\r
534**/\r
535UINTN\r
536EFIAPI\r
537InternalHexCharToUintn (\r
538 IN CHAR16 Char\r
539 );\r
540\r
541\r
542/**\r
543 Check if a Unicode character is a hexadecimal character.\r
544\r
545 This internal function checks if a Unicode character is a\r
546 decimal character. The valid hexadecimal character is\r
547 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
548\r
549\r
550 @param Char The character to check against.\r
551\r
552 @retval TRUE If the Char is a hexadecmial character.\r
553 @retval FALSE If the Char is not a hexadecmial character.\r
554\r
555**/\r
556BOOLEAN\r
557EFIAPI\r
558InternalIsHexaDecimalDigitCharacter (\r
559 IN CHAR16 Char\r
560 );\r
561\r
562\r
563/**\r
564 Check if a ASCII character is a decimal character.\r
565\r
566 This internal function checks if a Unicode character is a\r
567 decimal character. The valid decimal character is from\r
568 '0' to '9'.\r
569\r
570 @param Char The character to check against.\r
571\r
572 @retval TRUE If the Char is a decmial character.\r
573 @retval FALSE If the Char is not a decmial character.\r
574\r
575**/\r
576BOOLEAN\r
577EFIAPI\r
578InternalAsciiIsDecimalDigitCharacter (\r
579 IN CHAR8 Char\r
580 );\r
581\r
582\r
583/**\r
584 Converts a lowercase Ascii character to upper one.\r
585\r
586 If Chr is lowercase Ascii character, then converts it to upper one.\r
587\r
588 If Value >= 0xA0, then ASSERT().\r
589 If (Value & 0x0F) >= 0x0A, then ASSERT().\r
590\r
591 @param Chr one Ascii character\r
592\r
593 @return The uppercase value of Ascii character\r
594\r
595**/\r
596CHAR8\r
597EFIAPI\r
598InternalBaseLibAsciiToUpper (\r
599 IN CHAR8 Chr\r
600 );\r
601\r
602\r
603/**\r
604 Check if a ASCII character is a hexadecimal character.\r
605\r
606 This internal function checks if a ASCII character is a\r
607 decimal character. The valid hexadecimal character is\r
608 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
609\r
610\r
611 @param Char The character to check against.\r
612\r
613 @retval TRUE If the Char is a hexadecmial character.\r
614 @retval FALSE If the Char is not a hexadecmial character.\r
615\r
616**/\r
617BOOLEAN\r
618EFIAPI\r
619InternalAsciiIsHexaDecimalDigitCharacter (\r
620 IN CHAR8 Char\r
621 );\r
622\r
623\r
624/**\r
625 Convert a ASCII character to numerical value.\r
626\r
627 This internal function only deal with Unicode character\r
628 which maps to a valid hexadecimal ASII character, i.e.\r
629 '0' to '9', 'a' to 'f' or 'A' to 'F'. For other\r
630 ASCII character, the value returned does not make sense.\r
631\r
632 @param Char The character to convert.\r
633\r
634 @return The numerical value converted.\r
635\r
636**/\r
637UINTN\r
638EFIAPI\r
639InternalAsciiHexCharToUintn (\r
640 IN CHAR8 Char\r
641 );\r
642\r
643\r
e1f414b6 644//\r
645// Ia32 and x64 specific functions\r
646//\r
647#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
648\r
649/**\r
650 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
651\r
652 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
030cd1a2 653 function is only available on IA-32 and x64.\r
e1f414b6 654\r
127010dd 655 @param Gdtr The pointer to a GDTR descriptor.\r
e1f414b6 656\r
657**/\r
658VOID\r
659EFIAPI\r
660InternalX86ReadGdtr (\r
661 OUT IA32_DESCRIPTOR *Gdtr\r
662 );\r
663\r
664/**\r
665 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
666\r
667 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
030cd1a2 668 only available on IA-32 and x64.\r
e1f414b6 669\r
127010dd 670 @param Gdtr The pointer to a GDTR descriptor.\r
e1f414b6 671\r
672**/\r
673VOID\r
674EFIAPI\r
675InternalX86WriteGdtr (\r
676 IN CONST IA32_DESCRIPTOR *Gdtr\r
677 );\r
678\r
679/**\r
680 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
681\r
682 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
030cd1a2 683 function is only available on IA-32 and x64.\r
e1f414b6 684\r
127010dd 685 @param Idtr The pointer to an IDTR descriptor.\r
e1f414b6 686\r
687**/\r
688VOID\r
689EFIAPI\r
690InternalX86ReadIdtr (\r
691 OUT IA32_DESCRIPTOR *Idtr\r
692 );\r
693\r
694/**\r
695 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
696\r
697 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
030cd1a2 698 only available on IA-32 and x64.\r
e1f414b6 699\r
127010dd 700 @param Idtr The pointer to an IDTR descriptor.\r
e1f414b6 701\r
702**/\r
703VOID\r
704EFIAPI\r
705InternalX86WriteIdtr (\r
706 IN CONST IA32_DESCRIPTOR *Idtr\r
707 );\r
708\r
709/**\r
710 Save the current floating point/SSE/SSE2 context to a buffer.\r
711\r
712 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
713 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
030cd1a2 714 available on IA-32 and x64.\r
e1f414b6 715\r
127010dd 716 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
e1f414b6 717\r
718**/\r
719VOID\r
720EFIAPI\r
721InternalX86FxSave (\r
722 OUT IA32_FX_BUFFER *Buffer\r
723 );\r
724\r
725/**\r
726 Restores the current floating point/SSE/SSE2 context from a buffer.\r
727\r
728 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
729 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
030cd1a2 730 only available on IA-32 and x64.\r
e1f414b6 731\r
127010dd 732 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
e1f414b6 733\r
734**/\r
735VOID\r
736EFIAPI\r
737InternalX86FxRestore (\r
738 IN CONST IA32_FX_BUFFER *Buffer\r
739 );\r
740\r
741/**\r
742 Enables the 32-bit paging mode on the CPU.\r
743\r
744 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
745 must be properly initialized prior to calling this service. This function\r
746 assumes the current execution mode is 32-bit protected mode. This function is\r
747 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
748 transferred to the function specified by EntryPoint using the new stack\r
749 specified by NewStack and passing in the parameters specified by Context1 and\r
750 Context2. Context1 and Context2 are optional and may be NULL. The function\r
751 EntryPoint must never return.\r
752\r
753 There are a number of constraints that must be followed before calling this\r
754 function:\r
755 1) Interrupts must be disabled.\r
756 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
757 means all descriptors must have a base of 0 and a limit of 4GB.\r
758 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
759 descriptors.\r
760 4) CR3 must point to valid page tables that will be used once the transition\r
761 is complete, and those page tables must guarantee that the pages for this\r
762 function and the stack are identity mapped.\r
763\r
764 @param EntryPoint A pointer to function to call with the new stack after\r
765 paging is enabled.\r
766 @param Context1 A pointer to the context to pass into the EntryPoint\r
767 function as the first parameter after paging is enabled.\r
768 @param Context2 A pointer to the context to pass into the EntryPoint\r
769 function as the second parameter after paging is enabled.\r
770 @param NewStack A pointer to the new stack to use for the EntryPoint\r
771 function after paging is enabled.\r
772\r
773**/\r
774VOID\r
775EFIAPI\r
776InternalX86EnablePaging32 (\r
777 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
778 IN VOID *Context1, OPTIONAL\r
779 IN VOID *Context2, OPTIONAL\r
780 IN VOID *NewStack\r
781 );\r
782\r
783/**\r
784 Disables the 32-bit paging mode on the CPU.\r
785\r
786 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
787 mode. This function assumes the current execution mode is 32-paged protected\r
788 mode. This function is only available on IA-32. After the 32-bit paging mode\r
789 is disabled, control is transferred to the function specified by EntryPoint\r
790 using the new stack specified by NewStack and passing in the parameters\r
791 specified by Context1 and Context2. Context1 and Context2 are optional and\r
792 may be NULL. The function EntryPoint must never return.\r
793\r
794 There are a number of constraints that must be followed before calling this\r
795 function:\r
796 1) Interrupts must be disabled.\r
797 2) The caller must be in 32-bit paged mode.\r
798 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
799 4) CR3 must point to valid page tables that guarantee that the pages for\r
800 this function and the stack are identity mapped.\r
801\r
802 @param EntryPoint A pointer to function to call with the new stack after\r
803 paging is disabled.\r
804 @param Context1 A pointer to the context to pass into the EntryPoint\r
805 function as the first parameter after paging is disabled.\r
806 @param Context2 A pointer to the context to pass into the EntryPoint\r
807 function as the second parameter after paging is\r
808 disabled.\r
809 @param NewStack A pointer to the new stack to use for the EntryPoint\r
810 function after paging is disabled.\r
811\r
812**/\r
813VOID\r
814EFIAPI\r
815InternalX86DisablePaging32 (\r
816 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
817 IN VOID *Context1, OPTIONAL\r
818 IN VOID *Context2, OPTIONAL\r
819 IN VOID *NewStack\r
820 );\r
821\r
822/**\r
823 Enables the 64-bit paging mode on the CPU.\r
824\r
825 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
826 must be properly initialized prior to calling this service. This function\r
827 assumes the current execution mode is 32-bit protected mode with flat\r
828 descriptors. This function is only available on IA-32. After the 64-bit\r
829 paging mode is enabled, control is transferred to the function specified by\r
830 EntryPoint using the new stack specified by NewStack and passing in the\r
831 parameters specified by Context1 and Context2. Context1 and Context2 are\r
832 optional and may be 0. The function EntryPoint must never return.\r
833\r
834 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
835 is called. The descriptor in the GDT that this selector\r
836 references must be setup for long mode.\r
837 @param EntryPoint The 64-bit virtual address of the function to call with\r
838 the new stack after paging is enabled.\r
839 @param Context1 The 64-bit virtual address of the context to pass into\r
840 the EntryPoint function as the first parameter after\r
841 paging is enabled.\r
842 @param Context2 The 64-bit virtual address of the context to pass into\r
843 the EntryPoint function as the second parameter after\r
844 paging is enabled.\r
845 @param NewStack The 64-bit virtual address of the new stack to use for\r
846 the EntryPoint function after paging is enabled.\r
847\r
848**/\r
849VOID\r
850EFIAPI\r
851InternalX86EnablePaging64 (\r
852 IN UINT16 Cs,\r
853 IN UINT64 EntryPoint,\r
854 IN UINT64 Context1, OPTIONAL\r
855 IN UINT64 Context2, OPTIONAL\r
856 IN UINT64 NewStack\r
857 );\r
858\r
859/**\r
860 Disables the 64-bit paging mode on the CPU.\r
861\r
862 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
863 mode. This function assumes the current execution mode is 64-paging mode.\r
030cd1a2 864 This function is only available on x64. After the 64-bit paging mode is\r
e1f414b6 865 disabled, control is transferred to the function specified by EntryPoint\r
866 using the new stack specified by NewStack and passing in the parameters\r
867 specified by Context1 and Context2. Context1 and Context2 are optional and\r
868 may be 0. The function EntryPoint must never return.\r
869\r
870 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
871 is called. The descriptor in the GDT that this selector\r
872 references must be setup for 32-bit protected mode.\r
873 @param EntryPoint The 64-bit virtual address of the function to call with\r
874 the new stack after paging is disabled.\r
875 @param Context1 The 64-bit virtual address of the context to pass into\r
876 the EntryPoint function as the first parameter after\r
877 paging is disabled.\r
878 @param Context2 The 64-bit virtual address of the context to pass into\r
879 the EntryPoint function as the second parameter after\r
880 paging is disabled.\r
881 @param NewStack The 64-bit virtual address of the new stack to use for\r
882 the EntryPoint function after paging is disabled.\r
883\r
884**/\r
885VOID\r
886EFIAPI\r
887InternalX86DisablePaging64 (\r
888 IN UINT16 Cs,\r
889 IN UINT32 EntryPoint,\r
890 IN UINT32 Context1, OPTIONAL\r
891 IN UINT32 Context2, OPTIONAL\r
892 IN UINT32 NewStack\r
893 );\r
894\r
9ec9a7a5
QL
895/**\r
896 Generates a 16-bit random number through RDRAND instruction.\r
897\r
898 @param[out] Rand Buffer pointer to store the random result.\r
899\r
900 @retval TRUE RDRAND call was successful.\r
901 @retval FALSE Failed attempts to call RDRAND.\r
902\r
903 **/\r
904BOOLEAN\r
905EFIAPI\r
906InternalX86RdRand16 (\r
907 OUT UINT16 *Rand\r
908 );\r
909\r
910/**\r
911 Generates a 32-bit random number through RDRAND instruction.\r
912\r
913 @param[out] Rand Buffer pointer to store the random result.\r
914\r
915 @retval TRUE RDRAND call was successful.\r
916 @retval FALSE Failed attempts to call RDRAND.\r
917\r
918**/\r
919BOOLEAN\r
920EFIAPI\r
921InternalX86RdRand32 (\r
922 OUT UINT32 *Rand\r
923 );\r
924\r
925/**\r
926 Generates a 64-bit random number through RDRAND instruction.\r
927\r
928\r
929 @param[out] Rand Buffer pointer to store the random result.\r
930\r
931 @retval TRUE RDRAND call was successful.\r
932 @retval FALSE Failed attempts to call RDRAND.\r
933\r
934**/\r
935BOOLEAN\r
936EFIAPI\r
937InternalX86RdRand64 (\r
938 OUT UINT64 *Rand\r
939 );\r
940\r
e1f414b6 941\r
942#elif defined (MDE_CPU_IPF)\r
943//\r
944//\r
945// IPF specific functions\r
946//\r
947\r
aad6137d 948/**\r
949 Reads control register DCR.\r
950\r
951 This is a worker function for AsmReadControlRegister()\r
127010dd 952 when its parameter Index is IPF_CONTROL_REGISTER_DCR.\r
aad6137d 953\r
954 @return The 64-bit control register DCR.\r
955\r
956**/\r
957UINT64\r
958EFIAPI\r
959AsmReadControlRegisterDcr (\r
960 VOID\r
961 );\r
962\r
963\r
964/**\r
965 Reads control register ITM.\r
966\r
967 This is a worker function for AsmReadControlRegister()\r
127010dd 968 when its parameter Index is IPF_CONTROL_REGISTER_ITM.\r
aad6137d 969\r
970 @return The 64-bit control register ITM.\r
971\r
972**/\r
973UINT64\r
974EFIAPI\r
975AsmReadControlRegisterItm (\r
976 VOID\r
977 );\r
978\r
979\r
980/**\r
981 Reads control register IVA.\r
982\r
983 This is a worker function for AsmReadControlRegister()\r
127010dd 984 when its parameter Index is IPF_CONTROL_REGISTER_IVA.\r
aad6137d 985\r
986 @return The 64-bit control register IVA.\r
987\r
988**/\r
989UINT64\r
990EFIAPI\r
991AsmReadControlRegisterIva (\r
992 VOID\r
993 );\r
994\r
995\r
996/**\r
997 Reads control register PTA.\r
998\r
999 This is a worker function for AsmReadControlRegister()\r
127010dd 1000 when its parameter Index is IPF_CONTROL_REGISTER_PTA.\r
aad6137d 1001\r
1002 @return The 64-bit control register PTA.\r
1003\r
1004**/\r
1005UINT64\r
1006EFIAPI\r
1007AsmReadControlRegisterPta (\r
1008 VOID\r
1009 );\r
1010\r
1011\r
1012/**\r
1013 Reads control register IPSR.\r
1014\r
1015 This is a worker function for AsmReadControlRegister()\r
127010dd 1016 when its parameter Index is IPF_CONTROL_REGISTER_IPSR.\r
aad6137d 1017\r
1018 @return The 64-bit control register IPSR.\r
1019\r
1020**/\r
1021UINT64\r
1022EFIAPI\r
1023AsmReadControlRegisterIpsr (\r
1024 VOID\r
1025 );\r
1026\r
1027\r
1028/**\r
1029 Reads control register ISR.\r
1030\r
1031 This is a worker function for AsmReadControlRegister()\r
127010dd 1032 when its parameter Index is IPF_CONTROL_REGISTER_ISR.\r
aad6137d 1033\r
1034 @return The 64-bit control register ISR.\r
1035\r
1036**/\r
1037UINT64\r
1038EFIAPI\r
1039AsmReadControlRegisterIsr (\r
1040 VOID\r
1041 );\r
1042\r
1043\r
1044/**\r
1045 Reads control register IIP.\r
1046\r
1047 This is a worker function for AsmReadControlRegister()\r
127010dd 1048 when its parameter Index is IPF_CONTROL_REGISTER_IIP.\r
aad6137d 1049\r
1050 @return The 64-bit control register IIP.\r
1051\r
1052**/\r
1053UINT64\r
1054EFIAPI\r
1055AsmReadControlRegisterIip (\r
1056 VOID\r
1057 );\r
1058\r
1059\r
1060/**\r
1061 Reads control register IFA.\r
1062\r
1063 This is a worker function for AsmReadControlRegister()\r
127010dd 1064 when its parameter Index is IPF_CONTROL_REGISTER_IFA.\r
aad6137d 1065\r
1066 @return The 64-bit control register IFA.\r
1067\r
1068**/\r
1069UINT64\r
1070EFIAPI\r
1071AsmReadControlRegisterIfa (\r
1072 VOID\r
1073 );\r
1074\r
1075\r
1076/**\r
1077 Reads control register ITIR.\r
1078\r
1079 This is a worker function for AsmReadControlRegister()\r
127010dd 1080 when its parameter Index is IPF_CONTROL_REGISTER_ITIR.\r
aad6137d 1081\r
1082 @return The 64-bit control register ITIR.\r
1083\r
1084**/\r
1085UINT64\r
1086EFIAPI\r
1087AsmReadControlRegisterItir (\r
1088 VOID\r
1089 );\r
1090\r
1091\r
1092/**\r
1093 Reads control register IIPA.\r
1094\r
1095 This is a worker function for AsmReadControlRegister()\r
127010dd 1096 when its parameter Index is IPF_CONTROL_REGISTER_IIPA.\r
aad6137d 1097\r
1098 @return The 64-bit control register IIPA.\r
1099\r
1100**/\r
1101UINT64\r
1102EFIAPI\r
1103AsmReadControlRegisterIipa (\r
1104 VOID\r
1105 );\r
1106\r
1107\r
1108/**\r
1109 Reads control register IFS.\r
1110\r
1111 This is a worker function for AsmReadControlRegister()\r
127010dd 1112 when its parameter Index is IPF_CONTROL_REGISTER_IFS.\r
aad6137d 1113\r
1114 @return The 64-bit control register IFS.\r
1115\r
1116**/\r
1117UINT64\r
1118EFIAPI\r
1119AsmReadControlRegisterIfs (\r
1120 VOID\r
1121 );\r
1122\r
1123\r
1124/**\r
1125 Reads control register IIM.\r
1126\r
1127 This is a worker function for AsmReadControlRegister()\r
127010dd 1128 when its parameter Index is IPF_CONTROL_REGISTER_IIM.\r
aad6137d 1129\r
1130 @return The 64-bit control register IIM.\r
1131\r
1132**/\r
1133UINT64\r
1134EFIAPI\r
1135AsmReadControlRegisterIim (\r
1136 VOID\r
1137 );\r
1138\r
1139\r
1140/**\r
1141 Reads control register IHA.\r
1142\r
1143 This is a worker function for AsmReadControlRegister()\r
127010dd 1144 when its parameter Index is IPF_CONTROL_REGISTER_IHA.\r
aad6137d 1145\r
1146 @return The 64-bit control register IHA.\r
1147\r
1148**/\r
1149UINT64\r
1150EFIAPI\r
1151AsmReadControlRegisterIha (\r
1152 VOID\r
1153 );\r
1154\r
1155\r
1156/**\r
1157 Reads control register LID.\r
1158\r
1159 This is a worker function for AsmReadControlRegister()\r
127010dd 1160 when its parameter Index is IPF_CONTROL_REGISTER_LID.\r
aad6137d 1161\r
1162 @return The 64-bit control register LID.\r
1163\r
1164**/\r
1165UINT64\r
1166EFIAPI\r
1167AsmReadControlRegisterLid (\r
1168 VOID\r
1169 );\r
1170\r
1171\r
1172/**\r
1173 Reads control register IVR.\r
1174\r
1175 This is a worker function for AsmReadControlRegister()\r
127010dd 1176 when its parameter Index is IPF_CONTROL_REGISTER_IVR.\r
aad6137d 1177\r
1178 @return The 64-bit control register IVR.\r
1179\r
1180**/\r
1181UINT64\r
1182EFIAPI\r
1183AsmReadControlRegisterIvr (\r
1184 VOID\r
1185 );\r
1186\r
1187\r
1188/**\r
1189 Reads control register TPR.\r
1190\r
1191 This is a worker function for AsmReadControlRegister()\r
127010dd 1192 when its parameter Index is IPF_CONTROL_REGISTER_TPR.\r
aad6137d 1193\r
1194 @return The 64-bit control register TPR.\r
1195\r
1196**/\r
1197UINT64\r
1198EFIAPI\r
1199AsmReadControlRegisterTpr (\r
1200 VOID\r
1201 );\r
1202\r
1203\r
1204/**\r
1205 Reads control register EOI.\r
1206\r
1207 This is a worker function for AsmReadControlRegister()\r
127010dd 1208 when its parameter Index is IPF_CONTROL_REGISTER_EOI.\r
aad6137d 1209\r
1210 @return The 64-bit control register EOI.\r
1211\r
1212**/\r
1213UINT64\r
1214EFIAPI\r
1215AsmReadControlRegisterEoi (\r
1216 VOID\r
1217 );\r
1218\r
1219\r
1220/**\r
1221 Reads control register IRR0.\r
1222\r
1223 This is a worker function for AsmReadControlRegister()\r
127010dd 1224 when its parameter Index is IPF_CONTROL_REGISTER_IRR0.\r
aad6137d 1225\r
1226 @return The 64-bit control register IRR0.\r
1227\r
1228**/\r
1229UINT64\r
1230EFIAPI\r
1231AsmReadControlRegisterIrr0 (\r
1232 VOID\r
1233 );\r
1234\r
1235\r
1236/**\r
1237 Reads control register IRR1.\r
1238\r
1239 This is a worker function for AsmReadControlRegister()\r
127010dd 1240 when its parameter Index is IPF_CONTROL_REGISTER_IRR1.\r
aad6137d 1241\r
1242 @return The 64-bit control register IRR1.\r
1243\r
1244**/\r
1245UINT64\r
1246EFIAPI\r
1247AsmReadControlRegisterIrr1 (\r
1248 VOID\r
1249 );\r
1250\r
1251\r
1252/**\r
1253 Reads control register IRR2.\r
1254\r
1255 This is a worker function for AsmReadControlRegister()\r
127010dd 1256 when its parameter Index is IPF_CONTROL_REGISTER_IRR2.\r
aad6137d 1257\r
1258 @return The 64-bit control register IRR2.\r
1259\r
1260**/\r
1261UINT64\r
1262EFIAPI\r
1263AsmReadControlRegisterIrr2 (\r
1264 VOID\r
1265 );\r
1266\r
1267\r
1268/**\r
1269 Reads control register IRR3.\r
1270\r
1271 This is a worker function for AsmReadControlRegister()\r
127010dd 1272 when its parameter Index is IPF_CONTROL_REGISTER_IRR3.\r
aad6137d 1273\r
1274 @return The 64-bit control register IRR3.\r
1275\r
1276**/\r
1277UINT64\r
1278EFIAPI\r
1279AsmReadControlRegisterIrr3 (\r
1280 VOID\r
1281 );\r
1282\r
1283\r
1284/**\r
1285 Reads control register ITV.\r
1286\r
1287 This is a worker function for AsmReadControlRegister()\r
127010dd 1288 when its parameter Index is IPF_CONTROL_REGISTER_ITV.\r
aad6137d 1289\r
1290 @return The 64-bit control register ITV.\r
1291\r
1292**/\r
1293UINT64\r
1294EFIAPI\r
1295AsmReadControlRegisterItv (\r
1296 VOID\r
1297 );\r
1298\r
1299\r
1300/**\r
1301 Reads control register PMV.\r
1302\r
1303 This is a worker function for AsmReadControlRegister()\r
127010dd 1304 when its parameter Index is IPF_CONTROL_REGISTER_PMV.\r
aad6137d 1305\r
1306 @return The 64-bit control register PMV.\r
1307\r
1308**/\r
1309UINT64\r
1310EFIAPI\r
1311AsmReadControlRegisterPmv (\r
1312 VOID\r
1313 );\r
1314\r
1315\r
1316/**\r
1317 Reads control register CMCV.\r
1318\r
1319 This is a worker function for AsmReadControlRegister()\r
127010dd 1320 when its parameter Index is IPF_CONTROL_REGISTER_CMCV.\r
aad6137d 1321\r
1322 @return The 64-bit control register CMCV.\r
1323\r
1324**/\r
1325UINT64\r
1326EFIAPI\r
1327AsmReadControlRegisterCmcv (\r
1328 VOID\r
1329 );\r
1330\r
1331\r
1332/**\r
1333 Reads control register LRR0.\r
1334\r
1335 This is a worker function for AsmReadControlRegister()\r
127010dd 1336 when its parameter Index is IPF_CONTROL_REGISTER_LRR0.\r
aad6137d 1337\r
1338 @return The 64-bit control register LRR0.\r
1339\r
1340**/\r
1341UINT64\r
1342EFIAPI\r
1343AsmReadControlRegisterLrr0 (\r
1344 VOID\r
1345 );\r
1346\r
1347\r
1348/**\r
1349 Reads control register LRR1.\r
1350\r
1351 This is a worker function for AsmReadControlRegister()\r
127010dd 1352 when its parameter Index is IPF_CONTROL_REGISTER_LRR1.\r
aad6137d 1353\r
1354 @return The 64-bit control register LRR1.\r
1355\r
1356**/\r
1357UINT64\r
1358EFIAPI\r
1359AsmReadControlRegisterLrr1 (\r
1360 VOID\r
1361 );\r
1362\r
1363\r
1364/**\r
1365 Reads application register K0.\r
1366\r
1367 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1368 when its parameter Index is IPF_APPLICATION_REGISTER_K0.\r
aad6137d 1369\r
1370 @return The 64-bit application register K0.\r
1371\r
1372**/\r
1373UINT64\r
1374EFIAPI\r
1375AsmReadApplicationRegisterK0 (\r
1376 VOID\r
1377 );\r
1378\r
1379\r
1380\r
1381/**\r
1382 Reads application register K1.\r
1383\r
1384 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1385 when its parameter Index is IPF_APPLICATION_REGISTER_K1.\r
aad6137d 1386\r
1387 @return The 64-bit application register K1.\r
1388\r
1389**/\r
1390UINT64\r
1391EFIAPI\r
1392AsmReadApplicationRegisterK1 (\r
1393 VOID\r
1394 );\r
1395\r
1396\r
1397/**\r
1398 Reads application register K2.\r
1399\r
1400 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1401 when its parameter Index is IPF_APPLICATION_REGISTER_K2.\r
aad6137d 1402\r
1403 @return The 64-bit application register K2.\r
1404\r
1405**/\r
1406UINT64\r
1407EFIAPI\r
1408AsmReadApplicationRegisterK2 (\r
1409 VOID\r
1410 );\r
1411\r
1412\r
1413/**\r
1414 Reads application register K3.\r
1415\r
1416 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1417 when its parameter Index is IPF_APPLICATION_REGISTER_K3.\r
aad6137d 1418\r
1419 @return The 64-bit application register K3.\r
1420\r
1421**/\r
1422UINT64\r
1423EFIAPI\r
1424AsmReadApplicationRegisterK3 (\r
1425 VOID\r
1426 );\r
1427\r
1428\r
1429/**\r
1430 Reads application register K4.\r
1431\r
1432 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1433 when its parameter Index is IPF_APPLICATION_REGISTER_K4.\r
aad6137d 1434\r
1435 @return The 64-bit application register K4.\r
1436\r
1437**/\r
1438UINT64\r
1439EFIAPI\r
1440AsmReadApplicationRegisterK4 (\r
1441 VOID\r
1442 );\r
1443\r
1444\r
1445/**\r
1446 Reads application register K5.\r
1447\r
1448 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1449 when its parameter Index is IPF_APPLICATION_REGISTER_K5.\r
aad6137d 1450\r
1451 @return The 64-bit application register K5.\r
1452\r
1453**/\r
1454UINT64\r
1455EFIAPI\r
1456AsmReadApplicationRegisterK5 (\r
1457 VOID\r
1458 );\r
1459\r
1460\r
1461/**\r
1462 Reads application register K6.\r
1463\r
1464 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1465 when its parameter Index is IPF_APPLICATION_REGISTER_K6.\r
aad6137d 1466\r
1467 @return The 64-bit application register K6.\r
1468\r
1469**/\r
1470UINT64\r
1471EFIAPI\r
1472AsmReadApplicationRegisterK6 (\r
1473 VOID\r
1474 );\r
1475\r
1476\r
1477/**\r
1478 Reads application register K7.\r
1479\r
1480 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1481 when its parameter Index is IPF_APPLICATION_REGISTER_K7.\r
aad6137d 1482\r
1483 @return The 64-bit application register K7.\r
1484\r
1485**/\r
1486UINT64\r
1487EFIAPI\r
1488AsmReadApplicationRegisterK7 (\r
1489 VOID\r
1490 );\r
1491\r
1492\r
1493/**\r
1494 Reads application register RSC.\r
1495\r
1496 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1497 when its parameter Index is IPF_APPLICATION_REGISTER_RSC.\r
aad6137d 1498\r
1499 @return The 64-bit application register RSC.\r
1500\r
1501**/\r
1502UINT64\r
1503EFIAPI\r
1504AsmReadApplicationRegisterRsc (\r
1505 VOID\r
1506 );\r
1507\r
1508\r
1509/**\r
1510 Reads application register BSP.\r
1511\r
1512 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1513 when its parameter Index is IPF_APPLICATION_REGISTER_BSP.\r
aad6137d 1514\r
1515 @return The 64-bit application register BSP.\r
1516\r
1517**/\r
1518UINT64\r
1519EFIAPI\r
1520AsmReadApplicationRegisterBsp (\r
1521 VOID\r
1522 );\r
1523\r
1524\r
1525/**\r
1526 Reads application register BSPSTORE.\r
1527\r
1528 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1529 when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE.\r
aad6137d 1530\r
1531 @return The 64-bit application register BSPSTORE.\r
1532\r
1533**/\r
1534UINT64\r
1535EFIAPI\r
1536AsmReadApplicationRegisterBspstore (\r
1537 VOID\r
1538 );\r
1539\r
1540\r
1541/**\r
1542 Reads application register RNAT.\r
1543\r
1544 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1545 when its parameter Index is IPF_APPLICATION_REGISTER_RNAT.\r
aad6137d 1546\r
1547 @return The 64-bit application register RNAT.\r
1548\r
1549**/\r
1550UINT64\r
1551EFIAPI\r
1552AsmReadApplicationRegisterRnat (\r
1553 VOID\r
1554 );\r
1555\r
1556\r
1557/**\r
1558 Reads application register FCR.\r
1559\r
1560 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1561 when its parameter Index is IPF_APPLICATION_REGISTER_FCR.\r
aad6137d 1562\r
1563 @return The 64-bit application register FCR.\r
1564\r
1565**/\r
1566UINT64\r
1567EFIAPI\r
1568AsmReadApplicationRegisterFcr (\r
1569 VOID\r
1570 );\r
1571\r
1572\r
1573/**\r
1574 Reads application register EFLAG.\r
1575\r
1576 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1577 when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG.\r
aad6137d 1578\r
1579 @return The 64-bit application register EFLAG.\r
1580\r
1581**/\r
1582UINT64\r
1583EFIAPI\r
1584AsmReadApplicationRegisterEflag (\r
1585 VOID\r
1586 );\r
1587\r
1588\r
1589/**\r
1590 Reads application register CSD.\r
1591\r
1592 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1593 when its parameter Index is IPF_APPLICATION_REGISTER_CSD.\r
aad6137d 1594\r
1595 @return The 64-bit application register CSD.\r
1596\r
1597**/\r
1598UINT64\r
1599EFIAPI\r
1600AsmReadApplicationRegisterCsd (\r
1601 VOID\r
1602 );\r
1603\r
1604\r
1605/**\r
1606 Reads application register SSD.\r
1607\r
1608 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1609 when its parameter Index is IPF_APPLICATION_REGISTER_SSD.\r
aad6137d 1610\r
1611 @return The 64-bit application register SSD.\r
1612\r
1613**/\r
1614UINT64\r
1615EFIAPI\r
1616AsmReadApplicationRegisterSsd (\r
1617 VOID\r
1618 );\r
1619\r
1620\r
1621/**\r
1622 Reads application register CFLG.\r
1623\r
1624 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1625 when its parameter Index is IPF_APPLICATION_REGISTER_CFLG.\r
aad6137d 1626\r
1627 @return The 64-bit application register CFLG.\r
1628\r
1629**/\r
1630UINT64\r
1631EFIAPI\r
1632AsmReadApplicationRegisterCflg (\r
1633 VOID\r
1634 );\r
1635\r
1636\r
1637/**\r
1638 Reads application register FSR.\r
1639\r
1640 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1641 when its parameter Index is IPF_APPLICATION_REGISTER_FSR.\r
aad6137d 1642\r
1643 @return The 64-bit application register FSR.\r
1644\r
1645**/\r
1646UINT64\r
1647EFIAPI\r
1648AsmReadApplicationRegisterFsr (\r
1649 VOID\r
1650 );\r
1651\r
1652\r
1653/**\r
1654 Reads application register FIR.\r
1655\r
1656 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1657 when its parameter Index is IPF_APPLICATION_REGISTER_FIR.\r
aad6137d 1658\r
1659 @return The 64-bit application register FIR.\r
1660\r
1661**/\r
1662UINT64\r
1663EFIAPI\r
1664AsmReadApplicationRegisterFir (\r
1665 VOID\r
1666 );\r
1667\r
1668\r
1669/**\r
1670 Reads application register FDR.\r
1671\r
1672 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1673 when its parameter Index is IPF_APPLICATION_REGISTER_FDR.\r
aad6137d 1674\r
1675 @return The 64-bit application register FDR.\r
1676\r
1677**/\r
1678UINT64\r
1679EFIAPI\r
1680AsmReadApplicationRegisterFdr (\r
1681 VOID\r
1682 );\r
1683\r
1684\r
1685/**\r
1686 Reads application register CCV.\r
1687\r
1688 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1689 when its parameter Index is IPF_APPLICATION_REGISTER_CCV.\r
aad6137d 1690\r
1691 @return The 64-bit application register CCV.\r
1692\r
1693**/\r
1694UINT64\r
1695EFIAPI\r
1696AsmReadApplicationRegisterCcv (\r
1697 VOID\r
1698 );\r
1699\r
1700\r
1701/**\r
1702 Reads application register UNAT.\r
1703\r
1704 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1705 when its parameter Index is IPF_APPLICATION_REGISTER_UNAT.\r
aad6137d 1706\r
1707 @return The 64-bit application register UNAT.\r
1708\r
1709**/\r
1710UINT64\r
1711EFIAPI\r
1712AsmReadApplicationRegisterUnat (\r
1713 VOID\r
1714 );\r
1715\r
1716\r
1717/**\r
1718 Reads application register FPSR.\r
1719\r
1720 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1721 when its parameter Index is IPF_APPLICATION_REGISTER_FPSR.\r
aad6137d 1722\r
1723 @return The 64-bit application register FPSR.\r
1724\r
1725**/\r
1726UINT64\r
1727EFIAPI\r
1728AsmReadApplicationRegisterFpsr (\r
1729 VOID\r
1730 );\r
1731\r
1732\r
1733/**\r
1734 Reads application register ITC.\r
1735\r
1736 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1737 when its parameter Index is IPF_APPLICATION_REGISTER_ITC.\r
aad6137d 1738\r
1739 @return The 64-bit application register ITC.\r
1740\r
1741**/\r
1742UINT64\r
1743EFIAPI\r
1744AsmReadApplicationRegisterItc (\r
1745 VOID\r
1746 );\r
1747\r
1748\r
1749/**\r
1750 Reads application register PFS.\r
1751\r
1752 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1753 when its parameter Index is IPF_APPLICATION_REGISTER_PFS.\r
aad6137d 1754\r
1755 @return The 64-bit application register PFS.\r
1756\r
1757**/\r
1758UINT64\r
1759EFIAPI\r
1760AsmReadApplicationRegisterPfs (\r
1761 VOID\r
1762 );\r
1763\r
1764\r
1765/**\r
1766 Reads application register LC.\r
1767\r
1768 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1769 when its parameter Index is IPF_APPLICATION_REGISTER_LC.\r
aad6137d 1770\r
1771 @return The 64-bit application register LC.\r
1772\r
1773**/\r
1774UINT64\r
1775EFIAPI\r
1776AsmReadApplicationRegisterLc (\r
1777 VOID\r
1778 );\r
1779\r
1780\r
1781/**\r
1782 Reads application register EC.\r
1783\r
1784 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1785 when its parameter Index is IPF_APPLICATION_REGISTER_EC.\r
aad6137d 1786\r
1787 @return The 64-bit application register EC.\r
1788\r
1789**/\r
1790UINT64\r
1791EFIAPI\r
1792AsmReadApplicationRegisterEc (\r
1793 VOID\r
1794 );\r
1795\r
1796\r
1797\r
e1f414b6 1798/**\r
1799 Transfers control to a function starting with a new stack.\r
1800\r
1801 Transfers control to the function specified by EntryPoint using the new stack\r
1802 specified by NewStack and passing in the parameters specified by Context1 and\r
1803 Context2. Context1 and Context2 are optional and may be NULL. The function\r
1804 EntryPoint must never return.\r
1805\r
1806 If EntryPoint is NULL, then ASSERT().\r
1807 If NewStack is NULL, then ASSERT().\r
1808\r
1809 @param EntryPoint A pointer to function to call with the new stack.\r
1810 @param Context1 A pointer to the context to pass into the EntryPoint\r
1811 function.\r
1812 @param Context2 A pointer to the context to pass into the EntryPoint\r
1813 function.\r
1814 @param NewStack A pointer to the new stack to use for the EntryPoint\r
1815 function.\r
1816 @param NewBsp A pointer to the new memory location for RSE backing\r
1817 store.\r
1818\r
1819**/\r
1820VOID\r
1821EFIAPI\r
1822AsmSwitchStackAndBackingStore (\r
1823 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
1824 IN VOID *Context1, OPTIONAL\r
1825 IN VOID *Context2, OPTIONAL\r
1826 IN VOID *NewStack,\r
1827 IN VOID *NewBsp\r
1828 );\r
287f4f47 1829\r
1830/**\r
1831 Internal worker function to invalidate a range of instruction cache lines\r
1832 in the cache coherency domain of the calling CPU.\r
1833\r
1834 Internal worker function to invalidate the instruction cache lines specified\r
1835 by Address and Length. If Address is not aligned on a cache line boundary,\r
1836 then entire instruction cache line containing Address is invalidated. If\r
1837 Address + Length is not aligned on a cache line boundary, then the entire\r
1838 instruction cache line containing Address + Length -1 is invalidated. This\r
1839 function may choose to invalidate the entire instruction cache if that is more\r
1840 efficient than invalidating the specified range. If Length is 0, the no instruction\r
1841 cache lines are invalidated. Address is returned.\r
1842 This function is only available on IPF.\r
1843\r
1844 @param Address The base address of the instruction cache lines to\r
1845 invalidate. If the CPU is in a physical addressing mode, then\r
1846 Address is a physical address. If the CPU is in a virtual\r
1847 addressing mode, then Address is a virtual address.\r
1848\r
1849 @param Length The number of bytes to invalidate from the instruction cache.\r
1850\r
1851 @return Address\r
1852\r
1853**/\r
1854VOID *\r
1855EFIAPI\r
1856InternalFlushCacheRange (\r
1857 IN VOID *Address,\r
1858 IN UINTN Length\r
1859 );\r
1860\r
e1f414b6 1861#else\r
1862\r
1863#endif\r
1864\r
1865#endif\r