]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm
1. Fixed bug in FlushCacheLine.asm, added return value
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / EnablePaging64.asm
CommitLineData
878ddf1f 1;------------------------------------------------------------------------------\r
2;\r
3; Copyright (c) 2006, Intel Corporation\r
4; All rights reserved. This program and the accompanying materials\r
5; are licensed and made available under the terms and conditions of the BSD License\r
6; which accompanies this distribution. The full text of the license may be found at\r
7; http://opensource.org/licenses/bsd-license.php\r
8;\r
9; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
10; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
11;\r
12; Module Name:\r
13;\r
14; EnablePaging64.Asm\r
15;\r
16; Abstract:\r
17;\r
18; AsmEnablePaging64 function\r
19;\r
20; Notes:\r
21;\r
22;------------------------------------------------------------------------------\r
23\r
24 .686p\r
25 .model flat,C\r
26 .code\r
27\r
28InternalX86EnablePaging64 PROC\r
939d5406 29 cli
30\r
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\r
35 mov eax, cr4 \r
878ddf1f 36 or al, (1 SHL 5)\r
37 mov cr4, eax ; enable PAE\r
38 mov ecx, 0c0000080h\r
39 rdmsr\r
40 or ah, 1 ; set LME\r
41 wrmsr\r
42 mov eax, cr0\r
43 bts eax, 31\r
939d5406 44 mov cr0, eax ; enable paging
45 retf
46 jmp go_to_long_mode
47go_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
55cs_address:
56 dw 0h ; CS selector will be updated at runtime
57\r
58in_long_mode: ; now in long mode
878ddf1f 59 DB 67h, 48h\r
939d5406 60 mov ebx, [esp + 8] ; mov rbx, [esp]\r
61 DB 67h, 48h\r
62 mov ecx, [esp + 10h] ; mov rcx, [esp + 8]\r
878ddf1f 63 DB 67h, 48h\r
939d5406 64 mov edx, [esp + 18h] ; mov rdx, [esp + 10h]\r
878ddf1f 65 DB 67h, 48h\r
939d5406 66 mov esp, [esp + 20h] ; mov rsp, [esp + 18h]\r
878ddf1f 67 DB 48h\r
878ddf1f 68 call ebx ; call rbx\r
69 jmp $\r
70InternalX86EnablePaging64 ENDP\r
71\r
72 END\r