]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/BaseLibInternals.h
MdePkg/DxeRuntimeDebugLibSerialPort: Add new APIs
[mirror_edk2.git] / MdePkg / Library / BaseLib / BaseLibInternals.h
1 /** @file
2 Declaration of internal functions in BaseLib.
3
4 Copyright (c) 2006 - 2019, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __BASE_LIB_INTERNALS__
16 #define __BASE_LIB_INTERNALS__
17
18 #include <Base.h>
19 #include <Library/BaseLib.h>
20 #include <Library/BaseMemoryLib.h>
21 #include <Library/DebugLib.h>
22 #include <Library/PcdLib.h>
23
24 //
25 // Math functions
26 //
27
28 /**
29 Shifts a 64-bit integer left between 0 and 63 bits. The low bits
30 are filled with zeros. The shifted value is returned.
31
32 This function shifts the 64-bit value Operand to the left by Count bits. The
33 low Count bits are set to zero. The shifted value is returned.
34
35 @param Operand The 64-bit operand to shift left.
36 @param Count The number of bits to shift left.
37
38 @return Operand << Count
39
40 **/
41 UINT64
42 EFIAPI
43 InternalMathLShiftU64 (
44 IN UINT64 Operand,
45 IN UINTN Count
46 );
47
48 /**
49 Shifts a 64-bit integer right between 0 and 63 bits. The high bits
50 are filled with zeros. The shifted value is returned.
51
52 This function shifts the 64-bit value Operand to the right by Count bits. The
53 high Count bits are set to zero. The shifted value is returned.
54
55 @param Operand The 64-bit operand to shift right.
56 @param Count The number of bits to shift right.
57
58 @return Operand >> Count
59
60 **/
61 UINT64
62 EFIAPI
63 InternalMathRShiftU64 (
64 IN UINT64 Operand,
65 IN UINTN Count
66 );
67
68 /**
69 Shifts a 64-bit integer right between 0 and 63 bits. The high bits
70 are filled with original integer's bit 63. The shifted value is returned.
71
72 This function shifts the 64-bit value Operand to the right by Count bits. The
73 high Count bits are set to bit 63 of Operand. The shifted value is returned.
74
75 @param Operand The 64-bit operand to shift right.
76 @param Count The number of bits to shift right.
77
78 @return Operand arithmetically shifted right by Count
79
80 **/
81 UINT64
82 EFIAPI
83 InternalMathARShiftU64 (
84 IN UINT64 Operand,
85 IN UINTN Count
86 );
87
88 /**
89 Rotates a 64-bit integer left between 0 and 63 bits, filling
90 the low bits with the high bits that were rotated.
91
92 This function rotates the 64-bit value Operand to the left by Count bits. The
93 low Count bits are filled with the high Count bits of Operand. The rotated
94 value is returned.
95
96 @param Operand The 64-bit operand to rotate left.
97 @param Count The number of bits to rotate left.
98
99 @return Operand <<< Count
100
101 **/
102 UINT64
103 EFIAPI
104 InternalMathLRotU64 (
105 IN UINT64 Operand,
106 IN UINTN Count
107 );
108
109 /**
110 Rotates a 64-bit integer right between 0 and 63 bits, filling
111 the high bits with the high low bits that were rotated.
112
113 This function rotates the 64-bit value Operand to the right by Count bits.
114 The high Count bits are filled with the low Count bits of Operand. The rotated
115 value is returned.
116
117 @param Operand The 64-bit operand to rotate right.
118 @param Count The number of bits to rotate right.
119
120 @return Operand >>> Count
121
122 **/
123 UINT64
124 EFIAPI
125 InternalMathRRotU64 (
126 IN UINT64 Operand,
127 IN UINTN Count
128 );
129
130 /**
131 Switches the endianess of a 64-bit integer.
132
133 This function swaps the bytes in a 64-bit unsigned value to switch the value
134 from little endian to big endian or vice versa. The byte swapped value is
135 returned.
136
137 @param Operand A 64-bit unsigned value.
138
139 @return The byte swapped Operand.
140
141 **/
142 UINT64
143 EFIAPI
144 InternalMathSwapBytes64 (
145 IN UINT64 Operand
146 );
147
148 /**
149 Multiplies a 64-bit unsigned integer by a 32-bit unsigned integer
150 and generates a 64-bit unsigned result.
151
152 This function multiplies the 64-bit unsigned value Multiplicand by the 32-bit
153 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
154 bit unsigned result is returned.
155
156 @param Multiplicand A 64-bit unsigned value.
157 @param Multiplier A 32-bit unsigned value.
158
159 @return Multiplicand * Multiplier
160
161 **/
162 UINT64
163 EFIAPI
164 InternalMathMultU64x32 (
165 IN UINT64 Multiplicand,
166 IN UINT32 Multiplier
167 );
168
169 /**
170 Multiplies a 64-bit unsigned integer by a 64-bit unsigned integer
171 and generates a 64-bit unsigned result.
172
173 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
174 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
175 bit unsigned result is returned.
176
177 @param Multiplicand A 64-bit unsigned value.
178 @param Multiplier A 64-bit unsigned value.
179
180 @return Multiplicand * Multiplier
181
182 **/
183 UINT64
184 EFIAPI
185 InternalMathMultU64x64 (
186 IN UINT64 Multiplicand,
187 IN UINT64 Multiplier
188 );
189
190 /**
191 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
192 generates a 64-bit unsigned result.
193
194 This function divides the 64-bit unsigned value Dividend by the 32-bit
195 unsigned value Divisor and generates a 64-bit unsigned quotient. This
196 function returns the 64-bit unsigned quotient.
197
198 @param Dividend A 64-bit unsigned value.
199 @param Divisor A 32-bit unsigned value.
200
201 @return Dividend / Divisor
202
203 **/
204 UINT64
205 EFIAPI
206 InternalMathDivU64x32 (
207 IN UINT64 Dividend,
208 IN UINT32 Divisor
209 );
210
211 /**
212 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
213 generates a 32-bit unsigned remainder.
214
215 This function divides the 64-bit unsigned value Dividend by the 32-bit
216 unsigned value Divisor and generates a 32-bit remainder. This function
217 returns the 32-bit unsigned remainder.
218
219 @param Dividend A 64-bit unsigned value.
220 @param Divisor A 32-bit unsigned value.
221
222 @return Dividend % Divisor
223
224 **/
225 UINT32
226 EFIAPI
227 InternalMathModU64x32 (
228 IN UINT64 Dividend,
229 IN UINT32 Divisor
230 );
231
232 /**
233 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
234 generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
235
236 This function divides the 64-bit unsigned value Dividend by the 32-bit
237 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
238 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
239 This function returns the 64-bit unsigned quotient.
240
241 @param Dividend A 64-bit unsigned value.
242 @param Divisor A 32-bit unsigned value.
243 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
244 optional and may be NULL.
245
246 @return Dividend / Divisor
247
248 **/
249 UINT64
250 EFIAPI
251 InternalMathDivRemU64x32 (
252 IN UINT64 Dividend,
253 IN UINT32 Divisor,
254 OUT UINT32 *Remainder OPTIONAL
255 );
256
257 /**
258 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
259 generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
260
261 This function divides the 64-bit unsigned value Dividend by the 64-bit
262 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
263 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
264 This function returns the 64-bit unsigned quotient.
265
266 @param Dividend A 64-bit unsigned value.
267 @param Divisor A 64-bit unsigned value.
268 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
269 optional and may be NULL.
270
271 @return Dividend / Divisor
272
273 **/
274 UINT64
275 EFIAPI
276 InternalMathDivRemU64x64 (
277 IN UINT64 Dividend,
278 IN UINT64 Divisor,
279 OUT UINT64 *Remainder OPTIONAL
280 );
281
282 /**
283 Divides a 64-bit signed integer by a 64-bit signed integer and
284 generates a 64-bit signed result and an optional 64-bit signed remainder.
285
286 This function divides the 64-bit signed value Dividend by the 64-bit
287 signed value Divisor and generates a 64-bit signed quotient. If Remainder
288 is not NULL, then the 64-bit signed remainder is returned in Remainder.
289 This function returns the 64-bit signed quotient.
290
291 @param Dividend A 64-bit signed value.
292 @param Divisor A 64-bit signed value.
293 @param Remainder A pointer to a 64-bit signed value. This parameter is
294 optional and may be NULL.
295
296 @return Dividend / Divisor
297
298 **/
299 INT64
300 EFIAPI
301 InternalMathDivRemS64x64 (
302 IN INT64 Dividend,
303 IN INT64 Divisor,
304 OUT INT64 *Remainder OPTIONAL
305 );
306
307 /**
308 Transfers control to a function starting with a new stack.
309
310 Transfers control to the function specified by EntryPoint using the
311 new stack specified by NewStack and passing in the parameters specified
312 by Context1 and Context2. Context1 and Context2 are optional and may
313 be NULL. The function EntryPoint must never return.
314 Marker will be ignored on IA-32, x64, and EBC.
315 IPF CPUs expect one additional parameter of type VOID * that specifies
316 the new backing store pointer.
317
318 If EntryPoint is NULL, then ASSERT().
319 If NewStack is NULL, then ASSERT().
320
321 @param EntryPoint A pointer to function to call with the new stack.
322 @param Context1 A pointer to the context to pass into the EntryPoint
323 function.
324 @param Context2 A pointer to the context to pass into the EntryPoint
325 function.
326 @param NewStack A pointer to the new stack to use for the EntryPoint
327 function.
328 @param Marker VA_LIST marker for the variable argument list.
329
330 **/
331 VOID
332 EFIAPI
333 InternalSwitchStack (
334 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
335 IN VOID *Context1, OPTIONAL
336 IN VOID *Context2, OPTIONAL
337 IN VOID *NewStack,
338 IN VA_LIST Marker
339 );
340
341
342 /**
343 Worker function that returns a bit field from Operand.
344
345 Returns the bitfield specified by the StartBit and the EndBit from Operand.
346
347 @param Operand Operand on which to perform the bitfield operation.
348 @param StartBit The ordinal of the least significant bit in the bit field.
349 @param EndBit The ordinal of the most significant bit in the bit field.
350
351 @return The bit field read.
352
353 **/
354 UINTN
355 EFIAPI
356 BitFieldReadUint (
357 IN UINTN Operand,
358 IN UINTN StartBit,
359 IN UINTN EndBit
360 );
361
362
363 /**
364 Worker function that reads a bit field from Operand, performs a bitwise OR,
365 and returns the result.
366
367 Performs a bitwise OR between the bit field specified by StartBit and EndBit
368 in Operand and the value specified by AndData. All other bits in Operand are
369 preserved. The new value is returned.
370
371 @param Operand Operand on which to perform the bitfield operation.
372 @param StartBit The ordinal of the least significant bit in the bit field.
373 @param EndBit The ordinal of the most significant bit in the bit field.
374 @param OrData The value to OR with the read value from the value
375
376 @return The new value.
377
378 **/
379 UINTN
380 EFIAPI
381 BitFieldOrUint (
382 IN UINTN Operand,
383 IN UINTN StartBit,
384 IN UINTN EndBit,
385 IN UINTN OrData
386 );
387
388
389 /**
390 Worker function that reads a bit field from Operand, performs a bitwise AND,
391 and returns the result.
392
393 Performs a bitwise AND between the bit field specified by StartBit and EndBit
394 in Operand and the value specified by AndData. All other bits in Operand are
395 preserved. The new value is returned.
396
397 @param Operand Operand on which to perform the bitfield operation.
398 @param StartBit The ordinal of the least significant bit in the bit field.
399 @param EndBit The ordinal of the most significant bit in the bit field.
400 @param AndData The value to And with the read value from the value
401
402 @return The new value.
403
404 **/
405 UINTN
406 EFIAPI
407 BitFieldAndUint (
408 IN UINTN Operand,
409 IN UINTN StartBit,
410 IN UINTN EndBit,
411 IN UINTN AndData
412 );
413
414
415 /**
416 Worker function that checks ASSERT condition for JumpBuffer
417
418 Checks ASSERT condition for JumpBuffer.
419
420 If JumpBuffer is NULL, then ASSERT().
421 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
422
423 @param JumpBuffer A pointer to CPU context buffer.
424
425 **/
426 VOID
427 EFIAPI
428 InternalAssertJumpBuffer (
429 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
430 );
431
432
433 /**
434 Restores the CPU context that was saved with SetJump().
435
436 Restores the CPU context from the buffer specified by JumpBuffer.
437 This function never returns to the caller.
438 Instead is resumes execution based on the state of JumpBuffer.
439
440 @param JumpBuffer A pointer to CPU context buffer.
441 @param Value The value to return when the SetJump() context is restored.
442
443 **/
444 VOID
445 EFIAPI
446 InternalLongJump (
447 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
448 IN UINTN Value
449 );
450
451
452 /**
453 Check if a Unicode character is a decimal character.
454
455 This internal function checks if a Unicode character is a
456 decimal character. The valid decimal character is from
457 L'0' to L'9'.
458
459 @param Char The character to check against.
460
461 @retval TRUE If the Char is a decmial character.
462 @retval FALSE If the Char is not a decmial character.
463
464 **/
465 BOOLEAN
466 EFIAPI
467 InternalIsDecimalDigitCharacter (
468 IN CHAR16 Char
469 );
470
471
472 /**
473 Convert a Unicode character to numerical value.
474
475 This internal function only deal with Unicode character
476 which maps to a valid hexadecimal ASII character, i.e.
477 L'0' to L'9', L'a' to L'f' or L'A' to L'F'. For other
478 Unicode character, the value returned does not make sense.
479
480 @param Char The character to convert.
481
482 @return The numerical value converted.
483
484 **/
485 UINTN
486 EFIAPI
487 InternalHexCharToUintn (
488 IN CHAR16 Char
489 );
490
491
492 /**
493 Check if a Unicode character is a hexadecimal character.
494
495 This internal function checks if a Unicode character is a
496 decimal character. The valid hexadecimal character is
497 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
498
499
500 @param Char The character to check against.
501
502 @retval TRUE If the Char is a hexadecmial character.
503 @retval FALSE If the Char is not a hexadecmial character.
504
505 **/
506 BOOLEAN
507 EFIAPI
508 InternalIsHexaDecimalDigitCharacter (
509 IN CHAR16 Char
510 );
511
512
513 /**
514 Check if a ASCII character is a decimal character.
515
516 This internal function checks if a Unicode character is a
517 decimal character. The valid decimal character is from
518 '0' to '9'.
519
520 @param Char The character to check against.
521
522 @retval TRUE If the Char is a decmial character.
523 @retval FALSE If the Char is not a decmial character.
524
525 **/
526 BOOLEAN
527 EFIAPI
528 InternalAsciiIsDecimalDigitCharacter (
529 IN CHAR8 Char
530 );
531
532
533 /**
534 Check if a ASCII character is a hexadecimal character.
535
536 This internal function checks if a ASCII character is a
537 decimal character. The valid hexadecimal character is
538 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.
539
540
541 @param Char The character to check against.
542
543 @retval TRUE If the Char is a hexadecmial character.
544 @retval FALSE If the Char is not a hexadecmial character.
545
546 **/
547 BOOLEAN
548 EFIAPI
549 InternalAsciiIsHexaDecimalDigitCharacter (
550 IN CHAR8 Char
551 );
552
553
554 /**
555 Convert a ASCII character to numerical value.
556
557 This internal function only deal with Unicode character
558 which maps to a valid hexadecimal ASII character, i.e.
559 '0' to '9', 'a' to 'f' or 'A' to 'F'. For other
560 ASCII character, the value returned does not make sense.
561
562 @param Char The character to convert.
563
564 @return The numerical value converted.
565
566 **/
567 UINTN
568 EFIAPI
569 InternalAsciiHexCharToUintn (
570 IN CHAR8 Char
571 );
572
573
574 //
575 // Ia32 and x64 specific functions
576 //
577 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
578
579 /**
580 Reads the current Global Descriptor Table Register(GDTR) descriptor.
581
582 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
583 function is only available on IA-32 and x64.
584
585 @param Gdtr The pointer to a GDTR descriptor.
586
587 **/
588 VOID
589 EFIAPI
590 InternalX86ReadGdtr (
591 OUT IA32_DESCRIPTOR *Gdtr
592 );
593
594 /**
595 Writes the current Global Descriptor Table Register (GDTR) descriptor.
596
597 Writes and the current GDTR descriptor specified by Gdtr. This function is
598 only available on IA-32 and x64.
599
600 @param Gdtr The pointer to a GDTR descriptor.
601
602 **/
603 VOID
604 EFIAPI
605 InternalX86WriteGdtr (
606 IN CONST IA32_DESCRIPTOR *Gdtr
607 );
608
609 /**
610 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
611
612 Reads and returns the current IDTR descriptor and returns it in Idtr. This
613 function is only available on IA-32 and x64.
614
615 @param Idtr The pointer to an IDTR descriptor.
616
617 **/
618 VOID
619 EFIAPI
620 InternalX86ReadIdtr (
621 OUT IA32_DESCRIPTOR *Idtr
622 );
623
624 /**
625 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
626
627 Writes the current IDTR descriptor and returns it in Idtr. This function is
628 only available on IA-32 and x64.
629
630 @param Idtr The pointer to an IDTR descriptor.
631
632 **/
633 VOID
634 EFIAPI
635 InternalX86WriteIdtr (
636 IN CONST IA32_DESCRIPTOR *Idtr
637 );
638
639 /**
640 Save the current floating point/SSE/SSE2 context to a buffer.
641
642 Saves the current floating point/SSE/SSE2 state to the buffer specified by
643 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
644 available on IA-32 and x64.
645
646 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
647
648 **/
649 VOID
650 EFIAPI
651 InternalX86FxSave (
652 OUT IA32_FX_BUFFER *Buffer
653 );
654
655 /**
656 Restores the current floating point/SSE/SSE2 context from a buffer.
657
658 Restores the current floating point/SSE/SSE2 state from the buffer specified
659 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
660 only available on IA-32 and x64.
661
662 @param Buffer The pointer to a buffer to save the floating point/SSE/SSE2 context.
663
664 **/
665 VOID
666 EFIAPI
667 InternalX86FxRestore (
668 IN CONST IA32_FX_BUFFER *Buffer
669 );
670
671 /**
672 Enables the 32-bit paging mode on the CPU.
673
674 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
675 must be properly initialized prior to calling this service. This function
676 assumes the current execution mode is 32-bit protected mode. This function is
677 only available on IA-32. After the 32-bit paging mode is enabled, control is
678 transferred to the function specified by EntryPoint using the new stack
679 specified by NewStack and passing in the parameters specified by Context1 and
680 Context2. Context1 and Context2 are optional and may be NULL. The function
681 EntryPoint must never return.
682
683 There are a number of constraints that must be followed before calling this
684 function:
685 1) Interrupts must be disabled.
686 2) The caller must be in 32-bit protected mode with flat descriptors. This
687 means all descriptors must have a base of 0 and a limit of 4GB.
688 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
689 descriptors.
690 4) CR3 must point to valid page tables that will be used once the transition
691 is complete, and those page tables must guarantee that the pages for this
692 function and the stack are identity mapped.
693
694 @param EntryPoint A pointer to function to call with the new stack after
695 paging is enabled.
696 @param Context1 A pointer to the context to pass into the EntryPoint
697 function as the first parameter after paging is enabled.
698 @param Context2 A pointer to the context to pass into the EntryPoint
699 function as the second parameter after paging is enabled.
700 @param NewStack A pointer to the new stack to use for the EntryPoint
701 function after paging is enabled.
702
703 **/
704 VOID
705 EFIAPI
706 InternalX86EnablePaging32 (
707 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
708 IN VOID *Context1, OPTIONAL
709 IN VOID *Context2, OPTIONAL
710 IN VOID *NewStack
711 );
712
713 /**
714 Disables the 32-bit paging mode on the CPU.
715
716 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
717 mode. This function assumes the current execution mode is 32-paged protected
718 mode. This function is only available on IA-32. After the 32-bit paging mode
719 is disabled, control is transferred to the function specified by EntryPoint
720 using the new stack specified by NewStack and passing in the parameters
721 specified by Context1 and Context2. Context1 and Context2 are optional and
722 may be NULL. The function EntryPoint must never return.
723
724 There are a number of constraints that must be followed before calling this
725 function:
726 1) Interrupts must be disabled.
727 2) The caller must be in 32-bit paged mode.
728 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
729 4) CR3 must point to valid page tables that guarantee that the pages for
730 this function and the stack are identity mapped.
731
732 @param EntryPoint A pointer to function to call with the new stack after
733 paging is disabled.
734 @param Context1 A pointer to the context to pass into the EntryPoint
735 function as the first parameter after paging is disabled.
736 @param Context2 A pointer to the context to pass into the EntryPoint
737 function as the second parameter after paging is
738 disabled.
739 @param NewStack A pointer to the new stack to use for the EntryPoint
740 function after paging is disabled.
741
742 **/
743 VOID
744 EFIAPI
745 InternalX86DisablePaging32 (
746 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
747 IN VOID *Context1, OPTIONAL
748 IN VOID *Context2, OPTIONAL
749 IN VOID *NewStack
750 );
751
752 /**
753 Enables the 64-bit paging mode on the CPU.
754
755 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
756 must be properly initialized prior to calling this service. This function
757 assumes the current execution mode is 32-bit protected mode with flat
758 descriptors. This function is only available on IA-32. After the 64-bit
759 paging mode is enabled, control is transferred to the function specified by
760 EntryPoint using the new stack specified by NewStack and passing in the
761 parameters specified by Context1 and Context2. Context1 and Context2 are
762 optional and may be 0. The function EntryPoint must never return.
763
764 @param Cs The 16-bit selector to load in the CS before EntryPoint
765 is called. The descriptor in the GDT that this selector
766 references must be setup for long mode.
767 @param EntryPoint The 64-bit virtual address of the function to call with
768 the new stack after paging is enabled.
769 @param Context1 The 64-bit virtual address of the context to pass into
770 the EntryPoint function as the first parameter after
771 paging is enabled.
772 @param Context2 The 64-bit virtual address of the context to pass into
773 the EntryPoint function as the second parameter after
774 paging is enabled.
775 @param NewStack The 64-bit virtual address of the new stack to use for
776 the EntryPoint function after paging is enabled.
777
778 **/
779 VOID
780 EFIAPI
781 InternalX86EnablePaging64 (
782 IN UINT16 Cs,
783 IN UINT64 EntryPoint,
784 IN UINT64 Context1, OPTIONAL
785 IN UINT64 Context2, OPTIONAL
786 IN UINT64 NewStack
787 );
788
789 /**
790 Disables the 64-bit paging mode on the CPU.
791
792 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
793 mode. This function assumes the current execution mode is 64-paging mode.
794 This function is only available on x64. After the 64-bit paging mode is
795 disabled, control is transferred to the function specified by EntryPoint
796 using the new stack specified by NewStack and passing in the parameters
797 specified by Context1 and Context2. Context1 and Context2 are optional and
798 may be 0. The function EntryPoint must never return.
799
800 @param Cs The 16-bit selector to load in the CS before EntryPoint
801 is called. The descriptor in the GDT that this selector
802 references must be setup for 32-bit protected mode.
803 @param EntryPoint The 64-bit virtual address of the function to call with
804 the new stack after paging is disabled.
805 @param Context1 The 64-bit virtual address of the context to pass into
806 the EntryPoint function as the first parameter after
807 paging is disabled.
808 @param Context2 The 64-bit virtual address of the context to pass into
809 the EntryPoint function as the second parameter after
810 paging is disabled.
811 @param NewStack The 64-bit virtual address of the new stack to use for
812 the EntryPoint function after paging is disabled.
813
814 **/
815 VOID
816 EFIAPI
817 InternalX86DisablePaging64 (
818 IN UINT16 Cs,
819 IN UINT32 EntryPoint,
820 IN UINT32 Context1, OPTIONAL
821 IN UINT32 Context2, OPTIONAL
822 IN UINT32 NewStack
823 );
824
825 /**
826 Generates a 16-bit random number through RDRAND instruction.
827
828 @param[out] Rand Buffer pointer to store the random result.
829
830 @retval TRUE RDRAND call was successful.
831 @retval FALSE Failed attempts to call RDRAND.
832
833 **/
834 BOOLEAN
835 EFIAPI
836 InternalX86RdRand16 (
837 OUT UINT16 *Rand
838 );
839
840 /**
841 Generates a 32-bit random number through RDRAND instruction.
842
843 @param[out] Rand Buffer pointer to store the random result.
844
845 @retval TRUE RDRAND call was successful.
846 @retval FALSE Failed attempts to call RDRAND.
847
848 **/
849 BOOLEAN
850 EFIAPI
851 InternalX86RdRand32 (
852 OUT UINT32 *Rand
853 );
854
855 /**
856 Generates a 64-bit random number through RDRAND instruction.
857
858
859 @param[out] Rand Buffer pointer to store the random result.
860
861 @retval TRUE RDRAND call was successful.
862 @retval FALSE Failed attempts to call RDRAND.
863
864 **/
865 BOOLEAN
866 EFIAPI
867 InternalX86RdRand64 (
868 OUT UINT64 *Rand
869 );
870
871 #else
872
873 #endif
874
875 #endif