Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_Tte.cc
// ========== Copyright Header Begin ==========================================
//
// OpenSPARC T2 Processor File: SS_Tte.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 "SS_Tte.h"
void SS_Tte::snapshot( SS_SnapShot& ss, const char* prefix )/*{{{*/
{
char flg[32];
char* ptr = flg;
if (ss.do_save())
{
// Save the tte_flags as a char string rather then a number to
// make us independant of the implementations. The characters
// are choosens to "match" the flags, e.g. 'x' is execuable, etc.
// If flags == 0 then a '-' is used to give the flags string length.
if (p()) *ptr++ = 'p';
if (x()) *ptr++ = 'x';
if (w()) *ptr++ = 'w';
if (nfo()) *ptr++ = 'n';
if (ie()) *ptr++ = 'i';
if (cp()) *ptr++ = 'P';
if (cv()) *ptr++ = 'V';
if (e()) *ptr++ = 'e';
if (lock()) *ptr++ = 'L';
if (valid_bit()) *ptr++ = 'v';
if (real_bit()) *ptr++ = 'r';
if (flg == ptr) *ptr++ = '-';
*ptr = 0;
}
sprintf(ss.tag,"%s.pid",prefix); ss.val(&tte_pid);
sprintf(ss.tag,"%s.sze",prefix); ss.val(&tte_page_size);
sprintf(ss.tag,"%s.ctx",prefix); ss.val(&tte_context);
sprintf(ss.tag,"%s.flg",prefix); ss.val(flg);
sprintf(ss.tag,"%s.tag",prefix); ss.val(&tte_tag);
sprintf(ss.tag,"%s.pa",prefix); ss.val(&tte_taddr);
if (ss.do_load())
{
// Load the tte flags back, converting the characters back to
// numeric flags values. The character to flag conversion has to match
// the once in teh do_save() black above.
tte_flags = 0;
while (*ptr)
{
switch (*ptr++)
{
case '-': break;
case 'p': p(1); break;
case 'x': x(1); break;
case 'w': w(1); break;
case 'n': nfo(1); break;
case 'i': ie(1); break;
case 'P': cp(1); break;
case 'V': cv(1); break;
case 'e': e(1); break;
case 'L': lock(1); break;
case 'v': valid_bit(1); break;
case 'r': real_bit(1); break;
default: fprintf(stderr,"Warning: Unknown character in TTE flags of snapshot %s\n",flg);
}
}
adapt();
}
}
/*}}}*/
void SS_Tte::dump(FILE *fp)/*{{{*/
{
char m[7];
m[0] = is_real() ? 'r' : (is_virt() ? 'v' : '-');
m[1] = p() ? 'p' : '-';
m[2] = x() ? 'x' : '-';
m[3] = w() ? 'w' : '-';
m[4] = e() ? 'e' : '-';
m[5] = nfo() ? 'f' : '-';
m[6] = 0;
if (is_real())
fprintf(fp,"[%04x] %s %016llx(%016llx) %016llx %016llx ----\n",index,m,virt_page,tag(),virt_mask,phys_page);
else
fprintf(fp,"[%04x] %s %016llx(%016llx) %016llx %016llx %04x\n",index,m,virt_page,tag(),virt_mask,phys_page,context());
}
/*}}}*/