Skip to main content

islet_rmm/
cpu.rs

1use crate::config::NUM_OF_CPU_PER_CLUSTER;
2
3use aarch64_cpu::registers::*;
4
5#[no_mangle]
6pub extern "C" fn get_cpu_id() -> usize {
7    let (cluster, core) = id();
8    cluster * NUM_OF_CPU_PER_CLUSTER + core
9}
10
11#[cfg(any(feature = "fvp", not(feature = "qemu")))]
12#[inline(always)]
13pub fn id() -> (usize, usize) {
14    (
15        MPIDR_EL1.read(MPIDR_EL1::Aff2) as usize,
16        MPIDR_EL1.read(MPIDR_EL1::Aff1) as usize,
17    )
18}
19
20#[cfg(feature = "qemu")]
21#[inline(always)]
22pub fn id() -> (usize, usize) {
23    (
24        MPIDR_EL1.read(MPIDR_EL1::Aff1) as usize,
25        MPIDR_EL1.read(MPIDR_EL1::Aff0) as usize,
26    )
27}