blob: 1da2d4cadd8aaf78ea414eca082cffa44e73e792 [file] [log] [blame]
Soby Mathew0d268dc2016-07-11 14:13:56 +01001/*
Jimmy Brisson39f9eee2020-08-05 13:44:05 -05002 * Copyright (c) 2016-2020, ARM Limited and Contributors. All rights reserved.
Soby Mathew0d268dc2016-07-11 14:13:56 +01003 *
dp-armfa3cf0b2017-05-03 09:38:09 +01004 * SPDX-License-Identifier: BSD-3-Clause
Soby Mathew0d268dc2016-07-11 14:13:56 +01005 */
6#include <asm_macros.S>
7#include <platform_def.h>
8
9 .weak plat_arm_calc_core_pos
10 .weak plat_my_core_pos
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000011 .globl plat_crash_console_init
12 .globl plat_crash_console_putc
13 .globl plat_crash_console_flush
Soby Mathew0d268dc2016-07-11 14:13:56 +010014
15 /* -----------------------------------------------------
16 * unsigned int plat_my_core_pos(void)
17 * This function uses the plat_arm_calc_core_pos()
18 * definition to get the index of the calling CPU.
19 * -----------------------------------------------------
20 */
21func plat_my_core_pos
22 ldcopr r0, MPIDR
23 b plat_arm_calc_core_pos
24endfunc plat_my_core_pos
25
26 /* -----------------------------------------------------
27 * unsigned int plat_arm_calc_core_pos(uint64_t mpidr)
28 * Helper function to calculate the core position.
29 * With this function: CorePos = (ClusterId * 4) +
30 * CoreId
31 * -----------------------------------------------------
32 */
33func plat_arm_calc_core_pos
34 and r1, r0, #MPIDR_CPU_MASK
35 and r0, r0, #MPIDR_CLUSTER_MASK
36 add r0, r1, r0, LSR #6
37 bx lr
38endfunc plat_arm_calc_core_pos
Jeenu Viswambharanff640c42016-11-28 09:59:27 +000039
40 /* ---------------------------------------------
41 * int plat_crash_console_init(void)
42 * Function to initialize the crash console
43 * without a C Runtime to print crash report.
44 * Clobber list : r0 - r3
45 * ---------------------------------------------
46 */
47func plat_crash_console_init
48 ldr r0, =PLAT_ARM_CRASH_UART_BASE
49 ldr r1, =PLAT_ARM_CRASH_UART_CLK_IN_HZ
50 ldr r2, =ARM_CONSOLE_BAUDRATE
Daniel Boulby05e7f562018-09-19 13:58:20 +010051 b console_pl011_core_init
Jeenu Viswambharanff640c42016-11-28 09:59:27 +000052endfunc plat_crash_console_init
53
54 /* ---------------------------------------------
55 * int plat_crash_console_putc(int c)
56 * Function to print a character on the crash
57 * console without a C Runtime.
58 * Clobber list : r1 - r2
59 * ---------------------------------------------
60 */
61func plat_crash_console_putc
62 ldr r1, =PLAT_ARM_CRASH_UART_BASE
Daniel Boulby05e7f562018-09-19 13:58:20 +010063 b console_pl011_core_putc
Jeenu Viswambharanff640c42016-11-28 09:59:27 +000064endfunc plat_crash_console_putc
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000065
66 /* ---------------------------------------------
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050067 * void plat_crash_console_flush()
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000068 * Function to force a write of all buffered
69 * data that hasn't been output.
Jimmy Brisson39f9eee2020-08-05 13:44:05 -050070 * Out : void.
Jeenu Viswambharan46343c02018-01-25 12:49:57 +000071 * Clobber list : r0
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000072 * ---------------------------------------------
73 */
74func plat_crash_console_flush
Jeenu Viswambharan46343c02018-01-25 12:49:57 +000075 ldr r0, =PLAT_ARM_CRASH_UART_BASE
Daniel Boulby05e7f562018-09-19 13:58:20 +010076 b console_pl011_core_flush
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000077endfunc plat_crash_console_flush