Skip to content

Commit

Permalink
moved constants from thread.rs to consts.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
schoettner committed Jun 16, 2024
1 parent 21021ea commit 071f2b6
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 4 deletions.
5 changes: 5 additions & 0 deletions os/kernel/src/consts.rs
Original file line number Diff line number Diff line change
@@ -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;
1 change: 1 addition & 0 deletions os/kernel/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
20 changes: 16 additions & 4 deletions os/kernel/src/process/thread.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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<u64, StackAllocator>,
user_stack: Vec<u64, StackAllocator>,
old_rsp0: VirtAddr
old_rsp0: VirtAddr // used for thread switching; rsp3 is stored in TSS
}

pub struct Thread {
Expand Down

0 comments on commit 071f2b6

Please sign in to comment.