diff options
author | David Woodhouse <David.Woodhouse@intel.com> | 2013-01-19 17:34:28 +0000 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2013-02-05 20:06:56 -0500 |
commit | 02e94c1bd24fcf80204c43ef8bd2a148874876af (patch) | |
tree | 688257902542a89df223d89aa29859c8cd28b289 /src/entryfuncs.S | |
parent | 8a0a972f12037b8b4c4bf355bfdc6401afbca1c4 (diff) | |
download | seabios-02e94c1bd24fcf80204c43ef8bd2a148874876af.tar.gz |
Add macros for pushing and popping struct bregs
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>
Diffstat (limited to 'src/entryfuncs.S')
-rw-r--r-- | src/entryfuncs.S | 74 |
1 files changed, 29 insertions, 45 deletions
diff --git a/src/entryfuncs.S b/src/entryfuncs.S index afc5e611..ea6f9900 100644 --- a/src/entryfuncs.S +++ b/src/entryfuncs.S @@ -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. @@ -63,15 +87,7 @@ .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 @@ -79,15 +95,7 @@ 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. @@ -111,43 +119,19 @@ 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. |