]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X86EnablePaging64.c
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / MdePkg / Library / BaseLib / X86EnablePaging64.c
1 /** @file
2 IA-32/x64 AsmEnablePaging64()
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 64-bit paging mode on the CPU.
13
14 Enables the 64-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 with flat
17 descriptors. This function is only available on IA-32. After the 64-bit
18 paging mode is enabled, control is transferred to the function specified by
19 EntryPoint using the new stack specified by NewStack and passing in the
20 parameters specified by Context1 and Context2. Context1 and Context2 are
21 optional and may be 0. The function EntryPoint must never return.
22
23 If the current execution mode is not 32-bit protected mode with flat
24 descriptors, then ASSERT().
25 If EntryPoint is 0, then ASSERT().
26 If NewStack is 0, then ASSERT().
27
28 @param Cs The 16-bit selector to load in the CS before EntryPoint
29 is called. The descriptor in the GDT that this selector
30 references must be setup for long mode.
31 @param EntryPoint The 64-bit virtual address of the function to call with
32 the new stack after paging is enabled.
33 @param Context1 The 64-bit virtual address of the context to pass into
34 the EntryPoint function as the first parameter after
35 paging is enabled.
36 @param Context2 The 64-bit virtual address of the context to pass into
37 the EntryPoint function as the second parameter after
38 paging is enabled.
39 @param NewStack The 64-bit virtual address of the new stack to use for
40 the EntryPoint function after paging is enabled.
41
42 **/
43 VOID
44 EFIAPI
45 AsmEnablePaging64 (
46 IN UINT16 Cs,
47 IN UINT64 EntryPoint,
48 IN UINT64 Context1 OPTIONAL,
49 IN UINT64 Context2 OPTIONAL,
50 IN UINT64 NewStack
51 )
52 {
53 ASSERT (EntryPoint != 0);
54 ASSERT (NewStack != 0);
55 InternalX86EnablePaging64 (Cs, EntryPoint, Context1, Context2, NewStack);
56 }