]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X64/EnablePaging64.asm
Added a 64-bit version of EnablePaging64() on X64. AsmEnablePaging64() is the transit...
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / EnablePaging64.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 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 ; Module Name:
13 ;
14 ; EnablePaging64.Asm
15 ;
16 ; Abstract:
17 ;
18 ; AsmEnablePaging64 function
19 ;
20 ; Notes:
21 ;
22 ;------------------------------------------------------------------------------
23
24 .code
25
26 ;------------------------------------------------------------------------------
27 ; VOID
28 ; EFIAPI
29 ; InternalX86EnablePaging64 (
30 ; IN UINT16 Cs,
31 ; IN UINT64 EntryPoint,
32 ; IN UINT64 Context1, OPTIONAL
33 ; IN UINT64 Context2, OPTIONAL
34 ; IN UINT64 NewStack
35 ; );
36 ;------------------------------------------------------------------------------
37 InternalX86EnablePaging64 PROC
38 cli
39 mov dword ptr [rsp], @F ; offset for far retf, seg is the 1st arg
40 mov rax, cr4 ; mov eax, cr4
41 or al, (1 SHL 5)
42 mov cr4, rax ; enable PAE
43 mov ecx, 0c0000080h
44 rdmsr
45 or ah, 1 ; set LME
46 wrmsr
47 mov rax, cr0 ; mov eax, cr0
48 bts eax, 31
49 mov cr0, rax ; enable paging
50 retf
51 @@: ; long mode starts here
52 mov rbx, [esp]
53 mov rcx, [esp + 8]
54 mov rdx, [esp + 10h]
55 mov rsp, [esp + 18h]
56 add rsp, -20h
57 call rbx
58 jmp $ ; halt processor if EntryPoint() returned
59 InternalX86EnablePaging64 ENDP
60
61 END