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