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) 1989-2013. |
---|
8 | * On-Line Applications Research Corporation (OAR). |
---|
9 | * |
---|
10 | * Modified for LEON3 BSP. |
---|
11 | * COPYRIGHT (c) 2004. |
---|
12 | * Gaisler Research. |
---|
13 | * |
---|
14 | * The license and distribution terms for this file may be |
---|
15 | * found in the file LICENSE in this distribution or at |
---|
16 | * http://www.rtems.org/license/LICENSE. |
---|
17 | */ |
---|
18 | |
---|
19 | #include <bsp.h> |
---|
20 | #include <leon.h> |
---|
21 | #include <bsp/bootcard.h> |
---|
22 | #include <rtems/sysinit.h> |
---|
23 | |
---|
24 | #if defined(RTEMS_SMP) || defined(RTEMS_MULTIPROCESSING) |
---|
25 | /* Irq used by shared memory driver and for inter-processor interrupts. |
---|
26 | * Can be overridden by being defined in the application. |
---|
27 | */ |
---|
28 | const unsigned char LEON3_mp_irq __attribute__((weak)) = 14; |
---|
29 | #endif |
---|
30 | |
---|
31 | /* |
---|
32 | * Tells us if data cache snooping is available |
---|
33 | */ |
---|
34 | int CPU_SPARC_HAS_SNOOPING; |
---|
35 | |
---|
36 | /* Index of CPU, in an AMP system CPU-index may be non-zero */ |
---|
37 | uint32_t LEON3_Cpu_Index = 0; |
---|
38 | |
---|
39 | #if defined(RTEMS_SMP) |
---|
40 | /* Index of the boot CPU. Set by the first CPU at boot to its CPU ID. */ |
---|
41 | int LEON3_Boot_Cpu = -1; |
---|
42 | #endif |
---|
43 | |
---|
44 | /* |
---|
45 | * set_snooping |
---|
46 | * |
---|
47 | * Read the cache control register to determine if |
---|
48 | * bus snooping is available and enabled. This is needed for some |
---|
49 | * drivers so that they can select the most efficient copy routines. |
---|
50 | * |
---|
51 | */ |
---|
52 | |
---|
53 | static inline int set_snooping(void) |
---|
54 | { |
---|
55 | return (leon3_get_cache_control_register() >> 23) & 1; |
---|
56 | } |
---|
57 | |
---|
58 | /* |
---|
59 | * bsp_start |
---|
60 | * |
---|
61 | * This routine does the bulk of the system initialization. |
---|
62 | */ |
---|
63 | void bsp_start( void ) |
---|
64 | { |
---|
65 | CPU_SPARC_HAS_SNOOPING = set_snooping(); |
---|
66 | } |
---|
67 | |
---|
68 | static void leon3_cpu_index_init(void) |
---|
69 | { |
---|
70 | /* Get the LEON3 CPU index, normally 0, but for MP systems we do |
---|
71 | * _not_ assume that this is CPU0. One may run another OS on CPU0 |
---|
72 | * and RTEMS on this CPU, and AMP system with mixed operating |
---|
73 | * systems |
---|
74 | */ |
---|
75 | LEON3_Cpu_Index = _LEON3_Get_current_processor(); |
---|
76 | } |
---|
77 | |
---|
78 | RTEMS_SYSINIT_ITEM( |
---|
79 | leon3_cpu_index_init, |
---|
80 | RTEMS_SYSINIT_BSP_START, |
---|
81 | RTEMS_SYSINIT_ORDER_FIRST |
---|
82 | ); |
---|