summaryrefslogtreecommitdiff
path: root/big-little/virtualisor/cache_geom.c
diff options
context:
space:
mode:
Diffstat (limited to 'big-little/virtualisor/cache_geom.c')
-rw-r--r--big-little/virtualisor/cache_geom.c65
1 files changed, 32 insertions, 33 deletions
diff --git a/big-little/virtualisor/cache_geom.c b/big-little/virtualisor/cache_geom.c
index 17c3ee6..7bcb42b 100644
--- a/big-little/virtualisor/cache_geom.c
+++ b/big-little/virtualisor/cache_geom.c
@@ -36,51 +36,50 @@ static unsigned cm_ignline_cnt[NUM_CPUS][MAX_CACHE_LEVELS] = { 0 };
static unsigned cm_extline_cnt[NUM_CPUS][MAX_CACHE_LEVELS] = { 0 };
/*
- * Iterate through all the implemented cache
- * levels and save the geometry at each level.
+ * Iterate through all the implemented cache levels and save the geometry at
+ * each level.
*
*/
void find_cache_geometry(cache_geometry * cg_ptr)
{
- unsigned ctr, clidr, ccsidr, csselr, old_csselr;
+ unsigned ctr, csselr;
- /* Save Cache size selection register */
- old_csselr = read_csselr();
- clidr = read_clidr();
- cg_ptr->clidr = clidr;
+ /* Save cache size selection register */
+ csselr = read_csselr();
- for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
- unsigned cache_type = get_cache_type(clidr, ctr);
+ cg_ptr->clidr = read_clidr();
- /* Only seperate and Unifiied caches */
- if (cache_type >= 0x3) {
- /*
- * Choose the cache level & Data or Unified cache
- * as there are no set/way operations on the ICache
- */
- csselr = ctr << 1;
- write_csselr(csselr);
+ for (ctr = 0; ctr < MAX_CACHE_LEVELS; ctr++) {
+ unsigned cache_type = get_cache_type(cg_ptr->clidr, ctr);
+ if (cache_type == 0x03) {
+ /* instruction cache */
+ write_csselr((ctr << 1) | CIND_INST);
isb();
-
+ cg_ptr->ccsidr[ctr][CIND_INST] = read_ccsidr();
+ /* data cache */
+ write_csselr(ctr << 1);
+ isb();
+ cg_ptr->ccsidr[ctr][CIND_DATA] = read_ccsidr();
+ }
+ else if (cache_type == 0x04) {
+ /* unified cache */
+ write_csselr(ctr << 1);
+ isb();
+ cg_ptr->ccsidr[ctr][CIND_UNIF] = read_ccsidr();
+ }
+ else {
/*
- * Read the CCSIDR to record information about this
- * cache level.
- */
- ccsidr = read_ccsidr();
- cg_ptr->ccsidr[ctr] = ccsidr;
-
- } else {
- /*
- * Stop scanning at the first invalid/unsupported
- * cache level
+ * Stop scanning at the first invalid/unsupported cache
+ * level
*/
break;
}
+
}
- /* Restore Cache size selection register */
- write_csselr(old_csselr);
+ /* Restore cache size selection register */
+ write_csselr(csselr);
return;
}
@@ -203,7 +202,7 @@ unsigned map_cache_geometries(cache_geometry * hcg_ptr,
/*
* Enable bit for trapping set/way operations &
- * Cache identification regs
+ * cache identification registers
*/
hcr = read_hcr();
hcr |= HCR_TSW | HCR_TID2;
@@ -212,7 +211,6 @@ unsigned map_cache_geometries(cache_geometry * hcg_ptr,
isb();
} else {
-
/* Find the cache geometry on the target cpu */
find_cache_geometry(tcg_ptr);
@@ -235,7 +233,8 @@ unsigned map_cache_geometries(cache_geometry * hcg_ptr,
void handle_cm_op(unsigned reg,
void (*op_handler) (unsigned),
cache_geometry * hcg_ptr,
- cache_geometry * tcg_ptr, cache_diff * cd_ptr)
+ cache_geometry * tcg_ptr,
+ cache_diff * cd_ptr)
{
unsigned clvl = 0, cpu_id = read_cpuid();
unsigned tc_assoc = 0, tc_numsets = 0, tc_linesz = 0;