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