Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | /* |
2 | * ========== Copyright Header Begin ========================================== | |
3 | * | |
4 | * OpenSPARC T2 Processor File: SS_SnapShot.h | |
5 | * Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
6 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
7 | * | |
8 | * The above named program is free software; you can redistribute it and/or | |
9 | * modify it under the terms of the GNU General Public | |
10 | * License version 2 as published by the Free Software Foundation. | |
11 | * | |
12 | * The above named program is distributed in the hope that it will be | |
13 | * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
15 | * General Public License for more details. | |
16 | * | |
17 | * You should have received a copy of the GNU General Public | |
18 | * License along with this work; if not, write to the Free Software | |
19 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
20 | * | |
21 | * ========== Copyright Header End ============================================ | |
22 | */ | |
23 | #ifndef __SS_SnapShot_h__ | |
24 | #define __SS_SnapShot_h__ | |
25 | ||
26 | #include <stdio.h> | |
27 | #include "SS_Types.h" | |
28 | ||
29 | class SS_SnapShot | |
30 | { | |
31 | public: | |
32 | const uint_t VERSION; // Every time the snaphot layout changes this need to be bumped | |
33 | ||
34 | enum Status | |
35 | { | |
36 | OK = 0, // All good | |
37 | FILE_ERROR = 1, // Somethings wrong with file I/O | |
38 | LINE_ERROR = 2, // Line is not tag value pair | |
39 | TAG_ERROR = 3 // Expected a different tag | |
40 | }; | |
41 | ||
42 | enum Limits | |
43 | { | |
44 | LINE_SIZE = 1024 // Maximum size of a line in the snapshot file | |
45 | }; | |
46 | ||
47 | SS_SnapShot( FILE* f, bool _load ); | |
48 | ||
49 | bool do_load() { return load; } | |
50 | bool do_save() { return !load; } | |
51 | ||
52 | char tag[LINE_SIZE]; | |
53 | ||
54 | void val( uint8_t* ptr ); | |
55 | void val( uint16_t* ptr ); | |
56 | void val( uint32_t* ptr ); | |
57 | void val( uint64_t* ptr ); | |
58 | void val( int64_t* ptr ) { val((uint64_t*)ptr); } | |
59 | void val( bool* ptr ); | |
60 | void val( char* ptr ); | |
61 | ||
62 | Status get_status() { return status; } | |
63 | ||
64 | // get_version() and set_version() are used to record a version | |
65 | // number for the snapshot. This is a pure user feature that allows | |
66 | // to make a version number available everywhere snaphot is passed around. | |
67 | ||
68 | void set_version( uint_t v ) { version = v; } | |
69 | uint_t get_version() { return version; } | |
70 | ||
71 | protected: | |
72 | FILE* file; | |
73 | bool load; // True when loading snapshot, false when saving | |
74 | Status status; // The current status | |
75 | uint_t version; // A version number provided by the user. | |
76 | }; | |
77 | ||
78 | #endif | |
79 |