summaryrefslogtreecommitdiff
path: root/big-little/virtualisor/include/cache_geom.h
diff options
context:
space:
mode:
Diffstat (limited to 'big-little/virtualisor/include/cache_geom.h')
-rw-r--r--big-little/virtualisor/include/cache_geom.h101
1 files changed, 101 insertions, 0 deletions
diff --git a/big-little/virtualisor/include/cache_geom.h b/big-little/virtualisor/include/cache_geom.h
new file mode 100644
index 0000000..72935f5
--- /dev/null
+++ b/big-little/virtualisor/include/cache_geom.h
@@ -0,0 +1,101 @@
+/*
+ * $Copyright:
+ * ----------------------------------------------------------------
+ * This confidential and proprietary software may be used only as
+ * authorised by a licensing agreement from ARM Limited
+ * (C) COPYRIGHT 2008-2011 ARM Limited
+ * ALL RIGHTS RESERVED
+ * The entire notice above must be reproduced on all authorised
+ * copies and copies may only be made to the extent permitted
+ * by a licensing agreement from ARM Limited.
+ * ----------------------------------------------------------------
+ * File: kingfisher.h
+ * ----------------------------------------------------------------
+ * $
+ */
+
+#ifndef __CACHE_GEOM_H__
+#define __CACHE_GEOM_H__
+
+#define MAX_CACHE_LEVELS 0x8
+
+/* Target cpu cache relative to host cpu cache size */
+#define TCSZ_EQUAL 0x0
+#define TCSZ_SMALL 0x1
+#define TCSZ_BIG 0x2
+
+#define get_setway_reg(a, b , c, d, e) ((a << __clz(b)) | (c << (d + 4)) | (e << 1))
+#define get_cache_type(clidr, lvl) ((clidr >> (lvl * 0x3)) & 0x7)
+#define get_cache_level(reg) (reg >> 1) & 0x7
+#define get_cache_linesz(cg, lvl) (cg->ccsidr[lvl] & 0x7)
+#define get_cache_assoc(cg, lvl) ((cg->ccsidr[lvl] >> 3) & 0x3ff)
+#define get_cache_numsets(cg, lvl) ((cg->ccsidr[lvl] >> 13) & 0x7fff)
+
+/*
+ * Data structure that stores the foreseeable differences
+ * between the host and target caches at each implemented
+ * cache level.
+ * Absolute cache line numbers are calculated relative to
+ * the cache line size of the smaller cache to get the
+ * maximum granularity.
+ */
+typedef struct cache_diff {
+ /* Stores whether target cache is =,<,> host cache */
+ unsigned csize_diff;
+ /*
+ * Stores factor by which target cache line
+ * has to be multiplied to get absolute line
+ * no.
+ */
+ unsigned tcline_factor;
+ /*
+ * Stores factor by which absolute cache line
+ * no. has to be divided to get host cache line
+ * no.
+ */
+ unsigned hcline_factor;
+ /* Max absolute target cpu cache line number */
+ unsigned tnumabs_clines;
+ /* Max absolute host cpu cache line number */
+ unsigned hnumabs_clines;
+} cache_diff;
+
+/*
+ * Data structure that defines the cache topology of a cpu
+ */
+typedef struct cache_geom {
+ unsigned clidr;
+ /*
+ * One for each cpu to store the cache level
+ * the OS thinks its operating on.
+ */
+ unsigned ccselr;
+ /* One for each cache level */
+ unsigned ccsidr[MAX_CACHE_LEVELS];
+} cache_geometry;
+
+/*
+ * Data structure to hold cache virtualisation statistics.
+ * Reset for each switchover.
+ */
+typedef struct cache_stats {
+ /* Number of cm ops which did not cover the whole cache */
+ unsigned part_cmop_cnt;
+ /* Number of cm ops which spanned the entire cache */
+ unsigned cmpl_cmop_cnt;
+} cache_stats;
+
+extern unsigned map_cache_geometries(cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+extern void find_cache_geometry(cache_geometry *);
+extern void find_cache_diff(cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+extern void handle_cm_op(unsigned,
+ void (*) (unsigned),
+ cache_geometry *,
+ cache_geometry *,
+ cache_diff *);
+
+#endif /* __CACHE_GEOM_H__ */