]>
Commit | Line | Data |
---|---|---|
f1baef62 | 1 | /** @file\r |
2 | Non-existing BaseLib functions on x64\r | |
3 | \r | |
83584954 | 4 | Copyright (c) 2006 - 2008, Intel Corporation\r |
f1baef62 | 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 | |
f1baef62 | 13 | **/\r |
14 | \r | |
83584954 | 15 | #include <Library/BaseLib.h>\r |
16 | #include <Library/DebugLib.h>\r | |
f1baef62 | 17 | \r |
18 | /**\r | |
19 | Enables the 32-bit paging mode on the CPU.\r | |
20 | \r | |
21 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
22 | must be properly initialized prior to calling this service. This function\r | |
23 | assumes the current execution mode is 32-bit protected mode. This function is\r | |
24 | only available on IA-32. After the 32-bit paging mode is enabled, control is\r | |
25 | transferred to the function specified by EntryPoint using the new stack\r | |
26 | specified by NewStack and passing in the parameters specified by Context1 and\r | |
27 | Context2. Context1 and Context2 are optional and may be NULL. The function\r | |
28 | EntryPoint must never return.\r | |
29 | \r | |
30 | There are a number of constraints that must be followed before calling this\r | |
31 | function:\r | |
32 | 1) Interrupts must be disabled.\r | |
33 | 2) The caller must be in 32-bit protected mode with flat descriptors. This\r | |
34 | means all descriptors must have a base of 0 and a limit of 4GB.\r | |
35 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat\r | |
36 | descriptors.\r | |
37 | 4) CR3 must point to valid page tables that will be used once the transition\r | |
38 | is complete, and those page tables must guarantee that the pages for this\r | |
39 | function and the stack are identity mapped.\r | |
40 | \r | |
41 | @param EntryPoint A pointer to function to call with the new stack after\r | |
42 | paging is enabled.\r | |
43 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
44 | function as the first parameter after paging is enabled.\r | |
45 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
46 | function as the second parameter after paging is enabled.\r | |
47 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
48 | function after paging is enabled.\r | |
49 | \r | |
50 | **/\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 | //\r | |
83584954 | 61 | // This function cannot work on x64 platform\r |
f1baef62 | 62 | //\r |
63 | ASSERT (FALSE);\r | |
64 | }\r | |
65 | \r | |
66 | /**\r | |
67 | Disables the 32-bit paging mode on the CPU.\r | |
68 | \r | |
69 | Disables the 32-bit paging mode on the CPU and returns to 32-bit protected\r | |
70 | mode. This function assumes the current execution mode is 32-paged protected\r | |
71 | mode. This function is only available on IA-32. After the 32-bit paging mode\r | |
72 | is disabled, control is transferred to the function specified by EntryPoint\r | |
73 | using the new stack specified by NewStack and passing in the parameters\r | |
74 | specified by Context1 and Context2. Context1 and Context2 are optional and\r | |
75 | may be NULL. The function EntryPoint must never return.\r | |
76 | \r | |
77 | There are a number of constraints that must be followed before calling this\r | |
78 | function:\r | |
79 | 1) Interrupts must be disabled.\r | |
80 | 2) The caller must be in 32-bit paged mode.\r | |
81 | 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.\r | |
82 | 4) CR3 must point to valid page tables that guarantee that the pages for\r | |
83 | this function and the stack are identity mapped.\r | |
84 | \r | |
85 | @param EntryPoint A pointer to function to call with the new stack after\r | |
86 | paging is disabled.\r | |
87 | @param Context1 A pointer to the context to pass into the EntryPoint\r | |
88 | function as the first parameter after paging is disabled.\r | |
89 | @param Context2 A pointer to the context to pass into the EntryPoint\r | |
90 | function as the second parameter after paging is\r | |
91 | disabled.\r | |
92 | @param NewStack A pointer to the new stack to use for the EntryPoint\r | |
93 | function after paging is disabled.\r | |
94 | \r | |
95 | **/\r | |
96 | VOID\r | |
97 | EFIAPI\r | |
98 | InternalX86DisablePaging32 (\r | |
99 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,\r | |
100 | IN VOID *Context1, OPTIONAL\r | |
101 | IN VOID *Context2, OPTIONAL\r | |
102 | IN VOID *NewStack\r | |
103 | )\r | |
104 | {\r | |
105 | //\r | |
83584954 | 106 | // This function cannot work on x64 platform\r |
f1baef62 | 107 | //\r |
108 | ASSERT (FALSE);\r | |
109 | }\r | |
744e71a3 | 110 | \r |
111 | \r | |
112 | /**\r | |
113 | Enables the 64-bit paging mode on the CPU.\r | |
114 | \r | |
115 | Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables\r | |
116 | must be properly initialized prior to calling this service. This function\r | |
117 | assumes the current execution mode is 32-bit protected mode with flat\r | |
118 | descriptors. This function is only available on IA-32. After the 64-bit\r | |
119 | paging mode is enabled, control is transferred to the function specified by\r | |
120 | EntryPoint using the new stack specified by NewStack and passing in the\r | |
121 | parameters specified by Context1 and Context2. Context1 and Context2 are\r | |
122 | optional and may be 0. The function EntryPoint must never return.\r | |
123 | \r | |
124 | @param Cs The 16-bit selector to load in the CS before EntryPoint\r | |
125 | is called. The descriptor in the GDT that this selector\r | |
126 | references must be setup for long mode.\r | |
127 | @param EntryPoint The 64-bit virtual address of the function to call with\r | |
128 | the new stack after paging is enabled.\r | |
129 | @param Context1 The 64-bit virtual address of the context to pass into\r | |
130 | the EntryPoint function as the first parameter after\r | |
131 | paging is enabled.\r | |
132 | @param Context2 The 64-bit virtual address of the context to pass into\r | |
133 | the EntryPoint function as the second parameter after\r | |
134 | paging is enabled.\r | |
135 | @param NewStack The 64-bit virtual address of the new stack to use for\r | |
136 | the EntryPoint function after paging is enabled.\r | |
137 | \r | |
138 | **/\r | |
139 | VOID\r | |
140 | EFIAPI\r | |
141 | InternalX86EnablePaging64 (\r | |
142 | IN UINT16 Cs,\r | |
143 | IN UINT64 EntryPoint,\r | |
144 | IN UINT64 Context1, OPTIONAL\r | |
145 | IN UINT64 Context2, OPTIONAL\r | |
146 | IN UINT64 NewStack\r | |
147 | )\r | |
148 | {\r | |
149 | //\r | |
150 | // This function cannot work on x64 platform.\r | |
151 | //\r | |
152 | ASSERT (FALSE);\r | |
153 | }\r |