]> git.proxmox.com Git - mirror_edk2.git/blobdiff - EdkCompatibilityPkg/Foundation/Library/Thunk16/Ia32/Thunk16.S
Update to make end-of-line consistent for all source files in MdePkg. There are no...
[mirror_edk2.git] / EdkCompatibilityPkg / Foundation / Library / Thunk16 / Ia32 / Thunk16.S
index facbe46c93eab68e456fd6303018e783a01a0b9b..0f3abbd7890ed10bfe51fc316cd164636f5e513f 100644 (file)
-#*****************************************************************************
-#*
-#*   Copyright (c) 2006 - 2007, Intel Corporation                                                         
-#*   All rights reserved. This program and the accompanying materials                          
-#*   are licensed and made available under the terms and conditions of the BSD License         
-#*   which accompanies this distribution.  The full text of the license may be found at        
-#*   http://opensource.org/licenses/bsd-license.php                                            
-#*                                                                                             
-#*   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
-#*   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
-#*   
-#*   Module Name:
-#*
-#*    Thunk.asm
-#*  
-#*   Abstract:
-#*  
-#*    Real mode thunk
-#*  
-#*****************************************************************************
-#include <EfiBind.h>
-
-    .686p: 
-
-.globl ASM_PFX(mCode16Size)
-
-.data
-mCode16Size:    .long   _TEXT16SIZE
-
-.data
-
-NullSegSel:     .quad   0
-_16BitCsSel:    
-                .word   -1
-                .word   0
-                .byte   0
-                .byte   0x9b
-                .byte   0x8f            # 16-bit segment
-                .byte   0
-_16BitSsSel:
-                .word   -1
-                .word   0
-                .byte   0
-                .byte   0x93
-                .byte   0x8f           # 16-bit segment
-                .byte   0
-
-_16Gdtr:
-                .word      _16Gdtr - NullSegSel - 1
-                .long      NullSegSel
-
-
-.text
-.align  16
-
-
-ASM_PFX(Thunk16):
-    push   %ebp
-    push   %ebx
-    push   %esi
-    push   %edi
-    push   %ds
-    push   %es
-    push   %fs
-    push   %gs
-    mov    0x24(%esp),%esi
-    movzwl 0x32(%esi),%edx
-    mov    0xc(%esi),%edi
-    add    $0xffffffb0,%edi
-    push   %edi                       #; save stack offset
-    imul   $0x10,%edx,%eax            #; eax <- edx*16
-    add    %eax,%edi                  #; edi <- linear address of 16-bit stack
-    push   $0xd
-    pop    %ecx
-    rep movsl %ds:(%esi),%es:(%edi)   #; copy context to 16-bit stack
-    pop    %ebx                       #; ebx <- 16-bit stack offset
-    mov    $L_Label1,%eax
-    stos   %eax,%es:(%edi)
-    movl   %cs,%eax
-    stos   %ax,%es:(%edi)
-    mov    0x28(%esp),%eax
-    stos   %ax,%es:(%edi)
-    mov    %esp,%eax
-    stos   %eax,%es:(%edi)
-    movl   %ss,%eax
-    stos   %ax,%es:(%edi)
-    sgdtl  (%edi)
-    sidtl  0x24(%esp)
-    mov    %cr0,%esi
-    mov    %esi,0x6(%edi)             #; save CR0
-    and    $0x7ffffffe,%esi           #; esi <- CR0 to set
-    mov    %cr4,%eax
-    mov    %eax,0xa(%edi)             #; save CR4
-    and    $0xcf,%al                  #; clear PAE & PSE
-    mov    %edx,%edi                  #; edi <- 16-bit stack segment
-    mov    0x2c(%esp),%edx
-    shl    $0x10,%edx
-    push   %edx
-    pop    %edx
-    mov    $(_16BitSsSel - NullSegSel),%dx
-    lgdtl  _16Gdtr                    #bugbug mismatch.
-    .byte  0xea
-    .long  L_16Bit                    #bugbug mismatch.
-    .word  _16BitCsSel - NullSegSel
-L_16Bit:   
-    .byte  0x66 
-    movw   %dx,%ss
-    mov    %esi,%cr0
-    mov    %eax,%cr4
-    .byte  0x67
-    .byte  0xff
-    .byte  0x6c
-    .byte  0x24
-    .byte  0xfc
-    
-L_Lable1:
-    movl   %ss,%eax
-    shl    $0x4,%eax
-    add    %esp,%eax
-    lss    0x3c(%esp),%esp
-    lidtl  0x24(%esp)
-    pop    %gs
-    pop    %fs
-    pop    %es
-    pop    %ds
-    pop    %edi
-    pop    %esi
-    pop    %ebx
-    pop    %ebp
-    ret 
-
-.code16
-_Code16Addr:
-ASM_PFX(RealMode):
-    movw    %di, %ss                    # set up stack
-    movl    %ebx, %esp
-    lidt    %cs:_16Idtr - _Code16Addr  #lidt    fword ptr cs:[_16Idtr - _Code16Addr]
-    .byte   0x66
-    popaw
-    popw    %ds
-    popw    %es
-    popw    %fs
-    popw    %gs
-    addw    $4, %sp                     # skip EFlags
-    testw   $1, 14(%esp)                  #(_STK16 ptr [esp + 8]).ThunkFlags, 1
-    jz      1f
-    pushf
-1: 
-    pushw   %cs
-#    push    @FarCallRet - _Code16Addr
-    .byte   0x68                        # push /iw
-    .word   FarCallRet - _Code16Addr
-    jz      2f
-    ljmp    *6(%esp)                  #bugbug
-2: 
-    ljmp    *4(%esp)                  #bugbug
-FarCallRet: 
-    pushfl
-    pushw   %gs
-    pushw   %fs
-    pushw   %es
-    pushw   %ds
-    pushal
-    cli
-    .byte   0x66                        # sizeof (IA32_REGS) = 13 * 4 = 52
-    lgdt    66(%esp)                    #lgdt    (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr
-    mov     76(%esp), %eax
-    movl    %eax, %cr4
-    mov     72(%esp), %eax
-    movl    %eax, %cr0                   # restore CR0
-    ljmpl   *52(%esp)                    
-#RealMode ENDP
-
-.text
-_16Idtr:
-    .word 0x3ff                         #_16Idtr     FWORD   (1 SHL 10) - 1
-    .byte 0x00
-
-_TEXT16END: 
-
-_TEXT16SIZE = _TEXT16END - _Code16Addr
-
-
+#*****************************************************************************\r
+#*\r
+#*   Copyright (c) 2006 - 2007, Intel Corporation                                                         \r
+#*   All rights reserved. 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
+#*                                                                                             \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
+#*   Module Name:\r
+#*\r
+#*    Thunk.asm\r
+#*  \r
+#*   Abstract:\r
+#*  \r
+#*    Real mode thunk\r
+#*  \r
+#*****************************************************************************\r
+#include <EfiBind.h>\r
+\r
+    .686p: \r
+\r
+.globl ASM_PFX(mCode16Size)\r
+\r
+.data\r
+mCode16Size:    .long   _TEXT16SIZE\r
+\r
+.data\r
+\r
+NullSegSel:     .quad   0\r
+_16BitCsSel:    \r
+                .word   -1\r
+                .word   0\r
+                .byte   0\r
+                .byte   0x9b\r
+                .byte   0x8f            # 16-bit segment\r
+                .byte   0\r
+_16BitSsSel:\r
+                .word   -1\r
+                .word   0\r
+                .byte   0\r
+                .byte   0x93\r
+                .byte   0x8f           # 16-bit segment\r
+                .byte   0\r
+\r
+_16Gdtr:\r
+                .word      _16Gdtr - NullSegSel - 1\r
+                .long      NullSegSel\r
+\r
+\r
+.text\r
+.align  16\r
+\r
+\r
+ASM_PFX(Thunk16):\r
+    push   %ebp\r
+    push   %ebx\r
+    push   %esi\r
+    push   %edi\r
+    push   %ds\r
+    push   %es\r
+    push   %fs\r
+    push   %gs\r
+    mov    0x24(%esp),%esi\r
+    movzwl 0x32(%esi),%edx\r
+    mov    0xc(%esi),%edi\r
+    add    $0xffffffb0,%edi\r
+    push   %edi                       #; save stack offset\r
+    imul   $0x10,%edx,%eax            #; eax <- edx*16\r
+    add    %eax,%edi                  #; edi <- linear address of 16-bit stack\r
+    push   $0xd\r
+    pop    %ecx\r
+    rep movsl %ds:(%esi),%es:(%edi)   #; copy context to 16-bit stack\r
+    pop    %ebx                       #; ebx <- 16-bit stack offset\r
+    mov    $L_Label1,%eax\r
+    stos   %eax,%es:(%edi)\r
+    movl   %cs,%eax\r
+    stos   %ax,%es:(%edi)\r
+    mov    0x28(%esp),%eax\r
+    stos   %ax,%es:(%edi)\r
+    mov    %esp,%eax\r
+    stos   %eax,%es:(%edi)\r
+    movl   %ss,%eax\r
+    stos   %ax,%es:(%edi)\r
+    sgdtl  (%edi)\r
+    sidtl  0x24(%esp)\r
+    mov    %cr0,%esi\r
+    mov    %esi,0x6(%edi)             #; save CR0\r
+    and    $0x7ffffffe,%esi           #; esi <- CR0 to set\r
+    mov    %cr4,%eax\r
+    mov    %eax,0xa(%edi)             #; save CR4\r
+    and    $0xcf,%al                  #; clear PAE & PSE\r
+    mov    %edx,%edi                  #; edi <- 16-bit stack segment\r
+    mov    0x2c(%esp),%edx\r
+    shl    $0x10,%edx\r
+    push   %edx\r
+    pop    %edx\r
+    mov    $(_16BitSsSel - NullSegSel),%dx\r
+    lgdtl  _16Gdtr                    #bugbug mismatch.\r
+    .byte  0xea\r
+    .long  L_16Bit                    #bugbug mismatch.\r
+    .word  _16BitCsSel - NullSegSel\r
+L_16Bit:   \r
+    .byte  0x66 \r
+    movw   %dx,%ss\r
+    mov    %esi,%cr0\r
+    mov    %eax,%cr4\r
+    .byte  0x67\r
+    .byte  0xff\r
+    .byte  0x6c\r
+    .byte  0x24\r
+    .byte  0xfc\r
+    \r
+L_Lable1:\r
+    movl   %ss,%eax\r
+    shl    $0x4,%eax\r
+    add    %esp,%eax\r
+    lss    0x3c(%esp),%esp\r
+    lidtl  0x24(%esp)\r
+    pop    %gs\r
+    pop    %fs\r
+    pop    %es\r
+    pop    %ds\r
+    pop    %edi\r
+    pop    %esi\r
+    pop    %ebx\r
+    pop    %ebp\r
+    ret \r
+\r
+.code16\r
+_Code16Addr:\r
+ASM_PFX(RealMode):\r
+    movw    %di, %ss                    # set up stack\r
+    movl    %ebx, %esp\r
+    lidt    %cs:_16Idtr - _Code16Addr  #lidt    fword ptr cs:[_16Idtr - _Code16Addr]\r
+    .byte   0x66\r
+    popaw\r
+    popw    %ds\r
+    popw    %es\r
+    popw    %fs\r
+    popw    %gs\r
+    addw    $4, %sp                     # skip EFlags\r
+    testw   $1, 14(%esp)                  #(_STK16 ptr [esp + 8]).ThunkFlags, 1\r
+    jz      1f\r
+    pushf\r
+1: \r
+    pushw   %cs\r
+#    push    @FarCallRet - _Code16Addr\r
+    .byte   0x68                        # push /iw\r
+    .word   FarCallRet - _Code16Addr\r
+    jz      2f\r
+    ljmp    *6(%esp)                  #bugbug\r
+2: \r
+    ljmp    *4(%esp)                  #bugbug\r
+FarCallRet: \r
+    pushfl\r
+    pushw   %gs\r
+    pushw   %fs\r
+    pushw   %es\r
+    pushw   %ds\r
+    pushal\r
+    cli\r
+    .byte   0x66                        # sizeof (IA32_REGS) = 13 * 4 = 52\r
+    lgdt    66(%esp)                    #lgdt    (_STK16 ptr [esp + sizeof (IA32_REGS)]).SavedGdtr\r
+    mov     76(%esp), %eax\r
+    movl    %eax, %cr4\r
+    mov     72(%esp), %eax\r
+    movl    %eax, %cr0                   # restore CR0\r
+    ljmpl   *52(%esp)                    \r
+#RealMode ENDP\r
+\r
+.text\r
+_16Idtr:\r
+    .word 0x3ff                         #_16Idtr     FWORD   (1 SHL 10) - 1\r
+    .byte 0x00\r
+\r
+_TEXT16END: \r
+\r
+_TEXT16SIZE = _TEXT16END - _Code16Addr\r
+\r
+\r