blob: 48718c2e20e60c3abeed0e9d92c37f41c78d4ab5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
use crate::cpu_locals::CPULocals;
use core::{arch::asm, ptr::NonNull};
pub mod interrupts;
pub mod paging;
/// Returns a pointer to the per-CPU locals.
pub fn get_cpu_locals() -> NonNull<CPULocals> {
// SAFETY: The entrypoint sets this up, and safe code cannot invalidate it.
unsafe {
let tp;
asm!("mv {out}, tp", out = out(reg) tp);
NonNull::new_unchecked(tp)
}
}
/// Halts the hart.
pub fn sleep_forever() -> ! {
loop {
unsafe { asm!("wfi") }
}
}
|