]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/x86EnablePaging64.c
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / x86EnablePaging64.c
1 /*++
2
3 Copyright (c) 2004 - 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
8
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
11
12
13 Module Name:
14
15 x86EnablePaging64.c
16
17 Abstract:
18
19 IA-32/x64 specific functions.
20
21 --*/
22
23 #include "BaseLibInternal.h"
24
25 /**
26 Enables the 64-bit paging mode on the CPU.
27
28 Enables the 64-bit paging mode on the CPU. CR0, CR3, CR4, and the page tables
29 must be properly initialized prior to calling this service. This function
30 assumes the current execution mode is 32-bit protected mode with flat
31 descriptors. This function is only available on IA-32. After the 64-bit
32 paging mode is enabled, control is transferred to the function specified by
33 EntryPoint using the new stack specified by NewStack and passing in the
34 parameters specified by Context1 and Context2. Context1 and Context2 are
35 optional and may be 0. The function EntryPoint must never return.
36
37 If the current execution mode is not 32-bit protected mode with flat
38 descriptors, then ASSERT().
39 If EntryPoint is 0, then ASSERT().
40 If NewStack is 0, then ASSERT().
41
42 @param Cs The 16-bit selector to load in the CS before EntryPoint
43 is called. The descriptor in the GDT that this selector
44 references must be setup for long mode.
45 @param EntryPoint The 64-bit virtual address of the function to call with
46 the new stack after paging is enabled.
47 @param Context1 The 64-bit virtual address of the context to pass into
48 the EntryPoint function as the first parameter after
49 paging is enabled.
50 @param Context2 The 64-bit virtual address of the context to pass into
51 the EntryPoint function as the second parameter after
52 paging is enabled.
53 @param NewStack The 64-bit virtual address of the new stack to use for
54 the EntryPoint function after paging is enabled.
55
56 **/
57 VOID
58 EFIAPI
59 AsmEnablePaging64 (
60 IN UINT16 Cs,
61 IN UINT64 EntryPoint,
62 IN UINT64 Context1, OPTIONAL
63 IN UINT64 Context2, OPTIONAL
64 IN UINT64 NewStack
65 )
66 {
67 ASSERT (EntryPoint != 0);
68 ASSERT (NewStack != 0);
69 InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);
70 }