Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / api / sam / src / SS_VirtualStrand.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_VirtualStrand.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_VirtualStrand_h__
#define __SS_VirtualStrand_h__
#include "SS_Types.h"
#include "SS_Strand.h"
#include "SS_SamTracer.h"
#define bool_t bool
namespace Sam {
#include "vcpu.h"
#include "Memory.h"
}
class SS_SamTracer; // forward declaration
class SS_VirtualStrand : public Sam::Vcpu
{
public:
SS_VirtualStrand();
int stepi( int64_t n=1 )
{
uint64_t ret = 0;
if (config.delay >= n)
{
config.delay -= n; // skip n instructions
}
else // step n instruction
{
int ii = n - config.delay;
config.delay = 0;
// strand will not increments tick/stick after every step
if(sys_intf.vtrace) // tracer is enabled
{
strand->add_tracer(&tracer);
ret = strand->trc_step(ii);
strand->del_tracer(&tracer);
}
else if (strand->trc_hook || strand->sim_state.ras_enabled())
{
ret = strand->trc_step(ii);
}
else
{
ret = strand->run_step(ii);
}
}
return ret;
}
void update_stick(int64_t stickincr)
{
strand->run_tick(stickincr);
}
virtual void update_perfcntr (Sam::Vcpu::perfcntr which, int64_t incr)
{
strand->run_perf(strand, which, incr); // performance instrumentation counters
}
int interrupt( Sam::VCPU_InterruptRequest* );
RegError get_reg_index( const char* reg_name, RegIndex* index )
{
for (int i=SS_Registers::INDEX_BEGIN; i < SS_Registers::ALIAS_END; i++)
{
// First check all the alias names like pc for asr5, etc
// If reg_name is not an alias then check if it is say asr5
const char* name = get_reg_name(i);
if (!name)
continue;
if (strcmp(reg_name,name) == 0)
{
*index = RegIndex(i);
return REG_OK;
}
else if (strcmp(reg_name,SS_Registers::get_name(SS_Registers::Index(i))) == 0)
{
if (get_reg_name(i))
{
*index = RegIndex(i);
return REG_OK;
}
else
return REG_NOT_AVAILABLE;
}
}
return REG_NOT_AVAILABLE;
}
const char* get_reg_name( RegIndex index )
{
return (strand->get_state_name)(strand,SS_Registers::Index(index));
}
RegError get_reg( RegIndex index, uint64_t* data )
{
return RegError((strand->get_state)(strand,SS_Registers::Index(index),data));
}
RegError set_reg( RegIndex index, uint64_t data )
{
return RegError((strand->set_state)(strand,SS_Registers::Index(index),data));
}
int get_asi(uint8_t asi, uint64_t addr, uint64_t &data)
{
return (strand->asi_map.rd64( strand, asi, addr, &data )) != SS_AsiSpace::OK;
}
int set_asi(uint8_t asi, uint64_t addr, uint64_t data)
{
return (strand->asi_map.wr64( strand, asi, addr, data )) != SS_AsiSpace::OK;
}
TranslateError translate( TranslateMode mode, uint64_t addr, uint64_t context, uint64_t partitionid, uint64_t* phys_addr )
{
return (strand->cnv2pa)(strand,mode,addr,context,partitionid,phys_addr);
}
int get_tlb_entries(struct Sam::TLBInfo * &return_array);
int read_mem ( uint64_t addr, uint64_t *value, int size, int asi= 0x82, int is_physical=0 );
int write_mem ( uint64_t addr, uint64_t value, int size, int asi= 0x82, int is_physical=0 );
int set_breakpoint ( int *bp_id, Sam::VCPU_BpType type, uint64_t value,
Sam::VCPU_BpActionFn action, uint64_t mask= ~(uint64_t(0)));
int delete_breakpoint ( int bp_id = ~(0) );
// print breakpoint list
virtual int print_breakpoints ( FILE *fp );
// print all regs to file/consol
virtual int print_regs ( FILE *fp ) { return 1; }
// print tlbs to file/consol
virtual int print_tlbs ( FILE *fp );
SS_Strand* strand;
SS_SamTracer tracer;
};
#endif