Chandni Cherukuri | 8624474 | 2018-11-13 16:16:54 +0530 | [diff] [blame^] | 1 | /* |
| 2 | * Copyright (c) 2018, Arm Limited. All rights reserved. |
| 3 | * |
| 4 | * SPDX-License-Identifier: BSD-3-Clause |
| 5 | */ |
| 6 | |
| 7 | #include <asm_macros.S> |
| 8 | #include <pl011.h> |
| 9 | #include <platform_def.h> |
| 10 | |
| 11 | .globl platform_get_core_pos |
| 12 | .globl plat_crash_console_init |
| 13 | .globl plat_crash_console_putc |
| 14 | .globl plat_crash_console_flush |
| 15 | |
| 16 | /*---------------------------------------------------------------------- |
| 17 | * unsigned int platform_get_core_pos(unsigned long mpid) |
| 18 | * |
| 19 | * Function to calculate the core position on sgi platforms. |
| 20 | * |
| 21 | * (ClusterId * SGI_MAX_CPUS_PER_CLUSTER * SGI_MAX_PE_PER_CPU) + |
| 22 | * (CPUId * SGI_MAX_PE_PER_CPU) + |
| 23 | * ThreadId |
| 24 | * |
| 25 | * which can be simplified as: |
| 26 | * |
| 27 | * ((ClusterId * SGI_MAX_CPUS_PER_CLUSTER + CPUId) * SGI_MAX_PE_PER_CPU) |
| 28 | * + ThreadId |
| 29 | * --------------------------------------------------------------------- |
| 30 | */ |
| 31 | func platform_get_core_pos |
| 32 | /* |
| 33 | * Check for MT bit in MPIDR. If not set, shift MPIDR to left to make it |
| 34 | * look as if in a multi-threaded implementation. |
| 35 | */ |
| 36 | tst x0, #MPIDR_MT_MASK |
| 37 | lsl x3, x0, #MPIDR_AFFINITY_BITS |
| 38 | csel x3, x3, x0, eq |
| 39 | |
| 40 | /* Extract individual affinity fields from MPIDR */ |
| 41 | ubfx x0, x3, #MPIDR_AFF0_SHIFT, #MPIDR_AFFINITY_BITS |
| 42 | ubfx x1, x3, #MPIDR_AFF1_SHIFT, #MPIDR_AFFINITY_BITS |
| 43 | ubfx x2, x3, #MPIDR_AFF2_SHIFT, #MPIDR_AFFINITY_BITS |
| 44 | |
| 45 | /* Compute linear position */ |
| 46 | mov x3, #SGI_MAX_CPUS_PER_CLUSTER |
| 47 | madd x1, x2, x3, x1 |
| 48 | mov x3, #SGI_MAX_PE_PER_CPU |
| 49 | madd x0, x1, x3, x0 |
| 50 | ret |
| 51 | endfunc platform_get_core_pos |
| 52 | |
| 53 | /* --------------------------------------------- |
| 54 | * int plat_crash_console_init(void) |
| 55 | * Function to initialize the crash console |
| 56 | * without a C Runtime to print crash report. |
| 57 | * Clobber list : x0 - x4 |
| 58 | * --------------------------------------------- |
| 59 | */ |
| 60 | func plat_crash_console_init |
| 61 | mov_imm x0, PLAT_ARM_UART_BASE |
| 62 | mov_imm x1, PLAT_ARM_UART_CLK_IN_HZ |
| 63 | mov_imm x2, PL011_BAUDRATE |
| 64 | b console_core_init |
| 65 | endfunc plat_crash_console_init |
| 66 | |
| 67 | /* --------------------------------------------- |
| 68 | * int plat_crash_console_putc(int c) |
| 69 | * Function to print a character on the crash |
| 70 | * console without a C Runtime. |
| 71 | * Clobber list : x1, x2 |
| 72 | * --------------------------------------------- |
| 73 | */ |
| 74 | func plat_crash_console_putc |
| 75 | mov_imm x1, PLAT_ARM_UART_BASE |
| 76 | b console_core_putc |
| 77 | endfunc plat_crash_console_putc |
| 78 | |
| 79 | /* --------------------------------------------- |
| 80 | * int plat_crash_console_flush() |
| 81 | * Function to force a write of all buffered |
| 82 | * data that hasn't been output. |
| 83 | * Out : return -1 on error else return 0. |
| 84 | * Clobber list : r0 - r1 |
| 85 | * --------------------------------------------- |
| 86 | */ |
| 87 | func plat_crash_console_flush |
| 88 | mov_imm x1, PLAT_ARM_UART_BASE |
| 89 | b console_core_flush |
| 90 | endfunc plat_crash_console_flush |