mirror of
https://github.com/rcore-os/rCore.git
synced 2024-11-22 08:06:17 +04:00
Use tp to save hart id in riscv
This commit is contained in:
parent
698732105b
commit
0086768392
2
kernel/Cargo.lock
generated
2
kernel/Cargo.lock
generated
@ -722,7 +722,7 @@ checksum = "3a385d94f3f62e60445a0adb9ff8d9621faa272234530d4c0f848ec98f88e316"
|
||||
[[package]]
|
||||
name = "trapframe"
|
||||
version = "0.3.0"
|
||||
source = "git+https://github.com/rcore-os/trapframe-rs?rev=0efd4bd#0efd4bd5214971d635f5d3ee38884c987b876029"
|
||||
source = "git+https://github.com/rcore-os/trapframe-rs?rev=ece17c9#ece17c9aa3995cb67a5e46ec7fbf1dd590936549"
|
||||
dependencies = [
|
||||
"log",
|
||||
"raw-cpuid",
|
||||
|
@ -74,7 +74,7 @@ rcore-fs-devfs = { git = "https://github.com/rcore-os/rcore-fs", rev = "517af47"
|
||||
rlibc = "1.0"
|
||||
smoltcp = { git = "https://github.com/rcore-os/smoltcp", rev = "5bd87c7c", default-features = false, features = ["alloc", "log", "ethernet", "proto-ipv4", "proto-igmp", "socket-icmp", "socket-udp", "socket-tcp", "socket-raw"] }
|
||||
spin = "0.5"
|
||||
trapframe = { git = "https://github.com/rcore-os/trapframe-rs", rev = "0efd4bd" }
|
||||
trapframe = { git = "https://github.com/rcore-os/trapframe-rs", rev = "ece17c9" }
|
||||
virtio-drivers = { git = "https://github.com/rcore-os/virtio-drivers", rev = "dfa70e14" }
|
||||
volatile = "0.2"
|
||||
woke = "0.0.2"
|
||||
|
@ -1,17 +1,14 @@
|
||||
// TODO
|
||||
// tp is unused in kernel space
|
||||
pub unsafe fn set_cpu_id(cpu_id: usize) {
|
||||
//llvm_asm!("mv gp, $0" : : "r"(cpu_id));
|
||||
llvm_asm!("mv tp, $0" : : "r"(cpu_id));
|
||||
}
|
||||
|
||||
pub fn id() -> usize {
|
||||
0
|
||||
/*
|
||||
let cpu_id;
|
||||
unsafe {
|
||||
llvm_asm!("mv $0, gp" : "=r"(cpu_id));
|
||||
llvm_asm!("mv $0, tp" : "=r"(cpu_id));
|
||||
}
|
||||
cpu_id
|
||||
*/
|
||||
}
|
||||
|
||||
pub fn send_ipi(cpu_id: usize) {
|
||||
|
@ -445,7 +445,7 @@ pub fn spawn(thread: Arc<Thread>) {
|
||||
Syscall => exit = handle_syscall(&thread, &mut cx).await,
|
||||
IrqMin..=IrqMax => {
|
||||
crate::arch::interrupt::ack(trap_num);
|
||||
info!("handle irq {:#x}", trap_num);
|
||||
trace!("handle irq {:#x}", trap_num);
|
||||
if trap_num == Timer {
|
||||
crate::arch::interrupt::timer();
|
||||
} else {
|
||||
@ -460,7 +460,10 @@ pub fn spawn(thread: Arc<Thread>) {
|
||||
thread.vm.lock().handle_page_fault(addr as usize);
|
||||
}
|
||||
_ => {
|
||||
panic!("unhandled trap {} {:x?}", trap_num, cx);
|
||||
panic!(
|
||||
"unhandled trap in thread {} {} {:x?}",
|
||||
thread.tid, trap_num, cx
|
||||
);
|
||||
}
|
||||
}
|
||||
thread.end_running(cx);
|
||||
|
@ -316,9 +316,7 @@ impl Syscall<'_> {
|
||||
/// Get the current thread id
|
||||
pub fn sys_gettid(&mut self) -> SysResult {
|
||||
info!("gettid");
|
||||
// use pid as tid for now
|
||||
//Ok(thread::current().id())
|
||||
Ok(0)
|
||||
Ok(self.thread.tid)
|
||||
}
|
||||
|
||||
/// Get the parent process id
|
||||
|
Loading…
Reference in New Issue
Block a user