1 | /** @file
|
---|
2 | IA-32/x64 AsmEnablePaging32()
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
|
---|
5 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
6 |
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include "BaseLibInternals.h"
|
---|
10 |
|
---|
11 | /**
|
---|
12 | Enables the 32-bit paging mode on the CPU.
|
---|
13 |
|
---|
14 | Enables the 32-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
|
---|
15 | must be properly initialized prior to calling this service. This function
|
---|
16 | assumes the current execution mode is 32-bit protected mode. This function is
|
---|
17 | only available on IA-32. After the 32-bit paging mode is enabled, control is
|
---|
18 | transferred to the function specified by EntryPoint using the new stack
|
---|
19 | specified by NewStack and passing in the parameters specified by Context1 and
|
---|
20 | Context2. Context1 and Context2 are optional and may be NULL. The function
|
---|
21 | EntryPoint must never return.
|
---|
22 |
|
---|
23 | If the current execution mode is not 32-bit protected mode, then ASSERT().
|
---|
24 | If EntryPoint is NULL, then ASSERT().
|
---|
25 | If NewStack is NULL, then ASSERT().
|
---|
26 |
|
---|
27 | There are a number of constraints that must be followed before calling this
|
---|
28 | function:
|
---|
29 | 1) Interrupts must be disabled.
|
---|
30 | 2) The caller must be in 32-bit protected mode with flat descriptors. This
|
---|
31 | means all descriptors must have a base of 0 and a limit of 4GB.
|
---|
32 | 3) CR0 and CR4 must be compatible with 32-bit protected mode with flat
|
---|
33 | descriptors.
|
---|
34 | 4) CR3 must point to valid page tables that will be used once the transition
|
---|
35 | is complete, and those page tables must guarantee that the pages for this
|
---|
36 | function and the stack are identity mapped.
|
---|
37 |
|
---|
38 | @param EntryPoint A pointer to function to call with the new stack after
|
---|
39 | paging is enabled.
|
---|
40 | @param Context1 A pointer to the context to pass into the EntryPoint
|
---|
41 | function as the first parameter after paging is enabled.
|
---|
42 | @param Context2 A pointer to the context to pass into the EntryPoint
|
---|
43 | function as the second parameter after paging is enabled.
|
---|
44 | @param NewStack A pointer to the new stack to use for the EntryPoint
|
---|
45 | function after paging is enabled.
|
---|
46 |
|
---|
47 | **/
|
---|
48 | VOID
|
---|
49 | EFIAPI
|
---|
50 | AsmEnablePaging32 (
|
---|
51 | IN SWITCH_STACK_ENTRY_POINT EntryPoint,
|
---|
52 | IN VOID *Context1 OPTIONAL,
|
---|
53 | IN VOID *Context2 OPTIONAL,
|
---|
54 | IN VOID *NewStack
|
---|
55 | )
|
---|
56 | {
|
---|
57 | ASSERT (EntryPoint != NULL);
|
---|
58 | ASSERT (NewStack != NULL);
|
---|
59 | InternalX86EnablePaging32 (EntryPoint, Context1, Context2, NewStack);
|
---|
60 | }
|
---|