source: rtems/cpukit/score/cpu/v850/cpu.c @ 2afb22b

5
Last change on this file since 2afb22b was c499856, checked in by Chris Johns <chrisj@…>, on Mar 20, 2014 at 9:10:47 PM

Change all references of rtems.com to rtems.org.

  • Property mode set to 100644
File size: 2.3 KB
Line 
1/**
2 * @file
3 *
4 * @brief v850 CPU Initialize
5 */
6
7/*
8 *  COPYRIGHT (c) 1989-2012.
9 *  On-Line Applications Research Corporation (OAR).
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#ifdef HAVE_CONFIG_H
17#include "config.h"
18#endif
19
20#include <rtems/system.h>
21#include <rtems/score/isr.h>
22#include <rtems/score/wkspace.h>
23
24#include <string.h> /* for memset */
25
26/*
27 *  v850 Specific Information:
28 *
29 *  So far nothing known to be needed at this point during initialization.
30 */
31void _CPU_Initialize(void)
32{
33}
34
35/*
36 *  v850 Specific Information:
37 *
38 *  This method returns 0 if interrupts are enabled and 1 if they are disabled.
39 *  The v850 only has two interrupt levels (on and off).
40 */
41uint32_t _CPU_ISR_Get_level( void )
42{
43  unsigned int psw;
44
45  v850_get_psw( psw );
46
47  if ( (psw & V850_PSW_INTERRUPT_DISABLE_MASK) == V850_PSW_INTERRUPT_DISABLE )
48    return 1;
49
50  return 0;
51}
52
53/*
54 *  v850 Specific Information:
55 *
56 *  This method initializes a v850 context control structure.
57 */
58void _CPU_Context_Initialize(
59  Context_Control  *the_context,
60  uint32_t         *stack_base,
61  uint32_t          size,
62  uint32_t          new_level,
63  void             *entry_point,
64  bool              is_fp,
65  void             *tls_area
66)
67{
68  uint32_t  stack_high;  /* highest "stack aligned" address */
69  uint32_t  psw;         /* highest "stack aligned" address */
70
71  memset( the_context, 0, sizeof(Context_Control) );
72
73  /*
74   *  On CPUs with stacks which grow down, we build the stack
75   *  based on the stack_high address.
76   */
77  stack_high = ((uint32_t)(stack_base) + size);
78  stack_high &= ~(CPU_STACK_ALIGNMENT - 1);
79
80  v850_get_psw( psw );
81  psw &= ~V850_PSW_INTERRUPT_DISABLE_MASK;
82  if ( new_level )
83    psw |= V850_PSW_INTERRUPT_DISABLE;
84  else
85    psw |= V850_PSW_INTERRUPT_ENABLE;
86
87  the_context->r31              = (uint32_t) entry_point;
88  the_context->r3_stack_pointer = stack_high;
89  the_context->psw              = psw;
90
91#if 0
92  printk( "the_context = %p\n",      the_context );
93  printk( "stack base  = 0x%08x\n",  stack_base );
94  printk( "stack size  = 0x%08x\n",  size );
95  printk( "sp          = 0x%08x\n",  the_context->r3_stack_pointer );
96  printk( "psw         = 0x%08x\n",  the_context->psw );
97#endif
98}
99
Note: See TracBrowser for help on using the repository browser.