1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2008, 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 ;------------------------------------------------------------------------------
37 InternalX86DisablePaging64 PROC
39 lea rsi, @F ; rsi <- The start address of transition code
40 mov edi, [rsp + 28h] ; rdi <- New stack
41 lea rax, mTransitionEnd ; rax <- end of transition code
42 sub rax, rsi ; rax <- The size of transition piece code
43 add rax, 4 ; Round RAX up to the next 4 byte boundary
45 sub rdi, rax ; rdi <- Use stack to hold transition code
46 mov r10d, edi ; r10 <- The start address of transicition code below 4G
47 push rcx ; save rcx to stack
48 mov rcx, rax ; rcx <- The size of transition piece code
49 rep movsb ; copy transition code to top of new stack which must be below 4GB
54 mov eax, r10d ; eax <- start of the transition code on the stack
55 sub eax, 4 ; eax <- One slot below transition code on the stack
56 push rcx ; push Cs to stack
57 push r10 ; push address of tansition code on stack
58 DB 48h ; prefix to composite "retq" with next "retf"
59 retf ; Use far return to load CS register from stack
61 ; Start of transition code
63 mov esp, eax ; set up new stack
65 btr eax, 31 ; Clear CR0.PG
66 mov cr0, rax ; disable paging and caches
68 mov ebx, edx ; save EntryPoint to rbx, for rdmsr will overwrite rdx
71 and ah, NOT 1 ; clear LME
74 and al, NOT (1 SHL 5) ; clear PAE
76 push rdi ; push Context2
77 push rsi ; push Context1
78 call rbx ; transfer control to EntryPoint
79 hlt ; no one should get here
80 InternalX86DisablePaging64 ENDP
82 mTransitionEnd LABEL BYTE