]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/EnablePaging64.nasm
41f0ed1ce567108e2e40b4df71a17f2de9eb965e
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / EnablePaging64.nasm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006, Intel Corporation. All rights reserved.<BR>
4 ; 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 SECTION .text
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 global ASM_PFX(InternalX86EnablePaging64)
38 ASM_PFX(InternalX86EnablePaging64):
39 cli
40 mov DWORD [esp], .0 ; offset for far retf, seg is the 1st arg
41 mov eax, cr4
42 or al, (1 << 5)
43 mov cr4, eax ; enable PAE
44 mov ecx, 0xc0000080
45 rdmsr
46 or ah, 1 ; set LME
47 wrmsr
48 mov eax, cr0
49 bts eax, 31 ; set PG
50 mov cr0, eax ; enable paging
51 retf ; topmost 2 dwords hold the address
52 .0:
53 DB 0x67, 0x48 ; 32-bit address size, 64-bit operand size
54 mov ebx, [esp] ; mov rbx, [esp]
55 DB 0x67, 0x48
56 mov ecx, [esp + 8] ; mov rcx, [esp + 8]
57 DB 0x67, 0x48
58 mov edx, [esp + 0x10] ; mov rdx, [esp + 10h]
59 DB 0x67, 0x48
60 mov esp, [esp + 0x18] ; mov rsp, [esp + 18h]
61 DB 0x48
62 add esp, -0x20 ; add rsp, -20h
63 call ebx ; call rbx
64 hlt ; no one should get here
65