From 9d1fb3013dd72d06486af6b2067114562310d708 Mon Sep 17 00:00:00 2001 From: 17liamnaddell <liamnprg@gmail.com> Date: Wed, 18 Jul 2018 22:48:08 -0400 Subject: [PATCH] First round of documentation changes --- src/context/mod.rs | 2 ++ src/lib.rs | 1 + src/syscall/mod.rs | 8 +++++++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/src/context/mod.rs b/src/context/mod.rs index b815690f..f0bd6c07 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 a8e6c59c..c3caf85a 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 e65d2a22..b3043b58 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<usize>`, 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<usize> { + //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<usize> into -errno Error::mux(result) } -- GitLab