Function os::task::processor::current_kstack_top
source · pub fn current_kstack_top() -> usize
diff --git a/main/os/task/processor/fn.current_kstack_top.html b/main/os/task/processor/fn.current_kstack_top.html index 617d01c0..48201b44 100644 --- a/main/os/task/processor/fn.current_kstack_top.html +++ b/main/os/task/processor/fn.current_kstack_top.html @@ -1 +1 @@ -
pub fn current_process() -> Arc<ProcessControlBlock>
pub fn current_process() -> Arc<ProcessControlBlock>
pub fn current_task() -> Option<Arc<TaskControlBlock>>
pub fn current_task() -> Option<Arc<TaskControlBlock>>
pub fn current_trap_cx() -> &'static mut TrapContext
pub fn current_trap_cx() -> &'static mut TrapContext
pub fn take_current_task() -> Option<Arc<TaskControlBlock>>
pub fn take_current_task() -> Option<Arc<TaskControlBlock>>
pub struct PROCESSOR {
+PROCESSOR in os::task::processor - Rust pub struct PROCESSOR {
__private_field: (),
}
Fields§
§__private_field: ()
Methods from Deref<Target = UPIntrFreeCell<Processor>>§
sourcepub fn exclusive_access(&self) -> UPIntrRefMut<'_, T>
Panic if the data has been borrowed.
sourcepub fn exclusive_session<F, V>(&self, f: F) -> Vwhere
- F: FnOnce(&mut T) -> V,
Trait Implementations§
source§impl Deref for PROCESSOR
§type Target = UPIntrFreeCell<Processor>
The resulting type after dereferencing.source§fn deref(&self) -> &UPIntrFreeCell<Processor>
Dereferences the value.source§impl LazyStatic for PROCESSOR
Auto Trait Implementations§
§impl RefUnwindSafe for PROCESSOR
§impl Send for PROCESSOR
§impl Sync for PROCESSOR
§impl Unpin for PROCESSOR
§impl UnwindSafe for PROCESSOR
Blanket Implementations§
Trait Implementations§
source§impl Deref for PROCESSOR
§type Target = UPIntrFreeCell<Processor>
The resulting type after dereferencing.source§fn deref(&self) -> &UPIntrFreeCell<Processor>
Dereferences the value.source§impl LazyStatic for PROCESSOR
Auto Trait Implementations§
§impl RefUnwindSafe for PROCESSOR
§impl Send for PROCESSOR
§impl Sync for PROCESSOR
§impl Unpin for PROCESSOR
§impl UnwindSafe for PROCESSOR
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
diff --git a/main/os/task/processor/struct.Processor.html b/main/os/task/processor/struct.Processor.html
index 0a712d87..39b1dd09 100644
--- a/main/os/task/processor/struct.Processor.html
+++ b/main/os/task/processor/struct.Processor.html
@@ -1,7 +1,7 @@
-Processor in os::task::processor - Rust pub struct Processor {
+Processor in os::task::processor - Rust pub struct Processor {
current: Option<Arc<TaskControlBlock>>,
idle_task_cx: TaskContext,
-}
Fields§
§current: Option<Arc<TaskControlBlock>>
§idle_task_cx: TaskContext
Implementations§
source§impl Processor
sourcepub fn new() -> Self
sourcefn get_idle_task_cx_ptr(&mut self) -> *mut TaskContext
sourcepub fn take_current(&mut self) -> Option<Arc<TaskControlBlock>>
sourcepub fn current(&self) -> Option<Arc<TaskControlBlock>>
Auto Trait Implementations§
§impl !RefUnwindSafe for Processor
§impl Send for Processor
§impl Sync for Processor
§impl Unpin for Processor
§impl !UnwindSafe for Processor
Blanket Implementations§
source§impl<T> Any for Twhere
+}Fields§
§current: Option<Arc<TaskControlBlock>>
§idle_task_cx: TaskContext
Implementations§
source§impl Processor
sourcepub fn new() -> Self
sourcefn get_idle_task_cx_ptr(&mut self) -> *mut TaskContext
sourcepub fn take_current(&mut self) -> Option<Arc<TaskControlBlock>>
sourcepub fn current(&self) -> Option<Arc<TaskControlBlock>>
Auto Trait Implementations§
§impl !RefUnwindSafe for Processor
§impl Send for Processor
§impl Sync for Processor
§impl Unpin for Processor
§impl !UnwindSafe for Processor
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
diff --git a/main/src/os/task/processor.rs.html b/main/src/os/task/processor.rs.html
index 8a32ed0e..11038d3c 100644
--- a/main/src/os/task/processor.rs.html
+++ b/main/src/os/task/processor.rs.html
@@ -101,12 +101,21 @@
101
102
103
+104
+105
+106
+107
+108
+109
+110
+111
use super::__switch;
use super::{fetch_task, TaskStatus};
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 {
@@ -194,8 +203,15 @@
}
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) {
let idle_task_cx_ptr =