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 | _ARM_Send_event(); |
---|
46 | |
---|
47 | /* |
---|
48 | * Wait for secondary processor to complete its basic initialization so |
---|
49 | * that we can enable the unified L2 cache. |
---|
50 | */ |
---|
51 | started = _Per_CPU_State_wait_for_non_initial_state(cpu_index, 0); |
---|
52 | } else { |
---|
53 | started = false; |
---|
54 | } |
---|
55 | |
---|
56 | return started; |
---|
57 | } |
---|
58 | |
---|
59 | uint32_t _CPU_SMP_Initialize(void) |
---|
60 | { |
---|
61 | return 4; |
---|
62 | } |
---|
63 | |
---|
64 | void _CPU_SMP_Finalize_initialization( uint32_t cpu_count ) |
---|
65 | { |
---|
66 | /* Do nothing */ |
---|
67 | } |
---|
68 | |
---|
69 | void _CPU_SMP_Prepare_start_multitasking( void ) |
---|
70 | { |
---|
71 | /* Do nothing */ |
---|
72 | } |
---|
73 | |
---|
74 | void _CPU_SMP_Send_interrupt( uint32_t target_cpu_index ) |
---|
75 | { |
---|
76 | /* Generates IPI */ |
---|
77 | BCM2835_REG(BCM2836_MAILBOX_3_WRITE_SET_BASE + |
---|
78 | 0x10 * target_cpu_index) = 0x1; |
---|
79 | } |
---|