memstat.h 3.35 KB
/*
 * 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 */