diff options
author | Till Straumann <strauman@slac.stanford.edu> | 2009-10-29 03:15:03 +0000 |
---|---|---|
committer | Till Straumann <strauman@slac.stanford.edu> | 2009-10-29 03:15:03 +0000 |
commit | a6d48e3941123189084882866361ff009de1ee04 (patch) | |
tree | 96e033d504c0da7aeb1a0ac0185cb80a802db847 /cpukit/score/cpu/i386/cpu_asm.S | |
parent | 2009-10-28 Till Straumann <strauman@slac.stanford.edu> (diff) | |
download | rtems-a6d48e3941123189084882866361ff009de1ee04.tar.bz2 |
2009-10-28 Till Straumann <strauman@slac.stanford.edu>
* score/cpu/i386/rtems/score/cpu.h:
Added #ifdef ASM constructs so that this header can be
included from assembly code.
Increased CPU_STACK_ALIGNMENT to 16 bytes. Gcc maintains
16-byte alignment and it may be a advantageous to provide
initial 16-byte alignment. When using SSE some gcc versions
may produce code that crashes if the stack is not 16-byte aligned.
Make sure _CPU_Context_Initialize() sets the thread stack
up so that it is aligned to CPU_CACHE_ALIGNMENT.
* score/cpu/i386/cpu_asm.S:
Align stack to CPU_CACHE_ALIGNMENT before calling C-code.
Diffstat (limited to 'cpukit/score/cpu/i386/cpu_asm.S')
-rw-r--r-- | cpukit/score/cpu/i386/cpu_asm.S | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/cpukit/score/cpu/i386/cpu_asm.S b/cpukit/score/cpu/i386/cpu_asm.S index 7630aa3b35..4084e03fb8 100644 --- a/cpukit/score/cpu/i386/cpu_asm.S +++ b/cpukit/score/cpu/i386/cpu_asm.S @@ -14,6 +14,11 @@ */ #include <rtems/asm.h> +#include <rtems/score/cpu.h> + +#ifndef CPU_STACK_ALIGNMENT +#error "Missing header? CPU_STACK_ALIGNMENT not defined" +#endif /* * Format of i386 Register structure @@ -110,13 +115,17 @@ SYM (_CPU_Context_restore_fp): PUBLIC (_Exception_Handler) SYM (_Exception_Handler): - pusha /* Push general purpose registers */ - pushl esp /* Push exception frame address */ - movl _currentExcHandler, eax /* Call function storead in _currentExcHandler */ + pusha /* Push general purpose registers */ + movl esp, ebp /* Save original SP */ + subl $4, esp /* Reserve space for argument */ + /* Align stack (courtesy for C/gcc) */ + andl $ - CPU_STACK_ALIGNMENT, esp + movl ebp, (esp) /* Store argument */ + movl _currentExcHandler, eax /* Call function stored in _currentExcHandler */ call * eax - addl $4, esp - popa /* restore general purpose registers */ - addl $8, esp /* skill vector number and faultCode */ + movl ebp, esp /* Restore original SP */ + popa /* Restore general purpose registers */ + addl $8, esp /* Skill vector number and faultCode */ iret #define DISTINCT_EXCEPTION_WITH_FAULTCODE_ENTRY(_vector) \ |