Actually implement paging properly, bump version to 0.3.1
I was mixing up the virtual and physical addresses, oops
This commit is contained in:
parent
82edb1d8da
commit
7fd8d36281
2
Cargo.lock
generated
2
Cargo.lock
generated
|
@ -865,7 +865,7 @@ dependencies = [
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fox32"
|
name = "fox32"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"image",
|
"image",
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
[package]
|
[package]
|
||||||
name = "fox32"
|
name = "fox32"
|
||||||
version = "0.3.0"
|
version = "0.3.1"
|
||||||
authors = ["ry"]
|
authors = ["ry"]
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
build = "build.rs"
|
build = "build.rs"
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
// memory.rs
|
// memory.rs
|
||||||
|
|
||||||
|
const DEBUG: bool = false;
|
||||||
|
|
||||||
use crate::error;
|
use crate::error;
|
||||||
use crate::cpu::Exception;
|
use crate::cpu::Exception;
|
||||||
|
|
||||||
|
@ -115,17 +117,18 @@ impl Memory {
|
||||||
let table_rw = table & 0b10 != 0;
|
let table_rw = table & 0b10 != 0;
|
||||||
let table_address = table & 0xFFFFF000;
|
let table_address = table & 0xFFFFF000;
|
||||||
|
|
||||||
|
if table_present {
|
||||||
let tlb_entry = MemoryPage {
|
let tlb_entry = MemoryPage {
|
||||||
//physical_address: (((directory_index + 1) * (table_index + 1) * 4096) - 4096),
|
physical_address: table_address,
|
||||||
physical_address: (directory_index << 22) | (table_index << 12),
|
|
||||||
present: table_present,
|
present: table_present,
|
||||||
rw: table_rw,
|
rw: table_rw,
|
||||||
};
|
};
|
||||||
self.tlb().entry(table_address).or_insert(tlb_entry);
|
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)> {
|
pub fn virtual_to_physical(&self, virtual_address: u32) -> Option<(u32, bool)> {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user