* ========== Copyright Header Begin ==========================================
* OpenSPARC T2 Processor File: trapcount.h
* Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES.
* The above named program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License version 2 as published by the Free Software Foundation.
* The above named program is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
* You should have received a copy of the GNU General Public
* License along with this work; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.
* ========== Copyright Header End ============================================
#ifndef _trapcount_h_9ecb7c16_
#define _trapcount_h_9ecb7c16_
// standard C++ and STL includes
// base class for tracers/timing-models/analyzers
enum { MAX_TRAPTYPES
= 512 }; // 256 HW traps, 256 Tcc instrs
enum { MAX_SYSCALLS
= 256 };
enum { MAX_NCPUS
= 1024 }; // 5-bit NodeID, 5-bit AgentID
// enum { MAX_INOS = 65536 }; // 5-bit NodeID, 5-bit AgentID, 6-bit DeviceID
enum { MAX_MMUCNTXS
= 8192 }; // 13-bit field in TLB/TTE
typedef volatile long vint64_t
;
typedef std::map
<int, int64_t, std::less
<int> > inoarray64_t
;
typedef inoarray64_t::iterator inoiter
;
class Counters
{ // -------------------------------------------------- Counters
vint64_t traptypecount
[ MAX_TRAPTYPES
];
vint64_t syscallscount
[ MAX_SYSCALLS
];
vint64_t mondoxcalcount
[ MAX_NCPUS
];
// vint64_t mondoinocount[ MAX_INOS ];
inoarray64_t mondoinocount
; // better choice, always very sparse
void Reset (); // clear all counts to zero
typedef Counters
* CpuCounters
/*[MAX_NCPUS]*/; // ---------------- CpuCounters
// ------------ MmucntxCounters
typedef std::map
<int, Counters
, std::less
<int> > MmucntxCounters
;
// ------------- ThreadCounters
typedef std::map
<int64_t, Counters
, std::less
<int64_t> > ThreadCounters
;
class trapcount
: public VTracer
{ // ================================= VTracer
public: // this is the exported interface that blaze calls
// the imported interface that vtracers call is still implicit
trapcount(const char * tmp_modname
);
static int trapcount_ui_cmds (void*, int argc
, char * argv
[]);
int process_ui_cmd (int argc
, char **tmp_argv
);
int attach (VTracer_SAM_intf
* sam_intf
);
int instr (VCPU_Instruction
* ii
);
int trap (VCPU_Trap
* ti
);
int async (VCPU_AsyncData
* di
);
int sync (VCPU_Sync
* si
);
int64_t intervalsCounter
; // counts cpu[0] 0x04e traps
void configure_for_mode (modes _mode
);
Counters
* aggregate
; // MODE_AGGREGATE
Counters
* cpus
/*array[MAX_NCPUS]*/; // MODE_BY_CPU
MmucntxCounters
* mmucntxs
; // MODE_BY_MMUCNTX
ThreadCounters
* threads
; // MODE_BY_THREAD
void printCounts (int reset
);
int parse_args_v4(int argc
, const char * tmp_argv
[]); // !=0 --> error
int parse_args_v5(int argc
, const char * tmp_argv
[]); // ditto
void trace_on(); // initialize a new trace
VTracer_SAM_intf
* SAM_intf
;
#endif // _trapcount_h_9ecb7c16_