memstat.h
3.35 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
/*
* 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.
*
*/
/*****************************************************************
* memstat.h
*
*
* Author: $Author: blythe $
* Date: $Date: 2002/05/29 01:09:09 $
*****************************************************************/
#ifndef _MEM_STAT_H
#define _MEM_STAT_H
#include <stdio.h>
#include "statrecord.h"
#include "syslimits.h"
#include "simtypes.h"
#define MS_SAMPLE_MEMOP_INTERVAL 16
#define MS_SAMPLE_INSTR_INTERVAL 256
#define SAMPLE_PC_INTERVAL 256
typedef SimTime MemStatTime;
/*************************************************************************
* Global initialization and utility functions. The utility functions operate
* on the MemStatBuckets passed in as arguments.
*************************************************************************/
extern void MemStatInitCategoryFields(StatRecordFieldDesc *desc, char *tag,
int type);
extern void MemStatEarlyInit(void);
extern void MemStatLateInit(void);
extern int MemStatInitialized(void);
extern void MemStatReset(void);
extern void MemStatLog(FILE *f,char *,SimTime time,char *,char *,...);
extern int interest(PA pAddr); /* debug only */
extern int MSCacheState(int cpuNum, PA pAddr);
/***************************************************************
* Incrementers and state machine driving functions
***************************************************************/
extern void MemStatImiss(MemStatTime cycles, int cpu, VA vAddr, PA pAddr,
MemStatTime stallTime, int missType);
extern int MemStatDmiss(MemStatTime cycles, int cpu, VA pc, VA addr,
PA pAddr, MemStatTime stallTime, int missType, int way);
extern void MemStatCacheTrans(int cpu, PA pAddr,
int type, VA evictorAddr, int isUserMode);
extern void MemStatPrefetchNoMiss(int cpu, PA pAddr, int way);
/*
* NUM_CATEGS must be the last entry in the enumeration
*/
enum CacheMissCount {CATEG_ice,
CATEG_cold,
CATEG_inv,
CATEG_capinv,
CATEG_cap,
CATEG_Kcap,
CATEG_SelfCap,
CATEG_OtherCap,
NUM_CATEGS };
extern char *categName[];
/*****************************************************************
* I-cache utilization stats.
* Enabled by a compilation option: -DINSTR_UTIL
* Instructions are always word-aligned. We use the lower bits
* to mark the set. This works only for associativity <=4
* Enabled only by the compilation option -DINSTR_UTIL
*****************************************************************/
extern char *memStatInstrBits[SIM_MAXCPUS];
extern uint memStatInstrMask;
extern void MemStatNewILine(int cpuNum, VA vAddr, PA pAddr, int setEntry);
extern void MemStatReplaceILine(int cpunum, PA pAddr, int setEntry);
#ifdef INSTR_UTIL
#define MS_INSTRUCTION(_cpu,_pA) \
(memStatInstrBits[_cpu][(_pA&memStatInstrMask)+(PE[_cpu].cachedISetEntry]) = 1)
#define MS_INSTRUCTION_SET(_cpu,_setEntry) (PE[_cpu].cachedISetEntry=_setEntry)
#else
#define MS_INSTRUCTION(_cpu,_pA)
#define MS_INSTRUCTION_SET(_cpu,_set)
#endif
#endif /* MEMSTAT_H */