2 IA-32/x64 specific functions.
4 Copyright (c) 2006, 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
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.
13 Module Name: x86LowLevel.c
17 #include "BaseLibInternals.h"
20 // Bit-wise MSR operations
24 Reads a 64-bit MSR, performs a bitwise inclusive OR on the lower 32-bits, and
25 writes the result back to the 64-bit MSR.
27 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
28 between the lower 32-bits of the read result and the value specified by
29 OrData, and writes the result to the 64-bit MSR specified by Index. The lower
30 32-bits of the value written to the MSR is returned. No parameter checking is
31 performed on Index or OrData, and some of these may cause CPU exceptions. The
32 caller must either guarantee that Index and OrData are valid, or the caller
33 must establish proper exception handlers. This function is only available on
36 @param Index The 32-bit MSR index to write.
37 @param OrData The value to OR with the read value from the MSR.
39 @return The lower 32-bit value written to the MSR.
49 return (UINT32
)AsmMsrOr64 (Index
, OrData
);
53 Reads a 64-bit MSR, performs a bitwise AND on the lower 32-bits, and writes
54 the result back to the 64-bit MSR.
56 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
57 lower 32-bits of the read result and the value specified by AndData, and
58 writes the result to the 64-bit MSR specified by Index. The lower 32-bits of
59 the value written to the MSR is returned. No parameter checking is performed
60 on Index or AndData, and some of these may cause CPU exceptions. The caller
61 must either guarantee that Index and AndData are valid, or the caller must
62 establish proper exception handlers. This function is only available on IA-32
65 @param Index The 32-bit MSR index to write.
66 @param AndData The value to AND with the read value from the MSR.
68 @return The lower 32-bit value written to the MSR.
78 return (UINT32
)AsmMsrAnd64 (Index
, AndData
);
82 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive OR
83 on the lower 32-bits, and writes the result back to the 64-bit MSR.
85 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
86 lower 32-bits of the read result and the value specified by AndData
87 preserving the upper 32-bits, performs a bitwise inclusive OR between the
88 result of the AND operation and the value specified by OrData, and writes the
89 result to the 64-bit MSR specified by Address. The lower 32-bits of the value
90 written to the MSR is returned. No parameter checking is performed on Index,
91 AndData, or OrData, and some of these may cause CPU exceptions. The caller
92 must either guarantee that Index, AndData, and OrData are valid, or the
93 caller must establish proper exception handlers. This function is only
94 available on IA-32 and X64.
96 @param Index The 32-bit MSR index to write.
97 @param AndData The value to AND with the read value from the MSR.
98 @param OrData The value to OR with the result of the AND operation.
100 @return The lower 32-bit value written to the MSR.
111 return (UINT32
)AsmMsrAndThenOr64 (Index
, AndData
, OrData
);
115 Reads a bit field of an MSR.
117 Reads the bit field in the lower 32-bits of a 64-bit MSR. The bit field is
118 specified by the StartBit and the EndBit. The value of the bit field is
119 returned. The caller must either guarantee that Index is valid, or the caller
120 must set up exception handlers to catch the exceptions. This function is only
121 available on IA-32 and X64.
123 If StartBit is greater than 31, then ASSERT().
124 If EndBit is greater than 31, then ASSERT().
125 If EndBit is less than or equal to StartBit, then ASSERT().
127 @param Index The 32-bit MSR index to read.
128 @param StartBit The ordinal of the least significant bit in the bit field.
130 @param EndBit The ordinal of the most significant bit in the bit field.
133 @return The bit field read from the MSR.
138 AsmMsrBitFieldRead32 (
144 return BitFieldRead32 (AsmReadMsr32 (Index
), StartBit
, EndBit
);
148 Writes a bit field to an MSR.
150 Writes Value to a bit field in the lower 32-bits of a 64-bit MSR. The bit
151 field is specified by the StartBit and the EndBit. All other bits in the
152 destination MSR are preserved. The lower 32-bits of the MSR written is
153 returned. Extra left bits in Value are stripped. The caller must either
154 guarantee that Index and the data written is valid, or the caller must set up
155 exception handlers to catch the exceptions. This function is only available
158 If StartBit is greater than 31, then ASSERT().
159 If EndBit is greater than 31, then ASSERT().
160 If EndBit is less than or equal to StartBit, then ASSERT().
162 @param Index The 32-bit MSR index to write.
163 @param StartBit The ordinal of the least significant bit in the bit field.
165 @param EndBit The ordinal of the most significant bit in the bit field.
167 @param Value New value of the bit field.
169 @return The lower 32-bit of the value written to the MSR.
174 AsmMsrBitFieldWrite32 (
181 ASSERT (EndBit
< sizeof (Value
) * 8);
182 ASSERT (StartBit
<= EndBit
);
183 return (UINT32
)AsmMsrBitFieldWrite64 (Index
, StartBit
, EndBit
, Value
);
187 Reads a bit field in a 64-bit MSR, performs a bitwise OR, and writes the
188 result back to the bit field in the 64-bit MSR.
190 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
191 between the read result and the value specified by OrData, and writes the
192 result to the 64-bit MSR specified by Index. The lower 32-bits of the value
193 written to the MSR are returned. Extra left bits in OrData are stripped. The
194 caller must either guarantee that Index and the data written is valid, or
195 the caller must set up exception handlers to catch the exceptions. This
196 function is only available on IA-32 and X64.
198 If StartBit is greater than 31, then ASSERT().
199 If EndBit is greater than 31, then ASSERT().
200 If EndBit is less than or equal to StartBit, then ASSERT().
202 @param Index The 32-bit MSR index to write.
203 @param StartBit The ordinal of the least significant bit in the bit field.
205 @param EndBit The ordinal of the most significant bit in the bit field.
207 @param OrData The value to OR with the read value from the MSR.
209 @return The lower 32-bit of the value written to the MSR.
221 ASSERT (EndBit
< sizeof (OrData
) * 8);
222 ASSERT (StartBit
<= EndBit
);
223 return (UINT32
)AsmMsrBitFieldOr64 (Index
, StartBit
, EndBit
, OrData
);
227 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
228 result back to the bit field in the 64-bit MSR.
230 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
231 read result and the value specified by AndData, and writes the result to the
232 64-bit MSR specified by Index. The lower 32-bits of the value written to the
233 MSR are returned. Extra left bits in AndData are stripped. The caller must
234 either guarantee that Index and the data written is valid, or the caller must
235 set up exception handlers to catch the exceptions. This function is only
236 available on IA-32 and X64.
238 If StartBit is greater than 31, then ASSERT().
239 If EndBit is greater than 31, then ASSERT().
240 If EndBit is less than or equal to StartBit, then ASSERT().
242 @param Index The 32-bit MSR index to write.
243 @param StartBit The ordinal of the least significant bit in the bit field.
245 @param EndBit The ordinal of the most significant bit in the bit field.
247 @param AndData The value to AND with the read value from the MSR.
249 @return The lower 32-bit of the value written to the MSR.
254 AsmMsrBitFieldAnd32 (
261 ASSERT (EndBit
< sizeof (AndData
) * 8);
262 ASSERT (StartBit
<= EndBit
);
263 return (UINT32
)AsmMsrBitFieldAnd64 (Index
, StartBit
, EndBit
, AndData
);
267 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
268 bitwise inclusive OR, and writes the result back to the bit field in the
271 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by a
272 bitwise inclusive OR between the read result and the value specified by
273 AndData, and writes the result to the 64-bit MSR specified by Index. The
274 lower 32-bits of the value written to the MSR are returned. Extra left bits
275 in both AndData and OrData are stripped. The caller must either guarantee
276 that Index and the data written is valid, or the caller must set up exception
277 handlers to catch the exceptions. This function is only available on IA-32
280 If StartBit is greater than 31, then ASSERT().
281 If EndBit is greater than 31, then ASSERT().
282 If EndBit is less than or equal to StartBit, then ASSERT().
284 @param Index The 32-bit MSR index to write.
285 @param StartBit The ordinal of the least significant bit in the bit field.
287 @param EndBit The ordinal of the most significant bit in the bit field.
289 @param AndData The value to AND with the read value from the MSR.
290 @param OrData The value to OR with the result of the AND operation.
292 @return The lower 32-bit of the value written to the MSR.
297 AsmMsrBitFieldAndThenOr32 (
305 ASSERT (EndBit
< sizeof (AndData
) * 8);
306 ASSERT (StartBit
<= EndBit
);
307 return (UINT32
)AsmMsrBitFieldAndThenOr64 (
317 Reads a 64-bit MSR, performs a bitwise inclusive OR, and writes the result
318 back to the 64-bit MSR.
320 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
321 between the read result and the value specified by OrData, and writes the
322 result to the 64-bit MSR specified by Index. The value written to the MSR is
323 returned. No parameter checking is performed on Index or OrData, and some of
324 these may cause CPU exceptions. The caller must either guarantee that Index
325 and OrData are valid, or the caller must establish proper exception handlers.
326 This function is only available on IA-32 and X64.
328 @param Index The 32-bit MSR index to write.
329 @param OrData The value to OR with the read value from the MSR.
331 @return The value written back to the MSR.
341 return AsmWriteMsr64 (Index
, AsmReadMsr64 (Index
) | OrData
);
345 Reads a 64-bit MSR, performs a bitwise AND, and writes the result back to the
348 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
349 read result and the value specified by OrData, and writes the result to the
350 64-bit MSR specified by Index. The value written to the MSR is returned. No
351 parameter checking is performed on Index or OrData, and some of these may
352 cause CPU exceptions. The caller must either guarantee that Index and OrData
353 are valid, or the caller must establish proper exception handlers. This
354 function is only available on IA-32 and X64.
356 @param Index The 32-bit MSR index to write.
357 @param AndData The value to AND with the read value from the MSR.
359 @return The value written back to the MSR.
369 return AsmWriteMsr64 (Index
, AsmReadMsr64 (Index
) & AndData
);
373 Reads a 64-bit MSR, performs a bitwise AND followed by a bitwise inclusive
374 OR, and writes the result back to the 64-bit MSR.
376 Reads the 64-bit MSR specified by Index, performs a bitwise AND between read
377 result and the value specified by AndData, performs a bitwise inclusive OR
378 between the result of the AND operation and the value specified by OrData,
379 and writes the result to the 64-bit MSR specified by Index. The value written
380 to the MSR is returned. No parameter checking is performed on Index, AndData,
381 or OrData, and some of these may cause CPU exceptions. The caller must either
382 guarantee that Index, AndData, and OrData are valid, or the caller must
383 establish proper exception handlers. This function is only available on IA-32
386 @param Index The 32-bit MSR index to write.
387 @param AndData The value to AND with the read value from the MSR.
388 @param OrData The value to OR with the result of the AND operation.
390 @return The value written back to the MSR.
401 return AsmWriteMsr64 (Index
, (AsmReadMsr64 (Index
) & AndData
) | OrData
);
405 Reads a bit field of an MSR.
407 Reads the bit field in the 64-bit MSR. The bit field is specified by the
408 StartBit and the EndBit. The value of the bit field is returned. The caller
409 must either guarantee that Index is valid, or the caller must set up
410 exception handlers to catch the exceptions. This function is only available
413 If StartBit is greater than 63, then ASSERT().
414 If EndBit is greater than 63, then ASSERT().
415 If EndBit is less than or equal to StartBit, then ASSERT().
417 @param Index The 32-bit MSR index to read.
418 @param StartBit The ordinal of the least significant bit in the bit field.
420 @param EndBit The ordinal of the most significant bit in the bit field.
423 @return The value written back to the MSR.
428 AsmMsrBitFieldRead64 (
434 return BitFieldRead64 (AsmReadMsr64 (Index
), StartBit
, EndBit
);
438 Writes a bit field to an MSR.
440 Writes Value to a bit field in a 64-bit MSR. The bit field is specified by
441 the StartBit and the EndBit. All other bits in the destination MSR are
442 preserved. The MSR written is returned. Extra left bits in Value are
443 stripped. The caller must either guarantee that Index and the data written is
444 valid, or the caller must set up exception handlers to catch the exceptions.
445 This function is only available on IA-32 and X64.
447 If StartBit is greater than 63, then ASSERT().
448 If EndBit is greater than 63, then ASSERT().
449 If EndBit is less than or equal to StartBit, then ASSERT().
451 @param Index The 32-bit MSR index to write.
452 @param StartBit The ordinal of the least significant bit in the bit field.
454 @param EndBit The ordinal of the most significant bit in the bit field.
456 @param Value New value of the bit field.
458 @return The value written back to the MSR.
463 AsmMsrBitFieldWrite64 (
470 return AsmWriteMsr64 (
472 BitFieldWrite64 (AsmReadMsr64 (Index
), StartBit
, EndBit
, Value
)
477 Reads a bit field in a 64-bit MSR, performs a bitwise inclusive OR, and
478 writes the result back to the bit field in the 64-bit MSR.
480 Reads the 64-bit MSR specified by Index, performs a bitwise inclusive OR
481 between the read result and the value specified by OrData, and writes the
482 result to the 64-bit MSR specified by Index. The value written to the MSR is
483 returned. Extra left bits in OrData are stripped. The caller must either
484 guarantee that Index and the data written is valid, or the caller must set up
485 exception handlers to catch the exceptions. This function is only available
488 If StartBit is greater than 63, then ASSERT().
489 If EndBit is greater than 63, then ASSERT().
490 If EndBit is less than or equal to StartBit, then ASSERT().
492 @param Index The 32-bit MSR index to write.
493 @param StartBit The ordinal of the least significant bit in the bit field.
495 @param EndBit The ordinal of the most significant bit in the bit field.
497 @param OrData The value to OR with the read value from the bit field.
499 @return The value written back to the MSR.
511 return AsmWriteMsr64 (
513 BitFieldOr64 (AsmReadMsr64 (Index
), StartBit
, EndBit
, OrData
)
518 Reads a bit field in a 64-bit MSR, performs a bitwise AND, and writes the
519 result back to the bit field in the 64-bit MSR.
521 Reads the 64-bit MSR specified by Index, performs a bitwise AND between the
522 read result and the value specified by AndData, and writes the result to the
523 64-bit MSR specified by Index. The value written to the MSR is returned.
524 Extra left bits in AndData are stripped. The caller must either guarantee
525 that Index and the data written is valid, or the caller must set up exception
526 handlers to catch the exceptions. This function is only available on IA-32
529 If StartBit is greater than 63, then ASSERT().
530 If EndBit is greater than 63, then ASSERT().
531 If EndBit is less than or equal to StartBit, then ASSERT().
533 @param Index The 32-bit MSR index to write.
534 @param StartBit The ordinal of the least significant bit in the bit field.
536 @param EndBit The ordinal of the most significant bit in the bit field.
538 @param AndData The value to AND with the read value from the bit field.
540 @return The value written back to the MSR.
545 AsmMsrBitFieldAnd64 (
552 return AsmWriteMsr64 (
554 BitFieldAnd64 (AsmReadMsr64 (Index
), StartBit
, EndBit
, AndData
)
559 Reads a bit field in a 64-bit MSR, performs a bitwise AND followed by a
560 bitwise inclusive OR, and writes the result back to the bit field in the
563 Reads the 64-bit MSR specified by Index, performs a bitwise AND followed by
564 a bitwise inclusive OR between the read result and the value specified by
565 AndData, and writes the result to the 64-bit MSR specified by Index. The
566 value written to the MSR is returned. Extra left bits in both AndData and
567 OrData are stripped. The caller must either guarantee that Index and the data
568 written is valid, or the caller must set up exception handlers to catch the
569 exceptions. This function is only available on IA-32 and X64.
571 If StartBit is greater than 63, then ASSERT().
572 If EndBit is greater than 63, then ASSERT().
573 If EndBit is less than or equal to StartBit, then ASSERT().
575 @param Index The 32-bit MSR index to write.
576 @param StartBit The ordinal of the least significant bit in the bit field.
578 @param EndBit The ordinal of the most significant bit in the bit field.
580 @param AndData The value to AND with the read value from the bit field.
581 @param OrData The value to OR with the result of the AND operation.
583 @return The value written back to the MSR.
588 AsmMsrBitFieldAndThenOr64 (
596 return AsmWriteMsr64 (
598 BitFieldAndThenOr64 (
599 AsmReadMsr64 (Index
),
609 // Base Library CPU Functions
613 Retrieves the current CPU interrupt state.
615 Retrieves the current CPU interrupt state. Returns TRUE is interrupts are
616 currently enabled. Otherwise returns FALSE.
618 @retval TRUE CPU interrupts are enabled.
619 @retval FALSE CPU interrupts are disabled.
628 IA32_EFLAGS32 EFlags
;
630 EFlags
.UintN
= AsmReadEflags ();
631 return (BOOLEAN
)(EFlags
.Bits
.IF
== 1);
635 // Ia32 and x64 specific functions
639 Reads the current Global Descriptor Table Register(GDTR) descriptor.
641 Reads and returns the current GDTR descriptor and returns it in Gdtr. This
642 function is only available on IA-32 and X64.
644 If Gdtr is NULL, then ASSERT().
646 @param Gdtr Pointer to a GDTR descriptor.
652 OUT IA32_DESCRIPTOR
*Gdtr
655 ASSERT (Gdtr
!= NULL
);
656 InternalX86ReadGdtr (Gdtr
);
660 Writes the current Global Descriptor Table Register (GDTR) descriptor.
662 Writes and the current GDTR descriptor specified by Gdtr. This function is
663 only available on IA-32 and X64.
665 If Gdtr is NULL, then ASSERT().
667 @param Gdtr Pointer to a GDTR descriptor.
673 IN CONST IA32_DESCRIPTOR
*Gdtr
676 ASSERT (Gdtr
!= NULL
);
677 InternalX86WriteGdtr (Gdtr
);
681 Reads the current Interrupt Descriptor Table Register(GDTR) descriptor.
683 Reads and returns the current IDTR descriptor and returns it in Idtr. This
684 function is only available on IA-32 and X64.
686 If Idtr is NULL, then ASSERT().
688 @param Idtr Pointer to a IDTR descriptor.
694 OUT IA32_DESCRIPTOR
*Idtr
697 ASSERT (Idtr
!= NULL
);
698 InternalX86ReadIdtr (Idtr
);
702 Writes the current Interrupt Descriptor Table Register(GDTR) descriptor.
704 Writes the current IDTR descriptor and returns it in Idtr. This function is
705 only available on IA-32 and X64.
707 If Idtr is NULL, then ASSERT().
709 @param Idtr Pointer to a IDTR descriptor.
715 IN CONST IA32_DESCRIPTOR
*Idtr
718 ASSERT (Idtr
!= NULL
);
719 InternalX86WriteIdtr (Idtr
);
723 Save the current floating point/SSE/SSE2 context to a buffer.
725 Saves the current floating point/SSE/SSE2 state to the buffer specified by
726 Buffer. Buffer must be aligned on a 16-byte boundary. This function is only
727 available on IA-32 and X64.
729 If Buffer is NULL, then ASSERT().
730 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
732 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
738 OUT IA32_FX_BUFFER
*Buffer
741 ASSERT (Buffer
!= NULL
);
742 ASSERT (((UINTN
)Buffer
& 0xf) == 0);
743 InternalX86FxSave (Buffer
);
747 Restores the current floating point/SSE/SSE2 context from a buffer.
749 Restores the current floating point/SSE/SSE2 state from the buffer specified
750 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
751 only available on IA-32 and X64.
753 If Buffer is NULL, then ASSERT().
754 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
755 If Buffer was not saved with AsmFxSave(), then ASSERT().
757 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
763 IN CONST IA32_FX_BUFFER
*Buffer
766 ASSERT (Buffer
!= NULL
);
767 ASSERT (((UINTN
)Buffer
& 0xf) == 0);
768 InternalX86FxRestore (Buffer
);
772 Enables the 32-bit paging mode on the CPU.
774 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
775 must be properly initialized prior to calling this service. This function
776 assumes the current execution mode is 32-bit protected mode. This function is
777 only available on IA-32. After the 32-bit paging mode is enabled, control is
778 transferred to the function specified by EntryPoint using the new stack
779 specified by NewStack and passing in the parameters specified by Context1 and
780 Context2. Context1 and Context2 are optional and may be NULL. The function
781 EntryPoint must never return.
783 If the current execution mode is not 32-bit protected mode, then ASSERT().
784 If EntryPoint is NULL, then ASSERT().
785 If NewStack is NULL, then ASSERT().
787 There are a number of constraints that must be followed before calling this
789 1) Interrupts must be disabled.
790 2) The caller must be in 32-bit protected mode with flat descriptors. This
791 means all descriptors must have a base of 0 and a limit of 4GB.
792 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
794 4) CR3 must point to valid page tables that will be used once the transition
795 is complete, and those page tables must guarantee that the pages for this
796 function and the stack are identity mapped.
798 @param EntryPoint A pointer to function to call with the new stack after
800 @param Context1 A pointer to the context to pass into the EntryPoint
801 function as the first parameter after paging is enabled.
802 @param Context2 A pointer to the context to pass into the EntryPoint
803 function as the second parameter after paging is enabled.
804 @param NewStack A pointer to the new stack to use for the EntryPoint
805 function after paging is enabled.
811 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
812 IN VOID
*Context1
, OPTIONAL
813 IN VOID
*Context2
, OPTIONAL
817 ASSERT (EntryPoint
!= NULL
);
818 ASSERT (NewStack
!= NULL
);
819 InternalX86EnablePaging32 (EntryPoint
, Context1
, Context2
, NewStack
);
823 Disables the 32-bit paging mode on the CPU.
825 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
826 mode. This function assumes the current execution mode is 32-paged protected
827 mode. This function is only available on IA-32. After the 32-bit paging mode
828 is disabled, control is transferred to the function specified by EntryPoint
829 using the new stack specified by NewStack and passing in the parameters
830 specified by Context1 and Context2. Context1 and Context2 are optional and
831 may be NULL. The function EntryPoint must never return.
833 If the current execution mode is not 32-bit paged mode, then ASSERT().
834 If EntryPoint is NULL, then ASSERT().
835 If NewStack is NULL, then ASSERT().
837 There are a number of constraints that must be followed before calling this
839 1) Interrupts must be disabled.
840 2) The caller must be in 32-bit paged mode.
841 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
842 4) CR3 must point to valid page tables that guarantee that the pages for
843 this function and the stack are identity mapped.
845 @param EntryPoint A pointer to function to call with the new stack after
847 @param Context1 A pointer to the context to pass into the EntryPoint
848 function as the first parameter after paging is disabled.
849 @param Context2 A pointer to the context to pass into the EntryPoint
850 function as the second parameter after paging is
852 @param NewStack A pointer to the new stack to use for the EntryPoint
853 function after paging is disabled.
859 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
860 IN VOID
*Context1
, OPTIONAL
861 IN VOID
*Context2
, OPTIONAL
865 ASSERT (EntryPoint
!= NULL
);
866 ASSERT (NewStack
!= NULL
);
867 InternalX86DisablePaging32 (EntryPoint
, Context1
, Context2
, NewStack
);
871 Enables the 64-bit paging mode on the CPU.
873 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
874 must be properly initialized prior to calling this service. This function
875 assumes the current execution mode is 32-bit protected mode with flat
876 descriptors. This function is only available on IA-32. After the 64-bit
877 paging mode is enabled, control is transferred to the function specified by
878 EntryPoint using the new stack specified by NewStack and passing in the
879 parameters specified by Context1 and Context2. Context1 and Context2 are
880 optional and may be 0. The function EntryPoint must never return.
882 If the current execution mode is not 32-bit protected mode with flat
883 descriptors, then ASSERT().
884 If EntryPoint is 0, then ASSERT().
885 If NewStack is 0, then ASSERT().
887 @param Cs The 16-bit selector to load in the CS before EntryPoint
888 is called. The descriptor in the GDT that this selector
889 references must be setup for long mode.
890 @param EntryPoint The 64-bit virtual address of the function to call with
891 the new stack after paging is enabled.
892 @param Context1 The 64-bit virtual address of the context to pass into
893 the EntryPoint function as the first parameter after
895 @param Context2 The 64-bit virtual address of the context to pass into
896 the EntryPoint function as the second parameter after
898 @param NewStack The 64-bit virtual address of the new stack to use for
899 the EntryPoint function after paging is enabled.
906 IN UINT64 EntryPoint
,
907 IN UINT64 Context1
, OPTIONAL
908 IN UINT64 Context2
, OPTIONAL
912 ASSERT (EntryPoint
!= 0);
913 ASSERT (NewStack
!= 0);
914 InternalX86EnablePaging64 (Cs
, EntryPoint
, Context1
, Context2
, NewStack
);
918 Disables the 64-bit paging mode on the CPU.
920 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
921 mode. This function assumes the current execution mode is 64-paging mode.
922 This function is only available on X64. After the 64-bit paging mode is
923 disabled, control is transferred to the function specified by EntryPoint
924 using the new stack specified by NewStack and passing in the parameters
925 specified by Context1 and Context2. Context1 and Context2 are optional and
926 may be 0. The function EntryPoint must never return.
928 If the current execution mode is not 64-bit paged mode, then ASSERT().
929 If EntryPoint is 0, then ASSERT().
930 If NewStack is 0, then ASSERT().
932 @param Cs The 16-bit selector to load in the CS before EntryPoint
933 is called. The descriptor in the GDT that this selector
934 references must be setup for 32-bit protected mode.
935 @param EntryPoint The 64-bit virtual address of the function to call with
936 the new stack after paging is disabled.
937 @param Context1 The 64-bit virtual address of the context to pass into
938 the EntryPoint function as the first parameter after
940 @param Context2 The 64-bit virtual address of the context to pass into
941 the EntryPoint function as the second parameter after
943 @param NewStack The 64-bit virtual address of the new stack to use for
944 the EntryPoint function after paging is disabled.
951 IN UINT32 EntryPoint
,
952 IN UINT32 Context1
, OPTIONAL
953 IN UINT32 Context2
, OPTIONAL
957 ASSERT (EntryPoint
!= 0);
958 ASSERT (NewStack
!= 0);
959 InternalX86DisablePaging64 (Cs
, EntryPoint
, Context1
, Context2
, NewStack
);
963 // x86 version of MemoryFence()
967 Used to serialize load and store operations.
969 All loads and stores that proceed calls to this function are guaranteed to be
970 globally visible when this function returns.