diff --git a/src/context/mod.rs b/src/context/mod.rs index b815690..f0bd6c0 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -1,4 +1,6 @@ //! Context management +//! https://en.wikipedia.org/wiki/Context_switch +//! https://wiki.osdev.org/Context_Switching use alloc::boxed::Box; use core::alloc::{Alloc, GlobalAlloc, Layout}; use core::sync::atomic::Ordering; diff --git a/src/lib.rs b/src/lib.rs index a8e6c59..c3caf85 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -153,6 +153,7 @@ pub fn kmain(cpus: usize, env: &[u8]) -> ! { CPU_ID.store(0, Ordering::SeqCst); CPU_COUNT.store(cpus, Ordering::SeqCst); + //Initialize the first context, stored in kernel/src/context/mod.rs context::init(); let pid = syscall::getpid(); diff --git a/src/syscall/mod.rs b/src/syscall/mod.rs index e65d2a2..b3043b5 100644 --- a/src/syscall/mod.rs +++ b/src/syscall/mod.rs @@ -1,4 +1,6 @@ -///! Syscall handlers +//! +//! This module provides syscall definitions and the necessary resources to parse incoming +//! syscalls extern crate syscall; @@ -44,9 +46,12 @@ pub mod time; /// Validate input pub mod validate; +/// This function is composed of an inner function that returns a `Result`, then the syscall +/// function calls [`Error::mux`] on it pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: usize, stack: &mut SyscallStack) -> usize { #[inline(always)] fn inner(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: usize, stack: &mut SyscallStack) -> Result { + //SYS_* is declared in kernel/syscall/src/number.rs match a & SYS_CLASS { SYS_CLASS_FILE => { let fd = FileHandle::from(b); @@ -204,5 +209,6 @@ pub fn syscall(a: usize, b: usize, c: usize, d: usize, e: usize, f: usize, bp: u } */ + // errormux turns Result into -errno Error::mux(result) }