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