Documentation for the simulator

This commit is contained in:
Rémi Rativel 2023-05-09 22:02:22 +02:00
parent 28200ebc04
commit c60aaa1aae
5 changed files with 64 additions and 14 deletions

View File

@ -1,17 +1,38 @@
//! # Interrupt
//!
//! This module contains an interrupt Handler.
//! The methodes one_trick and idle aren't implemented for now
/// # Interrupt
///
/// Interrupt Handler
#[derive(PartialEq)] #[derive(PartialEq)]
pub struct Interrupt { pub struct Interrupt {
/// Current Status
level: InterruptStatus level: InterruptStatus
} }
impl Interrupt { impl Interrupt {
/// Interrupt constructor
///
/// ### Return
/// Interrupt with status Off
pub fn new() -> Self { pub fn new() -> Self {
Self { Self {
level: InterruptStatus::InterruptOff level: InterruptStatus::InterruptOff
} }
} }
/// Interrupt setter
/// Change the value of the Interrupt
///
/// ### Parameters
/// - **self** the interupt handler
/// - **new_status** the new status value
///
/// ### return
/// The previus status
pub fn set_status(&mut self, new_status: InterruptStatus) -> InterruptStatus { pub fn set_status(&mut self, new_status: InterruptStatus) -> InterruptStatus {
let old = self.level; let old = self.level;
self.level = new_status; self.level = new_status;
@ -25,6 +46,7 @@ impl Interrupt {
todo!(); todo!();
} }
/// Interupt getter
pub fn get_status(&self) -> InterruptStatus { pub fn get_status(&self) -> InterruptStatus {
self.level self.level
} }

View File

@ -1,9 +1,25 @@
//! # Loader
//!
//! This module contains a loader for file section.
//! Following the common standard file format for executable files
//! [ELF (Executable and Linkable Format)](https://en.wikipedia.org/wiki/Executable_and_Linkable_Forma)
//!
//! It's used to charge a programme into the machine from a binary file (.guac files)
//!
//! Basic usage:
//!
//! ```
//! let args = Args::parse();
//! let mut machine = Machine::new(args.debug & 1 != 0, read_settings().unwrap());
//! let (loader, ptr) = loader::Loader::new(args.executable.as_str(), &mut machine, 0).expect("An error occured while parsing the program");
//! ```
use crate::Machine; use crate::Machine;
use std::fs; use std::fs;
use std::io::Read; use std::io::Read;
/// The elf header defines principes aspects of the binary files, it's place at the start of the file /// The elf header defines principes aspects of the binary files, it's place at the start of the file
/// see <https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header> for more informations /// see [ELF file Header](https://en.wikipedia.org/wiki/Executable_and_Linkable_Format#File_header) for more informations
pub struct ElfHeader { pub struct ElfHeader {
/// Defines whether the file is big or little endian /// Defines whether the file is big or little endian
/// true correspond to big endian, false otherwise /// true correspond to big endian, false otherwise

View File

@ -1,4 +1,4 @@
//! # mem_cmp //! # Memory Comparator
//! //!
//! This module contains a MemChecker. //! This module contains a MemChecker.
//! //!

View File

@ -1,8 +1,8 @@
//! # mmu //! # MMU
//! //!
//! This module contains a MMU implementation //! This module contains a MMU implementation
//! //!
//! This part isn't tested and integrated to BurritOS because of the lack of pagination implementation //! This part isn't tested nor integrated to BurritOS because of the lack of pagination implementation
//! //!
//! //!

View File

@ -1,23 +1,35 @@
//Nombre maximum de correspondances dans une table des pages //! # Translation Table
//Cette donnée devra a terme etre recupérée depuis un fichier de configuration //!
//! This module implement a trnslation table used for fot the MMU Emulator
//!
//! This part isn't tested nor integrated to BurritOS,
//! but will be useful in the futur when the pagination will be implemented.
//!
//! It contains:
//! - all the setters and getters for translation table
//! - modificaters of table values
/// Maximum number in a Page Table
/// For a futur evolution of program, this value should be load from a configuration file
const MaxVirtPages : u64 = 200000; const MaxVirtPages : u64 = 200000;
/// Translation Table corresponding to a process
/* Une table de correspondance propre à un processus /// An iteration of type TranslationTable should be possesses by an oject of type Process
* Une variable de type TranslationTable devra etre possédée par un objet de type Process
*/
pub struct TranslationTable{ pub struct TranslationTable{
//capacité de cette table <=> nombre de correspondances possibles /// Table size <=> nb of possible translation
//A voir si cette donnée doit etre immuable
pub maxNumPages : u64, pub maxNumPages : u64,
//la table en question ///The table *Vec impemente Index Trait*
//Vec implemente le trait Index, donc un bon choix
pub pageTable : Vec<PageTableEntry> pub pageTable : Vec<PageTableEntry>
} }
impl TranslationTable { impl TranslationTable {
/// TranslationTable constructor
///
/// ### Return
/// TranslationTable with an empty Vector
pub fn create() -> TranslationTable { pub fn create() -> TranslationTable {
let mut tmp_vec : Vec<PageTableEntry> = Vec::new(); let mut tmp_vec : Vec<PageTableEntry> = Vec::new();