summaryrefslogtreecommitdiff
path: root/src/storage/cache.cc
diff options
context:
space:
mode:
authorbd <bdunahu@operationnull.com>2025-03-09 23:49:29 -0400
committerbd <bdunahu@operationnull.com>2025-03-09 23:49:29 -0400
commit2669ab2cfccd9b0b3954e6a68af3de67bd951938 (patch)
treeb5a53b6e85f59392267a8a26e631c00445c30e94 /src/storage/cache.cc
parent95d90e454beca2e467613d0c0fbb035b02eada23 (diff)
Properly set cache metadata when a value is loaded
Diffstat (limited to 'src/storage/cache.cc')
-rw-r--r--src/storage/cache.cc15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/storage/cache.cc b/src/storage/cache.cc
index 52f13b9..2031367 100644
--- a/src/storage/cache.cc
+++ b/src/storage/cache.cc
@@ -34,6 +34,7 @@ Response Cache::write(Accessor accessor, signed int data, int address)
int tag, index, offset;
get_bit_fields(address, &tag, &index, &offset);
this->data->at(index).at(offset) = data;
+ this->meta[index].at(1) = 1;
r = OK;
}
}
@@ -52,22 +53,24 @@ void Cache::fetch_resource(int expected)
Response r = OK;
int tag, index, offset;
std::array<signed int, LINE_SIZE> actual;
- std::array<int, 2> meta;
+ std::array<int, 2> *meta;
get_bit_fields(expected, &tag, &index, &offset);
- meta = this->meta.at(index);
+ meta = &this->meta.at(index);
- if (this->meta[index][0] != tag) {
+ if (meta->at(0) != tag) {
// address not in cache
- if (this->meta[index][1] >= 0) {
+ if (meta->at(1) >= 0) {
// occupant is dirty
// TODO
r = WAIT;
} else {
actual = this->data->at(index);
r = this->lower->read(L1CACHE, expected, actual);
- // clear dirty bit and set tag?
-
+ if (r == OK) {
+ meta->at(0) = tag;
+ meta->at(1) = -1;
+ }
}
}