4.104.115
Line | |
---|
1 | /* |
---|
2 | * COPYRIGHT (c) 1989-2008. |
---|
3 | * On-Line Applications Research Corporation (OAR). |
---|
4 | * |
---|
5 | * The license and distribution terms for this file may be |
---|
6 | * found in the file LICENSE in this distribution or at |
---|
7 | * http://www.rtems.com/license/LICENSE. |
---|
8 | * |
---|
9 | * $Id$ |
---|
10 | */ |
---|
11 | |
---|
12 | #include <stdint.h> |
---|
13 | #include <rtems/system.h> |
---|
14 | |
---|
15 | typedef struct { |
---|
16 | uint16_t sbLow; |
---|
17 | uint16_t sbHigh; /* push/pop sb */ |
---|
18 | uint16_t flg; /* push/pop flg */ |
---|
19 | uint32_t a1; /* pushm */ |
---|
20 | uint32_t a0; |
---|
21 | uint32_t r0r2; |
---|
22 | uint32_t r1r3; |
---|
23 | uint16_t frameLow; /* exitd */ |
---|
24 | uint16_t frameHigh; |
---|
25 | uint16_t startLow; |
---|
26 | uint16_t startHigh; |
---|
27 | uint16_t zero; |
---|
28 | } Starting_Frame; |
---|
29 | |
---|
30 | #define _get_sb( _sb ) \ |
---|
31 | asm volatile( "stc sb, %0" : "=r" (_sb)) |
---|
32 | |
---|
33 | void _CPU_Context_Initialize( |
---|
34 | Context_Control *the_context, |
---|
35 | uint32_t *stack_base, |
---|
36 | size_t size, |
---|
37 | uint32_t new_level, |
---|
38 | void *entry_point, |
---|
39 | bool is_fp |
---|
40 | ) |
---|
41 | { |
---|
42 | void *stackEnd = stack_base; |
---|
43 | register uint32_t sb; |
---|
44 | Starting_Frame *frame; |
---|
45 | |
---|
46 | _get_sb( sb ); |
---|
47 | stackEnd += size; |
---|
48 | |
---|
49 | frame = (Starting_Frame *)stackEnd; |
---|
50 | frame--; |
---|
51 | |
---|
52 | frame->zero = 0; |
---|
53 | frame->sbLow = ((uint32_t)sb) & 0xffff; |
---|
54 | frame->sbHigh = ((uint32_t)sb >> 16) & 0xffff; |
---|
55 | frame->flg = 0x80; /* User stack */ |
---|
56 | if ( !new_level ) /* interrupt level 0 --> enabled */ |
---|
57 | frame->flg |= 0x40; |
---|
58 | frame->a0 = 0x01020304; |
---|
59 | frame->a1 =0xa1a2a3a4; |
---|
60 | frame->r0r2 = 0; |
---|
61 | frame->r1r3 = 0; |
---|
62 | frame->frameLow = ((uint32_t)frame) & 0xffff; |
---|
63 | frame->frameHigh = ((uint32_t)frame >> 16) & 0xffff; |
---|
64 | frame->startLow = ((uint32_t)entry_point) & 0xffff; |
---|
65 | frame->startHigh = ((uint32_t)entry_point >> 16) & 0xffff; |
---|
66 | |
---|
67 | the_context->sp = (uint32_t)frame; |
---|
68 | the_context->fb = (uint32_t)&frame->frameLow; |
---|
69 | } |
---|
Note: See
TracBrowser
for help on using the repository browser.