hw_events.c 3.05 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. 
 *
 */

/*****************************************************************
 * hw_events.c
 *
 * Top level interface into the hardware event counters. Counters that
 * don't require large state machines are kept here. The memstat and
 * false sharing modules are called through here.
 *
 * $Author: blythe $
 * $Date: 2002/05/29 01:09:09 $
 ****************************************************************/

#include "hw_events.h"
#include "statrecord.h"
#include "visual.h"

HWEventBucket hwEventBucket;

#define DEFINE_SR_FIELD(_field, _type) \
  (hwEventBucket._field = StatRecordDefineField(# _field, _type))

extern void MipsyEarlyInit(void);

/* ***********************************************************************
 * Early initialization must takes place 
 *   1) after param.simos has been read
 *   2) before the TCL scripts are read in
 *   3) before the checkpoint is restored.
 * Therefore, their main role is in to initialize the statrecord counters
 * that will be used in the simulation
 * ***********************************************************************/
void
HWEventsEarlyInit(Tcl_Interp *interp)
{
   DEFINE_SR_FIELD(dTlb,        STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(iTlb,        STATRECORD_INSTRUCTION);
   DEFINE_SR_FIELD(cycleSample, STATRECORD_INSTRUCTION);
   DEFINE_SR_FIELD(instrSample, STATRECORD_INSTRUCTION);
   DEFINE_SR_FIELD(readSample,  STATRECORD_DATA);
   DEFINE_SR_FIELD(writeSample, STATRECORD_DATA);
   DEFINE_SR_FIELD(excStall,    STATRECORD_INSTRUCTION);
   DEFINE_SR_FIELD(scNak,       STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(scNakStall,  STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(prefetch,    STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(prefetchIssued, STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(prefetchNoMiss,  STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(prefetchNoUpg,  STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(prefetchTransFailed, STATRECORD_INSTRUCTION|STATRECORD_DATA);
   DEFINE_SR_FIELD(dStallPrefetch, STATRECORD_INSTRUCTION|STATRECORD_DATA);

   DEFINE_SR_FIELD(instrCount,  0);
   DEFINE_SR_FIELD(refCount,    0);
   MemStatEarlyInit();
   FalseSharingEarlyInit();
   InstrUtilEarlyInit();

   /*
    * StatRecordEarlyInit has to be called after
    * all modules have defined their counters
    */
   StatRecordEarlyInit();

}

/* ***************************************************************
 * HWEventsLateInit: called after the checkpoint has been restored
 * ***************************************************************/

void HWEventsLateInit(void) 
{
   static int initialized = 0;
   if (!initialized) { 
      initialized = 1;
      MemStatLateInit();
      StatRecordLateInit();
      FalseSharingLateInit();
      InstrUtilLateInit();
      /* Initialize the control/statistics module */
      Visual_Init();
   }
}