source: rtems/c/src/lib/libbsp/sparc/leon3/startup/bspstart.c @ c4ccf26c

5
Last change on this file since c4ccf26c was c4ccf26c, checked in by Sebastian Huber <sebastian.huber@…>, on 04/17/18 at 04:57:46

bsps: Convert all bsp_predriver_hook()

Use RTEMS_SYSINIT_ITEM() instead.

Update #2408.

  • Property mode set to 100644
File size: 3.0 KB
Line 
1/*
2 *  This set of routines starts the application.  It includes application,
3 *  board, and monitor specific initialization and configuration.
4 *  The generic CPU dependent initialization has been performed
5 *  before any of these are invoked.
6 *
7 *  COPYRIGHT (c) 2011
8 *  Aeroflex Gaisler
9 *
10 *  COPYRIGHT (c) 1989-2013.
11 *  On-Line Applications Research Corporation (OAR).
12 *
13 *  Modified for LEON3 BSP.
14 *  COPYRIGHT (c) 2004.
15 *  Gaisler Research.
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 <leon.h>
24#include <bsp/bootcard.h>
25#include <drvmgr/drvmgr.h>
26#include <rtems/sysinit.h>
27
28#if defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING)
29/* Irq used by shared memory driver and for inter-processor interrupts.
30 * Can be overridden by being defined in the application.
31 */
32const unsigned char LEON3_mp_irq __attribute__((weak)) = 14;
33#endif
34
35/*
36 * Tells us if data cache snooping is available
37 */
38int CPU_SPARC_HAS_SNOOPING;
39
40/* Index of CPU, in an AMP system CPU-index may be non-zero */
41uint32_t LEON3_Cpu_Index = 0;
42
43#if defined(RTEMS_SMP)
44/* Index of the boot CPU. Set by the first CPU at boot to its CPU ID. */
45int LEON3_Boot_Cpu = -1;
46#endif
47
48/*
49 * set_snooping
50 *
51 * Read the cache control register to determine if
52 * bus snooping is available and enabled. This is needed for some
53 * drivers so that they can select the most efficient copy routines.
54 *
55 */
56
57static inline int set_snooping(void)
58{
59  return (leon3_get_cache_control_register() >> 23) & 1;
60}
61
62/*
63 *  bsp_start
64 *
65 *  This routine does the bulk of the system initialization.
66 */
67void bsp_start( void )
68{
69  CPU_SPARC_HAS_SNOOPING = set_snooping();
70}
71
72static void leon3_cpu_index_init(void)
73{
74  /* Get the LEON3 CPU index, normally 0, but for MP systems we do
75   * _not_ assume that this is CPU0. One may run another OS on CPU0
76   * and RTEMS on this CPU, and AMP system with mixed operating
77   * systems
78   */
79  LEON3_Cpu_Index = _LEON3_Get_current_processor();
80}
81
82RTEMS_SYSINIT_ITEM(
83  leon3_cpu_index_init,
84  RTEMS_SYSINIT_BSP_START,
85  RTEMS_SYSINIT_ORDER_FIRST
86);
87
88static void leon3_interrupt_common_init( void )
89{
90  /* Initialize shared interrupt handling, must be done after IRQ
91   * controller has been found and initialized.
92   */
93  BSP_shared_interrupt_init();
94}
95
96/*
97 * Called just before drivers are initialized.  Is used to initialize shared
98 * interrupt handling.
99 */
100static void leon3_pre_driver_hook( void )
101{
102  bsp_spurious_initialize();
103
104#ifndef RTEMS_DRVMGR_STARTUP
105  leon3_interrupt_common_init();
106#endif
107}
108
109RTEMS_SYSINIT_ITEM(
110  leon3_pre_driver_hook,
111  RTEMS_SYSINIT_BSP_PRE_DRIVERS,
112  RTEMS_SYSINIT_ORDER_MIDDLE
113);
114
115#ifdef RTEMS_DRVMGR_STARTUP
116/*
117 * Initialize shared interrupt handling, must be done after IRQ controller has
118 * been found and initialized.
119 */
120RTEMS_SYSINIT_ITEM(
121  leon3_interrupt_common_init,
122  RTEMS_SYSINIT_DRVMGR_LEVEL_1,
123  RTEMS_SYSINIT_ORDER_LAST
124);
125#endif
Note: See TracBrowser for help on using the repository browser.