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 ;------------------------------------------------------------------------------
37 InternalX86DisablePaging64 PROC
39 lea rsi, @F ; rsi <- The start address of transition code
40 mov edi, [rsp + 28h] ; rdi <- New stack
41 sub edi, 64 ; rdi <- use 64 byte in stack to hold transition code
42 mov r10d, edi ; r10 <- The start address of transicition code below 4G
43 lea rax, mTransitionEnd ; rax <- end of transition code
44 sub rax, rsi ; rax <- The size of transition piece code
45 push rcx ; save rcx to stack
46 mov rcx, rax ; rcx <- The size of transition piece code
47 rep movsb ; copy transition code to (new stack - 64byte) below 4G
52 mov eax, [rsp + 28h] ; eax <- New Stack
53 push rcx ; push Cs to stack
55 DB 48h ; prefix to composite "retq" with next "retf"
56 retf ; Use far return to load CS register from stack
58 ; Start of transition code
60 mov esp, eax ; set up new stack
63 mov cr0, rax ; disable paging
65 mov rbx, rdx ; save EntryPoint to rbx, for rdmsr will overwrite rdx
68 and ah, NOT 1 ; clear LME
71 and al, NOT (1 SHL 5) ; clear PAE
73 push rdi ; push Context2
74 push rsi ; push Context1
75 call rbx ; transfer control to EntryPoint
76 hlt ; no one should get here
77 InternalX86DisablePaging64 ENDP
79 mTransitionEnd LABEL BYTE