source: rtems/bsps/sparc/leon3/start/bspclean.c @ 7a9b240

Last change on this file since 7a9b240 was 7a9b240, checked in by Joel Sherrill <joel@…>, on 03/01/22 at 21:34:50

bsps/sparc: Scripted embedded brains header file clean up

Updates #4625.

  • Property mode set to 100644
File size: 2.1 KB
Line 
1/**
2 * @file
3 * @ingroup sparc_leon3
4 * @brief LEON3 BSP fatal extension
5 *
6 *  Copyright (c) 2014 embedded brains GmbH.  All rights reserved.
7 *
8 *  COPYRIGHT (c) 2014
9 *  Aeroflex Gaisler
10 *
11 *  The license and distribution terms for this file may be
12 *  found in the file LICENSE in this distribution or at
13 *  http://www.rtems.org/license/LICENSE.
14 */
15
16#include <bsp.h>
17#include <bsp/bootcard.h>
18#include <rtems/score/smpimpl.h>
19
20#include <leon.h>
21
22void bsp_fatal_extension(
23  rtems_fatal_source source,
24  bool always_set_to_false,
25  rtems_fatal_code code
26)
27{
28#if defined(RTEMS_SMP)
29  /*
30   * On SMP we must wait for all other CPUs not requesting a fatal halt, they
31   * are responding to another CPU's fatal request. These CPUs goes into
32   * power-down. The CPU requesting fatal halt waits for the others and then
33   * handles the system shutdown via the normal procedure.
34   */
35  if ((source == RTEMS_FATAL_SOURCE_SMP) &&
36      (code == SMP_FATAL_SHUTDOWN_RESPONSE)) {
37    leon3_power_down_loop(); /* CPU didn't start shutdown sequence .. */
38  } else {
39    volatile struct irqmp_regs *irqmp = LEON3_IrqCtrl_Regs;
40
41    if (irqmp != NULL) {
42      /*
43       * Value was chosen to get something in the magnitude of 1ms on a 200MHz
44       * processor.
45       */
46      uint32_t max_wait = 1234567;
47      uint32_t self_cpu = rtems_scheduler_get_processor();
48      uint32_t cpu_count = rtems_scheduler_get_processor_maximum();
49      uint32_t halt_mask = 0;
50      uint32_t i;
51
52      for (i = 0; i < cpu_count; ++i) {
53        if ( (i != self_cpu) && _SMP_Should_start_processor( i ) ) {
54          halt_mask |= UINT32_C(1) << i;
55        }
56      }
57
58      /* Wait some time for secondary processors to halt */
59      i = 0;
60      while ((irqmp->mpstat & halt_mask) != halt_mask && i < max_wait) {
61        ++i;
62      }
63    }
64  }
65#endif
66
67#if BSP_PRINT_EXCEPTION_CONTEXT
68  if ( source == RTEMS_FATAL_SOURCE_EXCEPTION ) {
69    rtems_exception_frame_print( (const rtems_exception_frame *) code );
70  }
71#endif
72
73#if BSP_RESET_BOARD_AT_EXIT
74  /* If user wants to implement custom reset/reboot it can be done here */
75  bsp_reset();
76#endif
77}
Note: See TracBrowser for help on using the repository browser.