xref: /rk3399_ARM-atf/plat/common/aarch64/platform_helpers.S (revision b4cf974a3256275fe2c03d8eaaf07a5e5b337cfc)
1/*
2 * Copyright (c) 2013-2018, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#include <arch.h>
8#include <asm_macros.S>
9#include <console.h>
10#include <platform_def.h>
11
12	.weak	plat_report_exception
13#if !ERROR_DEPRECATED
14	.weak	plat_crash_console_init
15	.weak	plat_crash_console_putc
16	.weak	plat_crash_console_flush
17#endif
18	.weak	plat_reset_handler
19	.weak	plat_disable_acp
20	.weak	bl1_plat_prepare_exit
21	.weak	plat_panic_handler
22	.weak	bl31_plat_enable_mmu
23	.weak	bl32_plat_enable_mmu
24
25	.weak	plat_handle_uncontainable_ea
26	.weak	plat_handle_double_fault
27	.weak	plat_handle_el3_ea
28
29	.globl	platform_get_core_pos
30
31#define MPIDR_RES_BIT_MASK	0xff000000
32
33	/* -----------------------------------------------------
34	 * Placeholder function which should be redefined by
35	 * each platform.
36	 * -----------------------------------------------------
37	 */
38func plat_report_exception
39	ret
40endfunc plat_report_exception
41
42#if !ERROR_DEPRECATED
43#if MULTI_CONSOLE_API
44	/* -----------------------------------------------------
45	 * int plat_crash_console_init(void)
46	 * Use normal console by default. Switch it to crash
47	 * mode so serial consoles become active again.
48	 * NOTE: This default implementation will only work for
49	 * crashes that occur after a normal console (marked
50	 * valid for the crash state) has been registered with
51	 * the console framework. To debug crashes that occur
52	 * earlier, the platform has to override these functions
53	 * with an implementation that initializes a console
54	 * driver with hardcoded parameters. See
55	 * docs/porting-guide.rst for more information.
56	 * -----------------------------------------------------
57	 */
58func plat_crash_console_init
59#if defined(IMAGE_BL1)
60	/*
61	 * BL1 code can possibly crash so early that the data segment is not yet
62	 * accessible. Don't risk undefined behavior by trying to run the normal
63	 * console framework. Platforms that want to debug BL1 will need to
64	 * override this with custom functions that can run from registers only.
65	 */
66	mov	x0, #0
67	ret
68#else	/* IMAGE_BL1 */
69	mov	x3, x30
70	mov	x0, #CONSOLE_FLAG_CRASH
71	bl	console_switch_state
72	mov	x0, #1
73	ret	x3
74#endif
75endfunc plat_crash_console_init
76
77	/* -----------------------------------------------------
78	 * void plat_crash_console_putc(int character)
79	 * Output through the normal console by default.
80	 * -----------------------------------------------------
81	 */
82func plat_crash_console_putc
83	b	console_putc
84endfunc plat_crash_console_putc
85
86	/* -----------------------------------------------------
87	 * void plat_crash_console_flush(void)
88	 * Flush normal console by default.
89	 * -----------------------------------------------------
90	 */
91func plat_crash_console_flush
92	b	console_flush
93endfunc plat_crash_console_flush
94
95#else	/* MULTI_CONSOLE_API */
96
97	/* -----------------------------------------------------
98	 * In the old API these are all no-op stubs that need to
99	 * be overridden by the platform to be useful.
100	 * -----------------------------------------------------
101	 */
102func plat_crash_console_init
103	mov	x0, #0
104	ret
105endfunc plat_crash_console_init
106
107func plat_crash_console_putc
108	ret
109endfunc plat_crash_console_putc
110
111func plat_crash_console_flush
112	ret
113endfunc plat_crash_console_flush
114#endif
115#endif /* ERROR_DEPRECATED */
116
117	/* -----------------------------------------------------
118	 * Placeholder function which should be redefined by
119	 * each platform. This function should preserve x19 - x29.
120	 * -----------------------------------------------------
121	 */
122func plat_reset_handler
123	ret
124endfunc plat_reset_handler
125
126	/* -----------------------------------------------------
127	 * Placeholder function which should be redefined by
128	 * each platform. This function is allowed to use
129	 * registers x0 - x17.
130	 * -----------------------------------------------------
131	 */
132func plat_disable_acp
133	ret
134endfunc plat_disable_acp
135
136	/* -----------------------------------------------------
137	 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info);
138	 * Called before exiting BL1. Default: do nothing
139	 * -----------------------------------------------------
140	 */
141func bl1_plat_prepare_exit
142	ret
143endfunc bl1_plat_prepare_exit
144
145	/* -----------------------------------------------------
146	 * void plat_panic_handler(void) __dead2;
147	 * Endless loop by default.
148	 * -----------------------------------------------------
149	 */
150func plat_panic_handler
151	wfi
152	b	plat_panic_handler
153endfunc plat_panic_handler
154
155	/* -----------------------------------------------------
156	 * void bl31_plat_enable_mmu(uint32_t flags);
157	 *
158	 * Enable MMU in BL31.
159	 * -----------------------------------------------------
160	 */
161func bl31_plat_enable_mmu
162	b	enable_mmu_direct_el3
163endfunc bl31_plat_enable_mmu
164
165	/* -----------------------------------------------------
166	 * void bl32_plat_enable_mmu(uint32_t flags);
167	 *
168	 * Enable MMU in BL32.
169	 * -----------------------------------------------------
170	 */
171func bl32_plat_enable_mmu
172	b	enable_mmu_direct_el1
173endfunc bl32_plat_enable_mmu
174
175
176	/* -----------------------------------------------------
177	 * Platform handler for Uncontainable External Abort.
178	 *
179	 * x0: EA reason
180	 * x1: EA syndrome
181	 * -----------------------------------------------------
182	 */
183func plat_handle_uncontainable_ea
184	b	report_unhandled_exception
185endfunc plat_handle_uncontainable_ea
186
187	/* -----------------------------------------------------
188	 * Platform handler for Double Fault.
189	 *
190	 * x0: EA reason
191	 * x1: EA syndrome
192	 * -----------------------------------------------------
193	 */
194func plat_handle_double_fault
195	b	report_unhandled_exception
196endfunc plat_handle_double_fault
197
198	/* -----------------------------------------------------
199	 * Platform handler for EL3 External Abort.
200	 * -----------------------------------------------------
201	 */
202func plat_handle_el3_ea
203	b	report_unhandled_exception
204endfunc plat_handle_el3_ea
205