Debian Codegraph @

drivers/arm/css/sds/aarch64/sds_helpers.S

raw
1 /*
2 * Copyright (c) 2017, ARM Limited and Contributors. All rights reserved.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7 #include <arch.h>
8 #include <asm_macros.S>
9 #include <drivers/arm/css/sds.h>
10 #include <platform_def.h>
11
12 #include "../sds_private.h"
13
14 .globl sds_get_primary_cpu_id
15
16 /*
17 * int sds_get_primary_cpu_id(void);
18 * Return the primary CPI ID from SDS Structure
19 * Returns CPUID on success or -1 on failure
20 */
21 func sds_get_primary_cpu_id
22 mov_imm x0, PLAT_ARM_SDS_MEM_BASE
23 mov w2, #SDS_REGION_SIGNATURE
24 ldr w1, [x0]
25
26 /* Check if the SDS region signature found */
27 cmp w2, w1, uxth
28 b.ne 2f
29
30 /* Get the structure count from region descriptor in `w1 */
31 ubfx w1, w1, #SDS_REGION_STRUCT_COUNT_SHIFT, #SDS_REGION_STRUCT_COUNT_WIDTH
32 cbz w1, 2f
33 add x0, x0, #SDS_REGION_DESC_SIZE
34
35 /* Initialize the loop iterator count in w3 */
36 mov w3, #0
37 loop_begin:
38 ldrh w2, [x0]
39 cmp w2, #SDS_AP_CPU_INFO_STRUCT_ID
40 b.ne continue_loop
41
42 /* We have found the required structure */
43 ldr w0, [x0,#(SDS_HEADER_SIZE + SDS_AP_CPU_INFO_PRIMARY_CPUID_OFFSET)]
44 ret
45 continue_loop:
46 /* Increment the loop counter and exit loop if counter == structure count */
47 add w3, w3, #0x1
48 cmp w1, w3
49 b.eq 2f
50
51 /* Read the 2nd word in header */
52 ldr w2, [x0,#4]
53 /* Get the structure size from header */
54 ubfx x2, x2, #SDS_HEADER_STRUCT_SIZE_SHIFT, #SDS_HEADER_STRUCT_SIZE_WIDTH
55 /* Add the structure size and SDS HEADER SIZE to point to next header */
56 add x2, x2, #SDS_HEADER_SIZE
57 add x0, x0, x2
58 b loop_begin
59 2:
60 mov w0, #0xffffffff
61 ret
62 endfunc sds_get_primary_cpu_id