Files
RedBear-OS/src/arch/aarch64/misc.rs
T
Red Bear OS 82feefbaee Red Bear OS kernel baseline
From release 0.1.0 pre-patched archive.
This includes all Red Bear modifications previously maintained
as patches in local/patches/kernel/.
2026-06-27 09:19:25 +03:00

24 lines
653 B
Rust

use crate::{
cpu_set::LogicalCpuId,
memory::{RmmA, RmmArch},
percpu::PercpuBlock,
};
impl PercpuBlock {
pub fn current() -> &'static Self {
unsafe { &*(crate::arch::device::cpu::registers::control_regs::tpidr_el1() as *const Self) }
}
}
#[cold]
pub unsafe fn init(cpu_id: LogicalCpuId) {
unsafe {
let frame = crate::memory::allocate_frame().expect("failed to allocate percpu memory");
let virt = RmmA::phys_to_virt(frame.base()).data() as *mut PercpuBlock;
virt.write(PercpuBlock::init(cpu_id));
crate::arch::device::cpu::registers::control_regs::tpidr_el1_write(virt as u64);
}
}