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