Skip to content

Commit

Permalink
Static app task
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jun 30, 2023
1 parent 0135726 commit c084655
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 21 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,8 @@ Or you can run it on a real x86 computer by copying the disk image to a USB driv
The following features are planned to be added sooner or later:
- paging
- memory allocator
- process manager
- VESA video driver
- networking
- SATA AHCI disk driver
- graphical user interface

Expand Down
49 changes: 31 additions & 18 deletions kernel/src/multitasking/task.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,24 +9,6 @@ pub struct Task {
pub running: bool,
}

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,
};

#[repr(C, packed)]
pub struct CPUState {
//manually pushed
Expand All @@ -52,6 +34,30 @@ static mut IDLE_TASK: Task = Task {
running: false,
};

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

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,
};

impl Task {
//setup task stack, zeroing its cpu state and setting entry point
pub fn init(&mut self, entry_point: u32) {
Expand Down Expand Up @@ -195,6 +201,13 @@ impl TaskManager {
}
}

pub fn run_app(&mut self, app_entry_point: u32) {
unsafe {
APP_TASK.init(app_entry_point as u32);
self.add_task(&mut APP_TASK as *mut Task);
}
}

pub fn add_dummy_task_a(&mut self) {
unsafe {
TASK_A.init(task_a as u32);
Expand Down
3 changes: 1 addition & 2 deletions kernel/src/shell/shell.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,7 @@ impl Shell {
let signature = *(APP_TARGET as *mut u32);

if signature == APP_SIGNATURE {
//let mut task = Task::new((APP_TARGET + 4) as u32);
//TASK_MANAGER.add_task(&mut task as *mut Task);
TASK_MANAGER.run_app((APP_TARGET + 4) as u32);
} else {
libfelix::println!("File is not a valid executable!");
}
Expand Down

0 comments on commit c084655

Please sign in to comment.