source: rtems/cpukit/score/cpu/nios2/cpu.c @ 3c87adba

4.104.114.95
Last change on this file since 3c87adba was 3c87adba, checked in by Joel Sherrill <joel.sherrill@…>, on 07/31/08 at 14:55:56

2008-07-31 Joel Sherrill <joel.sherrill@…>

  • cpu.c, rtems/score/cpu.h: Correct prototype of Idle threads.
  • Property mode set to 100644
File size: 4.3 KB
Line 
1/*
2 *  NIOS2 CPU Dependent Source
3 *
4 *  COPYRIGHT (c) 1989-2006
5 *  On-Line Applications Research Corporation (OAR).
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
18/*  _CPU_Initialize
19 *
20 *  This routine performs processor dependent initialization.
21 *
22 *  INPUT PARAMETERS:
23 *    thread_dispatch - address of disptaching routine
24 *
25 *  NO_CPU Specific Information:
26 *
27 *  XXX document implementation including references if appropriate
28 */
29
30
31void _CPU_Initialize(
32  void      (*thread_dispatch)      /* ignored on this CPU */
33)
34{
35  /*
36   *  The thread_dispatch argument is the address of the entry point
37   *  for the routine called at the end of an ISR once it has been
38   *  decided a context switch is necessary.  On some compilation
39   *  systems it is difficult to call a high-level language routine
40   *  from assembly.  This allows us to trick these systems.
41   *
42   *  If you encounter this problem save the entry point in a CPU
43   *  dependent variable.
44   */
45
46  _CPU_Thread_dispatch_pointer = thread_dispatch;
47
48  /*
49   *  If there is not an easy way to initialize the FP context
50   *  during Context_Initialize, then it is usually easier to
51   *  save an "uninitialized" FP context here and copy it to
52   *  the task's during Context_Initialize.
53   */
54
55  /* FP context initialization support goes here */
56}
57
58/*PAGE
59 *
60 *  _CPU_ISR_Get_level
61 *
62 *  NO_CPU Specific Information:
63 *
64 *  XXX document implementation including references if appropriate
65 */
66 
67uint32_t   _CPU_ISR_Get_level( void )
68{
69  /*
70   *  This routine returns the current interrupt level.
71   */
72
73  return 0;
74}
75
76/*PAGE
77 *
78 *  _CPU_ISR_install_raw_handler
79 *
80 *  NO_CPU Specific Information:
81 *
82 *  XXX document implementation including references if appropriate
83 */
84 
85void _CPU_ISR_install_raw_handler(
86  uint32_t    vector,
87  proc_ptr    new_handler,
88  proc_ptr   *old_handler
89)
90{
91  /*
92   *  This is where we install the interrupt handler into the "raw" interrupt
93   *  table used by the CPU to dispatch interrupt handlers.
94   */
95}
96
97/*PAGE
98 *
99 *  _CPU_ISR_install_vector
100 *
101 *  This kernel routine installs the RTEMS handler for the
102 *  specified vector.
103 *
104 *  Input parameters:
105 *    vector      - interrupt vector number
106 *    old_handler - former ISR for this vector number
107 *    new_handler - replacement ISR for this vector number
108 *
109 *  Output parameters:  NONE
110 *
111 *
112 *  NO_CPU Specific Information:
113 *
114 *  XXX document implementation including references if appropriate
115 */
116
117void _CPU_ISR_install_vector(
118  uint32_t    vector,
119  proc_ptr    new_handler,
120  proc_ptr   *old_handler
121)
122{
123   *old_handler = _ISR_Vector_table[ vector ];
124
125   /*
126    *  If the interrupt vector table is a table of pointer to isr entry
127    *  points, then we need to install the appropriate RTEMS interrupt
128    *  handler for this vector number.
129    */
130
131   _CPU_ISR_install_raw_handler( vector, new_handler, old_handler );
132
133   /*
134    *  We put the actual user ISR address in '_ISR_vector_table'.  This will
135    *  be used by the _ISR_Handler so the user gets control.
136    */
137
138    _ISR_Vector_table[ vector ] = new_handler;
139}
140
141/*PAGE
142 *
143 *  _CPU_Install_interrupt_stack
144 *
145 *  NO_CPU Specific Information:
146 *
147 *  XXX document implementation including references if appropriate
148 */
149
150void _CPU_Install_interrupt_stack( void )
151{
152}
153
154/*PAGE
155 *
156 *  _CPU_Thread_Idle_body
157 *
158 *  NOTES:
159 *
160 *  1. This is the same as the regular CPU independent algorithm.
161 *
162 *  2. If you implement this using a "halt", "idle", or "shutdown"
163 *     instruction, then don't forget to put it in an infinite loop.
164 *
165 *  3. Be warned. Some processors with onboard DMA have been known
166 *     to stop the DMA if the CPU were put in IDLE mode.  This might
167 *     also be a problem with other on-chip peripherals.  So use this
168 *     hook with caution.
169 *
170 *  NO_CPU Specific Information:
171 *
172 *  XXX document implementation including references if appropriate
173 */
174
175void *_CPU_Thread_Idle_body( uint32_t ignored )
176{
177#if 1
178  for(;;);
179#else
180  for(;;)
181  {
182    uint32_t st = __builtin_rdctl(0); /* read status  register */
183
184    /* Differentiate between IRQ off and on (for debugging) */
185    if(st & 1)
186      for(;;);
187    else
188      for(;;);
189 
190    /* insert your "halt" instruction here */ ;
191  }
192#endif
193}
Note: See TracBrowser for help on using the repository browser.