source: rtems/c/src/exec/score/cpu/mips/cpu.c @ 32f415d

4.104.114.84.95
Last change on this file since 32f415d was 32f415d, checked in by Joel Sherrill <joel.sherrill@…>, on 12/13/00 at 18:09:48

2000-12-13 Joel Sherrill <joel@…>

  • cpu_asm.h: Removed.
  • Makefile.am: Remove cpu_asm.h.
  • rtems/score/mips64orion.h: Renamed mips.h.
  • rtems/score/mips.h: New file, formerly mips64orion.h. Header rewritten. (mips_get_sr, mips_set_sr, mips_enable_in_interrupt_mask, mips_disable_in_interrupt_mask): New macros.
  • rtems/score/Makefile.am: Reflect renaming mips64orion.h.
  • asm.h: Include <mips.h> not <mips64orion.h>. Now includes the few defines that were in <cpu_asm.h>.
  • cpu.c (_CPU_ISR_Get_level): Added MIPS ISA I version of this routine. MIPS ISA 3 is still in assembly for now. (_CPU_Thread_Idle_body): Rewrote in C.
  • cpu_asm.S: Rewrote file header. (FRAME,ENDFRAME) now in asm.h. (_CPU_ISR_Get_level): Removed ISA I version and rewrote in C. (_CPU_ISR_Set_level): Removed ISA I version and rewrote in C. (_CPU_Context_switch): MIPS ISA I now manages preserves SR_IEC and leaves other bits in SR alone on task switch. (mips_enable_interrupts,mips_disable_interrupts, mips_enable_global_interrupts,mips_disable_global_interrupts, disable_int, enable_int): Removed. (mips_get_sr): Rewritten as C macro. (_CPU_Thread_Idle_body): Rewritten in C. (init_exc_vecs): Rewritten in C as mips_install_isr_entries() and placed in libcpu. (exc_tlb_code, exc_xtlb_code, exc_cache_code, exc_norm_code): Moved to libcpu/mips/shared/interrupts. (general): Cleaned up comment blocks and #if 0 areas.
  • idtcpu.h: Made ifdef report an error.
  • iregdef.h: Removed warning.
  • rtems/score/cpu.h (CPU_INTERRUPT_NUMBER_OF_VECTORS): Now a variable number defined by libcpu. (_CPU_ISR_Disable, _CPU_ISR_Enable): Rewritten to use new routines to access SR. (_CPU_ISR_Set_level): Rewritten as macro for ISA I. (_CPU_Context_Initialize): Honor ISR level in task initialization. (_CPU_Fatal_halt): Use new _CPU_ISR_Disable() macro.
  • Property mode set to 100644
