]> git.proxmox.com Git - mirror_edk2.git/blob - EdkCompatibilityPkg/Foundation/Library/EdkIIGlueLib/Library/BaseLib/X64/DisablePaging64.asm
Add in the 1st version of ECP.
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / EdkIIGlueLib / Library / BaseLib / X64 / DisablePaging64.asm
1 ; Copyright (c) 2004, Intel Corporation
2 ; All rights reserved. This program and the accompanying materials
3 ; are licensed and made available under the terms and conditions of the BSD License
4 ; which accompanies this distribution. The full text of the license may be found at
5 ; http://opensource.org/licenses/bsd-license.php
6 ;
7 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
8 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
9 ;
10 ; Module Name:
11 ;
12 ; DisablePaging64.Asm
13 ;
14 ; Abstract:
15 ;
16 ; AsmDisablePaging64 function
17 ;
18 ; Notes:
19 ;
20 ;------------------------------------------------------------------------------
21
22 .code
23
24 ;------------------------------------------------------------------------------
25 ; VOID
26 ; EFIAPI
27 ; InternalX86DisablePaging64 (
28 ; IN UINT16 Cs,
29 ; IN UINT32 EntryPoint,
30 ; IN UINT32 Context1, OPTIONAL
31 ; IN UINT32 Context2, OPTIONAL
32 ; IN UINT32 NewStack
33 ; );
34 ;------------------------------------------------------------------------------
35 InternalX86DisablePaging64 PROC
36 cli
37 shl rcx, 32 ; rcx[32..47] <- Cs
38 lea eax, @F
39 mov esi, r8d
40 or rcx, rax ; rcx[0..47] <- Cs:@F
41 mov edi, r9d
42 mov eax, [rsp + 28h] ; eax <- New Stack
43 push rcx
44 retf ; switch to compatibility mode
45 @@:
46 mov esp, eax ; set up new stack
47 mov rax, cr0
48 btr eax, 31
49 mov cr0, rax ; disable paging
50 mov ecx, 0c0000080h
51 rdmsr
52 and ah, NOT 1 ; clear LME
53 wrmsr
54 mov rax, cr4
55 and al, NOT (1 SHL 5) ; clear PAE
56 mov cr4, rax
57 push rdi ; push Context2
58 push rsi ; push Context1
59 call rdx ; transfer control to EntryPoint
60 hlt ; no one should get here
61 InternalX86DisablePaging64 ENDP
62
63 END