summaryrefslogtreecommitdiffstats
path: root/c/src/lib/libbsp/powerpc/score603e/startup/spurious.c
blob: 7ba0632e77291bf764f15841c591481f495c66a7 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
/*
 *  Score603e Spurious Trap Handler
 *
 *  This is just enough of a trap handler to let us know what 
 *  the likely source of the trap was.
 *
 *  Developed as part of the port of RTEMS to the ERC32 implementation 
 *  of the SPARC by On-Line Applications Research Corporation (OAR) 
 *  under contract to the European Space Agency (ESA).
 *
 *  COPYRIGHT (c) 1995. European Space Agency.
 *
 *  This terms of the RTEMS license apply to this file.
 *
 *  $Id$
 */

#include <bsp.h>

#include <string.h>

static const char digits[16] = "0123456789abcdef";

rtems_isr bsp_stub_handler(
   rtems_vector_number trap
)
{
}

/*
 *  bsp_spurious_handler
 *
 *  Print a message on the debug console and then die
 */
rtems_isr bsp_spurious_handler(
   rtems_vector_number trap
)
{

  switch ( trap ) {
    case PPC_IRQ_SYSTEM_RESET:
      DEBUG_puts( "\nTrap: System reset" );
      break;
    case PPC_IRQ_MCHECK:
      DEBUG_puts( "\nTrap: Machine check" );
      break;
    case PPC_IRQ_PROTECT:
      DEBUG_puts( "\nTrap: DSI" );
      break;
    case PPC_IRQ_ISI:
      DEBUG_puts( "ISI" );
      break;
    case PPC_IRQ_EXTERNAL:
      DEBUG_puts( "\nTrap: External interupt" );
      break;
    case PPC_IRQ_ALIGNMENT:
      DEBUG_puts( "\nTrap: Alignment Exception" );
      break;
    case PPC_IRQ_PROGRAM:
      DEBUG_puts( "\nTrap: Program" );
      break;
    case PPC_IRQ_NOFP:
      DEBUG_puts( "\nTrap: Floating point unavailable" );
      break;
    case PPC_IRQ_DECREMENTER:
      DEBUG_puts( "\nTrap: Decrementer" );
      break;
    case PPC_IRQ_RESERVED_A:
      DEBUG_puts( "\nTrap: Reserved 0x00a00" );
      break;
    case PPC_IRQ_RESERVED_B:
      DEBUG_puts( "\nTrap: Reserved 0x00b00" );
      break;
    case PPC_IRQ_SCALL:
      DEBUG_puts( "\nTrap: System call" );
      break;
    case PPC_IRQ_TRACE:
      DEBUG_puts( "\nTrap: Trace" );
      break;
    case PPC_IRQ_FP_ASST:
      DEBUG_puts( "\nTrap: Floating point Assist" );
      break;

#if defined(ppc403)
#error "Please fill in names. "                                  
    case PPC_IRQ_CRIT :
      DEBUG_puts( "\nTrap: Critical Error ");     
      break;
    case PPC_IRQ_PIT:
      DEBUG_puts( "\nTrap: 0x01000" );
      break;
    case PPC_IRQ_FIT:
      DEBUG_puts( "\nTrap: 0x01010" );
      break;
    case PPC_IRQ_WATCHDOG :
      DEBUG_puts( "\nTrap: 0x01020" );
      break;
    case PPC_IRQ_DEBUG	 :
      DEBUG_puts( "\nTrap: 0x02000" );
      break;

#elif defined(ppc601)
#error "Please fill in names. "                                  
    case PPC_IRQ_TRACE    :
      DEBUG_puts( "\nTrap: 0x02000" );
      break;

#elif defined(ppc603)
#error "Please fill in names. "                                  
    case PPC_IRQ_TRANS_MISS :
      DEBUG_puts( "\nTrap: 0x1000" );
      break;
    case PPC_IRQ_DATA_LOAD:
      DEBUG_puts( "\nTrap: 0x1100" );
      break;
    case PPC_IRQ_DATA_STORE:
      DEBUG_puts( "\nTrap: 0x1200" );
      break;
    case PPC_IRQ_ADDR_BRK:
      DEBUG_puts( "\nTrap: 0x1300" );
      break;
    case PPC_IRQ_SYS_MGT:
      DEBUG_puts( "\nTrap: 0x1400" );
      break;

#elif defined(ppc603e)
    case PPC_TLB_INST_MISS:
      DEBUG_puts( "\nTrap: Instruction Translation Miss" );
      break;
    case PPC_TLB_LOAD_MISS:
      DEBUG_puts( "\nTrap: Data Load Translation Miss" );
      break;
    case PPC_TLB_STORE_MISS :
      DEBUG_puts( "\nTrap: Data store Translation Miss");
      break;
    case PPC_IRQ_ADDRBRK:
      DEBUG_puts( "\nTrap: Instruction address break point" );
      break;
    case PPC_IRQ_SYS_MGT:
      DEBUG_puts( "\nTrap: System management interrupt" );
      break;

#elif defined(mpc604)
#error "Please fill in names. "                                  
    case PPC_IRQ_ADDR_BRK:
      DEBUG_puts( "0x1300" );
      break;
    case PPC_IRQ_SYS_MGT:
      DEBUG_puts( "0x1400" );
      break;
#endif

  default:
     DEBUG_puts( "\nTrap: Undefined exception " );
     break;
  }

  /*
   *  What else can we do but stop ...
   */
  /*
   asm volatile( "" );
   */
   while (1);
}

