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