]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | AsmEnablePaging32 function\r | |
3 | \r | |
bb817c56 HT |
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r |
5 | This program and the accompanying materials\r | |
e1f414b6 | 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 | |
35a17154 | 8 | http://opensource.org/licenses/bsd-license.php.\r |
e1f414b6 | 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 | Enables the 32-bit paging mode on the CPU.\r | |
19 | \r | |
20 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
21 | must be properly initialized prior to calling this service. This function\r | |
22 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
23 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
24 | transferred to the function specified by EntryPoint using the new stack\r | |
25 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
26 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
27 | EntryPoint must never return.\r | |
28 | \r | |
29 | There are a number of constraints that must be followed before calling this\r | |
30 | function:\r | |
31 | 1) Interrupts must be disabled.\r | |
32 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
33 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
34 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
35 | descriptors.\r | |
36 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
37 | is complete, and those page tables must guarantee that the pages for this\r | |
38 | function and the stack are identity mapped.\r | |
39 | \r | |
40 | @param EntryPoint A pointer to function to call with the new stack after\r | |
41 | paging is enabled.\r | |
42 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
43 | function as the first parameter after paging is enabled.\r | |
44 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
45 | function as the second parameter after paging is enabled.\r | |
46 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
47 | function after paging is enabled.\r | |
48 | \r | |
49 | **/\r | |
e1f414b6 | 50 | __declspec (naked)\r |
51 | VOID\r | |
52 | EFIAPI\r | |
53 | InternalX86EnablePaging32 (\r | |
54 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
55 | IN VOID *Context1, OPTIONAL\r | |
56 | IN VOID *Context2, OPTIONAL\r | |
57 | IN VOID *NewStack\r | |
58 | )\r | |
59 | {\r | |
60 | _asm {\r | |
61 | push ebp\r | |
62 | mov ebp, esp\r | |
63 | mov ebx, EntryPoint\r | |
64 | mov ecx, Context1\r | |
65 | mov edx, Context2\r | |
66 | pushfd\r | |
67 | pop edi\r | |
68 | cli\r | |
69 | mov eax, cr0\r | |
70 | bts eax, 31\r | |
71 | mov esp, NewStack\r | |
72 | mov cr0, eax\r | |
73 | push edi\r | |
74 | popfd\r | |
75 | push edx\r | |
76 | push ecx\r | |
77 | call ebx\r | |
78 | jmp $\r | |
79 | }\r | |
80 | }\r | |
81 | \r |