Initial commit of OpenSPARC T2 architecture model.
[OpenSPARC-T2-SAM] / sam-t2 / sam / cpus / vonk / ss / lib / cpu / src / SS_SnapShot.h
/*
* ========== Copyright Header Begin ==========================================
*
* OpenSPARC T2 Processor File: SS_SnapShot.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_SnapShot_h__
#define __SS_SnapShot_h__
#include <stdio.h>
#include "SS_Types.h"
class SS_SnapShot
{
public:
const uint_t VERSION; // Every time the snaphot layout changes this need to be bumped
enum Status
{
OK = 0, // All good
FILE_ERROR = 1, // Somethings wrong with file I/O
LINE_ERROR = 2, // Line is not tag value pair
TAG_ERROR = 3 // Expected a different tag
};
enum Limits
{
LINE_SIZE = 1024 // Maximum size of a line in the snapshot file
};
SS_SnapShot( FILE* f, bool _load );
bool do_load() { return load; }
bool do_save() { return !load; }
char tag[LINE_SIZE];
void val( uint8_t* ptr );
void val( uint16_t* ptr );
void val( uint32_t* ptr );
void val( uint64_t* ptr );
void val( int64_t* ptr ) { val((uint64_t*)ptr); }
void val( bool* ptr );
void val( char* ptr );
Status get_status() { return status; }
// get_version() and set_version() are used to record a version
// number for the snapshot. This is a pure user feature that allows
// to make a version number available everywhere snaphot is passed around.
void set_version( uint_t v ) { version = v; }
uint_t get_version() { return version; }
protected:
FILE* file;
bool load; // True when loading snapshot, false when saving
Status status; // The current status
uint_t version; // A version number provided by the user.
};
#endif