]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/DisablePaging32.c
Update copyright for files modified in this year
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / DisablePaging32.c
CommitLineData
e1f414b6 1/** @file\r
2 AsmDisablePaging32 function.\r
3\r
373ade0e 4 Copyright (c) 2006 - 2008, Intel Corporation<BR>\r
e1f414b6 5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
47fc17d8 15#include "BaseLibInternals.h"\r
f734a10a 16\r
42eedea9 17/**\r
18 Disables the 32-bit paging mode on the CPU.\r
19\r
20 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r
21 mode. This function assumes the current execution mode is 32-paged protected\r
22 mode. This function is only available on IA-32. After the 32-bit paging mode\r
23 is disabled, control is transferred to the function specified by EntryPoint\r
24 using the new stack specified by NewStack and passing in the parameters\r
25 specified by Context1 and Context2. Context1 and Context2 are optional and\r
26 may be NULL. The function EntryPoint must never return.\r
27\r
28 There are a number of constraints that must be followed before calling this\r
29 function:\r
30 1) Interrupts must be disabled.\r
31 2) The caller must be in 32-bit paged mode.\r
32 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r
33 4) CR3 must point to valid page tables that guarantee that the pages for\r
34 this function and the stack are identity mapped.\r
35\r
36 @param EntryPoint A pointer to function to call with the new stack after\r
37 paging is disabled.\r
38 @param Context1 A pointer to the context to pass into the EntryPoint\r
39 function as the first parameter after paging is disabled.\r
40 @param Context2 A pointer to the context to pass into the EntryPoint\r
41 function as the second parameter after paging is\r
42 disabled.\r
43 @param NewStack A pointer to the new stack to use for the EntryPoint\r
44 function after paging is disabled.\r
45\r
46**/\r
e1f414b6 47__declspec (naked)\r
48VOID\r
49EFIAPI\r
50InternalX86DisablePaging32 (\r
51 IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r
52 IN VOID *Context1, OPTIONAL\r
53 IN VOID *Context2, OPTIONAL\r
54 IN VOID *NewStack\r
55 )\r
56{\r
57 _asm {\r
58 push ebp\r
59 mov ebp, esp\r
60 mov ebx, EntryPoint\r
61 mov ecx, Context1\r
62 mov edx, Context2\r
63 pushfd\r
64 pop edi // save EFLAGS to edi\r
65 cli\r
66 mov eax, cr0\r
67 btr eax, 31\r
68 mov esp, NewStack\r
69 mov cr0, eax\r
70 push edi\r
71 popfd // restore EFLAGS from edi\r
72 push edx\r
73 push ecx\r
74 call ebx\r
75 jmp $ // EntryPoint() should not return\r
76 }\r
77}\r