Skip to content

Commit

Permalink
Add comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mrgian committed Jun 15, 2023
1 parent 5c41782 commit 35dead3
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions kernel/src/shell.rs
Expand Up @@ -33,6 +33,7 @@ pub struct Shell {
}

impl Shell {
//init shell
pub fn init(&mut self) {
self.buffer = [0 as char; 256];
self.cursor = 0;
Expand All @@ -45,13 +46,15 @@ impl Shell {
}
}

//adds new char to shell buffer
pub fn add(&mut self, c: char) {
self.buffer[self.cursor] = c;
self.cursor += 1;

libfelix::print!("{}", c);
}

//backspace, removes last char from buffer and updates cursor
pub fn backspace(&mut self) {
if self.cursor > 0 {
self.buffer[self.cursor] = 0 as char;
Expand All @@ -63,6 +66,7 @@ impl Shell {
}
}

//shell enter
pub fn enter(&mut self) {
unsafe {
PRINTER.new_line();
Expand All @@ -72,6 +76,7 @@ impl Shell {
self.init();
}

//command interpreter
#[allow(unused_unsafe)]
fn interpret(&mut self) {
match self.buffer {
Expand Down Expand Up @@ -152,6 +157,7 @@ impl Shell {
}
}

//shows content of a file in ascii format
pub unsafe fn cat(&mut self, b: &[char]) {
for i in 4..15 {
self.arg[i - 4] = b[i];
Expand All @@ -173,6 +179,7 @@ impl Shell {
}
}

//loads an executable as a task
pub unsafe fn run(&mut self, b: &[char]) {
for i in 4..15 {
self.arg[i - 4] = b[i];
Expand Down Expand Up @@ -218,7 +225,7 @@ fn task_a() {
if a == 300_000_000 {
libfelix::println!("Process A running. {}% complete.", b);
a = 0;
b += 5;
b += 1;

if b == 100 {
libfelix::println!("Process A complete.");
Expand All @@ -237,7 +244,7 @@ fn task_b() {
if a == 300_000_000 {
libfelix::println!("Process B running. {}% complete.", b);
a = 0;
b += 5;
b += 1;

if b == 100 {
libfelix::println!("Process B complete.");
Expand All @@ -256,7 +263,7 @@ fn task_c() {
if a == 300_000_000 {
libfelix::println!("Process C running. {}% complete.", b);
a = 0;
b += 5;
b += 1;

if b == 100 {
libfelix::println!("Process C complete.");
Expand Down

0 comments on commit 35dead3

Please sign in to comment.