e1f414b6 |
1 | /** @file\r |
2 | IA-32/x64 AsmEnablePaging32()\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 |
e1f414b6 |
13 | **/\r |
14 | \r |
1efcc4ae |
15 | \r |
f734a10a |
16 | \r |
e1f414b6 |
17 | \r |
18 | #include "BaseLibInternals.h"\r |
19 | \r |
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 | If the current execution mode is not 32-bit protected mode, then ASSERT().\r |
33 | If EntryPoint is NULL, then ASSERT().\r |
34 | If NewStack is NULL, then ASSERT().\r |
35 | \r |
36 | There are a number of constraints that must be followed before calling this\r |
37 | function:\r |
38 | 1) Interrupts must be disabled.\r |
39 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r |
40 | means all descriptors must have a base of 0 and a limit of 4GB.\r |
41 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r |
42 | descriptors.\r |
43 | 4) CR3 must point to valid page tables that will be used once the transition\r |
44 | is complete, and those page tables must guarantee that the pages for this\r |
45 | function and the stack are identity mapped.\r |
46 | \r |
47 | @param EntryPoint A pointer to function to call with the new stack after\r |
48 | paging is enabled.\r |
49 | @param Context1 A pointer to the context to pass into the EntryPoint\r |
50 | function as the first parameter after paging is enabled.\r |
51 | @param Context2 A pointer to the context to pass into the EntryPoint\r |
52 | function as the second parameter after paging is enabled.\r |
53 | @param NewStack A pointer to the new stack to use for the EntryPoint\r |
54 | function after paging is enabled.\r |
55 | \r |
56 | **/\r |
57 | VOID\r |
58 | EFIAPI\r |
59 | AsmEnablePaging32 (\r |
60 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r |
61 | IN VOID *Context1, OPTIONAL\r |
62 | IN VOID *Context2, OPTIONAL\r |
63 | IN VOID *NewStack\r |
64 | )\r |
65 | {\r |
66 | ASSERT (EntryPoint != NULL);\r |
67 | ASSERT (NewStack != NULL);\r |
68 | InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack);\r |
69 | }\r |