source: rtems/cpukit/score/cpu/c4x/cpu.c @ 8bbead13

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

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

  • cpu.c: Change prototype of IDLE thread to consistently return void * and take a uintptr_t argument.
  • Property mode set to 100644
File size: 3.9 KB
Line 
1/*
2 *  C4x CPU Dependent Source
3 *
4 *
5 *  COPYRIGHT (c) 1989-1999.
6 *  On-Line Applications Research Corporation (OAR).
7 *
8 *  The license and distribution terms for this file may be
9 *  found in the file LICENSE in this distribution or at
10 *  http://www.rtems.com/license/LICENSE.
11 *
12 *  $Id$
13 */
14
15#include <rtems/system.h>
16#include <rtems/score/isr.h>
17#include <rtems/score/wkspace.h>
18
19
20/*  _CPU_Initialize
21 *
22 *  This routine performs processor dependent initialization.
23 *
24 *  INPUT PARAMETERS: NONE
25 *
26 *  C4x Specific Information:
27 *
28 */
29
30void _CPU_Initialize(void)
31{
32#if (CPU_HARDWARE_FP == TRUE)
33  /*
34   *  If there is not an easy way to initialize the FP context
35   *  during Context_Initialize, then it is usually easier to
36   *  save an "uninitialized" FP context here and copy it to
37   *  the task's during Context_Initialize.
38   */
39
40  /* FP context initialization support goes here */
41#endif
42}
43
44/*PAGE
45 *
46 *  _CPU_ISR_install_raw_handler
47 *
48 *  C4x Specific Information:
49 *
50 */
51 
52void _CPU_ISR_install_raw_handler(
53  uint32_t    vector,
54  proc_ptr    new_handler,
55  proc_ptr   *old_handler
56)
57{
58  void       **ittp;
59
60  /*
61   *  This is where we install the interrupt handler into the "raw" interrupt
62   *  table used by the CPU to dispatch interrupt handlers.
63   */
64   
65  ittp = c4x_get_ittp();
66  *old_handler = ittp[ vector ];
67  ittp[ vector ] = new_handler;
68}
69
70/*XXX */
71
72#define C4X_CACHE       1
73#define C4X_BASE_ST     (C4X_CACHE==1) ? 0x4800 : 0x4000
74
75void _CPU_Context_Initialize(
76  Context_Control       *_the_context,
77  void                  *_stack_base,
78  uint32_t              _size,
79  uint32_t              _isr,
80  void  (*_entry_point)(void),
81  int                   _is_fp
82)
83{
84  unsigned int *_stack;
85  _stack = (unsigned int *)_stack_base;
86
87  *_stack = (unsigned int) _entry_point;
88  _the_context->sp = (unsigned int) _stack;
89  _the_context->st = C4X_BASE_ST;
90  if ( _isr == 0 )
91    _the_context->st |= C4X_ST_GIE;
92}
93
94/*PAGE
95 *
96 *  _CPU_ISR_install_vector
97 *
98 *  This kernel routine installs the RTEMS handler for the
99 *  specified vector.
100 *
101 *  Input parameters:
102 *    vector      - interrupt vector number
103 *    old_handler - former ISR for this vector number
104 *    new_handler - replacement ISR for this vector number
105 *
106 *  Output parameters:  NONE
107 *
108 *
109 *  C4x Specific Information:
110 *
111 */
112
113void _CPU_ISR_install_vector(
114  uint32_t    vector,
115  proc_ptr    new_handler,
116  proc_ptr   *old_handler
117)
118{
119  proc_ptr ignored;
120  extern void rtems_irq_prologue_0(void);
121  extern void rtems_irq_prologue_1(void);
122  void *entry;
123
124  *old_handler = _ISR_Vector_table[ vector ];
125
126  /*
127   *  If the interrupt vector table is a table of pointer to isr entry
128   *  points, then we need to install the appropriate RTEMS interrupt
129   *  handler for this vector number.
130   */
131
132  entry = (void *)rtems_irq_prologue_0 +
133    ((rtems_irq_prologue_1 - rtems_irq_prologue_0) * vector);
134  _CPU_ISR_install_raw_handler( vector, entry, &ignored );
135
136  /*
137   *  We put the actual user ISR address in '_ISR_vector_table'.  This will
138   *  be used by the _ISR_Handler so the user gets control.
139   */
140
141   _ISR_Vector_table[ vector ] = new_handler;
142}
143
144/*PAGE
145 *
146 *  _CPU_Thread_Idle_body
147 *
148 *  NOTES:
149 *
150 *  1. This is the same as the regular CPU independent algorithm.
151 *
152 *  2. If you implement this using a "halt", "idle", or "shutdown"
153 *     instruction, then don't forget to put it in an infinite loop.
154 *
155 *  3. Be warned. Some processors with onboard DMA have been known
156 *     to stop the DMA if the CPU were put in IDLE mode.  This might
157 *     also be a problem with other on-chip peripherals.  So use this
158 *     hook with caution.
159 *
160 *  C4x Specific Information:
161 *
162 *
163 */
164
165#if (CPU_PROVIDES_IDLE_THREAD_BODY == 1)
166void *_CPU_Thread_Idle_body( uintptr_t ignored )
167{
168
169  for( ; ; ) {
170    __asm__( "idle" );
171    __asm__( "nop" );
172    __asm__( "nop" );
173    __asm__( "nop" );
174    /* insert your "halt" instruction here */ ;
175  }
176}
177#endif
Note: See TracBrowser for help on using the repository browser.