source: rtems/cpukit/score/cpu/bfin/cpu.c @ 9165349d

Last change on this file since 9165349d was 3fe2155, checked in by Sebastian Huber <sebastian.huber@…>, on 02/01/19 at 09:00:36

Remove superfluous <rtems/system.h> includes

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