1 #------------------------------------------------------------------------------
3 # Copyright (c) 2006 - 2008, 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
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.
18 # AsmDisablePaging64 function
22 #------------------------------------------------------------------------------
26 #------------------------------------------------------------------------------
29 # InternalX86DisablePaging64 (
31 # IN UINT32 EntryPoint,
32 # IN UINT32 Context1, OPTIONAL
33 # IN UINT32 Context2, OPTIONAL
36 #------------------------------------------------------------------------------
38 ASM_GLOBAL ASM_PFX(InternalX86DisablePaging64)
39 ASM_PFX(InternalX86DisablePaging64):
44 mov 0x28(%rsp), %eax # eax <- New Stack
45 push %rcx # push Cs to stack
47 .byte 0x48, 0xcb # retq: Use far return to load CS register from stack
48 # (Use raw byte code since some GNU assemblers generates incorrect code for "retq")
50 mov %eax,%esp # set up new stack
53 mov %rax,%cr0 # disable paging
55 mov %rdx,%rbx # save EntryPoint to rbx, for rdmsr will overwrite rdx
58 and $0xfe,%ah # clear LME
61 and $0xdf,%al # clear PAE
63 push %rdi # push Context2
64 push %rsi # push Context1
65 callq *%rbx # transfer control to EntryPoint
66 jmp . # no one should get here