File size: 5.7 KB
Line 
1/*
2 *  Mips CPU Dependent Source
3 *
4 *  Conversion to MIPS port by Alan Cudmore <alanc@linuxstart.com> and
5 *           Joel Sherrill <joel@OARcorp.com>.
6 *
7 *  Original MIP64ORION port by Craig Lebakken <craigl@transition.com>
8 *           COPYRIGHT (c) 1996 by Transition Networks Inc.
9 *
10 *         To anyone who acknowledges that this file is provided "AS IS"
11 *         without any express or implied warranty:
12 *             permission to use, copy, modify, and distribute this file
13 *             for any purpose is hereby granted without fee, provided that
14 *             the above copyright notice and this notice appears in all
15 *             copies, and that the name of Transition Networks not be used in
16 *             advertising or publicity pertaining to distribution of the
17 *             software without specific, written prior permission.
18 *             Transition Networks makes no representations about the
19 *             suitability of this software for any purpose.
20 *
21 *  Derived from c/src/exec/score/cpu/no_cpu/cpu.c:
22 *
23 *  COPYRIGHT (c) 1989-1999.
24 *  On-Line Applications Research Corporation (OAR).
25 *
26 *  The license and distribution terms for this file may be
27 *  found in the file LICENSE in this distribution or at
28 *  http://www.OARcorp.com/rtems/license.html.
29 *
30 *  $Id$
31 */
32
33/*
34 *  Rather than deleting this, it is commented out to (hopefully) help
35 *  the submitter send updates.
36 *
37 * static char _sccsid[] = "@(#)cpu.c 08/20/96     1.5\n";
38 */
39
40#include <rtems/system.h>
41#include <rtems/score/isr.h>
42#include <rtems/score/wkspace.h>
43
44
45ISR_Handler_entry _ISR_Vector_table[ ISR_NUMBER_OF_VECTORS ];
46
47/*  _CPU_Initialize
48 *
49 *  This routine performs processor dependent initialization.
50 *
51 *  INPUT PARAMETERS:
52 *    cpu_table       - CPU table to initialize
53 *    thread_dispatch - address of disptaching routine
54 */
55
56
57void null_handler( void )
58{
59}
60
61
62void _CPU_Initialize(
63  rtems_cpu_table  *cpu_table,
64  void      (*thread_dispatch)      /* ignored on this CPU */
65)
66{
67   unsigned int i = ISR_NUMBER_OF_VECTORS;
68
69   while ( i-- ) {
70      _ISR_Vector_table[i] = (ISR_Handler_entry)null_handler;
71   }
72
73  /*
74   *  The thread_dispatch argument is the address of the entry point
75   *  for the routine called at the end of an ISR once it has been
76   *  decided a context switch is necessary.  On some compilation
77   *  systems it is difficult to call a high-level language routine
78   *  from assembly.  This allows us to trick these systems.
79   *
80   *  If you encounter this problem save the entry point in a CPU
81   *  dependent variable.
82   */
83
84  _CPU_Thread_dispatch_pointer = thread_dispatch;
85
86  /*
87   *  If there is not an easy way to initialize the FP context
88   *  during Context_Initialize, then it is usually easier to
89   *  save an "uninitialized" FP context here and copy it to
90   *  the task's during Context_Initialize.
91   */
92
93  /* FP context initialization support goes here */
94
95  _CPU_Table = *cpu_table;
96
97}
98
99/*PAGE
100 *
101 *  _CPU_ISR_Get_level
102 *
103 *  This routine returns the current interrupt level.
104 */
105   
106#if __mips == 3
107
108/* in cpu_asm.S for now */
109
110#elif __mips == 1
111unsigned32 _CPU_ISR_Get_level( void )
112{
113  unsigned int sr;
114
115  mips_get_sr(sr);
116
117  return ((sr & SR_IEC) ? 0 : 1);
118}
119#else
120#error "CPU ISR level: unknown MIPS level for SR handling"
121#endif
122
123/*PAGE
124 *
125 *  _CPU_ISR_install_raw_handler
126 */
127 
128void _CPU_ISR_install_raw_handler(
129  unsigned32  vector,
130  proc_ptr    new_handler,
131  proc_ptr   *old_handler
132)
133{
134  /*
135   *  This is where we install the interrupt handler into the "raw" interrupt
136   *  table used by the CPU to dispatch interrupt handlers.
137   */
138/* Q: This will become necessary for Non IDT/Sim use...*/
139#if 0 /* not necessary */
140/* use IDT/Sim to set interrupt vector.  Needed to co-exist with debugger. */
141   add_ext_int_func( vector, new_handler );
142#endif
143}
144
145/*PAGE
146 *
147 *  _CPU_ISR_install_vector
148 *
149 *  This kernel routine installs the RTEMS handler for the
150 *  specified vector.
151 *
152 *  Input parameters:
153 *    vector      - interrupt vector number
154 *    old_handler - former ISR for this vector number
155 *    new_handler - replacement ISR for this vector number
156 *
157 *  Output parameters:  NONE
158 *
159 */
160
161void _CPU_ISR_install_vector(
162  unsigned32  vector,
163  proc_ptr    new_handler,
164  proc_ptr   *old_handler
165)
166{
167   *old_handler = _ISR_Vector_table[ vector ];
168
169   /*
170    *  If the interrupt vector table is a table of pointer to isr entry
171    *  points, then we need to install the appropriate RTEMS interrupt
172    *  handler for this vector number.
173    */
174
175   _CPU_ISR_install_raw_handler( vector, _ISR_Handler, old_handler );
176
177   /*
178    *  We put the actual user ISR address in '_ISR_vector_table'.  This will
179    *  be used by the _ISR_Handler so the user gets control.
180    */
181
182    _ISR_Vector_table[ vector ] = new_handler;
183}
184
185/*PAGE
186 *
187 *  _CPU_Install_interrupt_stack
188 */
189
190void _CPU_Install_interrupt_stack( void )
191{
192/* we don't support this yet */
193}
194
195/*PAGE
196 *
197 *  _CPU_Internal_threads_Idle_thread_body
198 *
199 *  NOTES:
200 *
201 *  1. This is the same as the regular CPU independent algorithm.
202 *
203 *  2. If you implement this using a "halt", "idle", or "shutdown"
204 *     instruction, then don't forget to put it in an infinite loop.
205 *
206 *  3. Be warned. Some processors with onboard DMA have been known
207 *     to stop the DMA if the CPU were put in IDLE mode.  This might
208 *     also be a problem with other on-chip peripherals.  So use this
209 *     hook with caution.
210 */
211
212void _CPU_Thread_Idle_body( void )
213{
214#if __mips == 3
215   for( ; ; )
216     asm volatile("wait"); /* use wait to enter low power mode */
217#elif __mips == 1
218   for( ; ; )
219     ;
220#else
221#error "IDLE: __mips not set to 1 or 3"
222#endif
223}
224
225extern void mips_break( int error );
226
227#include <stdio.h>
228
229void mips_fatal_error( int error )
230{
231   printf("fatal error 0x%x %d\n",error,error);
232   mips_break( error );
233}
Note: See TracBrowser for help on using the repository browser.