Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / n2 / api / sam / src / N2_VirtualCpu.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: N2_VirtualCpu.cc
// 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 ============================================
#include <string.h>
#include "SS_VirtualCpu.h"
#include "N2_Model.h"
namespace Sam {
#define bool_t bool
#include "vcpu.h"
}
static N2_Model* n2 = 0;
static SS_Model* n2_model()/*{{{*/
{
if (n2 == 0)
n2 = new N2_Model();
return n2;
}
/*}}}*/
static void* n2_create( Sam::VCPU_Config* config, Sam::VCPU_ImpIntf* interface )/*{{{*/
{
config->cpu_type =
(Sam::VCPU_Type)(Sam::VCPU_IMPL_VER_N2 | Sam::VCPU_IMPL_SIM_VONK);
return SS_VirtualCpu::create(n2_model,config,interface);
}
/*}}}*/
static int n2_destroy()/*{{{*/
{
SS_VirtualCpu::remove(n2);
n2 = 0;
return 0;
}
/*}}}*/
static int n2_reset( uint64_t pc )/*{{{*/
{
return 0;
}
/*}}}*/
static int n2_config( char* cmd, char* reply, int reply_size )/*{{{*/
{
return 0;
}
/*}}}*/
static int n2_snapshot( char* dir_name, bool load )/*{{{*/
{
return SS_VirtualCpu::snapshot(n2,dir_name,"/n2cpu.ss",load);
}
/*}}}*/
static int n2_save( char* dir_name )/*{{{*/
{
return n2_snapshot(dir_name,false);
}
/*}}}*/
static int n2_restore( char* dir_name )/*{{{*/
{
return n2_snapshot(dir_name,true);
}
/*}}}*/
static int n2_cycle ( uint64_t nn )
{
return SS_VirtualCpu::cycle(nn);
}
static Sam::VCPU_ExInterface n2_sam_interface =/*{{{*/
{
n2_create,
n2_reset,
n2_destroy,
n2_config,
n2_save,
n2_restore,
n2_cycle
};
/*}}}*/
extern "C" int get_ex_interface( Sam::VCPU_ExInterface* interface )/*{{{*/
{
*interface = n2_sam_interface;
return 0;
}
/*}}}*/
// global methods to access system info
extern "C" uint_t vcpu_get_sys_type()/*{{{*/
{
return Sam::VCPU_IMPL_VER_N2;
}
/*}}}*/
extern "C" uint_t vcpu_get_sys_size()/*{{{*/
{
return 0;
}
/*}}}*/
extern "C" void* vcpu_get_sys_pntr( uint_t i )/*{{{*/
{
assert(n2 && (i == 0));
return (void*)n2;
}
/*}}}*/