1 /** @file
2 Non-existing BaseLib functions on x64
3
4 Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php.
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #include <Library/BaseLib.h>
16 #include <Library/DebugLib.h>
17
18 /**
19 Enables the 32-bit paging mode on the CPU.
20
21 Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
22 must be properly initialized prior to calling this service. This function
23 assumes the current execution mode is 32-bit protected mode. This function is
24 only available on IA-32. After the 32-bit paging mode is enabled, control is
25 transferred to the function specified by EntryPoint using the new stack
26 specified by NewStack and passing in the parameters specified by Context1 and
27 Context2. Context1 and Context2 are optional and may be NULL. The function
28 EntryPoint must never return.
29
30 There are a number of constraints that must be followed before calling this
31 function:
32 1) Interrupts must be disabled.
33 2) The caller must be in 32-bit protected mode with flat descriptors. This
34 means all descriptors must have a base of 0 and a limit of 4GB.
35 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
36 descriptors.
37 4) CR3 must point to valid page tables that will be used once the transition
38 is complete, and those page tables must guarantee that the pages for this
39 function and the stack are identity mapped.
40
41 @param EntryPoint A pointer to function to call with the new stack after
42 paging is enabled.
43 @param Context1 A pointer to the context to pass into the EntryPoint
44 function as the first parameter after paging is enabled.
45 @param Context2 A pointer to the context to pass into the EntryPoint
46 function as the second parameter after paging is enabled.
47 @param NewStack A pointer to the new stack to use for the EntryPoint
48 function after paging is enabled.
49
50 **/
51 VOID
52 EFIAPI
InternalX86EnablePaging32(IN SWITCH_STACK_ENTRY_POINT EntryPoint,IN VOID * Context1,OPTIONAL IN VOID * Context2,OPTIONAL IN VOID * NewStack)53 InternalX86EnablePaging32 (
54 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
55 IN VOID *Context1, OPTIONAL
56 IN VOID *Context2, OPTIONAL
57 IN VOID *NewStack
58 )
59 {
60 //
61 // This function cannot work on x64 platform
62 //
63 ASSERT (FALSE);
64 }
65
66 /**
67 Disables the 32-bit paging mode on the CPU.
68
69 Disables the 32-bit paging mode on the CPU and returns to 32-bit protected
70 mode. This function assumes the current execution mode is 32-paged protected
71 mode. This function is only available on IA-32. After the 32-bit paging mode
72 is disabled, control is transferred to the function specified by EntryPoint
73 using the new stack specified by NewStack and passing in the parameters
74 specified by Context1 and Context2. Context1 and Context2 are optional and
75 may be NULL. The function EntryPoint must never return.
76
77 There are a number of constraints that must be followed before calling this
78 function:
79 1) Interrupts must be disabled.
80 2) The caller must be in 32-bit paged mode.
81 3) CR0, CR3, and CR4 must be compatible with 32-bit paged mode.
82 4) CR3 must point to valid page tables that guarantee that the pages for
83 this function and the stack are identity mapped.
84
85 @param EntryPoint A pointer to function to call with the new stack after
86 paging is disabled.
87 @param Context1 A pointer to the context to pass into the EntryPoint
88 function as the first parameter after paging is disabled.
89 @param Context2 A pointer to the context to pass into the EntryPoint
90 function as the second parameter after paging is
91 disabled.
92 @param NewStack A pointer to the new stack to use for the EntryPoint
93 function after paging is disabled.
94
95 **/
96 VOID
97 EFIAPI
InternalX86DisablePaging32(IN SWITCH_STACK_ENTRY_POINT EntryPoint,IN VOID * Context1,OPTIONAL IN VOID * Context2,OPTIONAL IN VOID * NewStack)98 InternalX86DisablePaging32 (
99 IN SWITCH_STACK_ENTRY_POINT EntryPoint,
100 IN VOID *Context1, OPTIONAL
101 IN VOID *Context2, OPTIONAL
102 IN VOID *NewStack
103 )
104 {
105 //
106 // This function cannot work on x64 platform
107 //
108 ASSERT (FALSE);
109 }
110
111
112 /**
113 Enables the 64-bit paging mode on the CPU.
114
115 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
116 must be properly initialized prior to calling this service. This function
117 assumes the current execution mode is 32-bit protected mode with flat
118 descriptors. This function is only available on IA-32. After the 64-bit
119 paging mode is enabled, control is transferred to the function specified by
120 EntryPoint using the new stack specified by NewStack and passing in the
121 parameters specified by Context1 and Context2. Context1 and Context2 are
122 optional and may be 0. The function EntryPoint must never return.
123
124 @param Cs The 16-bit selector to load in the CS before EntryPoint
125 is called. The descriptor in the GDT that this selector
126 references must be setup for long mode.
127 @param EntryPoint The 64-bit virtual address of the function to call with
128 the new stack after paging is enabled.
129 @param Context1 The 64-bit virtual address of the context to pass into
130 the EntryPoint function as the first parameter after
131 paging is enabled.
132 @param Context2 The 64-bit virtual address of the context to pass into
133 the EntryPoint function as the second parameter after
134 paging is enabled.
135 @param NewStack The 64-bit virtual address of the new stack to use for
136 the EntryPoint function after paging is enabled.
137
138 **/
139 VOID
140 EFIAPI
InternalX86EnablePaging64(IN UINT16 Cs,IN UINT64 EntryPoint,IN UINT64 Context1,OPTIONAL IN UINT64 Context2,OPTIONAL IN UINT64 NewStack)141 InternalX86EnablePaging64 (
142 IN UINT16 Cs,
143 IN UINT64 EntryPoint,
144 IN UINT64 Context1, OPTIONAL
145 IN UINT64 Context2, OPTIONAL
146 IN UINT64 NewStack
147 )
148 {
149 //
150 // This function cannot work on x64 platform.
151 //
152 ASSERT (FALSE);
153 }
154