]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm
97d859e966f5add11408dda8bc04463e7ed07505
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / 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 .686p
25 .model flat,C
26 .code
27
28 InternalX86EnablePaging64 PROC
29 cli
30
31 mov ebx, [esp + 4] ; save CS
32 mov eax, OFFSET cs_address
33 mov word ptr [eax], bx ; Update CS selector for far jump
34
35 mov eax, cr4
36 or al, (1 SHL 5)
37 mov cr4, eax ; enable PAE
38 mov ecx, 0c0000080h
39 rdmsr
40 or ah, 1 ; set LME
41 wrmsr
42 mov eax, cr0
43 bts eax, 31
44 mov cr0, eax ; enable paging
45 retf
46 jmp go_to_long_mode
47 go_to_long_mode:
48
49 ;
50 ; This is the next instruction after enabling paging. Jump to long mode
51 ;
52 db 067h
53 db 0eah ; Far Jump Offset:Selector to reload CS
54 dd OFFSET in_long_mode ; Offset is ensuing instruction boundary
55 cs_address:
56 dw 0h ; CS selector will be updated at runtime
57
58 in_long_mode: ; now in long mode
59 DB 67h, 48h
60 mov ebx, [esp + 8] ; mov rbx, [esp]
61 DB 67h, 48h
62 mov ecx, [esp + 10h] ; mov rcx, [esp + 8]
63 DB 67h, 48h
64 mov edx, [esp + 18h] ; mov rdx, [esp + 10h]
65 DB 67h, 48h
66 mov esp, [esp + 20h] ; mov rsp, [esp + 18h]
67 DB 48h
68 call ebx ; call rbx
69 jmp $
70 InternalX86EnablePaging64 ENDP
71
72 END