taille de la memoire recalculée
This commit is contained in:
parent
88a0b31300
commit
ea309ab124
@ -34,10 +34,13 @@ pub const STACK_REG: usize = 2;
|
||||
pub const NUM_INT_REGS: usize = 32;
|
||||
pub const NUM_FP_REGS: usize = 32;
|
||||
|
||||
/// doit disparaitre
|
||||
const MEM_SIZE : usize = 0x500000;
|
||||
//max number of physical page
|
||||
pub const NUM_PHY_PAGE : u64 = 400;
|
||||
//doit etre une puissance de deux
|
||||
pub const PAGE_SIZE : u64 = 128;
|
||||
//doit etre un multiple de PAGE_SIZE
|
||||
pub const MEM_SIZE : usize = (PAGE_SIZE*NUM_PHY_PAGE) as usize;
|
||||
|
||||
|
||||
pub trait RegisterNum: Add<Output=Self> + Sub<Output=Self> + PartialEq + Copy {}
|
||||
|
||||
|
@ -22,8 +22,8 @@ impl <'a>MMU <'_>{
|
||||
|
||||
fn translate(mmu : &mut MMU, virtAddr : u64, physAddr : &mut u64, size : usize, writing : bool) -> ExceptionType {
|
||||
|
||||
let virtual_page_index : u64 = virtAddr/PAGE_SIZE;
|
||||
let offset : u64 = virtAddr%PAGE_SIZE;
|
||||
let vpn : u64 = virtAddr/PAGE_SIZE; //virtual page index
|
||||
let offset : u64 = virtAddr%PAGE_SIZE; //adresse intra page
|
||||
|
||||
|
||||
|
||||
@ -36,12 +36,38 @@ impl <'a>MMU <'_>{
|
||||
Some(table_ref) => {
|
||||
|
||||
//On verifie que notre index est valide
|
||||
if virtual_page_index >= table_ref.get_max_num_pages(){
|
||||
|
||||
if vpn >= table_ref.get_max_num_pages(){
|
||||
println!("Error from translate :: index is out of bound");
|
||||
return ExceptionType::ADDRESSERROR_EXCEPTION;
|
||||
}
|
||||
|
||||
//is the page correctyl mapped ?
|
||||
//if table_ref.pageTable.get
|
||||
/*Doc nachos dit que ce test sert a savoir si la page est mappée
|
||||
*On teste les droit de lecture ecriture sur cette page
|
||||
*A confirmer avc isabelle
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
//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;
|
||||
}
|
||||
|
||||
//if the page is not yet in main memory, run the page fault manager
|
||||
//Page manager not implemented yet
|
||||
if !table_ref.get_bit_valid(vpn){
|
||||
println!("Error from translate :: no valid correspondance");
|
||||
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;
|
||||
}
|
||||
|
||||
//Make sure that the physical adress is correct
|
||||
let num_phy_page = (MEM_SIZE as u64)/PAGE_SIZE;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user