Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: SS_SnapShot.cc | |
4 | // Copyright (c) 2006 Sun Microsystems, Inc. All Rights Reserved. | |
5 | // DO NOT ALTER OR REMOVE COPYRIGHT NOTICES. | |
6 | // | |
7 | // The above named program is free software; you can redistribute it and/or | |
8 | // modify it under the terms of the GNU General Public | |
9 | // License version 2 as published by the Free Software Foundation. | |
10 | // | |
11 | // The above named program is distributed in the hope that it will be | |
12 | // useful, but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 | // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 | // General Public License for more details. | |
15 | // | |
16 | // You should have received a copy of the GNU General Public | |
17 | // License along with this work; if not, write to the Free Software | |
18 | // Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA. | |
19 | // | |
20 | // ========== Copyright Header End ============================================ | |
21 | ||
22 | #include <string.h> | |
23 | #include "SS_SnapShot.h" | |
24 | ||
25 | // The list here describes which class uses a particular | |
26 | // SS_SnapShot::VERSION, e.g. where and what fix/change | |
27 | // the version. | |
28 | // | |
29 | // 1 First version | |
30 | // 2 SS_Message - pending interrupt | |
31 | // 3 Rk_Strand - imu qd_reverse_map fix | |
32 | // 4 SS_Cpu - strand_stepping grows to 128 bits for xx | |
33 | ||
34 | SS_SnapShot::SS_SnapShot( FILE* f, bool _load )/*{{{*/ | |
35 | : | |
36 | VERSION(4), // When bumped add line above to keep track | |
37 | file(f), | |
38 | load(_load), | |
39 | status(OK) | |
40 | {} | |
41 | /*}}}*/ | |
42 | ||
43 | void SS_SnapShot::val( uint8_t* ptr )/*{{{*/ | |
44 | { | |
45 | if (status == OK) | |
46 | { | |
47 | if (load) | |
48 | { | |
49 | char line[LINE_SIZE]; | |
50 | char _tag[LINE_SIZE]; | |
51 | uint32_t _val; | |
52 | ||
53 | if (fgets(line,LINE_SIZE,file) == 0) | |
54 | status = FILE_ERROR; | |
55 | else if (sscanf(line,"%s%x",_tag,&_val) != 2) | |
56 | status = LINE_ERROR; | |
57 | else if (strcmp(tag,_tag) != 0) | |
58 | status = TAG_ERROR; | |
59 | else | |
60 | *ptr = _val; | |
61 | } | |
62 | else | |
63 | { | |
64 | fprintf(file,"%s\t%x\n",tag,*ptr); | |
65 | } | |
66 | } | |
67 | } | |
68 | /*}}}*/ | |
69 | void SS_SnapShot::val( uint16_t* ptr )/*{{{*/ | |
70 | { | |
71 | if (status == OK) | |
72 | { | |
73 | if (load) | |
74 | { | |
75 | char line[LINE_SIZE]; | |
76 | char _tag[LINE_SIZE]; | |
77 | uint32_t _val; | |
78 | ||
79 | if (fgets(line,LINE_SIZE,file) == 0) | |
80 | status = FILE_ERROR; | |
81 | else if (sscanf(line,"%s%x",_tag,&_val) != 2) | |
82 | status = LINE_ERROR; | |
83 | else if (strcmp(tag,_tag) != 0) | |
84 | status = TAG_ERROR; | |
85 | else | |
86 | *ptr = _val; | |
87 | } | |
88 | else | |
89 | { | |
90 | fprintf(file,"%s\t%x\n",tag,*ptr); | |
91 | } | |
92 | } | |
93 | } | |
94 | /*}}}*/ | |
95 | void SS_SnapShot::val( uint32_t* ptr )/*{{{*/ | |
96 | { | |
97 | if (status == OK) | |
98 | { | |
99 | if (load) | |
100 | { | |
101 | char line[LINE_SIZE]; | |
102 | char _tag[LINE_SIZE]; | |
103 | uint32_t _val; | |
104 | ||
105 | if (fgets(line,LINE_SIZE,file) == 0) | |
106 | status = FILE_ERROR; | |
107 | else if (sscanf(line,"%s%x",_tag,&_val) != 2) | |
108 | status = LINE_ERROR; | |
109 | else if (strcmp(tag,_tag) != 0) | |
110 | status = TAG_ERROR; | |
111 | else | |
112 | *ptr = _val; | |
113 | } | |
114 | else | |
115 | { | |
116 | fprintf(file,"%s\t%x\n",tag,*ptr); | |
117 | } | |
118 | } | |
119 | } | |
120 | /*}}}*/ | |
121 | void SS_SnapShot::val( uint64_t* ptr )/*{{{*/ | |
122 | { | |
123 | if (status == OK) | |
124 | { | |
125 | if (load) | |
126 | { | |
127 | char line[LINE_SIZE]; | |
128 | char _tag[LINE_SIZE]; | |
129 | uint64_t _val; | |
130 | ||
131 | if (fgets(line,LINE_SIZE,file) == 0) | |
132 | status = FILE_ERROR; | |
133 | else if (sscanf(line,"%s%llx",_tag,&_val) != 2) | |
134 | status = LINE_ERROR; | |
135 | else if (strcmp(tag,_tag) != 0) | |
136 | status = TAG_ERROR; | |
137 | else | |
138 | *ptr = _val; | |
139 | } | |
140 | else | |
141 | { | |
142 | fprintf(file,"%s\t%llx\n",tag,*ptr); | |
143 | } | |
144 | } | |
145 | } | |
146 | /*}}}*/ | |
147 | void SS_SnapShot::val( char* ptr )/*{{{*/ | |
148 | { | |
149 | if (status == OK) | |
150 | { | |
151 | if (load) | |
152 | { | |
153 | char line[LINE_SIZE]; | |
154 | char _tag[LINE_SIZE]; | |
155 | ||
156 | if (fgets(line,LINE_SIZE,file) == 0) | |
157 | status = FILE_ERROR; | |
158 | else if (sscanf(line,"%s%s",_tag,ptr) != 2) | |
159 | status = LINE_ERROR; | |
160 | else if (strcmp(tag,_tag) != 0) | |
161 | status = TAG_ERROR; | |
162 | } | |
163 | else | |
164 | { | |
165 | fprintf(file,"%s\t%s\n",tag,ptr); | |
166 | } | |
167 | } | |
168 | } | |
169 | /*}}}*/ | |
170 | ||
171 | void SS_SnapShot::val( bool* ptr )/*{{{*/ | |
172 | { | |
173 | if (status == OK) | |
174 | { | |
175 | if (load) | |
176 | { | |
177 | char line[LINE_SIZE]; | |
178 | char _tag[LINE_SIZE]; | |
179 | int _val; | |
180 | ||
181 | if (fgets(line,LINE_SIZE,file) == 0) | |
182 | status = FILE_ERROR; | |
183 | else if (sscanf(line,"%s%x",_tag,&_val) != 2) | |
184 | status = LINE_ERROR; | |
185 | else if (strcmp(tag,_tag) != 0) | |
186 | status = TAG_ERROR; | |
187 | else | |
188 | *ptr = _val; | |
189 | } | |
190 | else | |
191 | { | |
192 | fprintf(file,"%s\t%x\n",tag,*ptr); | |
193 | } | |
194 | } | |
195 | } | |
196 | /*}}}*/ |