]> git.proxmox.com Git - mirror_edk2.git/commitdiff
1. Fixed bug in FlushCacheLine.asm, added return value
authorvanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Jun 2006 08:42:05 +0000 (08:42 +0000)
committervanjeff <vanjeff@6f19259b-4bc3-4df7-8a09-765794883524>
Wed, 28 Jun 2006 08:42:05 +0000 (08:42 +0000)
2. Updated AsmEnablePaging64(), added far jump to long mode with updating CS

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@649 6f19259b-4bc3-4df7-8a09-765794883524

MdePkg/Library/BaseLib/Ia32/EnablePaging64.asm
MdePkg/Library/BaseLib/X64/FlushCacheLine.asm

index 6c9b0ea76bca8a44de6914f218b73ca1b13c4975..97d859e966f5add11408dda8bc04463e7ed07505 100644 (file)
     .code\r
 \r
 InternalX86EnablePaging64 PROC\r
     .code\r
 \r
 InternalX86EnablePaging64 PROC\r
-    cli\r
-    mov     [esp], @F                   ; offset for far retf\r
-    mov     eax, cr4\r
+    cli
+\r
+    mov     ebx, [esp + 4]              ; save CS
+    mov     eax, OFFSET cs_address
+    mov     word ptr [eax], bx          ; Update CS selector for far jump
+\r
+    mov     eax, cr4 \r
     or      al, (1 SHL 5)\r
     mov     cr4, eax                    ; enable PAE\r
     mov     ecx, 0c0000080h\r
     or      al, (1 SHL 5)\r
     mov     cr4, eax                    ; enable PAE\r
     mov     ecx, 0c0000080h\r
@@ -37,19 +41,30 @@ InternalX86EnablePaging64 PROC
     wrmsr\r
     mov     eax, cr0\r
     bts     eax, 31\r
     wrmsr\r
     mov     eax, cr0\r
     bts     eax, 31\r
-    mov     cr0, eax                    ; enable paging\r
-    retf\r
-@@:                                     ; long mode starts here\r
-    DB      67h, 48h\r
-    mov     ebx, [esp]                  ; mov rbx, [esp]\r
+    mov     cr0, eax                    ; enable paging
+    retf
+    jmp     go_to_long_mode
+go_to_long_mode:
+
+    ;
+    ; This is the next instruction after enabling paging.  Jump to long mode
+    ;
+    db      067h
+    db      0eah                        ;   Far Jump Offset:Selector to reload CS
+    dd      OFFSET in_long_mode         ;   Offset is ensuing instruction boundary
+cs_address:
+    dw      0h                          ;   CS selector will be updated at runtime 
+\r
+in_long_mode:                           ; now in long mode
     DB      67h, 48h\r
     DB      67h, 48h\r
-    mov     ecx, [esp + 8]              ; mov rcx, [esp + 8]\r
+    mov     ebx, [esp + 8]              ; mov rbx, [esp]\r
+    DB      67h, 48h\r                   
+    mov     ecx, [esp + 10h]            ; mov rcx, [esp + 8]\r
     DB      67h, 48h\r
     DB      67h, 48h\r
-    mov     edx, [esp + 10h]            ; mov rdx, [esp + 10h]\r
+    mov     edx, [esp + 18h]            ; mov rdx, [esp + 10h]\r
     DB      67h, 48h\r
     DB      67h, 48h\r
-    mov     esp, [esp + 18h]            ; mov rsp, [esp + 18h]\r
+    mov     esp, [esp + 20h]            ; mov rsp, [esp + 18h]\r
     DB      48h\r
     DB      48h\r
-    add     esp, -20h                   ; add rsp, -20h\r
     call    ebx                         ; call rbx\r
     jmp     $\r
 InternalX86EnablePaging64 ENDP\r
     call    ebx                         ; call rbx\r
     jmp     $\r
 InternalX86EnablePaging64 ENDP\r
index 9978e734aa52e40b430e762e7f524c96f9256067..44d7730947c7fe31f04a06fdda100617191698ac 100644 (file)
@@ -24,7 +24,7 @@
     .code\r
 \r
 ;------------------------------------------------------------------------------\r
     .code\r
 \r
 ;------------------------------------------------------------------------------\r
-; VOID *\r
+; VOID\r
 ; EFIAPI\r
 ; AsmFlushCacheLine (\r
 ;   IN      VOID                      *LinearAddress\r
 ; EFIAPI\r
 ; AsmFlushCacheLine (\r
 ;   IN      VOID                      *LinearAddress\r