Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_BreakPoint.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_BreakPoint.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 __SS_BreakPoint_h__
#define __SS_BreakPoint_h__
#include "SS_Instr.h"
#include "BL_Mutex.h"
#include "SS_Trap.h"
extern "C" SS_Vaddr run_exe_breakpoint( SS_Vaddr pc, SS_Vaddr npc, SS_Strand* s, SS_Instr* i );
class SS_Strand;
class SS_BreakPoint/*{{{*/
{
public:
typedef uint_t Ident; // Break point id type
enum Error
{
OK,
ID_UNKNOWN // Specified breakpoint id is unknown
};
enum Break
{
ON_INST_VA,
ON_INST_PA,
ON_INST_WORD,
ON_DATA_VA,
ON_DATA_PA,
ON_DATA_LOAD,
ON_DATA_STORE,
ON_TRAP,
ON_RED_MODE
};
SS_BreakPoint( Break _type, SS_BreakPoint* _next=0 );
Break type; // The type of the breakpoint
Ident id; // The id of this breakpoint
bool enabled; // Whether the breakpoint is enabled or not
bool triggered; // Whether the breakpoint triggered a break or not
SS_BreakPoint* next; // Next breakpoint in the list of allocated breakpoints
SS_BreakPoint* link; // Next breakpoint in the link
bool trigger( SS_Strand* s );
void unlink( SS_BreakPoint** root );
SS_Instr inst; // The original instruction once breakpoint has been inserted
union
{
SS_Vaddr va; // The virtual address that causes the breakpoint match
SS_Paddr pa; // The physical address that causes the breakpoint match
SS_Trap::Type tt; // trap type for trap breakpoints
};
void insert( SS_Instr* i ) // Insert this breakpoint in instruction i
{
orig = i; // Keep this method inline to avoid a call & save/restore
inst.exe = i->exe; // Copy fields individually ... instr cache striping
inst.rs1 = i->rs1;
inst.rs2 = i->rs2;
inst.rs3 = i->rs3;
inst.rd = i->rd;
inst.bp = i->bp;
inst.opc = i->opc;
inst.flg = i->flg;
i->bp = this;
i->exe = run_exe_breakpoint;
}
void remove(); // Remove this breakpoint on instruction
private:
static BL_Mutex id_mutex;
static Ident id_count;
SS_Instr* orig; // The original place of breakpoint insertion
};
/*}}}*/
class SS_BreakTrap : public SS_BreakPoint/*{{{*/
{
public:
SS_BreakTrap( SS_Trap::Type _tt, SS_BreakPoint* _next )
:
SS_BreakPoint(ON_TRAP,_next)
{
tt = _tt;
}
};
/*}}}*/
class SS_BreakRedMode : public SS_BreakPoint/*{{{*/
{
public:
SS_BreakRedMode( SS_BreakPoint* _next ) : SS_BreakPoint(ON_RED_MODE,_next) {}
};
/*}}}*/
class SS_BreakInstVa : public SS_BreakPoint/*{{{*/
{
public:
SS_BreakInstVa( SS_Vaddr _va, SS_BreakPoint* _next )
:
SS_BreakPoint(ON_INST_VA,_next)
{
va = _va;
}
// check_inst_va() checks is the va of the breakpoint matches
// the giving va hen both have been applied to the mask first.
bool check_inst_va( SS_Vaddr mask, SS_Vaddr _va )
{
assert(type == ON_INST_VA);
return enabled && ((va & mask) == (_va & mask));
}
bool break_inst_va( SS_Strand* strand, SS_Vaddr _va )
{
assert(type == ON_INST_VA);
return enabled && (va == _va) && trigger(strand);
}
};
/*}}}*/
#endif