RTEMS
bspclean.c
Go to the documentation of this file.
1 
22 #include <bsp.h>
23 #include <bsp/bootcard.h>
24 #include <rtems/bspIo.h>
25 #include <rtems/score/smpimpl.h>
26 
27 void bsp_fatal_extension(
28  rtems_fatal_source source,
29  bool always_set_to_false,
30  rtems_fatal_code code
31 )
32 {
33  /* On SMP we must wait for all other CPUs not requesting a fatal halt, they
34  * are responding to another CPU's fatal request. These CPUs goes into
35  * power-down. The CPU requesting fatal halt waits for the others and then
36  * handles the system shutdown via the normal procedure.
37  */
38  #ifdef RTEMS_SMP
39  if ((source == RTEMS_FATAL_SOURCE_SMP) &&
40  (code == SMP_FATAL_SHUTDOWN_RESPONSE)) {
41  leon3_power_down_loop(); /* CPU didn't start shutdown sequence .. */
42  } else {
43  volatile struct irqmp_regs *irqmp = LEON3_IrqCtrl_Regs;
44 
45  if (irqmp != NULL) {
46  /*
47  * Value was chosen to get something in the magnitude of 1ms on a 200MHz
48  * processor.
49  */
50  uint32_t max_wait = 1234567;
51  uint32_t self_cpu = rtems_scheduler_get_processor();
52  uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
53  uint32_t halt_mask = 0;
54  uint32_t i;
55 
56  for (i = 0; i < cpu_count; ++i) {
57  if ( (i != self_cpu) && _SMP_Should_start_processor( i ) ) {
58  halt_mask |= UINT32_C(1) << i;
59  }
60  }
61 
62  /* Wait some time for secondary processors to halt */
63  i = 0;
64  while ((irqmp->mpstat & halt_mask) != halt_mask && i < max_wait) {
65  ++i;
66  }
67  }
68  }
69  #endif
70 
71  #if (BSP_PRINT_EXCEPTION_CONTEXT)
72  if ( source == RTEMS_FATAL_SOURCE_EXCEPTION ) {
74  }
75  #endif
76 
77  /*
78  * If user wants to implement custom reset/reboot it can be done here
79  */
80  #if (BSP_RESET_BOARD_AT_EXIT)
81  bsp_reset();
82  #endif
83 }
static void rtems_exception_frame_print(const rtems_exception_frame *frame)
%
Definition: fatal.h:144
#define rtems_scheduler_get_processor()
Returns the index of the current processor.
Definition: tasks.h:329
Fatal source of SMP domain.
Definition: interr.h:126
bool _SMP_Should_start_processor(uint32_t cpu_index)
Checks if the processor with the specified index should be started.
Definition: smp.c:176
Fatal source of the exceptions.
Definition: interr.h:119
Internal_errors_Source
This type lists the possible sources from which an error can be reported.
Definition: interr.h:47
Interface to Kernel Print Methods.
#define rtems_scheduler_get_processor_maximum()
Returns the processor maximum supported by the system.
Definition: tasks.h:350
Internal_errors_t rtems_fatal_code
%
Definition: extension.h:132
SuperCore SMP Implementation.