1
0
forked from Rativel/BurritOS

BurritOS now read configuration file

This commit is contained in:
François Autin
2023-04-19 18:09:08 +02:00
parent 1c4c51b0ba
commit 73ac8d3083
9 changed files with 57 additions and 42 deletions

View File

@@ -6,15 +6,18 @@ pub struct MMU <'a>{
* Cette table est associée au processus courant
* Cette référence peut etre mise a jour par exemple lors d'un switchTo
*/
translationTable : Option<&'a mut TranslationTable>
translationTable : Option<&'a mut TranslationTable>,
numPhyPages : u64,
pageSize : u64
}
impl <'a>MMU <'_>{
fn create() -> MMU <'a>{
MMU{
translationTable : None
fn create(numPhyPages: u64, pageSize: u64) -> MMU <'a>{
MMU {
translationTable : None,
numPhyPages,
pageSize
}
}
@@ -88,8 +91,8 @@ impl <'a>MMU <'_>{
pub fn translate(mmu : &mut MMU, virtAddr : u64, physAddr : &mut u64, writing : bool) -> ExceptionType {
let vpn : u64 = virtAddr/PAGE_SIZE; //virtual page index
let offset : u64 = virtAddr%PAGE_SIZE; //adresse intra page
let vpn : u64 = virtAddr/(mmu.pageSize); //virtual page index
let offset : u64 = virtAddr%(mmu.pageSize); //adresse intra page
@@ -133,7 +136,7 @@ impl <'a>MMU <'_>{
}
//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) {
if table_ref.get_physical_page(vpn) < 0 || table_ref.get_physical_page(vpn) >= (mmu.numPhyPages as i32) {
println!("Error from translate :: no valid correspondance");
return ExceptionType::BusErrorException;
}
@@ -147,7 +150,7 @@ impl <'a>MMU <'_>{
//on se permet ici la conversion du champs physical_page de i32 vers u64
//si cette valeur avait été signée, cela aurait été detecté juste au dessus, renvoyant une BUSERROR_EXCEPTION
*physAddr = (table_ref.get_physical_page(vpn) as u64)*PAGE_SIZE + offset;
*physAddr = (table_ref.get_physical_page(vpn) as u64)*(mmu.pageSize) + offset;
}
}