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 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 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 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 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 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 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 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 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 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 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);
744 InternalX86FxSave (Buffer
);
747 // Mark one flag at end of Buffer, it will be check by AsmFxRestor()
749 *(UINT32
*) (&Buffer
[sizeof (IA32_FX_BUFFER
) - 4]) = 0xAA5555AA;
753 Restores the current floating point/SSE/SSE2 context from a buffer.
755 Restores the current floating point/SSE/SSE2 state from the buffer specified
756 by Buffer. Buffer must be aligned on a 16-byte boundary. This function is
757 only available on IA-32 and X64.
759 If Buffer is NULL, then ASSERT().
760 If Buffer is not aligned on a 16-byte boundary, then ASSERT().
761 If Buffer was not saved with AsmFxSave(), then ASSERT().
763 @param Buffer Pointer to a buffer to save the floating point/SSE/SSE2 context.
769 IN CONST IA32_FX_BUFFER
*Buffer
772 ASSERT (Buffer
!= NULL
);
773 ASSERT (((UINTN
)Buffer
& 0xf) == 0);
776 // Check the flag recorded by AsmFxSave()
778 ASSERT (*(UINT32
*) (&Buffer
[sizeof (IA32_FX_BUFFER
) - 4]) == 0xAA5555AA);
780 InternalX86FxRestore (Buffer
);
784 Enables the 32-bit paging mode on the CPU.
786 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
787 must be properly initialized prior to calling this service. This function
788 assumes the current execution mode is 32-bit protected mode. This function is
789 only available on IA-32. After the 32-bit paging mode is enabled, control is
790 transferred to the function specified by EntryPoint using the new stack
791 specified by NewStack and passing in the parameters specified by Context1 and
792 Context2. Context1 and Context2 are optional and may be NULL. The function
793 EntryPoint must never return.
795 If the current execution mode is not 32-bit protected mode, then ASSERT().
796 If EntryPoint is NULL, then ASSERT().
797 If NewStack is NULL, then ASSERT().
799 There are a number of constraints that must be followed before calling this
801 1) Interrupts must be disabled.
802 2) The caller must be in 32-bit protected mode with flat descriptors. This
803 means all descriptors must have a base of 0 and a limit of 4GB.
804 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
806 4) CR3 must point to valid page tables that will be used once the transition
807 is complete, and those page tables must guarantee that the pages for this
808 function and the stack are identity mapped.
810 @param EntryPoint A pointer to function to call with the new stack after
812 @param Context1 A pointer to the context to pass into the EntryPoint
813 function as the first parameter after paging is enabled.
814 @param Context2 A pointer to the context to pass into the EntryPoint
815 function as the second parameter after paging is enabled.
816 @param NewStack A pointer to the new stack to use for the EntryPoint
817 function after paging is enabled.
823 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
824 IN VOID
*Context1
, OPTIONAL
825 IN VOID
*Context2
, OPTIONAL
829 ASSERT (EntryPoint
!= NULL
);
830 ASSERT (NewStack
!= NULL
);
831 InternalX86EnablePaging32 (EntryPoint
, Context1
, Context2
, NewStack
);
835 Disables the 32-bit paging mode on the CPU.
837 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
838 mode. This function assumes the current execution mode is 32-paged protected
839 mode. This function is only available on IA-32. After the 32-bit paging mode
840 is disabled, control is transferred to the function specified by EntryPoint
841 using the new stack specified by NewStack and passing in the parameters
842 specified by Context1 and Context2. Context1 and Context2 are optional and
843 may be NULL. The function EntryPoint must never return.
845 If the current execution mode is not 32-bit paged mode, then ASSERT().
846 If EntryPoint is NULL, then ASSERT().
847 If NewStack is NULL, then ASSERT().
849 There are a number of constraints that must be followed before calling this
851 1) Interrupts must be disabled.
852 2) The caller must be in 32-bit paged mode.
853 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
854 4) CR3 must point to valid page tables that guarantee that the pages for
855 this function and the stack are identity mapped.
857 @param EntryPoint A pointer to function to call with the new stack after
859 @param Context1 A pointer to the context to pass into the EntryPoint
860 function as the first parameter after paging is disabled.
861 @param Context2 A pointer to the context to pass into the EntryPoint
862 function as the second parameter after paging is
864 @param NewStack A pointer to the new stack to use for the EntryPoint
865 function after paging is disabled.
871 IN SWITCH_STACK_ENTRY_POINT EntryPoint
,
872 IN VOID
*Context1
, OPTIONAL
873 IN VOID
*Context2
, OPTIONAL
877 ASSERT (EntryPoint
!= NULL
);
878 ASSERT (NewStack
!= NULL
);
879 InternalX86DisablePaging32 (EntryPoint
, Context1
, Context2
, NewStack
);
883 Enables the 64-bit paging mode on the CPU.
885 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
886 must be properly initialized prior to calling this service. This function
887 assumes the current execution mode is 32-bit protected mode with flat
888 descriptors. This function is only available on IA-32. After the 64-bit
889 paging mode is enabled, control is transferred to the function specified by
890 EntryPoint using the new stack specified by NewStack and passing in the
891 parameters specified by Context1 and Context2. Context1 and Context2 are
892 optional and may be 0. The function EntryPoint must never return.
894 If the current execution mode is not 32-bit protected mode with flat
895 descriptors, then ASSERT().
896 If EntryPoint is 0, then ASSERT().
897 If NewStack is 0, then ASSERT().
899 @param Cs The 16-bit selector to load in the CS before EntryPoint
900 is called. The descriptor in the GDT that this selector
901 references must be setup for long mode.
902 @param EntryPoint The 64-bit virtual address of the function to call with
903 the new stack after paging is enabled.
904 @param Context1 The 64-bit virtual address of the context to pass into
905 the EntryPoint function as the first parameter after
907 @param Context2 The 64-bit virtual address of the context to pass into
908 the EntryPoint function as the second parameter after
910 @param NewStack The 64-bit virtual address of the new stack to use for
911 the EntryPoint function after paging is enabled.
918 IN UINT64 EntryPoint
,
919 IN UINT64 Context1
, OPTIONAL
920 IN UINT64 Context2
, OPTIONAL
924 ASSERT (EntryPoint
!= 0);
925 ASSERT (NewStack
!= 0);
926 InternalX86EnablePaging64 (Cs
, EntryPoint
, Context1
, Context2
, NewStack
);
930 Disables the 64-bit paging mode on the CPU.
932 Disables the 64-bit paging mode on the CPU and returns to 32-bit protected
933 mode. This function assumes the current execution mode is 64-paging mode.
934 This function is only available on X64. After the 64-bit paging mode is
935 disabled, control is transferred to the function specified by EntryPoint
936 using the new stack specified by NewStack and passing in the parameters
937 specified by Context1 and Context2. Context1 and Context2 are optional and
938 may be 0. The function EntryPoint must never return.
940 If the current execution mode is not 64-bit paged mode, then ASSERT().
941 If EntryPoint is 0, then ASSERT().
942 If NewStack is 0, then ASSERT().
944 @param Cs The 16-bit selector to load in the CS before EntryPoint
945 is called. The descriptor in the GDT that this selector
946 references must be setup for 32-bit protected mode.
947 @param EntryPoint The 64-bit virtual address of the function to call with
948 the new stack after paging is disabled.
949 @param Context1 The 64-bit virtual address of the context to pass into
950 the EntryPoint function as the first parameter after
952 @param Context2 The 64-bit virtual address of the context to pass into
953 the EntryPoint function as the second parameter after
955 @param NewStack The 64-bit virtual address of the new stack to use for
956 the EntryPoint function after paging is disabled.
963 IN UINT32 EntryPoint
,
964 IN UINT32 Context1
, OPTIONAL
965 IN UINT32 Context2
, OPTIONAL
969 ASSERT (EntryPoint
!= 0);
970 ASSERT (NewStack
!= 0);
971 InternalX86DisablePaging64 (Cs
, EntryPoint
, Context1
, Context2
, NewStack
);
975 // x86 version of MemoryFence()
979 Used to serialize load and store operations.
981 All loads and stores that proceed calls to this function are guaranteed to be
982 globally visible when this function returns.