From fffa6ab3f3f00e3b7e354725f722a8f53d047df9 Mon Sep 17 00:00:00 2001 From: Florian Krohm Date: Sun, 7 Oct 2012 19:44:40 +0000 Subject: [PATCH] Add data structures for cache representation to libvex.h: VexCacheInfo, VexCache, and VexCacheKind. VexArchInfo gets a VexCacheInfo member which LibVEX_default_VexArchInfo initialises. git-svn-id: svn://svn.valgrind.org/vex/trunk@2548 --- VEX/priv/main_main.c | 4 ++++ VEX/pub/libvex.h | 41 +++++++++++++++++++++++++++++++++++++++-- 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/VEX/priv/main_main.c b/VEX/priv/main_main.c index a04a10f70d..bb178b02e2 100644 --- a/VEX/priv/main_main.c +++ b/VEX/priv/main_main.c @@ -1081,6 +1081,10 @@ void LibVEX_default_VexArchInfo ( /*OUT*/VexArchInfo* vai ) vai->ppc_dcbz_szB = 0; vai->ppc_dcbzl_szB = 0; + vai->hwcache_info.num_levels = 0; + vai->hwcache_info.num_caches = 0; + vai->hwcache_info.caches = NULL; + vai->hwcache_info.icaches_maintain_coherence = True; // whatever } /* Write default settings info *vbi. */ diff --git a/VEX/pub/libvex.h b/VEX/pub/libvex.h index 9d7f8bd7dd..ddbf87bf33 100644 --- a/VEX/pub/libvex.h +++ b/VEX/pub/libvex.h @@ -181,15 +181,52 @@ typedef extern const HChar* LibVEX_ppVexArch ( VexArch ); extern const HChar* LibVEX_ppVexHwCaps ( VexArch, UInt ); +/* The various kinds of caches */ +typedef enum { + DATA_CACHE, + INSN_CACHE, + UNIFIED_CACHE +} VexCacheKind; + +/* Information about a particular cache */ +typedef struct { + VexCacheKind kind; + UInt level; /* level this cache is at, e.g. 1 for L1 cache */ + UInt sizeB; /* size of this cache in bytes */ + UInt line_sizeB; /* cache line size in bytes */ + UInt assoc; /* set associativity */ +} VexCache; + +/* Convenience macro to initialise a VexCache */ +#define VEX_CACHE_INIT(_kind, _level, _size, _line_size, _assoc) \ + ({ (VexCache) { .kind = _kind, .level = _level, .sizeB = _size, \ + .line_sizeB = _line_size, .assoc = _assoc }; }) + +/* Information about the cache system as a whole */ +typedef struct { + UInt num_levels; + UInt num_caches; + /* Unordered array of caches for this host. NULL if there are + no caches. Users can assume that the array contains at most one + cache of a given kind per cache level. Additionally, if there exists + a unified cache at a particular level then no other cache exists + at that level. */ + VexCache *caches; + Bool icaches_maintain_coherence; +} VexCacheInfo; + /* This struct is a bit of a hack, but is needed to carry misc important bits of info about an arch. Fields which are meaningless - or ignored for the platform in question should be set to zero. */ + or ignored for the platform in question should be set to zero. + Nb: if you add fields to the struct make sure to update function + LibVEX_default_VexArchInfo. */ typedef struct { - /* This is the only mandatory field. */ + /* The following two fields are mandatory. */ UInt hwcaps; + VexCacheInfo hwcache_info; /* PPC32/PPC64 only: size of cache line */ Int ppc_cache_line_szB; /* PPC32/PPC64 only: sizes zeroed by the dcbz/dcbzl instructions -- 2.47.2