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