arch cpu_id
This commit is contained in:
parent
1e12ccddb3
commit
934dc13f96
4
kernel/rustkernel/src/arch/cpu.rs
Normal file
4
kernel/rustkernel/src/arch/cpu.rs
Normal file
@ -0,0 +1,4 @@
|
||||
//! Architecture-agnostic CPU functions.
|
||||
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
pub use super::riscv::cpu::cpu_id;
|
@ -1,5 +1,6 @@
|
||||
#[cfg(target_arch = "riscv64")]
|
||||
pub mod riscv;
|
||||
|
||||
pub mod cpu;
|
||||
pub mod interrupt;
|
||||
pub mod power;
|
||||
|
5
kernel/rustkernel/src/arch/riscv/cpu.rs
Normal file
5
kernel/rustkernel/src/arch/riscv/cpu.rs
Normal file
@ -0,0 +1,5 @@
|
||||
use super::asm::r_tp;
|
||||
|
||||
pub fn cpu_id() -> usize {
|
||||
unsafe { r_tp() as usize }
|
||||
}
|
@ -1,5 +1,6 @@
|
||||
pub mod asm;
|
||||
pub mod clint;
|
||||
pub mod cpu;
|
||||
pub mod memlayout;
|
||||
pub mod plic;
|
||||
pub mod power;
|
||||
|
@ -1,5 +1,4 @@
|
||||
use super::{context::Context, process::Process};
|
||||
use crate::arch::riscv::asm::r_tp;
|
||||
use core::ptr::{addr_of_mut, null_mut};
|
||||
|
||||
pub static mut CPUS: [Cpu; crate::NCPU] = [Cpu::new(); crate::NCPU];
|
||||
@ -29,7 +28,7 @@ impl Cpu {
|
||||
/// to prevent race with process being moved
|
||||
/// to a different CPU.
|
||||
pub fn current_id() -> usize {
|
||||
unsafe { r_tp() as usize }
|
||||
crate::arch::cpu::cpu_id()
|
||||
}
|
||||
/// Return this CPU's cpu struct.
|
||||
/// Interrupts must be disabled.
|
||||
|
Loading…
x
Reference in New Issue
Block a user