Skip to content

Commit

Permalink
Static dummy tasks
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jun 24, 2023
1 parent 1e44ea2 commit f7e7151
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 10 deletions.
6 changes: 3 additions & 3 deletions kernel/src/multitasking/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ const MAX_TASKS: i8 = 127;

//each task has a 4KiB stack containg the cpu state in the bottom part of it
pub struct Task {
stack: [u8; 4096],
cpu_state: *mut CPUState,
running: bool,
pub stack: [u8; 4096],
pub cpu_state: *mut CPUState,
pub running: bool,
}

impl Task {
Expand Down
31 changes: 25 additions & 6 deletions kernel/src/shell/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,30 @@
use crate::filesystem::fat::FAT;
use crate::syscalls::print::PRINTER;
use crate::multitasking::task::Task;
use crate::multitasking::task::CPUState;
use crate::multitasking::task::TASK_MANAGER;

const APP_TARGET: u32 = 0x0050_0000;
const APP_SIGNATURE: u32 = 0xB16B00B5;

static mut TASK_A: Task = Task {
stack: [0; 4096],
cpu_state: 0 as *mut CPUState,
running: false,
};

static mut TASK_B: Task = Task {
stack: [0; 4096],
cpu_state: 0 as *mut CPUState,
running: false,
};

static mut TASK_C: Task = Task {
stack: [0; 4096],
cpu_state: 0 as *mut CPUState,
running: false,
};

const HELP: &'static str = "Available commands:
ls - lists root directory entries
cat <file> - displays content of a file
Expand Down Expand Up @@ -125,16 +144,16 @@ impl Shell {

match a {
'a' => {
let mut task1 = Task::new(task_a as u32);
TASK_MANAGER.add_task(&mut task1 as *mut Task);
TASK_A = Task::new(task_a as u32);
TASK_MANAGER.add_task(&mut TASK_A as *mut Task);
}
'b' => {
let mut task1 = Task::new(task_b as u32);
TASK_MANAGER.add_task(&mut task1 as *mut Task);
TASK_B = Task::new(task_b as u32);
TASK_MANAGER.add_task(&mut TASK_B as *mut Task);
}
'c' => {
let mut task1 = Task::new(task_c as u32);
TASK_MANAGER.add_task(&mut task1 as *mut Task);
TASK_C = Task::new(task_c as u32);
TASK_MANAGER.add_task(&mut TASK_C as *mut Task);
}
_ => {
libfelix::println!("Specify test a, b, or c!");
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "nightly-2023-05-04"
channel = "nightly"
components = ["rustfmt", "rust-src"]

0 comments on commit f7e7151

Please sign in to comment.