mmu_(read/write)_mem impl
This commit is contained in:
parent
9c3501eb40
commit
539b3f6802
@ -18,23 +18,70 @@ impl <'a>MMU <'_>{
|
||||
}
|
||||
}
|
||||
|
||||
pub fn mmu_read_mem(mmu : &mut MMU, machine : &Machine, virt_addr : u64, value : &mut u64) -> bool {
|
||||
pub fn mmu_read_mem(mmu : &mut MMU, machine : &mut Machine, virt_addr : u64, value : &mut u64, size : i32) -> bool {
|
||||
//Pour plus tard eventuellement considerer le boutisme de notre mémoire
|
||||
//Peut etre pas si on fixe cela en BIG ENDIAN (octects poids fort au debut)
|
||||
let mut phy_addr : u64 = 0;
|
||||
let mut phy_addr_double_check : u64 = 0;
|
||||
|
||||
let exc = MMU::translate(mmu, virt_addr, &mut phy_addr, false);
|
||||
|
||||
MMU::translate(mmu, virt_addr, &mut phy_addr_double_check, false);
|
||||
|
||||
//PB ICI car double appel a translate et on doit a chaque appel passer mmu en param
|
||||
match exc {
|
||||
ExceptionType::NO_EXCEPTION => {
|
||||
if phy_addr != phy_addr_double_check {
|
||||
//Besoin ici d'une impl pour gestion d'exeption
|
||||
//dans nachos : g-machine->RaiseException(exc, virt_addr);
|
||||
println!("Error from mmu_read_mem :: phy_addr != phy_addr_double_check");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
*value = Machine::read_memory(machine, size, phy_addr as usize);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
//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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
pub fn mmu_write_mem(&mut self, machine : &mut Machine, virt_addr : u64, value : &mut u64) -> bool {
|
||||
//Pour plus tard eventuellement considerer le boutisme de notre mémoire
|
||||
pub fn mmu_write_mem(mmu : &mut MMU, machine : &mut Machine, virt_addr : u64, value : u64, size : i32) -> bool {
|
||||
//Pour plus tard eventuellement considerer le boutisme de notre mémoire
|
||||
//Peut etre pas si on fixe cela en BIG ENDIAN (octects poids fort au debut)
|
||||
let mut phy_addr : u64 = 0;
|
||||
let mut phy_addr_double_check : u64 = 0;
|
||||
|
||||
let exc = MMU::translate(mmu, virt_addr, &mut phy_addr, true);
|
||||
|
||||
MMU::translate(mmu, virt_addr, &mut phy_addr_double_check, true);
|
||||
|
||||
match exc {
|
||||
ExceptionType::NO_EXCEPTION => {
|
||||
if phy_addr != phy_addr_double_check {
|
||||
//Besoin ici d'une impl pour gestion d'exeption
|
||||
//dans nachos : g-machine->RaiseException(exc, virt_addr);
|
||||
println!("Error from mmu_write_mem :: phy_addr != phy_addr_double_check");
|
||||
return false;
|
||||
}
|
||||
else {
|
||||
Machine::write_memory(machine, size, phy_addr as usize, value);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
//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");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user