]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/BaseLibInternals.h
Code scrub:
[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 EFIAPI
315 InternalMathDivRemS64x64 (
316 IN INT64 Dividend,
317 IN INT64 Divisor,
318 OUT INT64 *Remainder OPTIONAL
319 );
320
321 /**
322 Transfers control to a function starting with a new stack.
323
324 Transfers control to the function specified by EntryPoint using the
325 new stack specified by NewStack and passing in the parameters specified
326 by Context1 and Context2. Context1 and Context2 are optional and may
327 be NULL. The function EntryPoint must never return.
328 Marker will be ignored on IA-32, x64, and EBC.
329 IPF CPUs expect one additional parameter of type VOID * that specifies
330 the new backing store pointer.
331
332 If EntryPoint is NULL, then ASSERT().
333 If NewStack is NULL, then ASSERT().
334
335 @param EntryPoint A pointer to function to call with the new stack.
336 @param Context1 A pointer to the context to pass into the EntryPoint
337 function.
338 @param Context2 A pointer to the context to pass into the EntryPoint
339 function.
340 @param NewStack A pointer to the new stack to use for the EntryPoint
341 function.
342 @param Marker VA_LIST marker for the variable argument list.
343
344 **/
345 VOID
346 EFIAPI
347 InternalSwitchStack (
348 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
349 IN VOID *Context1, OPTIONAL
350 IN VOID *Context2, OPTIONAL
351 IN VOID *NewStack,
352 IN VA_LIST Marker
353 );
354
355
356 /**
357 Worker function that locates the Node in the List
358
359 By searching the List, finds the location of the Node in List. At the same time,
360 verifies the validity of this list.
361
362 If List is NULL, then ASSERT().
363 If List->ForwardLink is NULL, then ASSERT().
364 If List->backLink is NULL, then ASSERT().
365 If Node is NULL, then ASSERT();
366 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
367 of nodes in ListHead, including the ListHead node, is greater than or
368 equal to PcdMaximumLinkedListLength, then ASSERT().
369
370 @param List A pointer to a node in a linked list.
371 @param Node A pointer to one nod.
372
373 @retval TRUE Node is in List
374 @retval FALSE Node isn't in List, or List is invalid
375
376 **/
377 BOOLEAN
378 EFIAPI
379 IsNodeInList (
380 IN CONST LIST_ENTRY *List,
381 IN CONST LIST_ENTRY *Node
382 );
383
384
385 /**
386 Performs an atomic increment of an 32-bit unsigned integer.
387
388 Performs an atomic increment of the 32-bit unsigned integer specified by
389 Value and returns the incremented value. The increment operation must be
390 performed using MP safe mechanisms. The state of the return value is not
391 guaranteed to be MP safe.
392
393 @param Value A pointer to the 32-bit value to increment.
394
395 @return The incremented value.
396
397 **/
398 UINT32
399 EFIAPI
400 InternalSyncIncrement (
401 IN volatile UINT32 *Value
402 );
403
404
405 /**
406 Performs an atomic decrement of an 32-bit unsigned integer.
407
408 Performs an atomic decrement of the 32-bit unsigned integer specified by
409 Value and returns the decrement value. The decrement operation must be
410 performed using MP safe mechanisms. The state of the return value is not
411 guaranteed to be MP safe.
412
413 @param Value A pointer to the 32-bit value to decrement.
414
415 @return The decrement value.
416
417 **/
418 UINT32
419 EFIAPI
420 InternalSyncDecrement (
421 IN volatile UINT32 *Value
422 );
423
424
425 /**
426 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
427
428 Performs an atomic compare exchange operation on the 32-bit unsigned integer
429 specified by Value. If Value is equal to CompareValue, then Value is set to
430 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
431 then Value is returned. The compare exchange operation must be performed using
432 MP safe mechanisms.
433
434 @param Value A pointer to the 32-bit value for the compare exchange
435 operation.
436 @param CompareValue 32-bit value used in compare operation.
437 @param ExchangeValue 32-bit value used in exchange operation.
438
439 @return The original *Value before exchange.
440
441 **/
442 UINT32
443 EFIAPI
444 InternalSyncCompareExchange32 (
445 IN volatile UINT32 *Value,
446 IN UINT32 CompareValue,
447 IN UINT32 ExchangeValue
448 );
449
450
451 /**
452 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
453
454 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
455 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
456 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
457 The compare exchange operation must be performed using MP safe mechanisms.
458
459 @param Value A pointer to the 64-bit value for the compare exchange
460 operation.
461 @param CompareValue 64-bit value used in compare operation.
462 @param ExchangeValue 64-bit value used in exchange operation.
463
464 @return The original *Value before exchange.
465
466 **/
467 UINT64
468 EFIAPI
469 InternalSyncCompareExchange64 (
470 IN volatile UINT64 *Value,
471 IN UINT64 CompareValue,
472 IN UINT64 ExchangeValue
473 );
474
475
476 /**
477 Worker function that returns a bit field from Operand
478
479 Returns the bitfield specified by the StartBit and the EndBit from Operand.
480
481 @param Operand Operand on which to perform the bitfield operation.
482 @param StartBit The ordinal of the least significant bit in the bit field.
483 @param EndBit The ordinal of the most significant bit in the bit field.
484
485 @return The bit field read.
486
487 **/
488 unsigned int
489 EFIAPI
490 BitFieldReadUint (
491 IN unsigned int Operand,
492 IN UINTN StartBit,
493 IN UINTN EndBit
494 );
495
496
497 /**
498 Worker function that reads a bit field from Operand, performs a bitwise OR,
499 and returns the result.
500
501 Performs a bitwise OR between the bit field specified by StartBit and EndBit
502 in Operand and the value specified by AndData. All other bits in Operand are
503 preserved. The new value is returned.
504
505 @param Operand Operand on which to perform the bitfield operation.
506 @param StartBit The ordinal of the least significant bit in the bit field.
507 @param EndBit The ordinal of the most significant bit in the bit field.
508 @param OrData The value to OR with the read value from the value
509
510 @return The new value.
511
512 **/
513 unsigned int
514 EFIAPI
515 BitFieldOrUint (
516 IN unsigned int Operand,
517 IN UINTN StartBit,
518 IN UINTN EndBit,
519 IN unsigned int OrData
520 );
521
522
523 /**
524 Worker function that reads a bit field from Operand, performs a bitwise AND,
525 and returns the result.
526
527 Performs a bitwise AND between the bit field specified by StartBit and EndBit
528 in Operand and the value specified by AndData. All other bits in Operand are
529 preserved. The new value is returned.
530
531 @param Operand Operand on which to perform the bitfield operation.
532 @param StartBit The ordinal of the least significant bit in the bit field.
533 @param EndBit The ordinal of the most significant bit in the bit field.
534 @param AndData The value to And with the read value from the value
535
536 @return The new value.
537
538 **/
539 unsigned int
540 EFIAPI
541 BitFieldAndUint (
542 IN unsigned int Operand,
543 IN UINTN StartBit,
544 IN UINTN EndBit,
545 IN unsigned int AndData
546 );
547
548
549 /**
550 Worker function that checks ASSERT condition for JumpBuffer
551
552 Checks ASSERT condition for JumpBuffer.
553
554 If JumpBuffer is NULL, then ASSERT().
555 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
556
557 @param JumpBuffer A pointer to CPU context buffer.
558
559 **/
560 VOID
561 EFIAPI
562 InternalAssertJumpBuffer (
563 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
564 );
565
566
567 /**
568 Restores the CPU context that was saved with SetJump().
569
570 Restores the CPU context from the buffer specified by JumpBuffer.
571 This function never returns to the caller.
572 Instead is resumes execution based on the state of JumpBuffer.
573
574 @param JumpBuffer A pointer to CPU context buffer.
575 @param Value The value to return when the SetJump() context is restored.
576
577 **/
578 VOID
579 EFIAPI
580 InternalLongJump (
581 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
582 IN UINTN Value
583 );
584
585
586 //
587 // Ia32 and x64 specific functions
588 //
589 #if defined (MDE_CPU_IA32) || defined (MDE_CPU_X64)
590
591 /**
592 Reads the current Global Descriptor Table Register(GDTR) descriptor.
593
594 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
595 function is only available on IA-32 and X64.
596
597 @param Gdtr Pointer to a GDTR descriptor.
598
599 **/
600 VOID
601 EFIAPI
602 InternalX86ReadGdtr (
603 OUT IA32_DESCRIPTOR *Gdtr
604 );
605
606 /**
607 Writes the current Global Descriptor Table Register (GDTR) descriptor.
608
609 Writes and the current GDTR descriptor specified by Gdtr. This function is
610 only available on IA-32 and X64.
611
612 @param Gdtr Pointer to a GDTR descriptor.
613
614 **/
615 VOID
616 EFIAPI
617 InternalX86WriteGdtr (
618 IN CONST IA32_DESCRIPTOR *Gdtr
619 );
620
621 /**
622 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
623
624 Reads and returns the current IDTR descriptor and returns it in Idtr. This
625 function is only available on IA-32 and X64.
626
627 @param Idtr Pointer to a IDTR descriptor.
628
629 **/
630 VOID
631 EFIAPI
632 InternalX86ReadIdtr (
633 OUT IA32_DESCRIPTOR *Idtr
634 );
635
636 /**
637 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
638
639 Writes the current IDTR descriptor and returns it in Idtr. This function is
640 only available on IA-32 and X64.
641
642 @param Idtr Pointer to a IDTR descriptor.
643
644 **/
645 VOID
646 EFIAPI
647 InternalX86WriteIdtr (
648 IN CONST IA32_DESCRIPTOR *Idtr
649 );
650
651 /**
652 Save the current floating point/SSE/SSE2 context to a buffer.
653
654 Saves the current floating point/SSE/SSE2 state to the buffer specified by
655 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
656 available on IA-32 and X64.
657
658 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
659
660 **/
661 VOID
662 EFIAPI
663 InternalX86FxSave (
664 OUT IA32_FX_BUFFER *Buffer
665 );
666
667 /**
668 Restores the current floating point/SSE/SSE2 context from a buffer.
669
670 Restores the current floating point/SSE/SSE2 state from the buffer specified
671 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
672 only available on IA-32 and X64.
673
674 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
675
676 **/
677 VOID
678 EFIAPI
679 InternalX86FxRestore (
680 IN CONST IA32_FX_BUFFER *Buffer
681 );
682
683 /**
684 Enables the 32-bit paging mode on the CPU.
685
686 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
687 must be properly initialized prior to calling this service. This function
688 assumes the current execution mode is 32-bit protected mode. This function is
689 only available on IA-32. After the 32-bit paging mode is enabled, control is
690 transferred to the function specified by EntryPoint using the new stack
691 specified by NewStack and passing in the parameters specified by Context1 and
692 Context2. Context1 and Context2 are optional and may be NULL. The function
693 EntryPoint must never return.
694
695 There are a number of constraints that must be followed before calling this
696 function:
697 1) Interrupts must be disabled.
698 2) The caller must be in 32-bit protected mode with flat descriptors. This
699 means all descriptors must have a base of 0 and a limit of 4GB.
700 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
701 descriptors.
702 4) CR3 must point to valid page tables that will be used once the transition
703 is complete, and those page tables must guarantee that the pages for this
704 function and the stack are identity mapped.
705
706 @param EntryPoint A pointer to function to call with the new stack after
707 paging is enabled.
708 @param Context1 A pointer to the context to pass into the EntryPoint
709 function as the first parameter after paging is enabled.
710 @param Context2 A pointer to the context to pass into the EntryPoint
711 function as the second parameter after paging is enabled.
712 @param NewStack A pointer to the new stack to use for the EntryPoint
713 function after paging is enabled.
714
715 **/
716 VOID
717 EFIAPI
718 InternalX86EnablePaging32 (
719 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
720 IN VOID *Context1, OPTIONAL
721 IN VOID *Context2, OPTIONAL
722 IN VOID *NewStack
723 );
724
725 /**
726 Disables the 32-bit paging mode on the CPU.
727
728 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
729 mode. This function assumes the current execution mode is 32-paged protected
730 mode. This function is only available on IA-32. After the 32-bit paging mode
731 is disabled, control is transferred to the function specified by EntryPoint
732 using the new stack specified by NewStack and passing in the parameters
733 specified by Context1 and Context2. Context1 and Context2 are optional and
734 may be NULL. The function EntryPoint must never return.
735
736 There are a number of constraints that must be followed before calling this
737 function:
738 1) Interrupts must be disabled.
739 2) The caller must be in 32-bit paged mode.
740 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
741 4) CR3 must point to valid page tables that guarantee that the pages for
742 this function and the stack are identity mapped.
743
744 @param EntryPoint A pointer to function to call with the new stack after
745 paging is disabled.
746 @param Context1 A pointer to the context to pass into the EntryPoint
747 function as the first parameter after paging is disabled.
748 @param Context2 A pointer to the context to pass into the EntryPoint
749 function as the second parameter after paging is
750 disabled.
751 @param NewStack A pointer to the new stack to use for the EntryPoint
752 function after paging is disabled.
753
754 **/
755 VOID
756 EFIAPI
757 InternalX86DisablePaging32 (
758 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
759 IN VOID *Context1, OPTIONAL
760 IN VOID *Context2, OPTIONAL
761 IN VOID *NewStack
762 );
763
764 /**
765 Enables the 64-bit paging mode on the CPU.
766
767 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
768 must be properly initialized prior to calling this service. This function
769 assumes the current execution mode is 32-bit protected mode with flat
770 descriptors. This function is only available on IA-32. After the 64-bit
771 paging mode is enabled, control is transferred to the function specified by
772 EntryPoint using the new stack specified by NewStack and passing in the
773 parameters specified by Context1 and Context2. Context1 and Context2 are
774 optional and may be 0. The function EntryPoint must never return.
775
776 @param Cs The 16-bit selector to load in the CS before EntryPoint
777 is called. The descriptor in the GDT that this selector
778 references must be setup for long mode.
779 @param EntryPoint The 64-bit virtual address of the function to call with
780 the new stack after paging is enabled.
781 @param Context1 The 64-bit virtual address of the context to pass into
782 the EntryPoint function as the first parameter after
783 paging is enabled.
784 @param Context2 The 64-bit virtual address of the context to pass into
785 the EntryPoint function as the second parameter after
786 paging is enabled.
787 @param NewStack The 64-bit virtual address of the new stack to use for
788 the EntryPoint function after paging is enabled.
789
790 **/
791 VOID
792 EFIAPI
793 InternalX86EnablePaging64 (
794 IN UINT16 Cs,
795 IN UINT64 EntryPoint,
796 IN UINT64 Context1, OPTIONAL
797 IN UINT64 Context2, OPTIONAL
798 IN UINT64 NewStack
799 );
800
801 /**
802 Disables the 64-bit paging mode on the CPU.
803
804 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
805 mode. This function assumes the current execution mode is 64-paging mode.
806 This function is only available on X64. After the 64-bit paging mode is
807 disabled, control is transferred to the function specified by EntryPoint
808 using the new stack specified by NewStack and passing in the parameters
809 specified by Context1 and Context2. Context1 and Context2 are optional and
810 may be 0. The function EntryPoint must never return.
811
812 @param Cs The 16-bit selector to load in the CS before EntryPoint
813 is called. The descriptor in the GDT that this selector
814 references must be setup for 32-bit protected mode.
815 @param EntryPoint The 64-bit virtual address of the function to call with
816 the new stack after paging is disabled.
817 @param Context1 The 64-bit virtual address of the context to pass into
818 the EntryPoint function as the first parameter after
819 paging is disabled.
820 @param Context2 The 64-bit virtual address of the context to pass into
821 the EntryPoint function as the second parameter after
822 paging is disabled.
823 @param NewStack The 64-bit virtual address of the new stack to use for
824 the EntryPoint function after paging is disabled.
825
826 **/
827 VOID
828 EFIAPI
829 InternalX86DisablePaging64 (
830 IN UINT16 Cs,
831 IN UINT32 EntryPoint,
832 IN UINT32 Context1, OPTIONAL
833 IN UINT32 Context2, OPTIONAL
834 IN UINT32 NewStack
835 );
836
837
838 #elif defined (MDE_CPU_IPF)
839 //
840 //
841 // IPF specific functions
842 //
843
844 /**
845 Transfers control to a function starting with a new stack.
846
847 Transfers control to the function specified by EntryPoint using the new stack
848 specified by NewStack and passing in the parameters specified by Context1 and
849 Context2. Context1 and Context2 are optional and may be NULL. The function
850 EntryPoint must never return.
851
852 If EntryPoint is NULL, then ASSERT().
853 If NewStack is NULL, then ASSERT().
854
855 @param EntryPoint A pointer to function to call with the new stack.
856 @param Context1 A pointer to the context to pass into the EntryPoint
857 function.
858 @param Context2 A pointer to the context to pass into the EntryPoint
859 function.
860 @param NewStack A pointer to the new stack to use for the EntryPoint
861 function.
862 @param NewBsp A pointer to the new memory location for RSE backing
863 store.
864
865 **/
866 VOID
867 EFIAPI
868 AsmSwitchStackAndBackingStore (
869 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
870 IN VOID *Context1, OPTIONAL
871 IN VOID *Context2, OPTIONAL
872 IN VOID *NewStack,
873 IN VOID *NewBsp
874 );
875 #else
876
877 #endif
878
879 #endif