From bebd225de81883c41b74a257ad3e7c5d11b7657c Mon Sep 17 00:00:00 2001 From: n9wx <1602946346@qq.com> Date: Fri, 29 Dec 2023 16:21:02 +0800 Subject: [PATCH] fix: backtrace --- os/src/task/processor.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/os/src/task/processor.rs b/os/src/task/processor.rs index dfa7d4c5..96361d7b 100644 --- a/os/src/task/processor.rs +++ b/os/src/task/processor.rs @@ -4,6 +4,7 @@ use super::{ProcessControlBlock, TaskContext, TaskControlBlock}; use crate::sync::UPIntrFreeCell; use crate::trap::TrapContext; use alloc::sync::Arc; +use core::arch::asm; use lazy_static::*; pub struct Processor { @@ -91,7 +92,14 @@ pub fn current_trap_cx_user_va() -> usize { } pub fn current_kstack_top() -> usize { - current_task().unwrap().kstack.get_top() + if let Some(task) = current_task() { + task.kstack.get_top() + } else { + let mut boot_stack_top; + unsafe { asm!("la {},boot_stack_top",out(reg) boot_stack_top) }; + boot_stack_top + } + // current_task().unwrap().kstack.get_top() } pub fn schedule(switched_task_cx_ptr: *mut TaskContext) {