source: rtems/bsps/sparc/leon3/start/bspclean.c @ 0446f680

5
Last change on this file since 0446f680 was 0446f680, checked in by Marçal Comajoan Cara <mcomajoancara@…>, on 12/03/18 at 20:37:32

Spelling and grammar fixes in source code comments (GCI 2018)

  • Property mode set to 100644
File size: 2.2 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 *  embedded brains GmbH
9 *  Dornierstr. 4
10 *  82178 Puchheim
11 *  Germany
12 *  <rtems@embedded-brains.de>
13 *
14 *  COPYRIGHT (c) 2014
15 *  Aeroflex Gaisler
16 *
17 *  The license and distribution terms for this file may be
18 *  found in the file LICENSE in this distribution or at
19 *  http://www.rtems.org/license/LICENSE.
20 */
21
22#include <bsp.h>
23#include <bsp/bootcard.h>
24#include <rtems/bspIo.h>
25#include <rtems/score/smpimpl.h>
26
27void 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_get_current_processor();
52      uint32_t cpu_count = rtems_get_processor_count();
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 ) {
73      rtems_exception_frame_print( (const rtems_exception_frame *) code );
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}
Note: See TracBrowser for help on using the repository browser.