TEMU  3.0
The Terma Emulator
Cache.h
Go to the documentation of this file.
1 //===------------------------------------------------------------*- C++ -*-===//
2 //
3 // TEMU: The Terma Emulator
4 // (c) Terma 2015
5 // Authors: Mattias Holm <maho (at) terma.com>
6 //
7 //===----------------------------------------------------------------------===//
8 
9 /*
10  * WARNING: The interfaces defined in this header are at present
11  * considered: EXPERIMENTAL!!! In particularly, this means
12  * that there is no guaranteed API stability for the cache
13  * interfaces at the moment.
14  */
15 
16 #ifndef TEMU_CACHE_H
17 #define TEMU_CACHE_H
18 
19 #include "temu-c/Support/Objsys.h"
20 #include "temu-c/Memory/Memory.h"
21 
22 #include <stdint.h>
23 
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
27 
28 // List of cache algorithms and corresponding numbers, numbers 0
29 // through 128 are reserved. Note that NONE implies that the cache is
30 // directly mapped, i.e. sets should be 1.
31 #define TEMU_CACHE_NONE 0
32 #define TEMU_CACHE_LRU 1
33 #define TEMU_CACHE_LRR 2
34 #define TEMU_CACHE_RND 3
35 
41 
45 
46 typedef struct temu_CacheIface {
47  void (*enable)(void *Obj);
48  void (*disable)(void *Obj);
49  void (*freeze)(void *Obj);
50 
51  void (*lockLine)(void *Obj, uint64_t Addr);
52  void (*unlockLine)(void *Obj, uint64_t Addr);
53 
54 
55  void (*invalidateAll)(void *Obj);
56  void (*invalidateLine)(void *Obj, uint64_t Addr);
57 
58  void (*evictAll)(void *Obj);
59  void (*evictLine)(void *Obj, uint64_t Addr);
60 
65  uint32_t (*getReplacementPolicy)(void *Obj);
67  uint32_t (*getSets)(void *Obj);
69  uint32_t (*getWays)(void *Obj);
71  uint32_t (*getLineSize)(void *Obj);
72 
74  int (*isValid)(void *Obj, uint64_t Addr);
75 
82  uint64_t (*readFlags)(void *Obj, uint64_t Addr);
83 
85  void (*writeFlags)(void *Obj, uint64_t Addr, uint64_t Flags);
86 
98  uint64_t (*readData)(void *Obj, uint64_t Addr);
99 
101  int (*writeData)(void *Obj, uint64_t Addr, uint64_t Data);
103 #define TEMU_CACHE_IFACE_TYPE "temu::CacheIface"
104 TEMU_IFACE_REFERENCE_TYPE(temu_Cache);
105 
112 typedef struct temu_CacheCtrlIface {
114  void (*evictionInProgress)(void *Obj);
115 
117  void (*evictionCompleted)(void *Obj);
119 #define TEMU_CACHE_CTRL_IFACE_TYPE "temu::CacheCtrlIface"
120 TEMU_IFACE_REFERENCE_TYPE(temu_CacheCtrl);
121 
122 #ifdef __cplusplus
123 }
124 #endif
125 
126 #endif /* ! TEMU_CACHE_H */
void(* evictionCompleted)(void *Obj)
Global evict operation completed.
Definition: Cache.h:117
uint64_t(* readData)(void *Obj, uint64_t Addr)
Definition: Cache.h:98
int(* writeData)(void *Obj, uint64_t Addr, uint64_t Data)
Write data in cache.
Definition: Cache.h:101
void(* invalidateAll)(void *Obj)
Invalidate entire cache.
Definition: Cache.h:55
void(* invalidateLine)(void *Obj, uint64_t Addr)
Invalidate single line.
Definition: Cache.h:56
void(* evictionInProgress)(void *Obj)
Global evict operation ongoing.
Definition: Cache.h:114
Definition: Cache.h:112
void(* freeze)(void *Obj)
Freeze cache.
Definition: Cache.h:49
uint32_t(* getSets)(void *Obj)
Get number of sets.
Definition: Cache.h:67
void(* evictAll)(void *Obj)
Evict all (i.e. spill to memory)
Definition: Cache.h:58
void(* enable)(void *Obj)
Enable cache.
Definition: Cache.h:47
uint32_t(* getReplacementPolicy)(void *Obj)
Definition: Cache.h:65
uint32_t(* getLineSize)(void *Obj)
Get line size in bytes.
Definition: Cache.h:71
TEMU_IFACE_REFERENCE_TYPE(temu_Cache)
void(* evictLine)(void *Obj, uint64_t Addr)
Evict line.
Definition: Cache.h:59
uint32_t(* getWays)(void *Obj)
Get number of ways.
Definition: Cache.h:69
uint64_t(* readFlags)(void *Obj, uint64_t Addr)
Definition: Cache.h:82
void(* lockLine)(void *Obj, uint64_t Addr)
Lock line for addr.
Definition: Cache.h:51
void(* unlockLine)(void *Obj, uint64_t Addr)
Unlock line.
Definition: Cache.h:52
struct temu_CacheIface temu_CacheIface
Definition: Cache.h:46
int(* isValid)(void *Obj, uint64_t Addr)
Check if an address belong to a cached line.
Definition: Cache.h:74
void(* disable)(void *Obj)
Disable cache.
Definition: Cache.h:48
struct temu_CacheCtrlIface temu_CacheCtrlIface
void(* writeFlags)(void *Obj, uint64_t Addr, uint64_t Flags)
Write flags data.
Definition: Cache.h:85