1 ;------------------------------------------------------------------------------
3 ; Copyright (c) 2006 - 2022, Intel Corporation. All rights reserved.<BR>
4 ; SPDX-License-Identifier: BSD-2-Clause-Patent
12 ; AsmDisablePaging64 function
16 ;------------------------------------------------------------------------------
21 ;------------------------------------------------------------------------------
24 ; InternalX86DisablePaging64 (
26 ; IN UINT32 EntryPoint,
27 ; IN UINT32 Context1, OPTIONAL
28 ; IN UINT32 Context2, OPTIONAL
31 ;------------------------------------------------------------------------------
32 global ASM_PFX(InternalX86DisablePaging64)
33 ASM_PFX(InternalX86DisablePaging64):
35 lea rsi, [.0] ; rsi <- The start address of transition code
36 mov edi, [rsp + 0x28] ; rdi <- New stack
37 lea rax, [mTransitionEnd] ; rax <- end of transition code
38 sub rax, rsi ; rax <- The size of transition piece code
39 add rax, 4 ; Round RAX up to the next 4 byte boundary
41 sub rdi, rax ; rdi <- Use stack to hold transition code
42 mov r10d, edi ; r10 <- The start address of transicition code below 4G
43 push rcx ; save rcx to stack
44 mov rcx, rax ; rcx <- The size of transition piece code
45 rep movsb ; copy transition code to top of new stack which must be below 4GB
50 mov eax, r10d ; eax <- start of the transition code on the stack
51 sub eax, 4 ; eax <- One slot below transition code on the stack
52 push rcx ; push Cs to stack
53 push r10 ; push address of tansition code on stack
56 ; Start of transition code
58 mov esp, eax ; set up new stack
60 btr eax, 31 ; Clear CR0.PG
61 mov cr0, rax ; disable paging and caches
63 mov ebx, edx ; save EntryPoint to rbx, for rdmsr will overwrite rdx
66 and ah, ~ 1 ; clear LME
69 and al, ~ (1 << 5) ; clear PAE
71 push rdi ; push Context2
72 push rsi ; push Context1
73 call rbx ; transfer control to EntryPoint
74 hlt ; no one should get here