]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm
d54c27e7197dfc48c00deb0105511f95f7234c08
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / EnablePaging64.asm
1 //
2 // Include common header file for this module.
3 //
4 #include "CommonHeader.h"
5
6 ;------------------------------------------------------------------------------
7 ;
8 ; Copyright (c) 2006, Intel Corporation
9 ; All rights reserved. This program and the accompanying materials
10 ; are licensed and made available under the terms and conditions of the BSD License
11 ; which accompanies this distribution. The full text of the license may be found at
12 ; http://opensource.org/licenses/bsd-license.php
13 ;
14 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 ;
17 ; Module Name:
18 ;
19 ; EnablePaging64.Asm
20 ;
21 ; Abstract:
22 ;
23 ; AsmEnablePaging64 function
24 ;
25 ; Notes:
26 ;
27 ;------------------------------------------------------------------------------
28
29 .686p
30 .model flat,C
31 .code
32
33 ;------------------------------------------------------------------------------
34 ; VOID
35 ; EFIAPI
36 ; InternalX86EnablePaging64 (
37 ; IN UINT16 Cs,
38 ; IN UINT64 EntryPoint,
39 ; IN UINT64 Context1, OPTIONAL
40 ; IN UINT64 Context2, OPTIONAL
41 ; IN UINT64 NewStack
42 ; );
43 ;------------------------------------------------------------------------------
44 InternalX86EnablePaging64 PROC
45 cli
46 mov [esp], @F ; offset for far retf, seg is the 1st arg
47 mov eax, cr4
48 or al, (1 SHL 5)
49 mov cr4, eax ; enable PAE
50 mov ecx, 0c0000080h
51 rdmsr
52 or ah, 1 ; set LME
53 wrmsr
54 mov eax, cr0
55 bts eax, 31 ; set PG
56 mov cr0, eax ; enable paging
57 retf ; topmost 2 dwords hold the address
58 @@: ; long mode starts here
59 DB 67h, 48h ; 32-bit address size, 64-bit operand size
60 mov ebx, [esp] ; mov rbx, [esp]
61 DB 67h, 48h
62 mov ecx, [esp + 8] ; mov rcx, [esp + 8]
63 DB 67h, 48h
64 mov edx, [esp + 10h] ; mov rdx, [esp + 10h]
65 DB 67h, 48h
66 mov esp, [esp + 18h] ; mov rsp, [esp + 18h]
67 DB 48h
68 add esp, -20h ; add rsp, -20h
69 call ebx ; call rbx
70 hlt ; no one should get here
71 InternalX86EnablePaging64 ENDP
72
73 END