Skip to content

Commit 052abc0

Browse files
Add function to get the core ID.
1 parent b164494 commit 052abc0

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

cortex-ar/src/asm.rs

+12
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,15 @@ pub fn sev() {
5656
core::arch::asm!("sev");
5757
}
5858
}
59+
60+
/// Which core are we?
61+
///
62+
/// Return the bottom 24-bits of the MPIDR
63+
#[inline]
64+
pub fn core_id() -> u32 {
65+
let r: u32;
66+
unsafe {
67+
core::arch::asm!("MRC p15, 0, {}, c0, c0, 5", out(reg) r, options(nomem, nostack, preserves_flags));
68+
}
69+
return r & 0x00FF_FFFF;
70+
}

0 commit comments

Comments
 (0)