]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/BaseLibInternals.h
Update the Guid Value of Ext SCSI Pass Thru Protocol
[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 Module Name: BaseLibInternals.h
14
15 **/
16
17 #ifndef __BASE_LIB_INTERNALS__
18 #define __BASE_LIB_INTERNALS__
19
20 #define QUIENT_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 / 10)
21 #define REMINDER_MAX_UINTN_DIVIDED_BY_10 ((UINTN) -1 % 10)
22
23 #define QUIENT_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 / 16)
24 #define REMINDER_MAX_UINTN_DIVIDED_BY_16 ((UINTN) -1 % 16)
25
26 #define QUIENT_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 / 10)
27 #define REMINDER_MAX_UINT64_DIVIDED_BY_10 ((UINT64) -1 % 10)
28
29 #define QUIENT_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 / 16)
30 #define REMINDER_MAX_UINT64_DIVIDED_BY_16 ((UINT64) -1 % 16)
31
32 //
33 // Math functions
34 //
35
36 /**
37 Shifts a 64-bit integer left between 0 and 63 bits. The low bits
38 are filled with zeros. The shifted value is returned.
39
40 This function shifts the 64-bit value Operand to the left by Count bits. The
41 low Count bits are set to zero. The shifted value is returned.
42
43 @param Operand The 64-bit operand to shift left.
44 @param Count The number of bits to shift left.
45
46 @return Operand << Count
47
48 **/
49 UINT64
50 EFIAPI
51 InternalMathLShiftU64 (
52 IN UINT64 Operand,
53 IN UINTN Count
54 );
55
56 /**
57 Shifts a 64-bit integer right between 0 and 63 bits. This high bits
58 are filled with zeros. The shifted value is returned.
59
60 This function shifts the 64-bit value Operand to the right by Count bits. The
61 high Count bits are set to zero. The shifted value is returned.
62
63 @param Operand The 64-bit operand to shift right.
64 @param Count The number of bits to shift right.
65
66 @return Operand >> Count
67
68 **/
69 UINT64
70 EFIAPI
71 InternalMathRShiftU64 (
72 IN UINT64 Operand,
73 IN UINTN Count
74 );
75
76 /**
77 Shifts a 64-bit integer right between 0 and 63 bits. The high bits
78 are filled with original integer's bit 63. The shifted value is returned.
79
80 This function shifts the 64-bit value Operand to the right by Count bits. The
81 high Count bits are set to bit 63 of Operand. The shifted value is returned.
82
83 @param Operand The 64-bit operand to shift right.
84 @param Count The number of bits to shift right.
85
86 @return Operand arithmetically shifted right by Count
87
88 **/
89 UINT64
90 EFIAPI
91 InternalMathARShiftU64 (
92 IN UINT64 Operand,
93 IN UINTN Count
94 );
95
96 /**
97 Rotates a 64-bit integer left between 0 and 63 bits, filling
98 the low bits with the high bits that were rotated.
99
100 This function rotates the 64-bit value Operand to the left by Count bits. The
101 low Count bits are fill with the high Count bits of Operand. The rotated
102 value is returned.
103
104 @param Operand The 64-bit operand to rotate left.
105 @param Count The number of bits to rotate left.
106
107 @return Operand <<< Count
108
109 **/
110 UINT64
111 EFIAPI
112 InternalMathLRotU64 (
113 IN UINT64 Operand,
114 IN UINTN Count
115 );
116
117 /**
118 Rotates a 64-bit integer right between 0 and 63 bits, filling
119 the high bits with the high low bits that were rotated.
120
121 This function rotates the 64-bit value Operand to the right by Count bits.
122 The high Count bits are fill with the low Count bits of Operand. The rotated
123 value is returned.
124
125 @param Operand The 64-bit operand to rotate right.
126 @param Count The number of bits to rotate right.
127
128 @return Operand >>> Count
129
130 **/
131 UINT64
132 EFIAPI
133 InternalMathRRotU64 (
134 IN UINT64 Operand,
135 IN UINTN Count
136 );
137
138 /**
139 Switches the endianess of a 64-bit integer.
140
141 This function swaps the bytes in a 64-bit unsigned value to switch the value
142 from little endian to big endian or vice versa. The byte swapped value is
143 returned.
144
145 @param Operand A 64-bit unsigned value.
146
147 @return The byte swaped Operand.
148
149 **/
150 UINT64
151 EFIAPI
152 InternalMathSwapBytes64 (
153 IN UINT64 Operand
154 );
155
156 /**
157 Multiples a 64-bit unsigned integer by a 32-bit unsigned integer
158 and generates a 64-bit unsigned result.
159
160 This function multiples the 64-bit unsigned value Multiplicand by the 32-bit
161 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
162 bit unsigned result is returned.
163
164 @param Multiplicand A 64-bit unsigned value.
165 @param Multiplier A 32-bit unsigned value.
166
167 @return Multiplicand * Multiplier
168
169 **/
170 UINT64
171 EFIAPI
172 InternalMathMultU64x32 (
173 IN UINT64 Multiplicand,
174 IN UINT32 Multiplier
175 );
176
177 /**
178 Multiples a 64-bit unsigned integer by a 64-bit unsigned integer
179 and generates a 64-bit unsigned result.
180
181 This function multiples the 64-bit unsigned value Multiplicand by the 64-bit
182 unsigned value Multiplier and generates a 64-bit unsigned result. This 64-
183 bit unsigned result is returned.
184
185 @param Multiplicand A 64-bit unsigned value.
186 @param Multiplier A 64-bit unsigned value.
187
188 @return Multiplicand * Multiplier
189
190 **/
191 UINT64
192 EFIAPI
193 InternalMathMultU64x64 (
194 IN UINT64 Multiplicand,
195 IN UINT64 Multiplier
196 );
197
198 /**
199 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
200 generates a 64-bit unsigned result.
201
202 This function divides the 64-bit unsigned value Dividend by the 32-bit
203 unsigned value Divisor and generates a 64-bit unsigned quotient. This
204 function returns the 64-bit unsigned quotient.
205
206 @param Dividend A 64-bit unsigned value.
207 @param Divisor A 32-bit unsigned value.
208
209 @return Dividend / Divisor
210
211 **/
212 UINT64
213 EFIAPI
214 InternalMathDivU64x32 (
215 IN UINT64 Dividend,
216 IN UINT32 Divisor
217 );
218
219 /**
220 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
221 generates a 32-bit unsigned remainder.
222
223 This function divides the 64-bit unsigned value Dividend by the 32-bit
224 unsigned value Divisor and generates a 32-bit remainder. This function
225 returns the 32-bit unsigned remainder.
226
227 @param Dividend A 64-bit unsigned value.
228 @param Divisor A 32-bit unsigned value.
229
230 @return Dividend % Divisor
231
232 **/
233 UINT32
234 EFIAPI
235 InternalMathModU64x32 (
236 IN UINT64 Dividend,
237 IN UINT32 Divisor
238 );
239
240 /**
241 Divides a 64-bit unsigned integer by a 32-bit unsigned integer and
242 generates a 64-bit unsigned result and an optional 32-bit unsigned remainder.
243
244 This function divides the 64-bit unsigned value Dividend by the 32-bit
245 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
246 is not NULL, then the 32-bit unsigned remainder is returned in Remainder.
247 This function returns the 64-bit unsigned quotient.
248
249 @param Dividend A 64-bit unsigned value.
250 @param Divisor A 32-bit unsigned value.
251 @param Remainder A pointer to a 32-bit unsigned value. This parameter is
252 optional and may be NULL.
253
254 @return Dividend / Divisor
255
256 **/
257 UINT64
258 EFIAPI
259 InternalMathDivRemU64x32 (
260 IN UINT64 Dividend,
261 IN UINT32 Divisor,
262 OUT UINT32 *Remainder
263 );
264
265 /**
266 Divides a 64-bit unsigned integer by a 64-bit unsigned integer and
267 generates a 64-bit unsigned result and an optional 64-bit unsigned remainder.
268
269 This function divides the 64-bit unsigned value Dividend by the 64-bit
270 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
271 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
272 This function returns the 64-bit unsigned quotient.
273
274 @param Dividend A 64-bit unsigned value.
275 @param Divisor A 64-bit unsigned value.
276 @param Remainder A pointer to a 64-bit unsigned value. This parameter is
277 optional and may be NULL.
278
279 @return Dividend / Divisor
280
281 **/
282 UINT64
283 EFIAPI
284 InternalMathDivRemU64x64 (
285 IN UINT64 Dividend,
286 IN UINT64 Divisor,
287 OUT UINT64 *Remainder
288 );
289
290 /**
291 Divides a 64-bit signed integer by a 64-bit signed integer and
292 generates a 64-bit signed result and a optional 64-bit signed remainder.
293
294 This function divides the 64-bit unsigned value Dividend by the 64-bit
295 unsigned value Divisor and generates a 64-bit unsigned quotient. If Remainder
296 is not NULL, then the 64-bit unsigned remainder is returned in Remainder.
297 This function returns the 64-bit unsigned quotient.
298
299 @param Dividend A 64-bit signed value.
300 @param Divisor A 64-bit signed value.
301 @param Remainder A pointer to a 64-bit signed value. This parameter is
302 optional and may be NULL.
303
304 @return Dividend / Divisor
305
306 **/
307 INT64
308 InternalMathDivRemS64x64 (
309 IN INT64 Dividend,
310 IN INT64 Divisor,
311 OUT INT64 *Remainder OPTIONAL
312 );
313
314 /**
315 Transfers control to a function starting with a new stack.
316
317 Transfers control to the function specified by EntryPoint using the
318 new stack specified by NewStack and passing in the parameters specified
319 by Context1 and Context2. Context1 and Context2 are optional and may
320 be NULL. The function EntryPoint must never return.
321 Marker will be ignored on IA-32, x64, and EBC.
322 IPF CPUs expect one additional parameter of type VOID * that specifies
323 the new backing store pointer.
324
325 If EntryPoint is NULL, then ASSERT().
326 If NewStack is NULL, then ASSERT().
327
328 @param EntryPoint A pointer to function to call with the new stack.
329 @param Context1 A pointer to the context to pass into the EntryPoint
330 function.
331 @param Context2 A pointer to the context to pass into the EntryPoint
332 function.
333 @param NewStack A pointer to the new stack to use for the EntryPoint
334 function.
335 @param Marker VA_LIST marker for the variable argument list.
336
337 **/
338 VOID
339 EFIAPI
340 InternalSwitchStack (
341 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
342 IN VOID *Context1, OPTIONAL
343 IN VOID *Context2, OPTIONAL
344 IN VOID *NewStack,
345 IN VA_LIST Marker
346 );
347
348
349 /**
350 Worker function that locates the Node in the List
351
352 By searching the List, finds the location of the Node in List. At the same time,
353 verifies the validity of this list.
354
355 If List is NULL, then ASSERT().
356 If List->ForwardLink is NULL, then ASSERT().
357 If List->backLink is NULL, then ASSERT().
358 If Node is NULL, then ASSERT();
359 If PcdMaximumLinkedListLenth is not zero, and prior to insertion the number
360 of nodes in ListHead, including the ListHead node, is greater than or
361 equal to PcdMaximumLinkedListLength, then ASSERT().
362
363 @param List A pointer to a node in a linked list.
364 @param Node A pointer to one nod.
365
366 @retval TRUE Node is in List
367 @retval FALSE Node isn't in List, or List is invalid
368
369 **/
370 BOOLEAN
371 IsNodeInList (
372 IN CONST LIST_ENTRY *List,
373 IN CONST LIST_ENTRY *Node
374 );
375
376
377 /**
378 Performs an atomic increment of an 32-bit unsigned integer.
379
380 Performs an atomic increment of the 32-bit unsigned integer specified by
381 Value and returns the incremented value. The increment operation must be
382 performed using MP safe mechanisms. The state of the return value is not
383 guaranteed to be MP safe.
384
385 @param Value A pointer to the 32-bit value to increment.
386
387 @return The incremented value.
388
389 **/
390 UINT32
391 EFIAPI
392 InternalSyncIncrement (
393 IN volatile UINT32 *Value
394 );
395
396
397 /**
398 Performs an atomic decrement of an 32-bit unsigned integer.
399
400 Performs an atomic decrement of the 32-bit unsigned integer specified by
401 Value and returns the decrement value. The decrement operation must be
402 performed using MP safe mechanisms. The state of the return value is not
403 guaranteed to be MP safe.
404
405 @param Value A pointer to the 32-bit value to decrement.
406
407 @return The decrement value.
408
409 **/
410 UINT32
411 EFIAPI
412 InternalSyncDecrement (
413 IN volatile UINT32 *Value
414 );
415
416
417 /**
418 Performs an atomic compare exchange operation on a 32-bit unsigned integer.
419
420 Performs an atomic compare exchange operation on the 32-bit unsigned integer
421 specified by Value. If Value is equal to CompareValue, then Value is set to
422 ExchangeValue and CompareValue is returned. If Value is not equal to CompareValue,
423 then Value is returned. The compare exchange operation must be performed using
424 MP safe mechanisms.
425
426 @param Value A pointer to the 32-bit value for the compare exchange
427 operation.
428 @param CompareValue 32-bit value used in compare operation.
429 @param ExchangeValue 32-bit value used in exchange operation.
430
431 @return The original *Value before exchange.
432
433 **/
434 UINT32
435 EFIAPI
436 InternalSyncCompareExchange32 (
437 IN volatile UINT32 *Value,
438 IN UINT32 CompareValue,
439 IN UINT32 ExchangeValue
440 );
441
442
443 /**
444 Performs an atomic compare exchange operation on a 64-bit unsigned integer.
445
446 Performs an atomic compare exchange operation on the 64-bit unsigned integer specified
447 by Value. If Value is equal to CompareValue, then Value is set to ExchangeValue and
448 CompareValue is returned. If Value is not equal to CompareValue, then Value is returned.
449 The compare exchange operation must be performed using MP safe mechanisms.
450
451 @param Value A pointer to the 64-bit value for the compare exchange
452 operation.
453 @param CompareValue 64-bit value used in compare operation.
454 @param ExchangeValue 64-bit value used in exchange operation.
455
456 @return The original *Value before exchange.
457
458 **/
459 UINT64
460 EFIAPI
461 InternalSyncCompareExchange64 (
462 IN volatile UINT64 *Value,
463 IN UINT64 CompareValue,
464 IN UINT64 ExchangeValue
465 );
466
467
468 /**
469 Worker function that returns a bit field from Operand
470
471 Returns the bitfield specified by the StartBit and the EndBit from Operand.
472
473 @param Operand Operand on which to perform the bitfield operation.
474 @param StartBit The ordinal of the least significant bit in the bit field.
475 @param EndBit The ordinal of the most significant bit in the bit field.
476
477 @return The bit field read.
478
479 **/
480 unsigned int
481 BitFieldReadUint (
482 IN unsigned int Operand,
483 IN UINTN StartBit,
484 IN UINTN EndBit
485 );
486
487
488 /**
489 Worker function that reads a bit field from Operand, performs a bitwise OR,
490 and returns the result.
491
492 Performs a bitwise OR between the bit field specified by StartBit and EndBit
493 in Operand and the value specified by AndData. All other bits in Operand are
494 preserved. The new value is returned.
495
496 @param Operand Operand on which to perform the bitfield operation.
497 @param StartBit The ordinal of the least significant bit in the bit field.
498 @param EndBit The ordinal of the most significant bit in the bit field.
499 @param OrData The value to OR with the read value from the value
500
501 @return The new value.
502
503 **/
504 unsigned int
505 BitFieldOrUint (
506 IN unsigned int Operand,
507 IN UINTN StartBit,
508 IN UINTN EndBit,
509 IN unsigned int OrData
510 );
511
512
513 /**
514 Worker function that reads a bit field from Operand, performs a bitwise AND,
515 and returns the result.
516
517 Performs a bitwise AND between the bit field specified by StartBit and EndBit
518 in Operand and the value specified by AndData. All other bits in Operand are
519 preserved. The new value is returned.
520
521 @param Operand Operand on which to perform the bitfield operation.
522 @param StartBit The ordinal of the least significant bit in the bit field.
523 @param EndBit The ordinal of the most significant bit in the bit field.
524 @param AndData The value to And with the read value from the value
525
526 @return The new value.
527
528 **/
529 unsigned int
530 BitFieldAndUint (
531 IN unsigned int Operand,
532 IN UINTN StartBit,
533 IN UINTN EndBit,
534 IN unsigned int AndData
535 );
536
537
538 /**
539 Worker function that checks ASSERT condition for JumpBuffer
540
541 Checks ASSERT condition for JumpBuffer.
542
543 If JumpBuffer is NULL, then ASSERT().
544 For IPF CPUs, if JumpBuffer is not aligned on a 16-byte boundary, then ASSERT().
545
546 @param JumpBuffer A pointer to CPU context buffer.
547
548 **/
549 VOID
550 InternalAssertJumpBuffer (
551 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer
552 );
553
554
555 /**
556 Restores the CPU context that was saved with SetJump().
557
558 Restores the CPU context from the buffer specified by JumpBuffer.
559 This function never returns to the caller.
560 Instead is resumes execution based on the state of JumpBuffer.
561
562 @param JumpBuffer A pointer to CPU context buffer.
563 @param Value The value to return when the SetJump() context is restored.
564
565 **/
566 VOID
567 EFIAPI
568 InternalLongJump (
569 IN BASE_LIBRARY_JUMP_BUFFER *JumpBuffer,
570 IN UINTN Value
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 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 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 Pointer to a 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 Pointer to a 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 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 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 #elif defined (MDE_CPU_IPF)
827 //
828 //
829 // IPF specific functions
830 //
831
832 /**
833 Transfers control to a function starting with a new stack.
834
835 Transfers control to the function specified by EntryPoint using the new stack
836 specified by NewStack and passing in the parameters specified by Context1 and
837 Context2. Context1 and Context2 are optional and may be NULL. The function
838 EntryPoint must never return.
839
840 If EntryPoint is NULL, then ASSERT().
841 If NewStack is NULL, then ASSERT().
842
843 @param EntryPoint A pointer to function to call with the new stack.
844 @param Context1 A pointer to the context to pass into the EntryPoint
845 function.
846 @param Context2 A pointer to the context to pass into the EntryPoint
847 function.
848 @param NewStack A pointer to the new stack to use for the EntryPoint
849 function.
850 @param NewBsp A pointer to the new memory location for RSE backing
851 store.
852
853 **/
854 VOID
855 EFIAPI
856 AsmSwitchStackAndBackingStore (
857 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
858 IN VOID *Context1, OPTIONAL
859 IN VOID *Context2, OPTIONAL
860 IN VOID *NewStack,
861 IN VOID *NewBsp
862 );
863 #else
864
865 #endif
866
867 #endif