]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/BaseLibInternals.h
MdePkg/BaseLib: Add bit field population calculating methods
[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
e1f414b6 342/**\r
24dcb5e5 343 Worker function that returns a bit field from Operand.\r
e1f414b6 344\r
345 Returns the bitfield specified by the StartBit and the EndBit from Operand.\r
346\r
347 @param Operand Operand on which to perform the bitfield operation.\r
348 @param StartBit The ordinal of the least significant bit in the bit field.\r
349 @param EndBit The ordinal of the most significant bit in the bit field.\r
350\r
351 @return The bit field read.\r
352\r
353**/\r
28ca72bc 354UINTN\r
38bbd3d9 355EFIAPI\r
e1f414b6 356BitFieldReadUint (\r
28ca72bc 357 IN UINTN Operand,\r
e1f414b6 358 IN UINTN StartBit,\r
359 IN UINTN EndBit\r
360 );\r
361\r
362\r
363/**\r
364 Worker function that reads a bit field from Operand, performs a bitwise OR,\r
365 and returns the result.\r
366\r
367 Performs a bitwise OR between the bit field specified by StartBit and EndBit\r
368 in Operand and the value specified by AndData. All other bits in Operand are\r
369 preserved. The new value is returned.\r
370\r
371 @param Operand Operand on which to perform the bitfield operation.\r
372 @param StartBit The ordinal of the least significant bit in the bit field.\r
373 @param EndBit The ordinal of the most significant bit in the bit field.\r
374 @param OrData The value to OR with the read value from the value\r
375\r
376 @return The new value.\r
377\r
378**/\r
28ca72bc 379UINTN\r
38bbd3d9 380EFIAPI\r
e1f414b6 381BitFieldOrUint (\r
28ca72bc 382 IN UINTN Operand,\r
e1f414b6 383 IN UINTN StartBit,\r
384 IN UINTN EndBit,\r
28ca72bc 385 IN UINTN OrData\r
e1f414b6 386 );\r
387\r
388\r
389/**\r
390 Worker function that reads a bit field from Operand, performs a bitwise AND,\r
391 and returns the result.\r
392\r
393 Performs a bitwise AND between the bit field specified by StartBit and EndBit\r
394 in Operand and the value specified by AndData. All other bits in Operand are\r
395 preserved. The new value is returned.\r
396\r
397 @param Operand Operand on which to perform the bitfield operation.\r
398 @param StartBit The ordinal of the least significant bit in the bit field.\r
399 @param EndBit The ordinal of the most significant bit in the bit field.\r
400 @param AndData The value to And with the read value from the value\r
401\r
402 @return The new value.\r
403\r
404**/\r
28ca72bc 405UINTN\r
38bbd3d9 406EFIAPI\r
e1f414b6 407BitFieldAndUint (\r
28ca72bc 408 IN UINTN Operand,\r
e1f414b6 409 IN UINTN StartBit,\r
410 IN UINTN EndBit,\r
28ca72bc 411 IN UINTN AndData\r
e1f414b6 412 );\r
413\r
414\r
415/**\r
416 Worker function that checks ASSERT condition for JumpBuffer\r
417\r
418 Checks ASSERT condition for JumpBuffer.\r
419\r
420 If JumpBuffer is NULL, then ASSERT().\r
421 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().\r
422\r
423 @param JumpBuffer A pointer to CPU context buffer.\r
424\r
425**/\r
426VOID\r
38bbd3d9 427EFIAPI\r
e1f414b6 428InternalAssertJumpBuffer (\r
429 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer\r
430 );\r
431\r
432\r
433/**\r
434 Restores the CPU context that was saved with SetJump().\r
435\r
436 Restores the CPU context from the buffer specified by JumpBuffer.\r
437 This function never returns to the caller.\r
438 Instead is resumes execution based on the state of JumpBuffer.\r
439\r
440 @param JumpBuffer A pointer to CPU context buffer.\r
441 @param Value The value to return when the SetJump() context is restored.\r
442\r
443**/\r
444VOID\r
445EFIAPI\r
446InternalLongJump (\r
447 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,\r
448 IN UINTN Value\r
449 );\r
450\r
451\r
d8af3301
HW
452/**\r
453 Check if a Unicode character is a decimal character.\r
454\r
455 This internal function checks if a Unicode character is a\r
456 decimal character. The valid decimal character is from\r
457 L'0' to L'9'.\r
458\r
459 @param Char The character to check against.\r
460\r
461 @retval TRUE If the Char is a decmial character.\r
462 @retval FALSE If the Char is not a decmial character.\r
463\r
464**/\r
465BOOLEAN\r
466EFIAPI\r
467InternalIsDecimalDigitCharacter (\r
468 IN CHAR16 Char\r
469 );\r
470\r
471\r
472/**\r
473 Convert a Unicode character to upper case only if\r
474 it maps to a valid small-case ASCII character.\r
475\r
476 This internal function only deal with Unicode character\r
477 which maps to a valid small-case ASCII character, i.e.\r
478 L'a' to L'z'. For other Unicode character, the input character\r
479 is returned directly.\r
480\r
481 @param Char The character to convert.\r
482\r
483 @retval LowerCharacter If the Char is with range L'a' to L'z'.\r
484 @retval Unchanged Otherwise.\r
485\r
486**/\r
487CHAR16\r
488EFIAPI\r
489InternalCharToUpper (\r
490 IN CHAR16 Char\r
491 );\r
492\r
493\r
494/**\r
495 Convert a Unicode character to numerical value.\r
496\r
497 This internal function only deal with Unicode character\r
498 which maps to a valid hexadecimal ASII character, i.e.\r
499 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other\r
500 Unicode character, the value returned does not make sense.\r
501\r
502 @param Char The character to convert.\r
503\r
504 @return The numerical value converted.\r
505\r
506**/\r
507UINTN\r
508EFIAPI\r
509InternalHexCharToUintn (\r
510 IN CHAR16 Char\r
511 );\r
512\r
513\r
514/**\r
515 Check if a Unicode character is a hexadecimal character.\r
516\r
517 This internal function checks if a Unicode character is a\r
518 decimal character. The valid hexadecimal character is\r
519 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
520\r
521\r
522 @param Char The character to check against.\r
523\r
524 @retval TRUE If the Char is a hexadecmial character.\r
525 @retval FALSE If the Char is not a hexadecmial character.\r
526\r
527**/\r
528BOOLEAN\r
529EFIAPI\r
530InternalIsHexaDecimalDigitCharacter (\r
531 IN CHAR16 Char\r
532 );\r
533\r
534\r
535/**\r
536 Check if a ASCII character is a decimal character.\r
537\r
538 This internal function checks if a Unicode character is a\r
539 decimal character. The valid decimal character is from\r
540 '0' to '9'.\r
541\r
542 @param Char The character to check against.\r
543\r
544 @retval TRUE If the Char is a decmial character.\r
545 @retval FALSE If the Char is not a decmial character.\r
546\r
547**/\r
548BOOLEAN\r
549EFIAPI\r
550InternalAsciiIsDecimalDigitCharacter (\r
551 IN CHAR8 Char\r
552 );\r
553\r
554\r
555/**\r
556 Converts a lowercase Ascii character to upper one.\r
557\r
558 If Chr is lowercase Ascii character, then converts it to upper one.\r
559\r
560 If Value >= 0xA0, then ASSERT().\r
561 If (Value & 0x0F) >= 0x0A, then ASSERT().\r
562\r
563 @param Chr one Ascii character\r
564\r
565 @return The uppercase value of Ascii character\r
566\r
567**/\r
568CHAR8\r
569EFIAPI\r
570InternalBaseLibAsciiToUpper (\r
571 IN CHAR8 Chr\r
572 );\r
573\r
574\r
575/**\r
576 Check if a ASCII character is a hexadecimal character.\r
577\r
578 This internal function checks if a ASCII character is a\r
579 decimal character. The valid hexadecimal character is\r
580 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
581\r
582\r
583 @param Char The character to check against.\r
584\r
585 @retval TRUE If the Char is a hexadecmial character.\r
586 @retval FALSE If the Char is not a hexadecmial character.\r
587\r
588**/\r
589BOOLEAN\r
590EFIAPI\r
591InternalAsciiIsHexaDecimalDigitCharacter (\r
592 IN CHAR8 Char\r
593 );\r
594\r
595\r
596/**\r
597 Convert a ASCII character to numerical value.\r
598\r
599 This internal function only deal with Unicode character\r
600 which maps to a valid hexadecimal ASII character, i.e.\r
601 '0' to '9', 'a' to 'f' or 'A' to 'F'. For other\r
602 ASCII character, the value returned does not make sense.\r
603\r
604 @param Char The character to convert.\r
605\r
606 @return The numerical value converted.\r
607\r
608**/\r
609UINTN\r
610EFIAPI\r
611InternalAsciiHexCharToUintn (\r
612 IN CHAR8 Char\r
613 );\r
614\r
615\r
e1f414b6 616//\r
617// Ia32 and x64 specific functions\r
618//\r
619#if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)\r
620\r
621/**\r
622 Reads the current Global Descriptor Table Register(GDTR) descriptor.\r
623\r
624 Reads and returns the current GDTR descriptor and returns it in Gdtr. This\r
030cd1a2 625 function is only available on IA-32 and x64.\r
e1f414b6 626\r
127010dd 627 @param Gdtr The pointer to a GDTR descriptor.\r
e1f414b6 628\r
629**/\r
630VOID\r
631EFIAPI\r
632InternalX86ReadGdtr (\r
633 OUT IA32_DESCRIPTOR *Gdtr\r
634 );\r
635\r
636/**\r
637 Writes the current Global Descriptor Table Register (GDTR) descriptor.\r
638\r
639 Writes and the current GDTR descriptor specified by Gdtr. This function is\r
030cd1a2 640 only available on IA-32 and x64.\r
e1f414b6 641\r
127010dd 642 @param Gdtr The pointer to a GDTR descriptor.\r
e1f414b6 643\r
644**/\r
645VOID\r
646EFIAPI\r
647InternalX86WriteGdtr (\r
648 IN CONST IA32_DESCRIPTOR *Gdtr\r
649 );\r
650\r
651/**\r
652 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
653\r
654 Reads and returns the current IDTR descriptor and returns it in Idtr. This\r
030cd1a2 655 function is only available on IA-32 and x64.\r
e1f414b6 656\r
127010dd 657 @param Idtr The pointer to an IDTR descriptor.\r
e1f414b6 658\r
659**/\r
660VOID\r
661EFIAPI\r
662InternalX86ReadIdtr (\r
663 OUT IA32_DESCRIPTOR *Idtr\r
664 );\r
665\r
666/**\r
667 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.\r
668\r
669 Writes the current IDTR descriptor and returns it in Idtr. This function is\r
030cd1a2 670 only available on IA-32 and x64.\r
e1f414b6 671\r
127010dd 672 @param Idtr The pointer to an IDTR descriptor.\r
e1f414b6 673\r
674**/\r
675VOID\r
676EFIAPI\r
677InternalX86WriteIdtr (\r
678 IN CONST IA32_DESCRIPTOR *Idtr\r
679 );\r
680\r
681/**\r
682 Save the current floating point/SSE/SSE2 context to a buffer.\r
683\r
684 Saves the current floating point/SSE/SSE2 state to the buffer specified by\r
685 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only\r
030cd1a2 686 available on IA-32 and x64.\r
e1f414b6 687\r
127010dd 688 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
e1f414b6 689\r
690**/\r
691VOID\r
692EFIAPI\r
693InternalX86FxSave (\r
694 OUT IA32_FX_BUFFER *Buffer\r
695 );\r
696\r
697/**\r
698 Restores the current floating point/SSE/SSE2 context from a buffer.\r
699\r
700 Restores the current floating point/SSE/SSE2 state from the buffer specified\r
701 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is\r
030cd1a2 702 only available on IA-32 and x64.\r
e1f414b6 703\r
127010dd 704 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.\r
e1f414b6 705\r
706**/\r
707VOID\r
708EFIAPI\r
709InternalX86FxRestore (\r
710 IN CONST IA32_FX_BUFFER *Buffer\r
711 );\r
712\r
713/**\r
714 Enables the 32-bit paging mode on the CPU.\r
715\r
716 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
717 must be properly initialized prior to calling this service. This function\r
718 assumes the current execution mode is 32-bit protected mode. This function is\r
719 only available on IA-32. After the 32-bit paging mode is enabled, control is\r
720 transferred to the function specified by EntryPoint using the new stack\r
721 specified by NewStack and passing in the parameters specified by Context1 and\r
722 Context2. Context1 and Context2 are optional and may be NULL. The function\r
723 EntryPoint must never return.\r
724\r
725 There are a number of constraints that must be followed before calling this\r
726 function:\r
727 1) Interrupts must be disabled.\r
728 2) The caller must be in 32-bit protected mode with flat descriptors. This\r
729 means all descriptors must have a base of 0 and a limit of 4GB.\r
730 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r
731 descriptors.\r
732 4) CR3 must point to valid page tables that will be used once the transition\r
733 is complete, and those page tables must guarantee that the pages for this\r
734 function and the stack are identity mapped.\r
735\r
736 @param EntryPoint A pointer to function to call with the new stack after\r
737 paging is enabled.\r
738 @param Context1 A pointer to the context to pass into the EntryPoint\r
739 function as the first parameter after paging is enabled.\r
740 @param Context2 A pointer to the context to pass into the EntryPoint\r
741 function as the second parameter after paging is enabled.\r
742 @param NewStack A pointer to the new stack to use for the EntryPoint\r
743 function after paging is enabled.\r
744\r
745**/\r
746VOID\r
747EFIAPI\r
748InternalX86EnablePaging32 (\r
749 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
750 IN VOID *Context1, OPTIONAL\r
751 IN VOID *Context2, OPTIONAL\r
752 IN VOID *NewStack\r
753 );\r
754\r
755/**\r
756 Disables the 32-bit paging mode on the CPU.\r
757\r
758 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
759 mode. This function assumes the current execution mode is 32-paged protected\r
760 mode. This function is only available on IA-32. After the 32-bit paging mode\r
761 is disabled, control is transferred to the function specified by EntryPoint\r
762 using the new stack specified by NewStack and passing in the parameters\r
763 specified by Context1 and Context2. Context1 and Context2 are optional and\r
764 may be NULL. The function EntryPoint must never return.\r
765\r
766 There are a number of constraints that must be followed before calling this\r
767 function:\r
768 1) Interrupts must be disabled.\r
769 2) The caller must be in 32-bit paged mode.\r
770 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
771 4) CR3 must point to valid page tables that guarantee that the pages for\r
772 this function and the stack are identity mapped.\r
773\r
774 @param EntryPoint A pointer to function to call with the new stack after\r
775 paging is disabled.\r
776 @param Context1 A pointer to the context to pass into the EntryPoint\r
777 function as the first parameter after paging is disabled.\r
778 @param Context2 A pointer to the context to pass into the EntryPoint\r
779 function as the second parameter after paging is\r
780 disabled.\r
781 @param NewStack A pointer to the new stack to use for the EntryPoint\r
782 function after paging is disabled.\r
783\r
784**/\r
785VOID\r
786EFIAPI\r
787InternalX86DisablePaging32 (\r
788 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
789 IN VOID *Context1, OPTIONAL\r
790 IN VOID *Context2, OPTIONAL\r
791 IN VOID *NewStack\r
792 );\r
793\r
794/**\r
795 Enables the 64-bit paging mode on the CPU.\r
796\r
797 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r
798 must be properly initialized prior to calling this service. This function\r
799 assumes the current execution mode is 32-bit protected mode with flat\r
800 descriptors. This function is only available on IA-32. After the 64-bit\r
801 paging mode is enabled, control is transferred to the function specified by\r
802 EntryPoint using the new stack specified by NewStack and passing in the\r
803 parameters specified by Context1 and Context2. Context1 and Context2 are\r
804 optional and may be 0. The function EntryPoint must never return.\r
805\r
806 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
807 is called. The descriptor in the GDT that this selector\r
808 references must be setup for long mode.\r
809 @param EntryPoint The 64-bit virtual address of the function to call with\r
810 the new stack after paging is enabled.\r
811 @param Context1 The 64-bit virtual address of the context to pass into\r
812 the EntryPoint function as the first parameter after\r
813 paging is enabled.\r
814 @param Context2 The 64-bit virtual address of the context to pass into\r
815 the EntryPoint function as the second parameter after\r
816 paging is enabled.\r
817 @param NewStack The 64-bit virtual address of the new stack to use for\r
818 the EntryPoint function after paging is enabled.\r
819\r
820**/\r
821VOID\r
822EFIAPI\r
823InternalX86EnablePaging64 (\r
824 IN UINT16 Cs,\r
825 IN UINT64 EntryPoint,\r
826 IN UINT64 Context1, OPTIONAL\r
827 IN UINT64 Context2, OPTIONAL\r
828 IN UINT64 NewStack\r
829 );\r
830\r
831/**\r
832 Disables the 64-bit paging mode on the CPU.\r
833\r
834 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected\r
835 mode. This function assumes the current execution mode is 64-paging mode.\r
030cd1a2 836 This function is only available on x64. After the 64-bit paging mode is\r
e1f414b6 837 disabled, control is transferred to the function specified by EntryPoint\r
838 using the new stack specified by NewStack and passing in the parameters\r
839 specified by Context1 and Context2. Context1 and Context2 are optional and\r
840 may be 0. The function EntryPoint must never return.\r
841\r
842 @param Cs The 16-bit selector to load in the CS before EntryPoint\r
843 is called. The descriptor in the GDT that this selector\r
844 references must be setup for 32-bit protected mode.\r
845 @param EntryPoint The 64-bit virtual address of the function to call with\r
846 the new stack after paging is disabled.\r
847 @param Context1 The 64-bit virtual address of the context to pass into\r
848 the EntryPoint function as the first parameter after\r
849 paging is disabled.\r
850 @param Context2 The 64-bit virtual address of the context to pass into\r
851 the EntryPoint function as the second parameter after\r
852 paging is disabled.\r
853 @param NewStack The 64-bit virtual address of the new stack to use for\r
854 the EntryPoint function after paging is disabled.\r
855\r
856**/\r
857VOID\r
858EFIAPI\r
859InternalX86DisablePaging64 (\r
860 IN UINT16 Cs,\r
861 IN UINT32 EntryPoint,\r
862 IN UINT32 Context1, OPTIONAL\r
863 IN UINT32 Context2, OPTIONAL\r
864 IN UINT32 NewStack\r
865 );\r
866\r
9ec9a7a5
QL
867/**\r
868 Generates a 16-bit random number through RDRAND instruction.\r
869\r
870 @param[out] Rand Buffer pointer to store the random result.\r
871\r
872 @retval TRUE RDRAND call was successful.\r
873 @retval FALSE Failed attempts to call RDRAND.\r
874\r
875 **/\r
876BOOLEAN\r
877EFIAPI\r
878InternalX86RdRand16 (\r
879 OUT UINT16 *Rand\r
880 );\r
881\r
882/**\r
883 Generates a 32-bit random number through RDRAND instruction.\r
884\r
885 @param[out] Rand Buffer pointer to store the random result.\r
886\r
887 @retval TRUE RDRAND call was successful.\r
888 @retval FALSE Failed attempts to call RDRAND.\r
889\r
890**/\r
891BOOLEAN\r
892EFIAPI\r
893InternalX86RdRand32 (\r
894 OUT UINT32 *Rand\r
895 );\r
896\r
897/**\r
898 Generates a 64-bit random number through RDRAND instruction.\r
899\r
900\r
901 @param[out] Rand Buffer pointer to store the random result.\r
902\r
903 @retval TRUE RDRAND call was successful.\r
904 @retval FALSE Failed attempts to call RDRAND.\r
905\r
906**/\r
907BOOLEAN\r
908EFIAPI\r
909InternalX86RdRand64 (\r
910 OUT UINT64 *Rand\r
911 );\r
912\r
e1f414b6 913\r
914#elif defined (MDE_CPU_IPF)\r
915//\r
916//\r
917// IPF specific functions\r
918//\r
919\r
aad6137d 920/**\r
921 Reads control register DCR.\r
922\r
923 This is a worker function for AsmReadControlRegister()\r
127010dd 924 when its parameter Index is IPF_CONTROL_REGISTER_DCR.\r
aad6137d 925\r
926 @return The 64-bit control register DCR.\r
927\r
928**/\r
929UINT64\r
930EFIAPI\r
931AsmReadControlRegisterDcr (\r
932 VOID\r
933 );\r
934\r
935\r
936/**\r
937 Reads control register ITM.\r
938\r
939 This is a worker function for AsmReadControlRegister()\r
127010dd 940 when its parameter Index is IPF_CONTROL_REGISTER_ITM.\r
aad6137d 941\r
942 @return The 64-bit control register ITM.\r
943\r
944**/\r
945UINT64\r
946EFIAPI\r
947AsmReadControlRegisterItm (\r
948 VOID\r
949 );\r
950\r
951\r
952/**\r
953 Reads control register IVA.\r
954\r
955 This is a worker function for AsmReadControlRegister()\r
127010dd 956 when its parameter Index is IPF_CONTROL_REGISTER_IVA.\r
aad6137d 957\r
958 @return The 64-bit control register IVA.\r
959\r
960**/\r
961UINT64\r
962EFIAPI\r
963AsmReadControlRegisterIva (\r
964 VOID\r
965 );\r
966\r
967\r
968/**\r
969 Reads control register PTA.\r
970\r
971 This is a worker function for AsmReadControlRegister()\r
127010dd 972 when its parameter Index is IPF_CONTROL_REGISTER_PTA.\r
aad6137d 973\r
974 @return The 64-bit control register PTA.\r
975\r
976**/\r
977UINT64\r
978EFIAPI\r
979AsmReadControlRegisterPta (\r
980 VOID\r
981 );\r
982\r
983\r
984/**\r
985 Reads control register IPSR.\r
986\r
987 This is a worker function for AsmReadControlRegister()\r
127010dd 988 when its parameter Index is IPF_CONTROL_REGISTER_IPSR.\r
aad6137d 989\r
990 @return The 64-bit control register IPSR.\r
991\r
992**/\r
993UINT64\r
994EFIAPI\r
995AsmReadControlRegisterIpsr (\r
996 VOID\r
997 );\r
998\r
999\r
1000/**\r
1001 Reads control register ISR.\r
1002\r
1003 This is a worker function for AsmReadControlRegister()\r
127010dd 1004 when its parameter Index is IPF_CONTROL_REGISTER_ISR.\r
aad6137d 1005\r
1006 @return The 64-bit control register ISR.\r
1007\r
1008**/\r
1009UINT64\r
1010EFIAPI\r
1011AsmReadControlRegisterIsr (\r
1012 VOID\r
1013 );\r
1014\r
1015\r
1016/**\r
1017 Reads control register IIP.\r
1018\r
1019 This is a worker function for AsmReadControlRegister()\r
127010dd 1020 when its parameter Index is IPF_CONTROL_REGISTER_IIP.\r
aad6137d 1021\r
1022 @return The 64-bit control register IIP.\r
1023\r
1024**/\r
1025UINT64\r
1026EFIAPI\r
1027AsmReadControlRegisterIip (\r
1028 VOID\r
1029 );\r
1030\r
1031\r
1032/**\r
1033 Reads control register IFA.\r
1034\r
1035 This is a worker function for AsmReadControlRegister()\r
127010dd 1036 when its parameter Index is IPF_CONTROL_REGISTER_IFA.\r
aad6137d 1037\r
1038 @return The 64-bit control register IFA.\r
1039\r
1040**/\r
1041UINT64\r
1042EFIAPI\r
1043AsmReadControlRegisterIfa (\r
1044 VOID\r
1045 );\r
1046\r
1047\r
1048/**\r
1049 Reads control register ITIR.\r
1050\r
1051 This is a worker function for AsmReadControlRegister()\r
127010dd 1052 when its parameter Index is IPF_CONTROL_REGISTER_ITIR.\r
aad6137d 1053\r
1054 @return The 64-bit control register ITIR.\r
1055\r
1056**/\r
1057UINT64\r
1058EFIAPI\r
1059AsmReadControlRegisterItir (\r
1060 VOID\r
1061 );\r
1062\r
1063\r
1064/**\r
1065 Reads control register IIPA.\r
1066\r
1067 This is a worker function for AsmReadControlRegister()\r
127010dd 1068 when its parameter Index is IPF_CONTROL_REGISTER_IIPA.\r
aad6137d 1069\r
1070 @return The 64-bit control register IIPA.\r
1071\r
1072**/\r
1073UINT64\r
1074EFIAPI\r
1075AsmReadControlRegisterIipa (\r
1076 VOID\r
1077 );\r
1078\r
1079\r
1080/**\r
1081 Reads control register IFS.\r
1082\r
1083 This is a worker function for AsmReadControlRegister()\r
127010dd 1084 when its parameter Index is IPF_CONTROL_REGISTER_IFS.\r
aad6137d 1085\r
1086 @return The 64-bit control register IFS.\r
1087\r
1088**/\r
1089UINT64\r
1090EFIAPI\r
1091AsmReadControlRegisterIfs (\r
1092 VOID\r
1093 );\r
1094\r
1095\r
1096/**\r
1097 Reads control register IIM.\r
1098\r
1099 This is a worker function for AsmReadControlRegister()\r
127010dd 1100 when its parameter Index is IPF_CONTROL_REGISTER_IIM.\r
aad6137d 1101\r
1102 @return The 64-bit control register IIM.\r
1103\r
1104**/\r
1105UINT64\r
1106EFIAPI\r
1107AsmReadControlRegisterIim (\r
1108 VOID\r
1109 );\r
1110\r
1111\r
1112/**\r
1113 Reads control register IHA.\r
1114\r
1115 This is a worker function for AsmReadControlRegister()\r
127010dd 1116 when its parameter Index is IPF_CONTROL_REGISTER_IHA.\r
aad6137d 1117\r
1118 @return The 64-bit control register IHA.\r
1119\r
1120**/\r
1121UINT64\r
1122EFIAPI\r
1123AsmReadControlRegisterIha (\r
1124 VOID\r
1125 );\r
1126\r
1127\r
1128/**\r
1129 Reads control register LID.\r
1130\r
1131 This is a worker function for AsmReadControlRegister()\r
127010dd 1132 when its parameter Index is IPF_CONTROL_REGISTER_LID.\r
aad6137d 1133\r
1134 @return The 64-bit control register LID.\r
1135\r
1136**/\r
1137UINT64\r
1138EFIAPI\r
1139AsmReadControlRegisterLid (\r
1140 VOID\r
1141 );\r
1142\r
1143\r
1144/**\r
1145 Reads control register IVR.\r
1146\r
1147 This is a worker function for AsmReadControlRegister()\r
127010dd 1148 when its parameter Index is IPF_CONTROL_REGISTER_IVR.\r
aad6137d 1149\r
1150 @return The 64-bit control register IVR.\r
1151\r
1152**/\r
1153UINT64\r
1154EFIAPI\r
1155AsmReadControlRegisterIvr (\r
1156 VOID\r
1157 );\r
1158\r
1159\r
1160/**\r
1161 Reads control register TPR.\r
1162\r
1163 This is a worker function for AsmReadControlRegister()\r
127010dd 1164 when its parameter Index is IPF_CONTROL_REGISTER_TPR.\r
aad6137d 1165\r
1166 @return The 64-bit control register TPR.\r
1167\r
1168**/\r
1169UINT64\r
1170EFIAPI\r
1171AsmReadControlRegisterTpr (\r
1172 VOID\r
1173 );\r
1174\r
1175\r
1176/**\r
1177 Reads control register EOI.\r
1178\r
1179 This is a worker function for AsmReadControlRegister()\r
127010dd 1180 when its parameter Index is IPF_CONTROL_REGISTER_EOI.\r
aad6137d 1181\r
1182 @return The 64-bit control register EOI.\r
1183\r
1184**/\r
1185UINT64\r
1186EFIAPI\r
1187AsmReadControlRegisterEoi (\r
1188 VOID\r
1189 );\r
1190\r
1191\r
1192/**\r
1193 Reads control register IRR0.\r
1194\r
1195 This is a worker function for AsmReadControlRegister()\r
127010dd 1196 when its parameter Index is IPF_CONTROL_REGISTER_IRR0.\r
aad6137d 1197\r
1198 @return The 64-bit control register IRR0.\r
1199\r
1200**/\r
1201UINT64\r
1202EFIAPI\r
1203AsmReadControlRegisterIrr0 (\r
1204 VOID\r
1205 );\r
1206\r
1207\r
1208/**\r
1209 Reads control register IRR1.\r
1210\r
1211 This is a worker function for AsmReadControlRegister()\r
127010dd 1212 when its parameter Index is IPF_CONTROL_REGISTER_IRR1.\r
aad6137d 1213\r
1214 @return The 64-bit control register IRR1.\r
1215\r
1216**/\r
1217UINT64\r
1218EFIAPI\r
1219AsmReadControlRegisterIrr1 (\r
1220 VOID\r
1221 );\r
1222\r
1223\r
1224/**\r
1225 Reads control register IRR2.\r
1226\r
1227 This is a worker function for AsmReadControlRegister()\r
127010dd 1228 when its parameter Index is IPF_CONTROL_REGISTER_IRR2.\r
aad6137d 1229\r
1230 @return The 64-bit control register IRR2.\r
1231\r
1232**/\r
1233UINT64\r
1234EFIAPI\r
1235AsmReadControlRegisterIrr2 (\r
1236 VOID\r
1237 );\r
1238\r
1239\r
1240/**\r
1241 Reads control register IRR3.\r
1242\r
1243 This is a worker function for AsmReadControlRegister()\r
127010dd 1244 when its parameter Index is IPF_CONTROL_REGISTER_IRR3.\r
aad6137d 1245\r
1246 @return The 64-bit control register IRR3.\r
1247\r
1248**/\r
1249UINT64\r
1250EFIAPI\r
1251AsmReadControlRegisterIrr3 (\r
1252 VOID\r
1253 );\r
1254\r
1255\r
1256/**\r
1257 Reads control register ITV.\r
1258\r
1259 This is a worker function for AsmReadControlRegister()\r
127010dd 1260 when its parameter Index is IPF_CONTROL_REGISTER_ITV.\r
aad6137d 1261\r
1262 @return The 64-bit control register ITV.\r
1263\r
1264**/\r
1265UINT64\r
1266EFIAPI\r
1267AsmReadControlRegisterItv (\r
1268 VOID\r
1269 );\r
1270\r
1271\r
1272/**\r
1273 Reads control register PMV.\r
1274\r
1275 This is a worker function for AsmReadControlRegister()\r
127010dd 1276 when its parameter Index is IPF_CONTROL_REGISTER_PMV.\r
aad6137d 1277\r
1278 @return The 64-bit control register PMV.\r
1279\r
1280**/\r
1281UINT64\r
1282EFIAPI\r
1283AsmReadControlRegisterPmv (\r
1284 VOID\r
1285 );\r
1286\r
1287\r
1288/**\r
1289 Reads control register CMCV.\r
1290\r
1291 This is a worker function for AsmReadControlRegister()\r
127010dd 1292 when its parameter Index is IPF_CONTROL_REGISTER_CMCV.\r
aad6137d 1293\r
1294 @return The 64-bit control register CMCV.\r
1295\r
1296**/\r
1297UINT64\r
1298EFIAPI\r
1299AsmReadControlRegisterCmcv (\r
1300 VOID\r
1301 );\r
1302\r
1303\r
1304/**\r
1305 Reads control register LRR0.\r
1306\r
1307 This is a worker function for AsmReadControlRegister()\r
127010dd 1308 when its parameter Index is IPF_CONTROL_REGISTER_LRR0.\r
aad6137d 1309\r
1310 @return The 64-bit control register LRR0.\r
1311\r
1312**/\r
1313UINT64\r
1314EFIAPI\r
1315AsmReadControlRegisterLrr0 (\r
1316 VOID\r
1317 );\r
1318\r
1319\r
1320/**\r
1321 Reads control register LRR1.\r
1322\r
1323 This is a worker function for AsmReadControlRegister()\r
127010dd 1324 when its parameter Index is IPF_CONTROL_REGISTER_LRR1.\r
aad6137d 1325\r
1326 @return The 64-bit control register LRR1.\r
1327\r
1328**/\r
1329UINT64\r
1330EFIAPI\r
1331AsmReadControlRegisterLrr1 (\r
1332 VOID\r
1333 );\r
1334\r
1335\r
1336/**\r
1337 Reads application register K0.\r
1338\r
1339 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1340 when its parameter Index is IPF_APPLICATION_REGISTER_K0.\r
aad6137d 1341\r
1342 @return The 64-bit application register K0.\r
1343\r
1344**/\r
1345UINT64\r
1346EFIAPI\r
1347AsmReadApplicationRegisterK0 (\r
1348 VOID\r
1349 );\r
1350\r
1351\r
1352\r
1353/**\r
1354 Reads application register K1.\r
1355\r
1356 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1357 when its parameter Index is IPF_APPLICATION_REGISTER_K1.\r
aad6137d 1358\r
1359 @return The 64-bit application register K1.\r
1360\r
1361**/\r
1362UINT64\r
1363EFIAPI\r
1364AsmReadApplicationRegisterK1 (\r
1365 VOID\r
1366 );\r
1367\r
1368\r
1369/**\r
1370 Reads application register K2.\r
1371\r
1372 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1373 when its parameter Index is IPF_APPLICATION_REGISTER_K2.\r
aad6137d 1374\r
1375 @return The 64-bit application register K2.\r
1376\r
1377**/\r
1378UINT64\r
1379EFIAPI\r
1380AsmReadApplicationRegisterK2 (\r
1381 VOID\r
1382 );\r
1383\r
1384\r
1385/**\r
1386 Reads application register K3.\r
1387\r
1388 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1389 when its parameter Index is IPF_APPLICATION_REGISTER_K3.\r
aad6137d 1390\r
1391 @return The 64-bit application register K3.\r
1392\r
1393**/\r
1394UINT64\r
1395EFIAPI\r
1396AsmReadApplicationRegisterK3 (\r
1397 VOID\r
1398 );\r
1399\r
1400\r
1401/**\r
1402 Reads application register K4.\r
1403\r
1404 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1405 when its parameter Index is IPF_APPLICATION_REGISTER_K4.\r
aad6137d 1406\r
1407 @return The 64-bit application register K4.\r
1408\r
1409**/\r
1410UINT64\r
1411EFIAPI\r
1412AsmReadApplicationRegisterK4 (\r
1413 VOID\r
1414 );\r
1415\r
1416\r
1417/**\r
1418 Reads application register K5.\r
1419\r
1420 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1421 when its parameter Index is IPF_APPLICATION_REGISTER_K5.\r
aad6137d 1422\r
1423 @return The 64-bit application register K5.\r
1424\r
1425**/\r
1426UINT64\r
1427EFIAPI\r
1428AsmReadApplicationRegisterK5 (\r
1429 VOID\r
1430 );\r
1431\r
1432\r
1433/**\r
1434 Reads application register K6.\r
1435\r
1436 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1437 when its parameter Index is IPF_APPLICATION_REGISTER_K6.\r
aad6137d 1438\r
1439 @return The 64-bit application register K6.\r
1440\r
1441**/\r
1442UINT64\r
1443EFIAPI\r
1444AsmReadApplicationRegisterK6 (\r
1445 VOID\r
1446 );\r
1447\r
1448\r
1449/**\r
1450 Reads application register K7.\r
1451\r
1452 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1453 when its parameter Index is IPF_APPLICATION_REGISTER_K7.\r
aad6137d 1454\r
1455 @return The 64-bit application register K7.\r
1456\r
1457**/\r
1458UINT64\r
1459EFIAPI\r
1460AsmReadApplicationRegisterK7 (\r
1461 VOID\r
1462 );\r
1463\r
1464\r
1465/**\r
1466 Reads application register RSC.\r
1467\r
1468 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1469 when its parameter Index is IPF_APPLICATION_REGISTER_RSC.\r
aad6137d 1470\r
1471 @return The 64-bit application register RSC.\r
1472\r
1473**/\r
1474UINT64\r
1475EFIAPI\r
1476AsmReadApplicationRegisterRsc (\r
1477 VOID\r
1478 );\r
1479\r
1480\r
1481/**\r
1482 Reads application register BSP.\r
1483\r
1484 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1485 when its parameter Index is IPF_APPLICATION_REGISTER_BSP.\r
aad6137d 1486\r
1487 @return The 64-bit application register BSP.\r
1488\r
1489**/\r
1490UINT64\r
1491EFIAPI\r
1492AsmReadApplicationRegisterBsp (\r
1493 VOID\r
1494 );\r
1495\r
1496\r
1497/**\r
1498 Reads application register BSPSTORE.\r
1499\r
1500 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1501 when its parameter Index is IPF_APPLICATION_REGISTER_BSPSTORE.\r
aad6137d 1502\r
1503 @return The 64-bit application register BSPSTORE.\r
1504\r
1505**/\r
1506UINT64\r
1507EFIAPI\r
1508AsmReadApplicationRegisterBspstore (\r
1509 VOID\r
1510 );\r
1511\r
1512\r
1513/**\r
1514 Reads application register RNAT.\r
1515\r
1516 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1517 when its parameter Index is IPF_APPLICATION_REGISTER_RNAT.\r
aad6137d 1518\r
1519 @return The 64-bit application register RNAT.\r
1520\r
1521**/\r
1522UINT64\r
1523EFIAPI\r
1524AsmReadApplicationRegisterRnat (\r
1525 VOID\r
1526 );\r
1527\r
1528\r
1529/**\r
1530 Reads application register FCR.\r
1531\r
1532 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1533 when its parameter Index is IPF_APPLICATION_REGISTER_FCR.\r
aad6137d 1534\r
1535 @return The 64-bit application register FCR.\r
1536\r
1537**/\r
1538UINT64\r
1539EFIAPI\r
1540AsmReadApplicationRegisterFcr (\r
1541 VOID\r
1542 );\r
1543\r
1544\r
1545/**\r
1546 Reads application register EFLAG.\r
1547\r
1548 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1549 when its parameter Index is IPF_APPLICATION_REGISTER_EFLAG.\r
aad6137d 1550\r
1551 @return The 64-bit application register EFLAG.\r
1552\r
1553**/\r
1554UINT64\r
1555EFIAPI\r
1556AsmReadApplicationRegisterEflag (\r
1557 VOID\r
1558 );\r
1559\r
1560\r
1561/**\r
1562 Reads application register CSD.\r
1563\r
1564 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1565 when its parameter Index is IPF_APPLICATION_REGISTER_CSD.\r
aad6137d 1566\r
1567 @return The 64-bit application register CSD.\r
1568\r
1569**/\r
1570UINT64\r
1571EFIAPI\r
1572AsmReadApplicationRegisterCsd (\r
1573 VOID\r
1574 );\r
1575\r
1576\r
1577/**\r
1578 Reads application register SSD.\r
1579\r
1580 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1581 when its parameter Index is IPF_APPLICATION_REGISTER_SSD.\r
aad6137d 1582\r
1583 @return The 64-bit application register SSD.\r
1584\r
1585**/\r
1586UINT64\r
1587EFIAPI\r
1588AsmReadApplicationRegisterSsd (\r
1589 VOID\r
1590 );\r
1591\r
1592\r
1593/**\r
1594 Reads application register CFLG.\r
1595\r
1596 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1597 when its parameter Index is IPF_APPLICATION_REGISTER_CFLG.\r
aad6137d 1598\r
1599 @return The 64-bit application register CFLG.\r
1600\r
1601**/\r
1602UINT64\r
1603EFIAPI\r
1604AsmReadApplicationRegisterCflg (\r
1605 VOID\r
1606 );\r
1607\r
1608\r
1609/**\r
1610 Reads application register FSR.\r
1611\r
1612 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1613 when its parameter Index is IPF_APPLICATION_REGISTER_FSR.\r
aad6137d 1614\r
1615 @return The 64-bit application register FSR.\r
1616\r
1617**/\r
1618UINT64\r
1619EFIAPI\r
1620AsmReadApplicationRegisterFsr (\r
1621 VOID\r
1622 );\r
1623\r
1624\r
1625/**\r
1626 Reads application register FIR.\r
1627\r
1628 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1629 when its parameter Index is IPF_APPLICATION_REGISTER_FIR.\r
aad6137d 1630\r
1631 @return The 64-bit application register FIR.\r
1632\r
1633**/\r
1634UINT64\r
1635EFIAPI\r
1636AsmReadApplicationRegisterFir (\r
1637 VOID\r
1638 );\r
1639\r
1640\r
1641/**\r
1642 Reads application register FDR.\r
1643\r
1644 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1645 when its parameter Index is IPF_APPLICATION_REGISTER_FDR.\r
aad6137d 1646\r
1647 @return The 64-bit application register FDR.\r
1648\r
1649**/\r
1650UINT64\r
1651EFIAPI\r
1652AsmReadApplicationRegisterFdr (\r
1653 VOID\r
1654 );\r
1655\r
1656\r
1657/**\r
1658 Reads application register CCV.\r
1659\r
1660 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1661 when its parameter Index is IPF_APPLICATION_REGISTER_CCV.\r
aad6137d 1662\r
1663 @return The 64-bit application register CCV.\r
1664\r
1665**/\r
1666UINT64\r
1667EFIAPI\r
1668AsmReadApplicationRegisterCcv (\r
1669 VOID\r
1670 );\r
1671\r
1672\r
1673/**\r
1674 Reads application register UNAT.\r
1675\r
1676 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1677 when its parameter Index is IPF_APPLICATION_REGISTER_UNAT.\r
aad6137d 1678\r
1679 @return The 64-bit application register UNAT.\r
1680\r
1681**/\r
1682UINT64\r
1683EFIAPI\r
1684AsmReadApplicationRegisterUnat (\r
1685 VOID\r
1686 );\r
1687\r
1688\r
1689/**\r
1690 Reads application register FPSR.\r
1691\r
1692 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1693 when its parameter Index is IPF_APPLICATION_REGISTER_FPSR.\r
aad6137d 1694\r
1695 @return The 64-bit application register FPSR.\r
1696\r
1697**/\r
1698UINT64\r
1699EFIAPI\r
1700AsmReadApplicationRegisterFpsr (\r
1701 VOID\r
1702 );\r
1703\r
1704\r
1705/**\r
1706 Reads application register ITC.\r
1707\r
1708 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1709 when its parameter Index is IPF_APPLICATION_REGISTER_ITC.\r
aad6137d 1710\r
1711 @return The 64-bit application register ITC.\r
1712\r
1713**/\r
1714UINT64\r
1715EFIAPI\r
1716AsmReadApplicationRegisterItc (\r
1717 VOID\r
1718 );\r
1719\r
1720\r
1721/**\r
1722 Reads application register PFS.\r
1723\r
1724 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1725 when its parameter Index is IPF_APPLICATION_REGISTER_PFS.\r
aad6137d 1726\r
1727 @return The 64-bit application register PFS.\r
1728\r
1729**/\r
1730UINT64\r
1731EFIAPI\r
1732AsmReadApplicationRegisterPfs (\r
1733 VOID\r
1734 );\r
1735\r
1736\r
1737/**\r
1738 Reads application register LC.\r
1739\r
1740 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1741 when its parameter Index is IPF_APPLICATION_REGISTER_LC.\r
aad6137d 1742\r
1743 @return The 64-bit application register LC.\r
1744\r
1745**/\r
1746UINT64\r
1747EFIAPI\r
1748AsmReadApplicationRegisterLc (\r
1749 VOID\r
1750 );\r
1751\r
1752\r
1753/**\r
1754 Reads application register EC.\r
1755\r
1756 This is a worker function for AsmReadApplicationRegister()\r
127010dd 1757 when its parameter Index is IPF_APPLICATION_REGISTER_EC.\r
aad6137d 1758\r
1759 @return The 64-bit application register EC.\r
1760\r
1761**/\r
1762UINT64\r
1763EFIAPI\r
1764AsmReadApplicationRegisterEc (\r
1765 VOID\r
1766 );\r
1767\r
1768\r
1769\r
e1f414b6 1770/**\r
1771 Transfers control to a function starting with a new stack.\r
1772\r
1773 Transfers control to the function specified by EntryPoint using the new stack\r
1774 specified by NewStack and passing in the parameters specified by Context1 and\r
1775 Context2. Context1 and Context2 are optional and may be NULL. The function\r
1776 EntryPoint must never return.\r
1777\r
1778 If EntryPoint is NULL, then ASSERT().\r
1779 If NewStack is NULL, then ASSERT().\r
1780\r
1781 @param EntryPoint A pointer to function to call with the new stack.\r
1782 @param Context1 A pointer to the context to pass into the EntryPoint\r
1783 function.\r
1784 @param Context2 A pointer to the context to pass into the EntryPoint\r
1785 function.\r
1786 @param NewStack A pointer to the new stack to use for the EntryPoint\r
1787 function.\r
1788 @param NewBsp A pointer to the new memory location for RSE backing\r
1789 store.\r
1790\r
1791**/\r
1792VOID\r
1793EFIAPI\r
1794AsmSwitchStackAndBackingStore (\r
1795 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
1796 IN VOID *Context1, OPTIONAL\r
1797 IN VOID *Context2, OPTIONAL\r
1798 IN VOID *NewStack,\r
1799 IN VOID *NewBsp\r
1800 );\r
287f4f47 1801\r
1802/**\r
1803 Internal worker function to invalidate a range of instruction cache lines\r
1804 in the cache coherency domain of the calling CPU.\r
1805\r
1806 Internal worker function to invalidate the instruction cache lines specified\r
1807 by Address and Length. If Address is not aligned on a cache line boundary,\r
1808 then entire instruction cache line containing Address is invalidated. If\r
1809 Address + Length is not aligned on a cache line boundary, then the entire\r
1810 instruction cache line containing Address + Length -1 is invalidated. This\r
1811 function may choose to invalidate the entire instruction cache if that is more\r
1812 efficient than invalidating the specified range. If Length is 0, the no instruction\r
1813 cache lines are invalidated. Address is returned.\r
1814 This function is only available on IPF.\r
1815\r
1816 @param Address The base address of the instruction cache lines to\r
1817 invalidate. If the CPU is in a physical addressing mode, then\r
1818 Address is a physical address. If the CPU is in a virtual\r
1819 addressing mode, then Address is a virtual address.\r
1820\r
1821 @param Length The number of bytes to invalidate from the instruction cache.\r
1822\r
1823 @return Address\r
1824\r
1825**/\r
1826VOID *\r
1827EFIAPI\r
1828InternalFlushCacheRange (\r
1829 IN VOID *Address,\r
1830 IN UINTN Length\r
1831 );\r
1832\r
e1f414b6 1833#else\r
1834\r
1835#endif\r
1836\r
1837#endif\r