]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/DisablePaging32.c
MdePkg: Change OPTIONAL keyword usage style
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / DisablePaging32.c
CommitLineData
e1f414b6 1/** @file\r
2 AsmDisablePaging32 function.\r
3\r
bb817c56 4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
9344f092 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e1f414b6 6\r
7**/\r
8\r
47fc17d8 9#include "BaseLibInternals.h"\r
f734a10a 10\r
42eedea9 11/**\r
12 Disables the 32-bit paging mode on the CPU.\r
13\r
14 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
15 mode. This function assumes the current execution mode is 32-paged protected\r
16 mode. This function is only available on IA-32. After the 32-bit paging mode\r
17 is disabled, control is transferred to the function specified by EntryPoint\r
18 using the new stack specified by NewStack and passing in the parameters\r
19 specified by Context1 and Context2. Context1 and Context2 are optional and\r
20 may be NULL. The function EntryPoint must never return.\r
21\r
22 There are a number of constraints that must be followed before calling this\r
23 function:\r
24 1) Interrupts must be disabled.\r
25 2) The caller must be in 32-bit paged mode.\r
26 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
27 4) CR3 must point to valid page tables that guarantee that the pages for\r
28 this function and the stack are identity mapped.\r
29\r
30 @param EntryPoint A pointer to function to call with the new stack after\r
31 paging is disabled.\r
32 @param Context1 A pointer to the context to pass into the EntryPoint\r
33 function as the first parameter after paging is disabled.\r
34 @param Context2 A pointer to the context to pass into the EntryPoint\r
35 function as the second parameter after paging is\r
36 disabled.\r
37 @param NewStack A pointer to the new stack to use for the EntryPoint\r
38 function after paging is disabled.\r
39\r
40**/\r
e1f414b6 41__declspec (naked)\r
42VOID\r
43EFIAPI\r
44InternalX86DisablePaging32 (\r
45 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
d0e2f823
MK
46 IN VOID *Context1 OPTIONAL,\r
47 IN VOID *Context2 OPTIONAL,\r
e1f414b6 48 IN VOID *NewStack\r
49 )\r
50{\r
51 _asm {\r
52 push ebp\r
53 mov ebp, esp\r
54 mov ebx, EntryPoint\r
55 mov ecx, Context1\r
56 mov edx, Context2\r
57 pushfd\r
58 pop edi // save EFLAGS to edi\r
59 cli\r
60 mov eax, cr0\r
61 btr eax, 31\r
62 mov esp, NewStack\r
63 mov cr0, eax\r
64 push edi\r
65 popfd // restore EFLAGS from edi\r
66 push edx\r
67 push ecx\r
68 call ebx\r
69 jmp $ // EntryPoint() should not return\r
70 }\r
71}\r