]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X64/DisablePaging64.asm
1. Port X64, IPF and EBC arch for BaseLib
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / DisablePaging64.asm
1 ;------------------------------------------------------------------------------
2 ;
3 ; Copyright (c) 2006, 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
8 ;
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.
11 ;
12 ; Module Name:
13 ;
14 ; DisablePaging64.Asm
15 ;
16 ; Abstract:
17 ;
18 ; AsmDisablePaging64 function
19 ;
20 ; Notes:
21 ;
22 ;------------------------------------------------------------------------------
23
24 .code
25
26 ;------------------------------------------------------------------------------
27 ; VOID
28 ; EFIAPI
29 ; InternalX86DisablePaging64 (
30 ; IN UINT16 Cs,
31 ; IN UINT32 EntryPoint,
32 ; IN UINT32 Context1, OPTIONAL
33 ; IN UINT32 Context2, OPTIONAL
34 ; IN UINT32 NewStack
35 ; );
36 ;------------------------------------------------------------------------------
37 InternalX86DisablePaging64 PROC
38 cli
39 shl rcx, 32 ; rcx[32..47] <- Cs
40 lea eax, @F
41 mov esi, r8d
42 or rcx, rax ; rcx[0..47] <- Cs:@F
43 mov edi, r9d
44 mov eax, [rsp + 28h] ; eax <- New Stack
45 push rcx
46 retf ; switch to compatibility mode
47 @@:
48 mov esp, eax ; set up new stack
49 mov rax, cr0
50 btr eax, 31
51 mov cr0, rax ; disable paging
52 mov ecx, 0c0000080h
53 rdmsr
54 and ah, NOT 1 ; clear LME
55 wrmsr
56 mov rax, cr4
57 and al, NOT (1 SHL 5) ; clear PAE
58 mov cr4, rax
59 push rdi ; push Context2
60 push rsi ; push Context1
61 call rdx ; transfer control to EntryPoint
62 hlt ; no one should get here
63 InternalX86DisablePaging64 ENDP
64
65 END