blob: 8cf067f20147d23ce10e7db815470fa425494cd3 [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"
9#include "platform.h"
10
11/* Initial value of each entry in the cpus_table[] array */
12#define NO_CPU 0xDEADDEADDEADDEAD
13
14/*
15 * Declare a per-CPU array to mark the CPUs presence.
16 *
17 * If cpus_table[i] == NO_CPU then CPU 'i' hasn't successfully booted to the
18 * to the EL3 test payload yet.
19 *
20 * Otherwise, it successfully booted (and cpus_table[i] should contain the
21 * CPU MPID).
22 */
23 .data
24 .align 3
25cpus_table:
26 .rept CPUS_COUNT
27 .quad NO_CPU
28 .endr
29
30
31 .text
32 .global mark_cpu_presence
33 .global is_cpu_present
34
35 /*
36 * void mark_cpu_presence();
37 * Mark the calling CPU present in the CPUs array.
38 * clobbers: x0, x1, x2, x9
39 */
40func mark_cpu_presence
41 /* Store masked MPID in x2 */
42 mrs x0, mpidr_el1
43 ldr x1, =MPIDR_AFFINITY_MASK
44 and x2, x0, x1
45
46 /* Store core position in x0 */
47 mov x9, x30
48 bl platform_get_core_pos
49 mov x30, x9
50
51 /* Write masked CPU MPID in the CPU entry */
52 adr x1, cpus_table
53 add x1, x1, x0, lsl #3
54 str x2, [x1]
55
56 ret
57endfunc mark_cpu_presence
58
59 /*
60 * unsigned int is_cpu_present(unsigned int core_pos);
61 * Return 0 if CPU is absent, 1 if it is present.
62 * clobbers: x0, x1
63 */
64func is_cpu_present
65 adr x1, cpus_table
66 add x1, x1, x0, lsl #3
67 ldr x0, [x1]
68
69 ldr x1, =NO_CPU
70 cmp x0, x1
71 b.eq 1f
72 mov x0, #1
73 ret
741:
75 mov x0, #0
76 ret
77endfunc is_cpu_present