xref: /rk3399_ARM-atf/plat/common/aarch64/platform_helpers.S (revision ff2743e544f0f82381ebb9dff8f14eacb837d2e0)
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
21#if !ENABLE_PLAT_COMPAT
22	.globl	platform_get_core_pos
23
24#define MPIDR_RES_BIT_MASK	0xff000000
25
26	/* ------------------------------------------------------------------
27	 *  int platform_get_core_pos(int mpidr)
28	 *  Returns the CPU index of the CPU specified by mpidr. This is
29	 *  defined when platform compatibility is disabled to enable Trusted
30	 *  Firmware components like SPD using the old  platform API to work.
31	 *  This API is deprecated and it assumes that the mpidr specified is
32	 *  that of a valid and present CPU. Instead, plat_my_core_pos()
33	 *  should be used for CPU index of the current CPU and
34	 *  plat_core_pos_by_mpidr() should be used for CPU index of a
35	 *  CPU specified by its mpidr.
36	 * ------------------------------------------------------------------
37	 */
38func_deprecated platform_get_core_pos
39	bic	x0, x0, #MPIDR_RES_BIT_MASK
40	mrs	x1, mpidr_el1
41	bic	x1, x1, #MPIDR_RES_BIT_MASK
42	cmp	x0, x1
43	beq	plat_my_core_pos
44	b	platform_core_pos_helper
45endfunc_deprecated platform_get_core_pos
46#endif
47
48	/* -----------------------------------------------------
49	 * Placeholder function which should be redefined by
50	 * each platform.
51	 * -----------------------------------------------------
52	 */
53func plat_report_exception
54	ret
55endfunc plat_report_exception
56
57#if MULTI_CONSOLE_API
58	/* -----------------------------------------------------
59	 * int plat_crash_console_init(void)
60	 * Use normal console by default. Switch it to crash
61	 * mode so serial consoles become active again.
62	 * NOTE: This default implementation will only work for
63	 * crashes that occur after a normal console (marked
64	 * valid for the crash state) has been registered with
65	 * the console framework. To debug crashes that occur
66	 * earlier, the platform has to override these functions
67	 * with an implementation that initializes a console
68	 * driver with hardcoded parameters. See
69	 * docs/porting-guide.rst for more information.
70	 * -----------------------------------------------------
71	 */
72func plat_crash_console_init
73#if defined(IMAGE_BL1)
74	/*
75	 * BL1 code can possibly crash so early that the data segment is not yet
76	 * accessible. Don't risk undefined behavior by trying to run the normal
77	 * console framework. Platforms that want to debug BL1 will need to
78	 * override this with custom functions that can run from registers only.
79	 */
80	mov	x0, #0
81	ret
82#else	/* IMAGE_BL1 */
83	mov	x3, x30
84	mov	x0, #CONSOLE_FLAG_CRASH
85	bl	console_switch_state
86	mov	x0, #1
87	ret	x3
88#endif
89endfunc plat_crash_console_init
90
91	/* -----------------------------------------------------
92	 * void plat_crash_console_putc(int character)
93	 * Output through the normal console by default.
94	 * -----------------------------------------------------
95	 */
96func plat_crash_console_putc
97	b	console_putc
98endfunc plat_crash_console_putc
99
100	/* -----------------------------------------------------
101	 * void plat_crash_console_flush(void)
102	 * Flush normal console by default.
103	 * -----------------------------------------------------
104	 */
105func plat_crash_console_flush
106	b	console_flush
107endfunc plat_crash_console_flush
108
109#else	/* MULTI_CONSOLE_API */
110
111	/* -----------------------------------------------------
112	 * In the old API these are all no-op stubs that need to
113	 * be overridden by the platform to be useful.
114	 * -----------------------------------------------------
115	 */
116func plat_crash_console_init
117	mov	x0, #0
118	ret
119endfunc plat_crash_console_init
120
121func plat_crash_console_putc
122	ret
123endfunc plat_crash_console_putc
124
125func plat_crash_console_flush
126	ret
127endfunc plat_crash_console_flush
128#endif
129
130	/* -----------------------------------------------------
131	 * Placeholder function which should be redefined by
132	 * each platform. This function should preserve x19 - x29.
133	 * -----------------------------------------------------
134	 */
135func plat_reset_handler
136	ret
137endfunc plat_reset_handler
138
139	/* -----------------------------------------------------
140	 * Placeholder function which should be redefined by
141	 * each platform. This function is allowed to use
142	 * registers x0 - x17.
143	 * -----------------------------------------------------
144	 */
145func plat_disable_acp
146	ret
147endfunc plat_disable_acp
148
149	/* -----------------------------------------------------
150	 * void bl1_plat_prepare_exit(entry_point_info_t *ep_info);
151	 * Called before exiting BL1. Default: do nothing
152	 * -----------------------------------------------------
153	 */
154func bl1_plat_prepare_exit
155	ret
156endfunc bl1_plat_prepare_exit
157
158	/* -----------------------------------------------------
159	 * void plat_panic_handler(void) __dead2;
160	 * Endless loop by default.
161	 * -----------------------------------------------------
162	 */
163func plat_panic_handler
164	wfi
165	b	plat_panic_handler
166endfunc plat_panic_handler
167