Renamed exceptions to follow CamlCase convention

This commit is contained in:
François Autin 2023-03-23 20:54:05 +01:00
parent 43de76bd72
commit 21159d3d98
No known key found for this signature in database
GPG Key ID: 343F5D382E1DD77C
2 changed files with 20 additions and 22 deletions

View File

@ -11,16 +11,17 @@ use std::fs::File;
* Decommenter la variant si il est utilisé quelque part
*/
pub enum ExceptionType {
NO_EXCEPTION,//Everything ok!
//Everything ok!
NoException,
//SYSCALL_EXCEPTION,//A program executed a system call.
PAGEFAULT_EXCEPTION,//Page fault exception
READONLY_EXCEPTION,//Write attempted to a page marked "read-only" */
BUSERROR_EXCEPTION,
PagefaultException,//Page fault exception
ReadOnlyException,//Write attempted to a page marked "read-only" */
BusErrorException,
/* translation resulted
in an invalid physical
address (mis-aligned or
out-of-bounds) */
ADDRESSERROR_EXCEPTION, /* Reference that was
AddressErrorException, /* Reference that was
not mapped in the address
space */
//OVERFLOW_EXCEPTION, //Integer overflow in add or sub.
@ -30,18 +31,15 @@ pub enum ExceptionType {
pub const STACK_REG: usize = 2;
pub const NUM_INT_REGS: usize = 32;
pub const NUM_FP_REGS: usize = 32;
//max number of physical page
/// max number of physical pages
pub const NUM_PHY_PAGE : u64 = 400;
//doit etre une puissance de deux
/// Must be 2^x
pub const PAGE_SIZE : u64 = 128;
//doit etre un multiple de PAGE_SIZE
/// Must be a multiple of PAGE_SIZE
pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE*100) as usize;
pub trait RegisterNum: Add<Output=Self> + Sub<Output=Self> + PartialEq + Copy {}
impl RegisterNum for i64 {}

View File

@ -29,7 +29,7 @@ impl <'a>MMU <'_>{
MMU::translate(mmu, virt_addr, &mut phy_addr_double_check, false);
match exc {
ExceptionType::NO_EXCEPTION => {
ExceptionType::NoException => {
if phy_addr != phy_addr_double_check {
//Besoin ici d'une impl pour gestion d'exeption
//dans nachos : g-machine->RaiseException(exc, virt_addr);
@ -44,7 +44,7 @@ impl <'a>MMU <'_>{
_ => {
//Besoin ici d'une impl pour gestion d'exeption
//dans nachos : g-machine->RaiseException(exc, virt_addr);
println!("Error from mmu_read_mem :: Exception different from NO_EXCEPTION");
println!("Error from mmu_read_mem :: Exception different from NoException");
return false;
}
}
@ -63,7 +63,7 @@ impl <'a>MMU <'_>{
MMU::translate(mmu, virt_addr, &mut phy_addr_double_check, true);
match exc {
ExceptionType::NO_EXCEPTION => {
ExceptionType::NoException => {
if phy_addr != phy_addr_double_check {
//Besoin ici d'une impl pour gestion d'exeption
//dans nachos : g-machine->RaiseException(exc, virt_addr);
@ -78,7 +78,7 @@ impl <'a>MMU <'_>{
_ => {
//Besoin ici d'une impl pour gestion d'exeption
//dans nachos : g-machine->RaiseException(exc, virt_addr);
println!("Error from mmu_write_mem :: Exception different from NO_EXCEPTION");
println!("Error from mmu_write_mem :: Exception different from NoException");
return false;
}
}
@ -96,7 +96,7 @@ impl <'a>MMU <'_>{
match &mut mmu.translationTable {
None => {
println!("Error from translate : MMU refers to None (No page Table)");
return ExceptionType::ADDRESSERROR_EXCEPTION;
return ExceptionType::AddressErrorException;
}
Some(table_ref) => {
@ -104,7 +104,7 @@ impl <'a>MMU <'_>{
//On verifie que notre index est valide
if vpn >= table_ref.get_max_num_pages(){
println!("Error from translate :: index is out of bound");
return ExceptionType::ADDRESSERROR_EXCEPTION;
return ExceptionType::AddressErrorException;
}
/*Doc nachos dit que ce test sert a savoir si la page est mappée
@ -113,13 +113,13 @@ impl <'a>MMU <'_>{
*/
if !table_ref.get_bit_read(vpn) && !table_ref.get_bit_write(vpn) {
println!("Error from translate :: virtual page # {} not mapped",vpn);
return ExceptionType::ADDRESSERROR_EXCEPTION;
return ExceptionType::AddressErrorException;
}
//si on souhaite effectuer un acces lecture, on verifie que l'on dispose du droit d'acces sur cette page
if writing && !table_ref.get_bit_write(vpn) {
println!("Error from translate :: write access on a read only virtual page # {}",vpn);
return ExceptionType::READONLY_EXCEPTION;
return ExceptionType::AddressErrorException;
}
//if the page is not yet in main memory, run the page fault manager
@ -129,13 +129,13 @@ impl <'a>MMU <'_>{
println!("We need to update the page table by raising an exception -> not implemented");
//Ici il faudra reverifier le bit valid apres intervention du page fault manager
return ExceptionType::ADDRESSERROR_EXCEPTION;
return ExceptionType::AddressErrorException;
}
//Make sure that the physical adress is correct
if table_ref.get_physical_page(vpn) < 0 || table_ref.get_physical_page(vpn) >= (NUM_PHY_PAGE as i32) {
println!("Error from translate :: no valid correspondance");
return ExceptionType::BUSERROR_EXCEPTION;
return ExceptionType::BusErrorException;
}
//Set U/M bits to 1
@ -151,6 +151,6 @@ impl <'a>MMU <'_>{
}
}
ExceptionType::NO_EXCEPTION
ExceptionType::NoException
}
}