aboutsummaryrefslogtreecommitdiffstats
path: root/vgasrc
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2014-11-05 09:05:36 -0500
committerKevin O'Connor <kevin@koconnor.net>2014-11-12 12:17:57 -0500
commitaa66d6539cb11720477f2219a5821a9de1916384 (patch)
tree5e0cd3c967b3096142c39bf105a3b34aa1a0dc04 /vgasrc
parentb4eb6fc5cc051e18d07f9483c093c9c32cece2f7 (diff)
downloadseabios-aa66d6539cb11720477f2219a5821a9de1916384.tar.gz
seabios-aa66d6539cb11720477f2219a5821a9de1916384.tar.xz
seabios-aa66d6539cb11720477f2219a5821a9de1916384.zip
Use an aligned stack offset when entering on the extra stack
The size of 'struct bregs' is not evenly divisible by four and where the assembler placed a 'struct bregs' on the extra stack as part of entering into the C functions it caused the C functions to run with a non-aligned stack. It's technically not correct to use an unaligned stack and it is certainly less efficient. This patch avoids using BREGS_size (the sizeof struct bregs) and instead introduces PUSHBREGS_size (the size of the general purpose registers in struct bregs) in the assembler. Where the code actually did use the %cs:%ip and flags, an extra 8 (instead of 6) bytes are added to maintain a sane alignment. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'vgasrc')
-rw-r--r--vgasrc/vgaentry.S20
1 files changed, 10 insertions, 10 deletions
diff --git a/vgasrc/vgaentry.S b/vgasrc/vgaentry.S
index c05502d..f9cf656 100644
--- a/vgasrc/vgaentry.S
+++ b/vgasrc/vgaentry.S
@@ -112,10 +112,10 @@ entry_10_extrastack:
pushw %ds // Set %ds:%eax to space on ExtraStack
pushl %eax
movw %cs:ExtraStackSeg, %ds
- movl $(CONFIG_VGA_EXTRA_STACK_SIZE-BREGS_size-8), %eax
+ movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-16), %eax
SAVEBREGS_POP_DSEAX // Save registers on extra stack
- movl %esp, BREGS_size+0(%eax)
- movw %ss, BREGS_size+4(%eax)
+ movl %esp, PUSHBREGS_size+8(%eax)
+ movw %ss, PUSHBREGS_size+12(%eax)
popl BREGS_code(%eax)
popw BREGS_flags(%eax)
@@ -125,8 +125,8 @@ entry_10_extrastack:
VGA_CALLL handle_10
movl %esp, %eax // Restore registers and return
- movw BREGS_size+4(%eax), %ss
- movl BREGS_size+0(%eax), %esp
+ movw PUSHBREGS_size+12(%eax), %ss
+ movl PUSHBREGS_size+8(%eax), %esp
popl %edx
popw %dx
pushw BREGS_flags(%eax)
@@ -148,10 +148,10 @@ entry_timer_hook_extrastack:
pushw %ds // Set %ds:%eax to space on ExtraStack
pushl %eax
movw %cs:ExtraStackSeg, %ds
- movl $(CONFIG_VGA_EXTRA_STACK_SIZE-BREGS_size-8), %eax
+ movl $(CONFIG_VGA_EXTRA_STACK_SIZE-PUSHBREGS_size-8), %eax
SAVEBREGS_POP_DSEAX
- movl %esp, BREGS_size(%eax)
- movw %ss, BREGS_size+4(%eax)
+ movl %esp, PUSHBREGS_size(%eax)
+ movw %ss, PUSHBREGS_size+4(%eax)
movw %ds, %dx // Setup %ss/%esp and call function
movw %dx, %ss
@@ -159,7 +159,7 @@ entry_timer_hook_extrastack:
calll handle_timer_hook
movl %esp, %eax // Restore registers and return
- movw BREGS_size+4(%eax), %ss
- movl BREGS_size(%eax), %esp
+ movw PUSHBREGS_size+4(%eax), %ss
+ movl PUSHBREGS_size(%eax), %esp
RESTOREBREGS_DSEAX
ljmpw *%cs:Timer_Hook_Resume