]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/Ia32/EnablePaging64.s
b365ea762af4984760b1ea947f9ae1544655d7a7
[mirror_edk2.git] / MdePkg / Library / BaseLib / Ia32 / EnablePaging64.s
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
25 #.MODEL flat
26
27
28 #------------------------------------------------------------------------------
29 # VOID
30 # EFIAPI
31 # AsmEnablePaging64 (
32 # IN UINT16 CodeSelector,
33 # IN UINT64 EntryPoint,
34 # IN UINT64 Context1, OPTIONAL
35 # IN UINT64 Context2, OPTIONAL
36 # IN UINT64 NewStack
37 # );
38 #------------------------------------------------------------------------------
39 .global _AsmEnablePaging64
40 _AsmEnablePaging64:
41 cli
42 movl $$LongStart, (%esp)
43 movl %cr4, %eax
44 orb $0x20, %al
45 movl %eax, %cr4 # enable PAE
46 movl $0xc0000080, %ecx
47 rdmsr
48 orb $1, %ah # set LME
49 wrmsr
50 movl %cr0, %eax
51 btsl $31, %eax
52 movl %eax, %cr0 # enable paging
53 lret
54 LongStart: # long mode starts here
55 .byte 0x67,0x48
56 movl (%esp), %ebx # mov rbx, [esp]
57 .byte 0x67,0x48
58 movl 8(%esp), %ecx # mov rcx, [esp + 8]
59 .byte 0x67,0x48
60 movl 0x10(%esp), %edx # mov rdx, [esp + 10h]
61 .byte 0x67,0x48
62 movl 0x18(%esp), %esp # mov rsp, [esp + 18h]
63 .byte 0x48
64 addl $0x-20, %esp # add rsp, -20h
65 call *%ebx # call rbx
66 jmp .