-
-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bb19c3b
commit 00fdbc1
Showing
8 changed files
with
126 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#include "cache_control.h" | ||
#include "system.h" | ||
|
||
CacheControl::CacheControl(System* sys) : sys(sys) { reset(); } | ||
|
||
void CacheControl::reset() { cache._reg = 0; } | ||
|
||
uint32_t CacheControl::read(uint32_t address) { return cache._reg; } | ||
|
||
void CacheControl::write(uint32_t address, uint32_t data) { | ||
cache._reg = data; | ||
sys->cpu->icacheEnabled = cache.icacheEnable; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
#pragma once | ||
#include "device.h" | ||
|
||
struct System; | ||
|
||
union CacheConfiguration { | ||
struct { | ||
uint32_t lock : 1; // lock, Tag Test Mode | ||
uint32_t inv : 1; // inv, Invalidate Mode | ||
uint32_t tag : 1; // tag, Tag Test Mode (used by BIOS when invalidating icache) | ||
uint32_t scratchpad : 1; // ram, use dcache as scratchpad (ignore valid bits) | ||
|
||
uint32_t dcacheRefillSize : 2; // dblksz | ||
uint32_t : 1; | ||
uint32_t dcacheEnable : 1; // ds, used with bit3 to enable scratchpad | ||
|
||
uint32_t icacheRefillSize : 2; // iblksz | ||
uint32_t is0 : 1; // is0, enable icache set 0 - cleared to 0 | ||
uint32_t icacheEnable : 1; // is1, enable icache set 1 - 1 to enable | ||
|
||
uint32_t interruptPolarity : 1; // intp, not used, should be 0 | ||
uint32_t enableReadPriority : 1; // rdpri, loads operations will have priority over store | ||
uint32_t noWaitState : 1; // nopad | ||
uint32_t enableBusGrant : 1; // bgnt, should be 0 | ||
|
||
uint32_t loadScheduling : 1; // ldsch | ||
uint32_t noStreaming : 1; // nostr, not used, should be 0 | ||
|
||
uint32_t : 14; | ||
}; | ||
uint32_t _reg; | ||
|
||
template <class Archive> | ||
void serialize(Archive& ar) { | ||
ar(_reg); | ||
} | ||
}; | ||
|
||
class CacheControl { | ||
System* sys; | ||
|
||
CacheConfiguration cache; | ||
|
||
public: | ||
CacheControl(System* sys); | ||
void reset(); | ||
uint32_t read(uint32_t address); | ||
void write(uint32_t address, uint32_t data); | ||
|
||
template <class Archive> | ||
void serialize(Archive& ar) { | ||
ar(cache); | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters