memref.h
3.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
/*
* Copyright (C) 1996-1998 by the Board of Trustees
* of Leland Stanford Junior University.
*
* This file is part of the SimOS distribution.
* See LICENSE file for terms of the license.
*
*/
/*****************************************************************
* memref.h
*
* This is the generic cache interface from mipsy that allows a
* cache/memory system simulator to see all the memory references and
* control the memory * system delays seen by the processor.
*
* Author: $Author: blythe $
* Date: $Date: 2002/05/29 01:09:09 $
*******************************************************************/
#ifndef _MEMREF_H
#define _MEMREF_H
#include "simtypes.h"
typedef enum {
BYTE_SZ, HALF_SZ, WORD_SZ, DOUBLE_SZ
} RefSize;
typedef enum {
NO_FLAVOR, LL_FLAVOR, SC_FLAVOR, PREF_FLAVOR, PREFX_FLAVOR, GETX_FLAVOR
} RefFlavor;
#ifdef QUICK_CHECK
# define QUICK_ICACHE_CHECK(_p, _P) (ICACHE_ONE_LINE(_p) == (_P)->cachedILine)
#else
# define QUICK_ICACHE_CHECK(_p, _P) (0)
#endif
/*
* MemRefInit() - Call to initialize memory system simulator.
*
*/
extern void MemRefInit(void);
/*
* MemRefResetStats(cpuNum) - Call to reset all statistics
* cpuNum - CPU to reset
*/
extern void MemRefResetStats(int cpuNum);
/*
* MemRefPrintPeriodicStats() - Call to print out any periodic stats
* that the cache might be keeping.
* cpuNum - CPU's cache to print
*/
extern void MemRefPeriodicStats(int cpuNum);
/*
* MemRefDumpStats() - Can be called anytime to dump all statistics.
* cpuNum - CPU's cache to print
*/
extern void MemRefDumpStats(int cpuNum);
/*
* MemRefExit() - Clean up and print final statistics.
*/
extern void MemRefExit(void);
/*
* MemRef... calls
* cpuNum - CPU generating reference.
* accessType - Type of reference. Defined by macros below.
* vAddr - Virtual address of reference.
* pAddr - Physical address of reference.
*/
extern Result MemRefReadInst(int cpuNum, VA, PA, Inst *inst);
extern Result MemRefReadData(int cpuNum, VA, PA, void *data,
RefSize size, RefFlavor flavor);
extern Result MemRefWriteData(int cpuNum, VA, PA, uint64 data,
RefSize size, RefFlavor flavor);
/*
* MemRefSync- Called when a CPU executes a "sync" instruction.
*/
extern Result MemRefSync(int cpuNum);
/*
* Debugging interface - methods for reading and writing data without
* affecting the caches.
*/
extern void MemRefDebugReadData(int cpuNum, VA, PA, char *buff, int size);
extern void MemRefDebugWriteData(int cpuNum, VA, PA, char *buff, int size);
/*
* Support routines for cache operations callable from the
* CPU. We don't implement all different cache ops.
*/
extern Result MemRefIndexHitWBInval(int cpuNum, VA, PA);
extern Result MemRefHitWBInval(int cpuNum, VA, PA);
/*
* Handle prefetch operations. Returns non-zero if the prefetch
* fails. This interface needs some work.
*/
extern Result MemRefPrefetch(int cpuNum, VA vAddr, PA pAddr, int hint);
extern Result MemRefReadUncached(int cpuNum, VA, PA, void *data, RefSize size);
extern Result MemRefWriteUncached(int cpuNum, VA, PA, void *data,
RefSize size, bool accelerated);
extern Result MemRefDMAWrite(int cpuNum, PA pAddr, int transId, int length,
byte *data);
extern Result MemRefDMARead(int cpuNum, PA pAddr, int transId, int length,
byte *data);
void MemRefRemoveReq(int cpuNum, PA pAddr, int size);
/* CALLS THAT MEMREF MAKE BACK TO THE CPU MODEL */
extern void MemRefDone(int cpuNum);
/*
* Here are some useful utility that a memory simulator will want to use.
*
* MemRefTime - Return the current simulator time.
* MemRefMode - Return the current mode of cpu.
*/
extern SimTime MemRefTime(int cpuNum);
extern int MemRefMode(int cpuNum);
#endif /* _MEMREF_H */