2 * Copyright (c) 2018, ARM Limited and Contributors. All rights reserved.
4 * SPDX-License-Identifier: BSD-3-Clause
7 #include <asm_macros.S>
9 #include <platform_def.h>
11 .weak plat_my_core_pos
12 .globl plat_crash_console_init
13 .globl plat_crash_console_putc
14 .globl plat_crash_console_flush
15 .weak platform_mem_init
16 .globl plat_ls_calc_core_pos
19 /* -----------------------------------------------------
20 * unsigned int plat_my_core_pos(void)
21 * This function uses the plat_ls_calc_core_pos()
22 * definition to get the index of the calling CPU.
23 * -----------------------------------------------------
27 b plat_ls_calc_core_pos
28 endfunc plat_my_core_pos
30 /* -----------------------------------------------------
31 * unsigned int plat_ls_calc_core_pos(u_register_t mpidr)
32 * Helper function to calculate the core position.
33 * With this function: CorePos = (ClusterId * 4) +
35 * -----------------------------------------------------
37 func plat_ls_calc_core_pos
38 and x1, x0, #MPIDR_CPU_MASK
39 and x0, x0, #MPIDR_CLUSTER_MASK
40 add x0, x1, x0, LSR #6
42 endfunc plat_ls_calc_core_pos
44 /* ---------------------------------------------
45 * int plat_crash_console_init(void)
46 * Function to initialize the crash console
47 * without a C Runtime to print crash report.
48 * Clobber list : x0 - x4
49 * ---------------------------------------------
53 /* -----------------------------------------------------
54 * int plat_crash_console_init(void)
55 * Use normal console by default. Switch it to crash
56 * mode so serial consoles become active again.
57 * NOTE: This default implementation will only work for
58 * crashes that occur after a normal console (marked
59 * valid for the crash state) has been registered with
60 * the console framework. To debug crashes that occur
61 * earlier, the platform has to override these functions
62 * with an implementation that initializes a console
63 * driver with hardcoded parameters. See
64 * docs/porting-guide.rst for more information.
65 * -----------------------------------------------------
67 func plat_crash_console_init
68 #if defined(IMAGE_BL1)
70 * BL1 code can possibly crash so early that the data segment is not yet
71 * accessible. Don't risk undefined behavior by trying to run the normal
72 * console framework. Platforms that want to debug BL1 will need to
73 * override this with custom functions that can run from registers only.
79 mov x0, #CONSOLE_FLAG_CRASH
80 bl console_switch_state
84 endfunc plat_crash_console_init
86 /* -----------------------------------------------------
87 * void plat_crash_console_putc(int character)
88 * Output through the normal console by default.
89 * -----------------------------------------------------
91 func plat_crash_console_putc
93 endfunc plat_crash_console_putc
95 /* -----------------------------------------------------
96 * void plat_crash_console_flush(void)
97 * Flush normal console by default.
98 * -----------------------------------------------------
100 func plat_crash_console_flush
102 endfunc plat_crash_console_flush
104 #else /* MULTI_CONSOLE_API */
106 /* -----------------------------------------------------
107 * In the old API these are all no-op stubs that need to
108 * be overridden by the platform to be useful.
109 * -----------------------------------------------------
111 func plat_crash_console_init
112 mov_imm x0, PLAT_LS1043_UART_BASE
113 mov_imm x1, PLAT_LS1043_UART_CLOCK
114 mov_imm x2, PLAT_LS1043_UART_BAUDRATE
116 endfunc plat_crash_console_init
118 /* ---------------------------------------------
119 * int plat_crash_console_putc(int c)
120 * Function to print a character on the crash
121 * console without a C Runtime.
122 * Clobber list : x1, x2
123 * ---------------------------------------------
125 func plat_crash_console_putc
126 mov_imm x1, PLAT_LS1043_UART_BASE
128 endfunc plat_crash_console_putc
130 /* ---------------------------------------------
131 * int plat_crash_console_flush()
132 * Function to force a write of all buffered
133 * data that hasn't been output.
134 * Out : return -1 on error else return 0.
135 * Clobber list : r0 - r1
136 * ---------------------------------------------
138 func plat_crash_console_flush
139 mov_imm x1, PLAT_LS1043_UART_BASE
141 endfunc plat_crash_console_flush
143 /* ---------------------------------------------------------------------
144 * We don't need to carry out any memory initialization on LS
145 * platforms. The Secure SRAM is accessible straight away.
146 * ---------------------------------------------------------------------
148 func platform_mem_init
150 endfunc platform_mem_init