Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Model.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: SS_Model.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 ============================================
/************************************************************************
**
** Copyright (C) 2006, Sun Microsystems, Inc.
**
** Sun considers its source code as an unpublished, proprietary
** trade secret and it is available only under strict license provisions.
** This copyright notice is placed here only to protect Sun in the event
** the source is deemed a published work. Disassembly, decompilation,
** or other means of reducing the object code to human readable form
** is prohibited by the license agreement under which this code is
** provided to the user or company in possession of this copy.
**
*************************************************************************/
#include "SS_Model.h"
#include "SS_Strand.h"
SS_Model::SS_Model()/*{{{*/
:
SS_Node("sim"),
cpu_count(0)
{}
/*}}}*/
void SS_Model::hard_reset()/*{{{*/
{
for (uint_t i=0; i < cpu_cnt(); i++)
cpu[i]->hard_reset();
}
/*}}}*/
void SS_Model::warm_reset(bool intp)/*{{{*/
{
for (uint_t i=0; i < cpu_cnt(); i++)
cpu[i]->warm_reset(intp);
}
/*}}}*/
void SS_Model::xtrn_reset()/*{{{*/
{
for (uint_t i=0; i < cpu_cnt(); i++)
cpu[i]->xtrn_reset();
}
/*}}}*/
void SS_Model::flush( SS_Paddr pa )/*{{{*/
{
for (uint_t i=0; i < cpu_count; i++)
cpu[i]->flush(pa);
}
/*}}}*/
bool SS_Model::flush( SS_Strand* s, SS_Paddr pa, uint_t size )/*{{{*/
{
// Figure out how many strands need to receive the flush broadcast.
// ToDo: this number n is rather static == number of vcpu instances.
for (uint_t i=0; i < cpu_count; i++)
cpu[i]->flush(s,pa,size);
return true;
}
/*}}}*/
void SS_Model::ras_flush( SS_Strand* requesting_strand, SS_Paddr pa, uint64_t size, SS_MemErrDetector::CacheType type )/*{{{*/
{
for (uint_t i=0; i < cpu_count; i++)
cpu[i]->ras_flush(requesting_strand, pa, size, type);
}
/*}}}*/
void SS_Model::snapshot( SS_SnapShot& ss )/*{{{*/
{
char prefix[32];
get_name(prefix);
// First save of the version of the snapshot and safe it in the
// snapshot object so that all snaphot routine know the version
// by doing ss.get_version() when needed.
uint_t version = ss.VERSION;
sprintf(ss.tag,"%s.version",prefix); ss.val(&version);
ss.set_version(version);
// Get the number of cpu's and sanity check that we load the
// same number of cpu objects.
uint_t _cpu_count = cpu_count;
sprintf(ss.tag,"%s.nr_cpus",prefix); ss.val(&cpu_count);
if (_cpu_count != cpu_count)
{
fprintf(stderr,"ERROR: Snapshot %s.nr_cpus mismatch, was %d is now %d,"
" snapshot ignored\n",prefix,_cpu_count,cpu_count);
return;
}
// Now do the rest of the snapshot routine
for (uint_t i=0; i < cpu_count; i++)
cpu[i]->snapshot(ss);
}
/*}}}*/
void SS_Model::ras_enable(char* cmd)/*{{{*/
{
uint_t n = 0;
for (uint_t i=0; i < cpu_count; i++)
cpu[i]->ras_enable(cmd);
}
/*}}}*/