/*
 *  bsp_spurious_initialize
 *
 *  Install the spurious handler for most traps.
 */

void bsp_spurious_initialize()
{
  uint32_t         trap;

  for ( trap=0 ; trap < PPC_IRQ_LAST ; trap++ ) {
    if (trap == PPC_IRQ_DECREMENTER)
      ;
      /* set_vector( bsp_stub_handler, trap, 1 ); */
    else
      set_vector( bsp_spurious_handler, trap,  1 ); 
  }
}

void bsp_set_trap_vectors( void )
{
  volatile uint32_t         *ptr;

  /* reset_vector  */
  ptr = (uint32_t*)0x00100  ;
  *ptr = 0x48000000;

  /* org    mach_vector  */
  ptr = (uint32_t*)0x00200;
  *ptr = 0x48000000;

  /* org    prot_vector  */
  ptr = (uint32_t*)0x00300;
  *ptr = 0x48000000;

  /* org    isi_vector  */
  ptr = (uint32_t*)0x00400;
  *ptr = 0x48000000;

  /* org    ext_vector  */
  ptr = (uint32_t*)0x0500  ;
  *ptr = 0x48000000;

  /* org    align_vector  */
  ptr = (uint32_t*)0x00600  ;
  *ptr = 0x48000000;

  /* org    prog_vector  */
  ptr = (uint32_t*)0x00700  ;
  *ptr = 0x48000000;

  /* org    float_vector  */
  ptr = (uint32_t*)0x00800;
  *ptr = 0x48000000;

  /* org    dec_vector  - rfi */
  ptr = (uint32_t*)0x900;
  *ptr = 0x4c000064;

  /* org    sys_vector  */
  ptr = (uint32_t*)0x0c00  ;
  *ptr = 0x48000000;

  /* org    trace_vector  */
  ptr = (uint32_t*)0x0d00  ;
  *ptr = 0x48000000;

  /* org    itm_vector  */
  ptr = (uint32_t*)0x01000  ;
  *ptr = 0x48000000;

  /* org    dltm_vector  */
  ptr = (uint32_t*)0x01100  ;
  *ptr = 0x48000000;

  /* org    dstm_vector  */
  ptr = (uint32_t*)0x1200  ;
  *ptr = 0x48000000;

  /* org    addr_vector  */
  ptr = (uint32_t*)0x1300  ;
  *ptr = 0x48000000;

  /* org    sysmgmt_vector  */
  ptr = (uint32_t*)0x1400  ;
  *ptr = 0x48000000;

}