blob: f56b21531153506524766c388261cd2441da12b8 [file] [log] [blame]
Soby Mathew0d268dc2016-07-11 14:13:56 +01001/*
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +00002 * Copyright (c) 2016-2017, 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
51 b console_core_init
52endfunc 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
63 b console_core_putc
64endfunc plat_crash_console_putc
Antonio Nino Diazd3ec5432017-02-17 17:11:27 +000065
66 /* ---------------------------------------------
67 * int plat_crash_console_flush()
68 * Function to force a write of all buffered
69 * data that hasn't been output.
70 * Out : return -1 on error else return 0.
71 * Clobber list : r0 - r1
72 * ---------------------------------------------
73 */
74func plat_crash_console_flush
75 ldr r1, =PLAT_ARM_CRASH_UART_BASE
76 b console_core_flush
77endfunc plat_crash_console_flush