diff --git a/os/kernel/src/consts.rs b/os/kernel/src/consts.rs new file mode 100644 index 0000000..97a9b8f --- /dev/null +++ b/os/kernel/src/consts.rs @@ -0,0 +1,5 @@ + + +pub const MAIN_USER_STACK_START: usize = 0x400000000000; +pub const MAX_USER_STACK_SIZE: usize = 0x40000000; +pub const KERNEL_STACK_PAGES: usize = 64; diff --git a/os/kernel/src/lib.rs b/os/kernel/src/lib.rs index b05a2a3..f3825df 100644 --- a/os/kernel/src/lib.rs +++ b/os/kernel/src/lib.rs @@ -62,6 +62,7 @@ pub mod memory; pub mod log; pub mod syscall; pub mod process; +pub mod consts; pub mod built_info { // The file has been placed there by the build script. diff --git a/os/kernel/src/process/thread.rs b/os/kernel/src/process/thread.rs index 1628a4e..c444fc5 100644 --- a/os/kernel/src/process/thread.rs +++ b/os/kernel/src/process/thread.rs @@ -1,3 +1,11 @@ +/* ╔═════════════════════════════════════════════════════════════════════════╗ + ║ Module: thread ║ + ╟─────────────────────────────────────────────────────────────────────────╢ + ║ Descr.: Implementation of threads. ║ + ╟─────────────────────────────────────────────────────────────────────────╢ + ║ Author: Fabian Ruhland, HHU ║ + ╚═════════════════════════════════════════════════════════════════════════╝ +*/ use crate::process::scheduler; use alloc::rc::Rc; use alloc::sync::Arc; @@ -19,14 +27,18 @@ use crate::memory::r#virtual::{VirtualMemoryArea, VmaType}; use crate::process::process::Process; use crate::syscall::syscall_dispatcher::CORE_LOCAL_STORAGE_TSS_RSP0_PTR_INDEX; -pub const MAIN_USER_STACK_START: usize = 0x400000000000; -pub const MAX_USER_STACK_SIZE: usize = 0x40000000; -const KERNEL_STACK_PAGES: usize = 64; +use crate::consts::MAIN_USER_STACK_START; +use crate::consts::MAX_USER_STACK_SIZE; +use crate::consts::KERNEL_STACK_PAGES; + +/** + Description: Each thread has a user and kernel stack. +*/ struct Stacks { kernel_stack: Vec, user_stack: Vec, - old_rsp0: VirtAddr + old_rsp0: VirtAddr // used for thread switching; rsp3 is stored in TSS } pub struct Thread {