1/*
2 * Copyright (c) 2006-2021, RT-Thread Development Team
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 *
6 * Change Logs:
7 * Date           Author       Notes
8 * 2021-04-29     Carl    the first version
9 *
10 */
11
12#include "rtconfig.h"
13
14.globl rt_hw_cpu_id
15rt_hw_cpu_id:
16    mrc p15, 0, r0, c0, c0, 5
17    ubfx r0, r0, #0, #12
18    cmp r0, #0
19    beq core0
20    cmp r0, #1
21    beq core1
22    cmp r0, #256
23    beq core2
24    ldr r1,= #257
25    cmp r0, r1
26    beq core3
27    b default
28core0:
29    mov r0, #0
30    b return
31core1:
32    mov r0, #1
33    b return
34core2:
35    mov r0, #2
36    b return
37core3:
38    mov r0, #3
39    b return
40default:
41    and r0, r0, #15
42return:
43    bx lr
44
45