source: rtems/cpukit/score/cpu/bfin/cpu.c @ ff8f05b

4.104.115
Last change on this file since ff8f05b was cca8379, checked in by Joel Sherrill <joel.sherrill@…>, on 02/12/09 at 15:55:55

2009-02-12 Joel Sherrill <joel.sherrill@…>

  • cpu.c, rtems/score/cpu.h: Change prototype of IDLE thread to consistently return void * and take a uintptr_t argument.
  • Property mode set to 100644
File size: 4.8 KB
Line 
1/*  Blackfin CPU Dependent Source
2 *
3 *  COPYRIGHT (c) 2006 by Atos Automacao Industrial Ltda.
4 *             written by Alain Schaefer <alain.schaefer@easc.ch>
5 *                    and Antonio Giovanini <antonio@atos.com.br>
6 *
7 *  The license and distribution terms for this file may be
8 *  found in the file LICENSE in this distribution or at
9 *  http://www.rtems.com/license/LICENSE.
10 *
11 *  $Id$
12 */
13
14#include <rtems/system.h>
15#include <rtems/score/isr.h>
16#include <rtems/score/wkspace.h>
17#include <rtems/score/bfin.h>
18#include <rtems/bfin/bfin.h>
19
20/*  _CPU_Initialize
21 *
22 *  This routine performs processor dependent initialization.
23 *
24 *  INPUT PARAMETERS: NONE
25 *
26 *  NO_CPU Specific Information:
27 *
28 *  XXX document implementation including references if appropriate
29 */
30
31
32extern void _ISR15_Handler(void);
33extern void _CPU_Emulation_handler(void);
34extern void _CPU_Reset_handler(void);
35extern void _CPU_NMI_handler(void);
36extern void _CPU_Exception_handler(void);
37extern void _CPU_Unhandled_Interrupt_handler(void);
38
39void _CPU_Initialize(void)
40{
41  /*
42   *  If there is not an easy way to initialize the FP context
43   *  during Context_Initialize, then it is usually easier to
44   *  save an "uninitialized" FP context here and copy it to
45   *  the task's during Context_Initialize.
46   */
47
48  /* FP context initialization support goes here */
49
50
51
52  proc_ptr ignored;
53
54#if 0
55  /* occassionally useful debug stuff */
56  int i;
57  _CPU_ISR_install_raw_handler(0, _CPU_Emulation_handler, &ignored);
58  _CPU_ISR_install_raw_handler(1, _CPU_Reset_handler, &ignored);
59  _CPU_ISR_install_raw_handler(2, _CPU_NMI_handler, &ignored);
60  _CPU_ISR_install_raw_handler(3, _CPU_Exception_handler, &ignored);
61  for (i = 5; i < 15; i++)
62    _CPU_ISR_install_raw_handler(i, _CPU_Unhandled_Interrupt_handler, &ignored);
63#endif
64
65  /* install handler that will be used to call _Thread_Dispatch */
66  _CPU_ISR_install_raw_handler( 15, _ISR15_Handler, &ignored );
67  /* enable self nesting */
68  __asm__ __volatile__ ("syscfg = %0" : : "d" (0x00000004));
69}
70
71
72
73
74/*PAGE
75 *
76 *  _CPU_ISR_Get_level
77 *
78 *  NO_CPU Specific Information:
79 *
80 *  XXX document implementation including references if appropriate
81 */
82
83uint32_t   _CPU_ISR_Get_level( void )
84{
85  /*
86   *  This routine returns the current interrupt level.
87   */
88
89    register uint32_t   _tmpimask;
90
91    /*read from the IMASK registers*/
92
93    _tmpimask = *((uint32_t*)IMASK);
94
95    return (_tmpimask & 0xffe0) ? 0 : 1;
96}
97
98/*PAGE
99 *
100 *  _CPU_ISR_install_raw_handler
101 *
102 *  NO_CPU Specific Information:
103 *
104 *  XXX document implementation including references if appropriate
105 */
106
107void _CPU_ISR_install_raw_handler(
108  uint32_t    vector,
109  proc_ptr    new_handler,
110  proc_ptr   *old_handler
111)
112{
113   proc_ptr *interrupt_table = NULL;
114  /*
115   *  This is where we install the interrupt handler into the "raw" interrupt
116   *  table used by the CPU to dispatch interrupt handlers.
117   */
118
119   /* base of vector table on blackfin architecture */
120   interrupt_table = (void*)0xFFE02000;
121
122   *old_handler = interrupt_table[ vector ];
123   interrupt_table[ vector ] = new_handler;
124
125}
126
127/*PAGE
128 *
129 *  _CPU_ISR_install_vector
130 *
131 *  This kernel routine installs the RTEMS handler for the
132 *  specified vector.
133 *
134 *  Input parameters:
135 *    vector      - interrupt vector number
136 *    old_handler - former ISR for this vector number
137 *    new_handler - replacement ISR for this vector number
138 *
139 *  Output parameters:  NONE
140 *
141 *
142 *  NO_CPU Specific Information:
143 *
144 *  XXX document implementation including references if appropriate
145 */
146
147void _CPU_ISR_install_vector(
148  uint32_t    vector,
149  proc_ptr    new_handler,
150  proc_ptr   *old_handler
151)
152{
153   proc_ptr ignored;
154
155   *old_handler = _ISR_Vector_table[ vector ];
156
157   /*
158    *  We put the actual user ISR address in '_ISR_vector_table'.  This will
159    *  be used by the _ISR_Handler so the user gets control.
160    */
161
162    _ISR_Vector_table[ vector ] = new_handler;
163
164    _CPU_ISR_install_raw_handler( vector, _ISR_Handler, &ignored );
165}
166
167#if (CPU_PROVIDES_IDLE_THREAD_BODY == TRUE)
168void *_CPU_Thread_Idle_body(uint32_t ignored)
169{
170  while (1) {
171    __asm__ __volatile__("ssync; idle; ssync");
172  }
173}
174#endif
175
176/*
177 * Copied from the arm port.
178 */
179void _CPU_Context_Initialize(
180  Context_Control  *the_context,
181  uint32_t         *stack_base,
182  uint32_t          size,
183  uint32_t          new_level,
184  void             *entry_point,
185  bool              is_fp
186)
187{
188    uint32_t     stack_high;  /* highest "stack aligned" address */
189    stack_high = ((uint32_t)(stack_base) + size);
190
191    the_context->register_sp = stack_high;
192    the_context->register_rets = (uint32_t) entry_point;
193    the_context->imask = new_level ? 0 : 0xffff;
194}
195
196
197
198/*PAGE
199 *
200 *  _CPU_Install_interrupt_stack
201 *
202 *  NO_CPU Specific Information:
203 *
204 *  XXX document implementation including references if appropriate
205 */
206
207void _CPU_Install_interrupt_stack( void )
208{
209}
Note: See TracBrowser for help on using the repository browser.