]> xenbits.xensource.com Git - seabios.git/commitdiff
Add macros for pushing and popping struct bregs
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sat, 19 Jan 2013 17:34:28 +0000 (17:34 +0000)
committerKevin O'Connor <kevin@koconnor.net>
Wed, 6 Feb 2013 01:06:56 +0000 (20:06 -0500)
I want to do this too, and can't bring myself to introduce yet another copy.

Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Acked-by: Marc Jones <marc.jones@se-eng.com>
src/entryfuncs.S

index afc5e611944afb4ad9d3eb01800acbe59635b424..ea6f9900bf0b1c1f6940fcd4743e3af8778a0bd8 100644 (file)
@@ -9,6 +9,30 @@
  * Entry macros
  ****************************************************************/
 
+        .macro PUSHBREGS
+        pushl %eax              // Save registers (matches struct bregs)
+        pushl %ecx
+        pushl %edx
+        pushl %ebx
+        pushl %ebp
+        pushl %esi
+        pushl %edi
+        pushw %es
+        pushw %ds
+        .endm
+
+        .macro POPBREGS
+        popw %ds                // Restore registers (from struct bregs)
+        popw %es
+        popl %edi
+        popl %esi
+        popl %ebp
+        popl %ebx
+        popl %edx
+        popl %ecx
+        popl %eax
+        .endm
+
         // Call a C function - this does the minimal work necessary to
         // call into C.  It sets up %ds, backs up %es, and backs up
         // those registers that are call clobbered by the C compiler.
         .macro ENTRY_ARG cfunc
         cli
         cld
-        pushl %eax              // Save registers (matches struct bregs)
-        pushl %ecx
-        pushl %edx
-        pushl %ebx
-        pushl %ebp
-        pushl %esi
-        pushl %edi
-        pushw %es
-        pushw %ds
+        PUSHBREGS
         movw %ss, %ax           // Move %ss to %ds
         movw %ax, %ds
         movl %esp, %ebx         // Backup %esp, then zero high bits
         movl %esp, %eax         // First arg is pointer to struct bregs
         calll \cfunc
         movl %ebx, %esp         // Restore %esp (including high bits)
-        popw %ds                // Restore registers (from struct bregs)
-        popw %es
-        popl %edi
-        popl %esi
-        popl %ebp
-        popl %ebx
-        popl %edx
-        popl %ecx
-        popl %eax
+        POPBREGS
         .endm
 
         // As above, but get calling function from stack.
         movl %esp, %eax         // First arg is pointer to struct bregs
         calll *%ecx
         movl %ebx, %esp         // Restore %esp (including high bits)
-        popw %ds                // Restore registers (from struct bregs)
-        popw %es
-        popl %edi
-        popl %esi
-        popl %ebp
-        popl %ebx
-        popl %edx
-        popl %ecx
-        popl %eax
+        POPBREGS
         .endm
 
         // Same as ENTRY_ARG, but don't mangle %esp
         .macro ENTRY_ARG_ESP cfunc
         cli
         cld
-        pushl %eax              // Save registers (matches struct bregs)
-        pushl %ecx
-        pushl %edx
-        pushl %ebx
-        pushl %ebp
-        pushl %esi
-        pushl %edi
-        pushw %es
-        pushw %ds
+        PUSHBREGS
         movw %ss, %ax           // Move %ss to %ds
         movw %ax, %ds
         movl %esp, %eax         // First arg is pointer to struct bregs
         calll \cfunc
-        popw %ds                // Restore registers (from struct bregs)
-        popw %es
-        popl %edi
-        popl %esi
-        popl %ebp
-        popl %ebx
-        popl %edx
-        popl %ecx
-        popl %eax
+        POPBREGS
         .endm
 
         // Reset stack, transition to 32bit mode, and call a C function.