Skip to content

Commit

Permalink
Actually implement paging properly, bump version to 0.3.1
Browse files Browse the repository at this point in the history
I was mixing up the virtual and physical addresses, oops
  • Loading branch information
ry755 committed Aug 16, 2022
1 parent 82edb1d commit 7fd8d36
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "fox32"
version = "0.3.0"
version = "0.3.1"
authors = ["ry"]
edition = "2021"
build = "build.rs"
Expand Down
19 changes: 11 additions & 8 deletions src/memory.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// memory.rs

const DEBUG: bool = false;

use crate::error;
use crate::cpu::Exception;

Expand Down Expand Up @@ -115,17 +117,18 @@ impl Memory {
let table_rw = table & 0b10 != 0;
let table_address = table & 0xFFFFF000;

let tlb_entry = MemoryPage {
//physical_address: (((directory_index + 1) * (table_index + 1) * 4096) - 4096),
physical_address: (directory_index << 22) | (table_index << 12),
present: table_present,
rw: table_rw,
};
self.tlb().entry(table_address).or_insert(tlb_entry);
if table_present {
let tlb_entry = MemoryPage {
physical_address: table_address,
present: table_present,
rw: table_rw,
};
self.tlb().entry((directory_index << 22) | (table_index << 12)).or_insert(tlb_entry);
}
}
}
}
println!("{:#X?}", self.tlb());
if DEBUG { println!("{:#X?}", self.tlb()); }
}

pub fn virtual_to_physical(&self, virtual_address: u32) -> Option<(u32, bool)> {
Expand Down

0 comments on commit 7fd8d36

Please sign in to comment.