comparison src/cs/services/dar/dar_emergency.c @ 0:945cf7f506b2

src/cs: chipsetsw import from tcs211-fcmodem binary blobs and LCD demo files have been excluded, all line endings are LF only
author Mychaela Falconia <falcon@freecalypso.org>
date Sun, 25 Sep 2016 22:50:11 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:945cf7f506b2
1 /****************************************************************************/
2 /* */
3 /* File Name: dar_emergency.c */
4 /* */
5 /* Purpose: This function is called when the DAR entity has detected */
6 /* an emergency ( Error or exception) */
7 /* */
8 /* */
9 /* Version 0.1 */
10 /* */
11 /* Date Modification */
12 /* ------------------------------------ */
13 /* 17 October 2001 Create */
14 /* */
15 /* Author Stephanie Gerthoux */
16 /* */
17 /* (C) Copyright 2001 by Texas Instruments Incorporated, All Rights Reserved*/
18 /****************************************************************************/
19
20 #include "rv/rv_defined_swe.h"
21 #ifdef RVM_DAR_SWE
22 /* ************************************************ */
23 /* THE DAR ENTITY IS ENABLED */
24 /* ************************************************ */
25
26 #include <string.h>
27 #include "rvm/rvm_gen.h"
28 #include "dar/dar_api.h"
29 #include "dar/dar_macro_i.h"
30 #include "dar/dar_messages_i.h"
31 #include "dar/dar_const_i.h"
32 #include "dar/dar_diagnose_i.h"
33 #include "dar/dar_msg_ft.h"
34
35 #ifndef _WINDOWS
36 #include "timer/timer.h"
37 #endif
38
39 /**** Global variable ****/
40 /* index used in the circular buffer*/
41 extern UINT16 dar_current_index;
42
43 /* Write buffer*/
44 extern char dar_write_buffer[DAR_MAX_BUFFER_SIZE];
45
46 /* Get the dar current status */
47 extern T_DAR_RECOVERY_STATUS dar_current_status;
48
49 /* Get the dar exception status */
50 extern UINT8 dar_exception_status;
51
52 /* Define a pointer to the Global Environment Control block */
53 extern T_DAR_ENV_CTRL_BLK *dar_gbl_var_p;
54
55 /* Define the recovery buffer */
56 extern UINT8 dar_recovery_buffer[DAR_RECOVERY_DATA_MAX_BUFFER_SIZE];
57
58 /* Ram buffer that contains the Debug Unit register */
59 extern UINT32 debug_RAM[DEBUG_UNIT_WORD_SIZE];
60
61
62 /**** Extern functions ****/
63 extern void * dar_read_mbox (UINT8 mbox);
64
65 extern void exception(void);
66
67
68 /********************************************************************************/
69 /* */
70 /* Function Name: dar_process_emergency */
71 /* */
72 /* Purpose: This function is called to process emergency data and to store */
73 /* them in RAM buffer when an emergency has been detected */
74 /* */
75 /* */
76 /* Input Parameters: */
77 /* Pointer to the message to store */
78 /* Data Format, ( the Binary format is not supported) */
79 /* Data Use Id, */
80 /* Flags */
81 /* */
82 /* Output Parameters: */
83 /* Validation of the diagnose execution. */
84 /* */
85 /* */
86 /* */
87 /* Revision History: */
88 /* None. */
89 /* */
90 /********************************************************************************/
91 T_RV_RET dar_process_emergency( T_DAR_INFO *buffer_p,
92 T_DAR_FORMAT format,
93 T_RVM_USE_ID dar_use_id,
94 UINT32 flags)
95 {
96 /* Declare local variables */
97 UINT32 i = 0;
98 UINT32 length = 0;
99 T_RV_HDR *msg_p = ( T_RV_HDR*) dar_read_mbox(DAR_MBOX);
100
101 /**** Update the DAR recovery status ****/
102 dar_current_status = DAR_EMERGENCY_SCUTTLING;
103
104 /**** Empty the mail box before the reset of the system ****/
105 while(msg_p != NULL)
106 {
107 /* If it's a Write message, store it in the RAM */
108 /* ( it is not interesting to store filter message ) */
109 if ((msg_p->msg_id) == DAR_WRITE_REQ)
110 {
111 /* store the message in the RAM*/
112 dar_write_data_in_buffer((T_DAR_WRITE_START *)msg_p);
113 }
114
115 /* free the Header of the message */
116 rvf_free_buf((T_RVF_BUFFER *) msg_p);
117
118 /* Read the next message */
119 msg_p = ( T_RV_HDR*) dar_read_mbox(DAR_MBOX);
120
121 } /* while (msg_p != NULL) */
122
123 /**** Store emergency data in RAM buffer ****/
124 /* Diagnose string length */
125 length = (UINT16) strlen(buffer_p);
126
127 /**** Check if the DAR entity is started ****/
128 if (dar_gbl_var_p != NULL )
129 {
130 /* Data format */
131 dar_gbl_var_p->format = format;
132 }
133
134 if ( flags & DAR_NEW_ENTRY )
135 {
136 /** Circular buffer to store data **/
137 /* Add 0xFF to separate 2 strings */
138 dar_write_buffer[dar_current_index] = 0xF;
139 DAR_PLUS_PLUS(dar_current_index); /* to detected if it is the end of the buffer */
140 dar_write_buffer[dar_current_index] = 0xF;
141 DAR_PLUS_PLUS(dar_current_index); /* to detected if it is the end of the buffer */
142
143 /* The group_nb is 16 bit length, and the buffer is an UINT8 length */
144 /* So the group_nb must be stocked by dividing it in 2 parts */
145 dar_write_buffer[dar_current_index] = ((dar_use_id>>16)& 0x7FFF)>>8;
146 /*add the 8 first bits of the Use id group*/
147 DAR_PLUS_PLUS(dar_current_index);
148 dar_write_buffer[dar_current_index] = (dar_use_id>>16)& 0x7FFF;
149 /*add the 8 last bits of the Use id group*/
150 DAR_PLUS_PLUS(dar_current_index);
151
152 /* The mask is 16 bit length, and the buffer is an UINT8 length */
153 /* So the mask must be stocked by dividing it in 2 parts */
154 dar_write_buffer[dar_current_index] = ((dar_use_id)&0xFFFF)>>8;
155 /* add the 8 first bits of the Use id mask */
156 DAR_PLUS_PLUS(dar_current_index);
157 dar_write_buffer[dar_current_index] = (dar_use_id)&0xFFFF;
158 /* add the 8 last bits of the Use id mask */
159 DAR_PLUS_PLUS(dar_current_index);
160
161 /* Add the dar_level data */
162 dar_write_buffer[dar_current_index] = DAR_ERROR;
163 DAR_PLUS_PLUS(dar_current_index);
164 }
165
166 /* circular buffer to store diagnose data in RAM buffer */
167 for (i=0; i < length; i++ )
168 {
169 /* copy string in the RAM char by char*/
170 dar_write_buffer[dar_current_index]=buffer_p[i];
171
172 /* detection of the end of the buffer */
173 /* When current = DAR_MAX_BUFFER_SIZE , current = 0 */
174 DAR_PLUS_PLUS(dar_current_index);
175 }
176
177 /* DAR information is redirected to standard trace */
178 //DAR_SEND_TRACE("Circular buffer :",RV_TRACE_LEVEL_ERROR);
179 //rvf_send_trace(buffer_p, length, NULL_PARAM, RV_TRACE_LEVEL_ERROR, DAR_USE_ID);
180
181 /* Trace the buffer (used for debug) */
182 rvf_delay(RVF_MS_TO_TICKS(1000));
183
184
185 /**** Check if the DAR entity is started ****/
186 if (dar_gbl_var_p != NULL )
187 {
188 if (dar_gbl_var_p->entity_dar_callback != NULL )
189 {
190 /* Call the MMI callback function to save some parameters before reset */
191 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
192 }
193 }
194
195 /* The system is reset if requested */
196 if ( flags & DAR_EMERGENCY_RESET )
197 {
198 dar_reset();
199 }
200 return(RV_OK);
201
202 } /* dar_process_emergency */
203
204
205 /********************************************************************************/
206 /* */
207 /* Function Name: dar_exception_arm_undefined */
208 /* */
209 /* Purpose: This function is called to process ARM undefined instruction */
210 /* exception and to store this exception in the RAM buffer */
211 /* */
212 /* Input Parameters: */
213 /* None */
214 /* */
215 /* Output Parameters: */
216 /* Validation of the diagnose execution. */
217 /* */
218 /* */
219 /* */
220 /* Revision History: */
221 /* None. */
222 /* */
223 /********************************************************************************/
224 void dar_exception_arm_undefined(void)
225 {
226 /* Declare local variables */
227 T_DAR_INFO *buffer_p= " DAR Emergency exception : ARM undefined ";/*exception data to store*/
228
229 /* Update the DAR recovery status */
230 dar_current_status = DAR_EMERGENCY_SCUTTLING;
231
232 /* Update the DAR exception status */
233 dar_exception_status = DAR_EXCEPTION_UNDEFINED;
234
235 /* Empty the mail box and store data in RAM buffer */
236 dar_empty_mb_and_save_data(buffer_p);
237
238 /* Check if the DAR entity is started */
239 if (dar_gbl_var_p != NULL )
240 {
241 if (dar_gbl_var_p->entity_dar_callback != NULL)
242 {
243 /* Call the MMI callback function to save some parameters before reset */
244 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
245 }
246 }
247
248 #ifndef _WINDOWS
249 /* branch to "exception" defined in the int.s*/
250 exception();
251 #endif
252
253 } /* dar_exception_arm_undefined */
254
255 /********************************************************************************/
256 /* */
257 /* Function Name: dar_exception_arm_swi */
258 /* */
259 /* Purpose: This function is called to process ARM SW Interrupt exception */
260 /* and to store this exception in the RAM buffer */
261 /* */
262 /* Input Parameters: */
263 /* None */
264 /* */
265 /* Output Parameters: */
266 /* Validation of the diagnose execution. */
267 /* */
268 /* */
269 /* */
270 /* Revision History: */
271 /* None. */
272 /* */
273 /********************************************************************************/
274 void dar_exception_arm_swi(void)
275 {
276 /* Declare local variables */
277 T_DAR_INFO *buffer_p= " DAR Emergency exception : ARM SWI ";/*exception data to store*/
278
279 /* Update the DAR recovery status */
280 dar_current_status = DAR_EMERGENCY_SCUTTLING;
281
282 /* Update the DAR exception status */
283 dar_exception_status = DAR_EXCEPTION_SWI;
284
285 /* Empty the mail box and store data in RAM buffer */
286 dar_empty_mb_and_save_data(buffer_p);
287
288 /* Check if the DAR entity is started */
289 if (dar_gbl_var_p != NULL )
290 {
291 if ( dar_gbl_var_p->entity_dar_callback != NULL)
292 {
293 /* Call the MMI callback function to save some parameters before reset */
294 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
295 }
296 }
297
298 #ifndef _WINDOWS
299 /* branch to "exception" defined in the int.s*/
300 exception();
301 #endif
302
303 } /* dar_exception_arm_swi */
304
305 /********************************************************************************/
306 /* */
307 /* Function Name: dar_exception_arm_abort_prefetch */
308 /* */
309 /* Purpose: This function is called to process ARM abort prefetch exception */
310 /* and to store this exception in the RAM buffer */
311 /* */
312 /* Input Parameters: */
313 /* None */
314 /* */
315 /* Output Parameters: */
316 /* Validation of the diagnose execution. */
317 /* */
318 /* */
319 /* */
320 /* Revision History: */
321 /* None. */
322 /* */
323 /********************************************************************************/
324 void dar_exception_arm_abort_prefetch(void)
325 {
326 #ifndef _WINDOWS
327 /* Local variable */
328 UINT8 i;
329 #endif
330
331 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
332 /* Debug unit pointer */
333 volatile UINT32 *debug_register_p;
334 #endif
335
336 /* Declare local variables */
337 T_DAR_INFO *buffer_p = " DAR Emergency exception : ARM abort prefetch";/*exception data to store*/
338
339 /* Update the DAR recovery status */
340 dar_current_status = DAR_EMERGENCY_SCUTTLING;
341
342 /* Update the DAR exception status */
343 dar_exception_status = DAR_EXCEPTION_PREFETCH_ABORT;
344
345 /* Empty the mail box and store data in RAM buffer */
346 dar_empty_mb_and_save_data(buffer_p);
347
348 /* Check if the DAR entity is started */
349 if (dar_gbl_var_p != NULL )
350 {
351 if (dar_gbl_var_p->entity_dar_callback != NULL)
352 {
353 /* Call the MMI callback function to save some parameters before reset */
354 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
355 }
356 }
357
358 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
359 /* Initialize the adress of the Debug Unit pointer */
360 debug_register_p = (volatile UINT32*) DAR_DEBUG_UNIT_REGISTER;
361 #endif
362
363 #ifndef _WINDOWS
364 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
365 /* Save the Debug Unit into the RAM */
366 for (i=0; i<DEBUG_UNIT_WORD_SIZE; i++ )
367 {
368 debug_RAM[i] = *debug_register_p;
369 debug_register_p++;
370 }
371 #endif
372
373 /* branch to "exception" defined in the int.s*/
374 exception();
375 #endif
376
377 } /* dar_exception_arm_abort_prefetch */
378
379 /********************************************************************************/
380 /* */
381 /* Function Name: dar_exception_arm_abort_data */
382 /* */
383 /* Purpose: This function is called to process ARM abort data exception */
384 /* and to store this exception in the RAM buffer */
385 /* */
386 /* Input Parameters: */
387 /* None */
388 /* */
389 /* Output Parameters: */
390 /* Validation of the diagnose execution. */
391 /* */
392 /* */
393 /* */
394 /* Revision History: */
395 /* None. */
396 /* */
397 /********************************************************************************/
398 void dar_exception_arm_abort_data(void)
399 {
400 #ifndef _WINDOWS
401 /* Local variable */
402 UINT8 i;
403 #endif
404
405 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
406 /* Debug unit pointer */
407 volatile UINT32 *debug_register_p;
408 #endif
409
410 /* Declare local variables */
411 T_DAR_INFO *buffer_p= " DAR Emergency exception : ARM abort data";/*exception data to store*/
412
413 /* Update the DAR recovery status */
414 dar_current_status = DAR_EMERGENCY_SCUTTLING;
415
416 /* Update the DAR exception status */
417 dar_exception_status = DAR_EXCEPTION_DATA_ABORT;
418
419 /* Empty the mail box and store data in RAM buffer */
420 dar_empty_mb_and_save_data(buffer_p);
421
422 /* Check if the DAR entity is started */
423 if (dar_gbl_var_p != NULL )
424 {
425 if (dar_gbl_var_p->entity_dar_callback != NULL)
426 {
427
428 /* Call the MMI callback function to save some parameters before reset */
429 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
430 }
431 }
432
433 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
434 /* Initialize the adress of the Debug Unit pointer */
435 debug_register_p = (volatile UINT32*) DAR_DEBUG_UNIT_REGISTER;
436 #endif
437
438 #ifndef _WINDOWS
439 #if ((CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12))
440 /* Save the Debug Unit into the RAM */
441 for (i=0; i<DEBUG_UNIT_WORD_SIZE; i++ )
442 {
443 debug_RAM[i] = *debug_register_p;
444 debug_register_p++;
445 }
446 #endif
447
448 /* branch to "exception" defined in the int.s*/
449 exception();
450 #endif
451
452 } /* dar_exception_arm_abort_data */
453
454 /********************************************************************************/
455 /* */
456 /* Function Name: dar_exception_arm_reserved */
457 /* */
458 /* Purpose: This function is called to process ARM exception */
459 /* and to store this exception in the RAM buffer */
460 /* */
461 /* Input Parameters: */
462 /* None */
463 /* */
464 /* Output Parameters: */
465 /* Validation of the diagnose execution. */
466 /* */
467 /* */
468 /* */
469 /* Revision History: */
470 /* None. */
471 /* */
472 /********************************************************************************/
473 void dar_exception_arm_reserved(void)
474 {
475 /* Declare local variables */
476 T_DAR_INFO *buffer_p= " DAR Emergency exception : ARM reserved";/*exception data to store*/
477
478 /* Update the DAR recovery status */
479 dar_current_status = DAR_EMERGENCY_SCUTTLING;
480
481 /* Update the DAR exception status */
482 dar_exception_status = DAR_EXCEPTION_RESERVED;
483
484 /* Empty the mail box and store data in RAM buffer */
485 dar_empty_mb_and_save_data(buffer_p);
486
487 /* Check if the DAR entity is started */
488 if (dar_gbl_var_p != NULL )
489 {
490 if (dar_gbl_var_p->entity_dar_callback != NULL)
491 {
492 /* Call the MMI callback function to save some parameters before reset */
493 dar_gbl_var_p->entity_dar_callback(dar_recovery_buffer,DAR_RECOVERY_DATA_MAX_BUFFER_SIZE);
494 }
495 }
496
497 #ifndef _WINDOWS
498 /* branch to "exception" defined in the int.s*/
499 exception();
500 #endif
501
502 } /* dar_exception_arm_reserved */
503
504 /********************************************************************************/
505 /* */
506 /* Function Name: dar_exception */
507 /* */
508 /* Purpose: This function is called to vector exceptions to the correct */
509 /* handler */
510 /* */
511 /* Input Parameters: */
512 /* abort type which come from int.s ( -> magic number) */
513 /* */
514 /* Output Parameters: */
515 /* Validation of the diagnose execution. */
516 /* */
517 /* */
518 /* */
519 /* Revision History: */
520 /* None. */
521 /* */
522 /********************************************************************************/
523 void dar_exception(int abort_type)
524 {
525 switch (abort_type)
526 {
527 /* magic numbers come from int.s There is no way to make compiler derived
528 * constants out of them
529 */
530 case 1:
531 dar_exception_arm_undefined();
532 break;
533 case 2:
534 dar_exception_arm_swi();
535 break;
536 case 3:
537 dar_exception_arm_abort_prefetch();
538 break;
539 case 4:
540 dar_exception_arm_abort_data();
541 break;
542 case 5:
543 dar_exception_arm_reserved();
544 break;
545 }
546 } /* dar_exception */
547
548 #else
549 /* ************************************************ */
550 /* THE DAR ENTITY IS DISABLED */
551 /* ************************************************ */
552
553 void dar_exception(int abort_type)
554 {
555 #ifndef _WINDOWS
556 /* branch to "exception" defined in the int.s*/
557 exception();
558 #endif
559 } /* dar_exception */
560
561 #endif /* #ifdef RVM_DAR_SWE */
562