aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Cargo.lock4
-rw-r--r--TODO.md1
-rw-r--r--src/shareable_cache.rs15
3 files changed, 18 insertions, 2 deletions
diff --git a/Cargo.lock b/Cargo.lock
index 4a4255b..b1a2219 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -6,7 +6,7 @@ dependencies = [
"env_logger 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.4 (registry+https://github.com/rust-lang/crates.io-index)",
"rustc-serialize 0.3.16 (registry+https://github.com/rust-lang/crates.io-index)",
- "rustv 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)",
+ "rustv 0.4.1 (registry+https://github.com/rust-lang/crates.io-index)",
"time 0.1.34 (registry+https://github.com/rust-lang/crates.io-index)",
]
@@ -94,7 +94,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
[[package]]
name = "rustv"
-version = "0.4.0"
+version = "0.4.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
dependencies = [
"elfloader32 0.0.3 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/TODO.md b/TODO.md
index eeaefe6..5de3a9a 100644
--- a/TODO.md
+++ b/TODO.md
@@ -21,6 +21,7 @@ https://git.lidavidm.me/cacheracer/.
map to an actual array element)
- [ ] `ReverseMmu` needs to mark VA 0x0 as invalid somehow
- [x] Sneak attack/retreat needs to be per-core
+- [x] ~~Invalidate~~/update other caches when a write is made
- [ ] Implement global data structures
- [ ] Player status
- [ ] Core status
diff --git a/src/shareable_cache.rs b/src/shareable_cache.rs
index 9f558cd..9e0725a 100644
--- a/src/shareable_cache.rs
+++ b/src/shareable_cache.rs
@@ -45,6 +45,16 @@ impl<'a> ShareableCache<'a> {
(primary_accessible, secondary_accessible)
}
+
+ fn snoop(cache: &mut SharedMemory<'a>,
+ address: isa::Address, value: isa::Word) {
+ // Cache snooping: update all cache lines when a write is made
+ if cache.borrow().is_address_accessible(address) {
+ // Depends on invariant: write_word completes instantly
+ // when the address is accessible (in-cache)
+ cache.borrow_mut().write_word(address, value);
+ }
+ }
}
impl<'a> MemoryInterface for ShareableCache<'a> {
@@ -97,22 +107,27 @@ impl<'a> MemoryInterface for ShareableCache<'a> {
self.address_accessible(address);
if primary_accessible {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
else if secondary_accessible {
+ ShareableCache::snoop(&mut self.primary, address, value);
self.secondary.borrow_mut().write_word(address, value)
}
else {
self.use_secondary = !self.use_secondary;
if self.use_secondary {
+ ShareableCache::snoop(&mut self.primary, address, value);
self.secondary.borrow_mut().write_word(address, value)
}
else {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
}
}
else {
+ ShareableCache::snoop(&mut self.secondary, address, value);
self.primary.borrow_mut().write_word(address, value)
}
}