]> git.proxmox.com Git - mirror_edk2.git/blob - MdePkg/Library/BaseLib/X64/DisablePaging64.asm
Fixes for ARM build in the EdkCompatibilityPkg and a couple of Xcode fixes for MdePkg.
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / DisablePaging64.asm
1 ;------------------------------------------------------------------------------
2 ;
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
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 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
48 pop rcx ; restore rcx
49
50 mov esi, r8d
51 mov edi, r9d
52 mov eax, [rsp + 28h] ; eax <- New Stack
53 push rcx ; push Cs to stack
54 push r10
55 DB 48h ; prefix to composite "retq" with next "retf"
56 retf ; Use far return to load CS register from stack
57
58 ; Start of transition code
59 @@:
60 mov esp, eax ; set up new stack
61 mov rax, cr0
62 btr eax, 31
63 mov cr0, rax ; disable paging
64
65 mov rbx, rdx ; save EntryPoint to rbx, for rdmsr will overwrite rdx
66 mov ecx, 0c0000080h
67 rdmsr
68 and ah, NOT 1 ; clear LME
69 wrmsr
70 mov rax, cr4
71 and al, NOT (1 SHL 5) ; clear PAE
72 mov cr4, rax
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
78
79 mTransitionEnd LABEL BYTE
80
81 END