diff options
author | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-10-02 21:32:44 +0000 |
---|---|---|
committer | Joel Sherrill <joel.sherrill@OARcorp.com> | 2008-10-02 21:32:44 +0000 |
commit | ed6e94718057565c287a28d186d06816b74c65cf (patch) | |
tree | 7f83b4da2f2d9111ef37b266c892ebcd8373dc20 /cpukit/score/cpu/m32c/context_init.c | |
parent | 2008-10-02 Joel Sherrill <joel.sherrill@oarcorp.com> (diff) | |
download | rtems-ed6e94718057565c287a28d186d06816b74c65cf.tar.bz2 |
2008-10-02 Joel Sherrill <joel.sherrill@oarcorp.com>
* .cvsignore, ChangeLog, Makefile.am, context_init.c, context_switch.S,
cpu.c, cpu_asm.c, preinstall.am, varvects.S, varvects.h, rtems/asm.h,
rtems/score/cpu.h, rtems/score/cpu_asm.h, rtems/score/m32c.h,
rtems/score/types.h: New files.
Diffstat (limited to '')
-rw-r--r-- | cpukit/score/cpu/m32c/context_init.c | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/cpukit/score/cpu/m32c/context_init.c b/cpukit/score/cpu/m32c/context_init.c new file mode 100644 index 0000000000..e975eeab00 --- /dev/null +++ b/cpukit/score/cpu/m32c/context_init.c @@ -0,0 +1,61 @@ +/* + */ + +#include <stdint.h> +#include <rtems/system.h> + +typedef struct { + uint16_t sbLow; + uint16_t sbHigh; /* push/pop sb */ + uint16_t flg; /* push/pop flg */ + uint32_t a1; /* pushm */ + uint32_t a0; + uint32_t r0r2; + uint32_t r1r3; + uint16_t frameLow; /* exitd */ + uint16_t frameHigh; + uint16_t startLow; + uint16_t startHigh; + uint16_t zero; +} Starting_Frame; + +#define _get_sb( _sb ) \ + asm volatile( "stc sb, %0" : "=r" (_sb)) + +void _CPU_Context_Initialize( + Context_Control *the_context, + uint32_t *stack_base, + size_t size, + uint32_t new_level, + void *entry_point, + bool is_fp +) +{ + void *stackEnd = stack_base; + register uint32_t sb; + Starting_Frame *frame; + + _get_sb( sb ); + stackEnd += size; + + frame = (Starting_Frame *)stackEnd; + frame--; + + frame->zero = 0; + frame->sbLow = ((uint32_t)sb) & 0xffff; + frame->sbHigh = ((uint32_t)sb >> 16) & 0xffff; + frame->flg = 0x80; /* User stack */ + if ( !new_level ) /* interrupt level 0 --> enabled */ + frame->flg |= 0x40; + frame->a0 = 0x01020304; + frame->a1 =0xa1a2a3a4; + frame->r0r2 = 0; + frame->r1r3 = 0; + frame->frameLow = ((uint32_t)frame) & 0xffff; + frame->frameHigh = ((uint32_t)frame >> 16) & 0xffff; + frame->startLow = ((uint32_t)entry_point) & 0xffff; + frame->startHigh = ((uint32_t)entry_point >> 16) & 0xffff; + + the_context->sp = (uint32_t)frame; + the_context->fb = (uint32_t)&frame->frameLow; +} |