source: rtems/c/src/exec/score/cpu/arm/cpu.c @ d56918c9

4.104.114.84.95
Last change on this file since d56918c9 was d56918c9, checked in by Joel Sherrill <joel.sherrill@…>, on Jan 6, 2002 at 8:05:09 PM

2002-01-03 Ralf Corsepius <corsepiu@…>

  • cpu.c: Include rtems/bspIo.h instead of bspIo.h.
  • Property mode set to 100644
File size: 4.7 KB
Line 
1/*
2 *  ARM CPU Dependent Source
3 *
4 *
5 *  COPYRIGHT (c) 2000 Canon Research Centre France SA.
6 *  Emmanuel Raguet, mailto:raguet@crf.canon.fr
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.OARcorp.com/rtems/license.html.
11 *
12 */
13
14#include <rtems/system.h>
15#include <rtems.h>
16#include <rtems/bspIo.h>
17#include <rtems/score/isr.h>
18#include <rtems/score/wkspace.h>
19#include <rtems/score/thread.h>
20#include <rtems/score/cpu.h>
21
22/*  _CPU_Initialize
23 *
24 *  This routine performs processor dependent initialization.
25 *
26 *  INPUT PARAMETERS:
27 *    cpu_table       - CPU table to initialize
28 *    thread_dispatch - address of disptaching routine
29 */
30
31
32void _CPU_Initialize(
33  rtems_cpu_table  *cpu_table,
34  void      (*thread_dispatch)      /* ignored on this CPU */
35)
36{
37  _CPU_Table = *cpu_table;
38}
39
40/*PAGE
41 *
42 *  _CPU_ISR_Get_level
43 */
44 
45unsigned32 _CPU_ISR_Get_level( void )
46{
47  /*
48   *  This routine returns the current interrupt level.
49   */
50
51  return 0;
52}
53
54/*
55 *  _CPU_ISR_install_vector
56 *
57 *  This kernel routine installs the RTEMS handler for the
58 *  specified vector.
59 *
60 *  Input parameters:
61 *    vector      - interrupt vector number
62 *    old_handler - former ISR for this vector number
63 *    new_handler - replacement ISR for this vector number
64 *
65 *  Output parameters:  NONE
66 *
67 */
68
69void _CPU_ISR_install_vector(
70  unsigned32  vector,
71  proc_ptr    new_handler,
72  proc_ptr   *old_handler
73)
74{
75  /* pointer on the redirection table in RAM */
76  long *VectorTable = (long *)(MAX_EXCEPTIONS * 4); 
77
78  if (old_handler != NULL)
79    old_handler = *(proc_ptr *)(VectorTable + vector);
80  *(VectorTable + vector) = (long)new_handler ;
81 
82}
83
84/*PAGE
85 *
86 *  _CPU_Install_interrupt_stack
87 */
88
89void _CPU_Install_interrupt_stack( void )
90{
91}
92
93/*PAGE
94 *
95 *  _CPU_Thread_Idle_body
96 *
97 *  NOTES:
98 *
99 *  1. This is the same as the regular CPU independent algorithm.
100 *
101 *  2. If you implement this using a "halt", "idle", or "shutdown"
102 *     instruction, then don't forget to put it in an infinite loop.
103 *
104 *  3. Be warned. Some processors with onboard DMA have been known
105 *     to stop the DMA if the CPU were put in IDLE mode.  This might
106 *     also be a problem with other on-chip peripherals.  So use this
107 *     hook with caution.
108 */
109
110void _CPU_Thread_Idle_body( void )
111{
112
113  while(1);
114    /* insert your "halt" instruction here */ ;
115}
116
117void _defaultExcHandler (CPU_Exception_frame *ctx)
118{
119  printk("----------------------------------------------------------\n");
120  printk("Exception %d caught at PC %x by thread %d\n",
121         ctx->register_pc, ctx->register_lr - 4,
122         _Thread_Executing->Object.id);
123  printk("----------------------------------------------------------\n");
124  printk("Processor execution context at time of the fault was  :\n");
125  printk("----------------------------------------------------------\n");
126  printk(" r0 = %x     r1 = %x     r2 = %x     r3 = %x\n",
127         ctx->register_r0, ctx->register_r1, ctx->register_r2, ctx->register_r3);
128  printk(" r4 = %x     r5 = %x     r6 = %x     r7 = %x\n",
129         ctx->register_r4, ctx->register_r5, ctx->register_r6, ctx->register_r7);
130  printk(" r8 = %x     r9 = %x     r10 = %x\n",
131         ctx->register_r8, ctx->register_r9, ctx->register_r10);
132  printk(" fp = %x     ip = %x     sp = %x     pc = %x\n",
133         ctx->register_fp, ctx->register_ip, ctx->register_sp, ctx->register_lr - 4);
134  printk("----------------------------------------------------------\n");
135
136 if (_ISR_Nest_level > 0) {
137    /*
138     * In this case we shall not delete the task interrupted as
139     * it has nothing to do with the fault. We cannot return either
140     * because the eip points to the faulty instruction so...
141     */
142    printk("Exception while executing ISR!!!. System locked\n");
143    while(1);
144  }
145 else {
146   printk(" ************ FAULTY THREAD WILL BE DELETED **************\n");
147   rtems_task_delete(_Thread_Executing->Object.id);
148 }
149}
150
151cpuExcHandlerType _currentExcHandler = _defaultExcHandler;
152
153extern void _Exception_Handler_Undef_Swi(); 
154extern void _Exception_Handler_Abort(); 
155
156void rtems_exception_init_mngt()
157{
158        ISR_Level level;
159     
160      _CPU_ISR_Disable(level);
161      _CPU_ISR_install_vector(ARM_EXCEPTION_UNDEF,      _Exception_Handler_Undef_Swi, NULL); 
162      _CPU_ISR_install_vector(ARM_EXCEPTION_SWI,        _Exception_Handler_Undef_Swi, NULL); 
163      _CPU_ISR_install_vector(ARM_EXCEPTION_PREF_ABORT, _Exception_Handler_Abort    , NULL); 
164      _CPU_ISR_install_vector(ARM_EXCEPTION_DATA_ABORT, _Exception_Handler_Abort    , NULL);
165      _CPU_ISR_install_vector(ARM_EXCEPTION_FIQ,        _Exception_Handler_Abort    , NULL);
166      _CPU_ISR_install_vector(ARM_EXCEPTION_IRQ,        _Exception_Handler_Abort    , NULL);
167      _CPU_ISR_Enable(level);
168}
169 
170
Note: See TracBrowser for help on using the repository browser.