source: rtems/cpukit/score/cpu/m32c/context_init.c @ c9f5531

4.104.11
Last change on this file since c9f5531 was c9f5531, checked in by Joel Sherrill <joel.sherrill@…>, on Mar 27, 2010 at 3:01:57 PM

2010-03-27 Joel Sherrill <joel.sherrill@…>

  • context_init.c, context_switch.S, cpu.c, cpu_asm.c, varvects.S: Add include of config.h
  • Property mode set to 100644
File size: 1.8 KB
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#ifdef HAVE_CONFIG_H
13#include "config.h"
14#endif
15
16#include <stdint.h>
17#include <rtems/system.h>
18
19typedef struct {
20  uint16_t sbLow;
21  uint16_t sbHigh;       /* push/pop sb */
22  uint16_t flg;          /* push/pop flg */
23  uint32_t a1;           /* pushm */
24  uint32_t a0;
25  uint32_t r0r2;
26  uint32_t r1r3;
27  uint16_t frameLow;     /* exitd */
28  uint16_t frameHigh;
29  uint16_t startLow;
30  uint16_t startHigh;
31  uint16_t zero;
32} Starting_Frame;
33
34#define _get_sb( _sb ) \
35  asm volatile( "stc sb, %0" : "=r" (_sb))
36
37void _CPU_Context_Initialize(
38  Context_Control  *the_context,
39  uint32_t         *stack_base,
40  size_t            size,
41  uint32_t          new_level,
42  void             *entry_point,
43  bool              is_fp
44)
45{
46  void *stackEnd = stack_base;
47  register uint32_t sb;
48  Starting_Frame *frame;
49
50  _get_sb( sb );
51  stackEnd += size;
52
53  frame = (Starting_Frame *)stackEnd;
54  frame--;
55
56  frame->zero = 0;
57  frame->sbLow = ((uint32_t)sb) & 0xffff;
58  frame->sbHigh = ((uint32_t)sb >> 16) & 0xffff;
59  frame->flg = 0x80;        /* User stack */
60  if ( !new_level )         /* interrupt level 0 --> enabled */
61    frame->flg |= 0x40;
62  frame->a0 = 0x01020304;
63  frame->a1 =0xa1a2a3a4;
64  frame->r0r2 = 0;
65  frame->r1r3 = 0;
66  frame->frameLow = ((uint32_t)frame)  & 0xffff;
67  frame->frameHigh = ((uint32_t)frame >> 16) & 0xffff;
68  frame->startLow = ((uint32_t)entry_point) & 0xffff;
69  frame->startHigh = ((uint32_t)entry_point >> 16) & 0xffff;
70
71  the_context->sp = (uint32_t)frame;
72  the_context->fb = (uint32_t)&frame->frameLow;
73}
Note: See TracBrowser for help on using the repository browser.