]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdePkg/Library/BaseLib/X64/DisablePaging64.asm
Minor grammatical work--mostly adding periods. Items with ONLY period added did...
[mirror_edk2.git] / MdePkg / Library / BaseLib / X64 / DisablePaging64.asm
index 29bf558e6c8df6154e3d0e0a5691363a0a0ae70b..32dcd5aa1f1f3b67662262e1b0635d586a44c4ed 100644 (file)
@@ -1,10 +1,10 @@
 ;------------------------------------------------------------------------------\r
 ;\r
-; Copyright (c) 2006 - 2008, Intel Corporation\r
-; All rights reserved. This program and the accompanying materials\r
+; Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>\r
+; This program and the accompanying materials\r
 ; are licensed and made available under the terms and conditions of the BSD License\r
 ; which accompanies this distribution.  The full text of the license may be found at\r
-; http://opensource.org/licenses/bsd-license.php\r
+; http://opensource.org/licenses/bsd-license.php.\r
 ;\r
 ; THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
 ; WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 ;------------------------------------------------------------------------------\r
 InternalX86DisablePaging64    PROC\r
     cli\r
-    shl     rcx, 32                     ; rcx[32..47] <- Cs\r
-    lea     eax, @F\r
+    lea     rsi, @F                     ; rsi <- The start address of transition code\r
+    mov     edi, [rsp + 28h]            ; rdi <- New stack\r
+    lea     rax, mTransitionEnd         ; rax <- end of transition code\r
+    sub     rax, rsi                    ; rax <- The size of transition piece code \r
+    add     rax, 4                      ; Round RAX up to the next 4 byte boundary\r
+    and     al, 0fch\r
+    sub     rdi, rax                    ; rdi <- Use stack to hold transition code\r
+    mov     r10d, edi                   ; r10 <- The start address of transicition code below 4G\r
+    push    rcx                         ; save rcx to stack\r
+    mov     rcx, rax                    ; rcx <- The size of transition piece code\r
+    rep     movsb                       ; copy transition code to top of new stack which must be below 4GB\r
+    pop     rcx                         ; restore rcx\r
+    \r
     mov     esi, r8d\r
-    or      rcx, rax                    ; rcx[0..47] <- Cs:@F\r
     mov     edi, r9d\r
-    mov     eax, [rsp + 28h]            ; eax <- New Stack\r
-    push    rcx\r
-    retf                                ; switch to compatibility mode\r
+    mov     eax, r10d                   ; eax <- start of the transition code on the stack\r
+    sub     eax, 4                      ; eax <- One slot below transition code on the stack\r
+    push    rcx                         ; push Cs to stack\r
+    push    r10                         ; push address of tansition code on stack\r
+    DB      48h                         ; prefix to composite "retq" with next "retf"\r
+    retf                                ; Use far return to load CS register from stack\r
+\r
+; Start of transition code\r
 @@:\r
     mov     esp, eax                    ; set up new stack\r
     mov     rax, cr0\r
-    btr     eax, 31\r
-    mov     cr0, rax                    ; disable paging\r
-\r
-    mov     rbx, rdx                    ; save EntryPoint to rbx, for rdmsr will overwrite rdx\r
+    btr     eax, 31                     ; Clear CR0.PG\r
+    mov     cr0, rax                    ; disable paging and caches\r
+    \r
+    mov     ebx, edx                    ; save EntryPoint to rbx, for rdmsr will overwrite rdx\r
     mov     ecx, 0c0000080h\r
     rdmsr\r
     and     ah, NOT 1                   ; clear LME\r
@@ -64,4 +79,6 @@ InternalX86DisablePaging64    PROC
     hlt                                 ; no one should get here\r
 InternalX86DisablePaging64    ENDP\r
 \r
+mTransitionEnd LABEL    BYTE\r
+\r
     END\r