Soby Mathew | 0d268dc | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 1 | /* |
Jeenu Viswambharan | 46343c0 | 2018-01-25 12:49:57 +0000 | [diff] [blame] | 2 | * Copyright (c) 2016-2018, ARM Limited and Contributors. All rights reserved. |
Soby Mathew | 0d268dc | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 3 | * |
dp-arm | fa3cf0b | 2017-05-03 09:38:09 +0100 | [diff] [blame] | 4 | * SPDX-License-Identifier: BSD-3-Clause |
Soby Mathew | 0d268dc | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 5 | */ |
| 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 Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 11 | .globl plat_crash_console_init |
| 12 | .globl plat_crash_console_putc |
| 13 | .globl plat_crash_console_flush |
Soby Mathew | 0d268dc | 2016-07-11 14:13:56 +0100 | [diff] [blame] | 14 | |
| 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 | */ |
| 21 | func plat_my_core_pos |
| 22 | ldcopr r0, MPIDR |
| 23 | b plat_arm_calc_core_pos |
| 24 | endfunc 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 | */ |
| 33 | func 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 |
| 38 | endfunc plat_arm_calc_core_pos |
Jeenu Viswambharan | ff640c4 | 2016-11-28 09:59:27 +0000 | [diff] [blame] | 39 | |
| 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 | */ |
| 47 | func 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 |
| 52 | endfunc 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 | */ |
| 61 | func plat_crash_console_putc |
| 62 | ldr r1, =PLAT_ARM_CRASH_UART_BASE |
| 63 | b console_core_putc |
| 64 | endfunc plat_crash_console_putc |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 65 | |
| 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. |
Jeenu Viswambharan | 46343c0 | 2018-01-25 12:49:57 +0000 | [diff] [blame] | 71 | * Clobber list : r0 |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 72 | * --------------------------------------------- |
| 73 | */ |
| 74 | func plat_crash_console_flush |
Jeenu Viswambharan | 46343c0 | 2018-01-25 12:49:57 +0000 | [diff] [blame] | 75 | ldr r0, =PLAT_ARM_CRASH_UART_BASE |
Antonio Nino Diaz | d3ec543 | 2017-02-17 17:11:27 +0000 | [diff] [blame] | 76 | b console_core_flush |
| 77 | endfunc plat_crash_console_flush |