1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup raspberrypi |
---|
5 | * |
---|
6 | * @brief Raspberry pi SMP management functions provided to SuperCore |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2016 Pavel Pisa <pisa@cmp.felk.cvut.cz> |
---|
11 | * |
---|
12 | * Czech Technical University in Prague |
---|
13 | * Zikova 1903/4 |
---|
14 | * 166 36 Praha 6 |
---|
15 | * Czech Republic |
---|
16 | * |
---|
17 | * Reuses some ideas from Rohini Kulkarni <krohini1593@gmail.com> |
---|
18 | * GSoC 2015 project and Altera Cyclone-V SMP code |
---|
19 | * by embedded brains GmbH |
---|
20 | * |
---|
21 | * The license and distribution terms for this file may be |
---|
22 | * found in the file LICENSE in this distribution or at |
---|
23 | * http://www.rtems.org/license/LICENSE. |
---|
24 | */ |
---|
25 | |
---|
26 | #include <rtems/score/smpimpl.h> |
---|
27 | |
---|
28 | #include <bsp/start.h> |
---|
29 | #include <bsp/raspberrypi.h> |
---|
30 | #include <bsp.h> |
---|
31 | #include <bsp/arm-cp15-start.h> |
---|
32 | #include <libcpu/arm-cp15.h> |
---|
33 | #include <rtems.h> |
---|
34 | #include <bsp/irq-generic.h> |
---|
35 | #include <assert.h> |
---|
36 | |
---|
37 | bool _CPU_SMP_Start_processor( uint32_t cpu_index ) |
---|
38 | { |
---|
39 | bool started; |
---|
40 | uint32_t cpu_index_self = _SMP_Get_current_processor(); |
---|
41 | |
---|
42 | if (cpu_index != cpu_index_self) { |
---|
43 | |
---|
44 | BCM2835_REG(BCM2836_MAILBOX_3_WRITE_SET_BASE + 0x10 * cpu_index) = (uint32_t)_start; |
---|
45 | |
---|
46 | /* |
---|
47 | * Wait for secondary processor to complete its basic initialization so |
---|
48 | * that we can enable the unified L2 cache. |
---|
49 | */ |
---|
50 | started = _Per_CPU_State_wait_for_non_initial_state(cpu_index, 0); |
---|
51 | } else { |
---|
52 | started = false; |
---|
53 | } |
---|
54 | |
---|
55 | return started; |
---|
56 | } |
---|
57 | |
---|
58 | uint32_t _CPU_SMP_Initialize(void) |
---|
59 | { |
---|
60 | uint32_t cpu_count = (uint32_t)bsp_processor_count; |
---|
61 | |
---|
62 | if ( cpu_count > 4 ) |
---|
63 | cpu_count = 4; |
---|
64 | |
---|
65 | return cpu_count; |
---|
66 | } |
---|
67 | |
---|
68 | void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) |
---|
69 | { |
---|
70 | /* Do nothing */ |
---|
71 | } |
---|
72 | |
---|
73 | void _CPU_SMP_Prepare_start_multitasking( void ) |
---|
74 | { |
---|
75 | /* Do nothing */ |
---|
76 | } |
---|
77 | |
---|
78 | void _CPU_SMP_Send_interrupt( uint32_t target_cpu_index ) |
---|
79 | { |
---|
80 | /* Generates IPI */ |
---|
81 | BCM2835_REG(BCM2836_MAILBOX_3_WRITE_SET_BASE + |
---|
82 | 0x10 * target_cpu_index) = 0x1; |
---|
83 | } |
---|