]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Fix the bug that if code is run above 4G, AsmDisablePaging64 will be failure.
authorklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Jun 2009 11:21:48 +0000 (11:21 +0000)
committerklu2 <klu2@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 5 Jun 2009 11:21:48 +0000 (11:21 +0000)
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@8478 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/X64/DisablePaging64.asm

index f11f6ff291a988002528e78641bcd668ce5aee92..502a54c4e5657e7919000c5ee26e45546ea73885 100644 (file)
 ;------------------------------------------------------------------------------\r
 InternalX86DisablePaging64    PROC\r
     cli\r
-    lea     r10, @F\r
+    lea     rsi, @F                     ; rsi <- The start address of transition code\r
+    mov     rdi, [rsp + 28h]            ; rdi <- New stack\r
+    sub     rdi, 64                     ; rdi <- use 64 byte in stack to hold transition code  \r
+    mov     r10, rdi                    ; r10 <- The start address of transicition code below 4G\r
+    lea     rax, mTransitionEnd         ; rax <- end of transition code\r
+    sub     rax, rsi                    ; rax <- The size of transition piece code \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 (new stack - 64byte) below 4G\r
+    pop     rcx                         ; restore rcx\r
+    \r
     mov     esi, r8d\r
     mov     edi, r9d\r
     mov     eax, [rsp + 28h]            ; eax <- New Stack\r
@@ -44,6 +54,8 @@ InternalX86DisablePaging64    PROC
     push    r10\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
@@ -64,4 +76,6 @@ InternalX86DisablePaging64    PROC
     hlt                                 ; no one should get here\r
 InternalX86DisablePaging64    ENDP\r
 \r
+mTransitionEnd LABEL    BYTE\r
+\r
     END\r