blob: 9b929799d8f8958e930649fdc13ff0c09e186e39 [file] [log] [blame]
Sandrine Bailleux798140d2014-07-17 16:06:39 +01001/*
2 * Copyright (c) 2013-2014, ARM Limited and Contributors. All rights reserved.
3 *
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are met:
6 *
7 * Redistributions of source code must retain the above copyright notice, this
8 * list of conditions and the following disclaimer.
9 *
10 * Redistributions in binary form must reproduce the above copyright notice,
11 * this list of conditions and the following disclaimer in the documentation
12 * and/or other materials provided with the distribution.
13 *
14 * Neither the name of ARM nor the names of its contributors may be used
15 * to endorse or promote products derived from this software without specific
16 * prior written permission.
17 *
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
21 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
22 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
23 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
24 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
25 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
26 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
27 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
28 * POSSIBILITY OF SUCH DAMAGE.
29 */
30
31#include <arch.h>
32#include <asm_macros.S>
33#include "../juno_def.h"
34
Juan Castillo21b04192014-08-12 17:24:30 +010035 .globl platform_is_primary_cpu
Sandrine Bailleux798140d2014-07-17 16:06:39 +010036 .globl platform_get_entrypoint
37 .globl platform_cold_boot_init
38 .globl plat_secondary_cold_boot_setup
39
Juan Castillo21b04192014-08-12 17:24:30 +010040 /* -----------------------------------------------------
41 * unsigned int platform_is_primary_cpu (unsigned int mpid);
42 *
43 * Given the mpidr say whether this cpu is the primary
44 * cpu (applicable ony after a cold boot)
45 * -----------------------------------------------------
46 */
47func platform_is_primary_cpu
48 mov x9, x30
49 bl platform_get_core_pos
50 ldr x1, =SCP_BOOT_CFG_ADDR
51 ldr x1, [x1]
52 ubfx x1, x1, #PRIMARY_CPU_SHIFT, #PRIMARY_CPU_MASK
53 cmp x0, x1
54 cset x0, eq
55 ret x9
Kévin Petita877c252015-03-24 14:03:57 +000056endfunc platform_is_primary_cpu
Sandrine Bailleux798140d2014-07-17 16:06:39 +010057
58 /* -----------------------------------------------------
59 * void plat_secondary_cold_boot_setup (void);
60 *
61 * This function performs any platform specific actions
62 * needed for a secondary cpu after a cold reset e.g
63 * mark the cpu's presence, mechanism to place it in a
64 * holding pen etc.
65 * -----------------------------------------------------
66 */
67func plat_secondary_cold_boot_setup
68 /* Juno todo: Implement secondary CPU cold boot setup on Juno */
69cb_panic:
70 b cb_panic
Kévin Petita877c252015-03-24 14:03:57 +000071endfunc plat_secondary_cold_boot_setup
Sandrine Bailleux798140d2014-07-17 16:06:39 +010072
73
74 /* -----------------------------------------------------
75 * void platform_get_entrypoint (unsigned int mpid);
76 *
77 * Main job of this routine is to distinguish between
78 * a cold and warm boot.
79 * On a cold boot the secondaries first wait for the
80 * platform to be initialized after which they are
81 * hotplugged in. The primary proceeds to perform the
82 * platform initialization.
83 * On a warm boot, each cpu jumps to the address in its
84 * mailbox.
85 *
86 * TODO: Not a good idea to save lr in a temp reg
87 * -----------------------------------------------------
88 */
89func platform_get_entrypoint
90 mov x9, x30 // lr
91 bl platform_get_core_pos
92 ldr x1, =TRUSTED_MAILBOXES_BASE
93 lsl x0, x0, #TRUSTED_MAILBOX_SHIFT
94 ldr x0, [x1, x0]
95 ret x9
Kévin Petita877c252015-03-24 14:03:57 +000096endfunc platform_get_entrypoint
Sandrine Bailleux798140d2014-07-17 16:06:39 +010097
98
99 /* -----------------------------------------------------
100 * void platform_cold_boot_init (bl1_main function);
101 *
102 * Routine called only by the primary cpu after a cold
103 * boot to perform early platform initialization
104 * -----------------------------------------------------
105 */
106func platform_cold_boot_init
107 mov x20, x0
108
109 /* ---------------------------------------------
110 * Give ourselves a small coherent stack to
111 * ease the pain of initializing the MMU and
112 * CCI in assembler
113 * ---------------------------------------------
114 */
115 mrs x0, mpidr_el1
116 bl platform_set_coherent_stack
117
118 /* ---------------------------------------------
119 * Architectural init. can be generic e.g.
120 * enabling stack alignment and platform spec-
121 * ific e.g. MMU & page table setup as per the
122 * platform memory map. Perform the latter here
123 * and the former in bl1_main.
124 * ---------------------------------------------
125 */
126 bl bl1_early_platform_setup
127 bl bl1_plat_arch_setup
128
129 /* ---------------------------------------------
130 * Give ourselves a stack allocated in Normal
131 * -IS-WBWA memory
132 * ---------------------------------------------
133 */
134 mrs x0, mpidr_el1
135 bl platform_set_stack
136
137 /* ---------------------------------------------
138 * Jump to the main function. Returning from it
139 * is a terminal error.
140 * ---------------------------------------------
141 */
142 blr x20
143
144cb_init_panic:
145 b cb_init_panic
Kévin Petita877c252015-03-24 14:03:57 +0000146endfunc platform_cold_boot_init