From f7e7151728cfd2df74fa0bd0329c6a04b40ee13e Mon Sep 17 00:00:00 2001 From: mrgian Date: Sat, 24 Jun 2023 18:52:06 +0200 Subject: [PATCH] Static dummy tasks --- kernel/src/multitasking/task.rs | 6 +++--- kernel/src/shell/shell.rs | 31 +++++++++++++++++++++++++------ rust-toolchain.toml | 2 +- 3 files changed, 29 insertions(+), 10 deletions(-) diff --git a/kernel/src/multitasking/task.rs b/kernel/src/multitasking/task.rs index 349431a..6c72859 100644 --- a/kernel/src/multitasking/task.rs +++ b/kernel/src/multitasking/task.rs @@ -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 { diff --git a/kernel/src/shell/shell.rs b/kernel/src/shell/shell.rs index 472cd2f..d6c2ad3 100644 --- a/kernel/src/shell/shell.rs +++ b/kernel/src/shell/shell.rs @@ -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 - displays content of a file @@ -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!"); diff --git a/rust-toolchain.toml b/rust-toolchain.toml index d1a2f31..ce5e6ed 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "nightly-2023-05-04" +channel = "nightly" components = ["rustfmt", "rust-src"]