1 #------------------------------------------------------------------------------
3 # Copyright (c) 2006 - 2009, 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
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):
41 lea L1(%rip), %rsi # rsi <- The start address of transition code
42 mov 0x28(%rsp), %edi # rdi <- New stack
43 lea _mTransitionEnd(%rip), %rax # rax <- end of transition code
44 sub %rsi, %rax # rax <- The size of transition piece code
45 add $4, %rax # round rax up to the next 4 byte boundary
47 sub %rax, %rdi # rdi <- use stack to hold transition code
48 mov %edi, %r10d # r10 <- The start address of transicition code below 4G
49 push %rcx # save rcx to stack
50 mov %rax, %rcx # rcx <- The size of transition piece code
52 movsb # copy transition code to (new stack - 64byte) below 4G
53 pop %rcx # restore rcx
59 push %rcx # push Cs to stack
60 push %r10 # push address of transition code on stack
61 .byte 0x48, 0xcb # retq: Use far return to load CS register from stack
62 # (Use raw byte code since some GNU assemblers generates incorrect code for "retq")
64 mov %eax,%esp # set up new stack
66 btr $0x1f,%eax # clear CR0.PG
67 mov %rax,%cr0 # disable paging
69 mov %edx,%ebx # save EntryPoint to ebx, for rdmsr will overwrite edx
72 and $0xfe,%ah # clear LME
75 and $0xdf,%al # clear PAE
77 push %rdi # push Context2
78 push %rsi # push Context1
79 callq *%rbx # transfer control to EntryPoint
80 jmp . # no one should get here