]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X86EnablePaging32.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86EnablePaging32.c
1 /** @file
2 IA-32/x64 AsmEnablePaging32()
3
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9
10
11
12 #include "BaseLibInternals.h"
13
14 /**
15 Enables the 32-bit paging mode on the CPU.
16
17 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
18 must be properly initialized prior to calling this service. This function
19 assumes the current execution mode is 32-bit protected mode. This function is
20 only available on IA-32. After the 32-bit paging mode is enabled, control is
21 transferred to the function specified by EntryPoint using the new stack
22 specified by NewStack and passing in the parameters specified by Context1 and
23 Context2. Context1 and Context2 are optional and may be NULL. The function
24 EntryPoint must never return.
25
26 If the current execution mode is not 32-bit protected mode, then ASSERT().
27 If EntryPoint is NULL, then ASSERT().
28 If NewStack is NULL, then ASSERT().
29
30 There are a number of constraints that must be followed before calling this
31 function:
32 1) Interrupts must be disabled.
33 2) The caller must be in 32-bit protected mode with flat descriptors. This
34 means all descriptors must have a base of 0 and a limit of 4GB.
35 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
36 descriptors.
37 4) CR3 must point to valid page tables that will be used once the transition
38 is complete, and those page tables must guarantee that the pages for this
39 function and the stack are identity mapped.
40
41 @param EntryPoint A pointer to function to call with the new stack after
42 paging is enabled.
43 @param Context1 A pointer to the context to pass into the EntryPoint
44 function as the first parameter after paging is enabled.
45 @param Context2 A pointer to the context to pass into the EntryPoint
46 function as the second parameter after paging is enabled.
47 @param NewStack A pointer to the new stack to use for the EntryPoint
48 function after paging is enabled.
49
50 **/
51 VOID
52 EFIAPI
53 AsmEnablePaging32 (
54 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
55 IN VOID *Context1, OPTIONAL
56 IN VOID *Context2, OPTIONAL
57 IN VOID *NewStack
58 )
59 {
60 ASSERT (EntryPoint != NULL);
61 ASSERT (NewStack != NULL);
62 InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack);
63 }