Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | // ========== Copyright Header Begin ========================================== |
2 | // | |
3 | // OpenSPARC T2 Processor File: SS_Tte.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 "SS_Tte.h" | |
23 | ||
24 | void SS_Tte::snapshot( SS_SnapShot& ss, const char* prefix )/*{{{*/ | |
25 | { | |
26 | char flg[32]; | |
27 | char* ptr = flg; | |
28 | ||
29 | if (ss.do_save()) | |
30 | { | |
31 | // Save the tte_flags as a char string rather then a number to | |
32 | // make us independant of the implementations. The characters | |
33 | // are choosens to "match" the flags, e.g. 'x' is execuable, etc. | |
34 | // If flags == 0 then a '-' is used to give the flags string length. | |
35 | ||
36 | if (p()) *ptr++ = 'p'; | |
37 | if (x()) *ptr++ = 'x'; | |
38 | if (w()) *ptr++ = 'w'; | |
39 | if (nfo()) *ptr++ = 'n'; | |
40 | if (ie()) *ptr++ = 'i'; | |
41 | if (cp()) *ptr++ = 'P'; | |
42 | if (cv()) *ptr++ = 'V'; | |
43 | if (e()) *ptr++ = 'e'; | |
44 | if (lock()) *ptr++ = 'L'; | |
45 | if (valid_bit()) *ptr++ = 'v'; | |
46 | if (real_bit()) *ptr++ = 'r'; | |
47 | if (flg == ptr) *ptr++ = '-'; | |
48 | *ptr = 0; | |
49 | } | |
50 | ||
51 | sprintf(ss.tag,"%s.pid",prefix); ss.val(&tte_pid); | |
52 | sprintf(ss.tag,"%s.sze",prefix); ss.val(&tte_page_size); | |
53 | sprintf(ss.tag,"%s.ctx",prefix); ss.val(&tte_context); | |
54 | sprintf(ss.tag,"%s.flg",prefix); ss.val(flg); | |
55 | sprintf(ss.tag,"%s.tag",prefix); ss.val(&tte_tag); | |
56 | sprintf(ss.tag,"%s.pa",prefix); ss.val(&tte_taddr); | |
57 | ||
58 | if (ss.do_load()) | |
59 | { | |
60 | // Load the tte flags back, converting the characters back to | |
61 | // numeric flags values. The character to flag conversion has to match | |
62 | // the once in teh do_save() black above. | |
63 | ||
64 | tte_flags = 0; | |
65 | while (*ptr) | |
66 | { | |
67 | switch (*ptr++) | |
68 | { | |
69 | case '-': break; | |
70 | case 'p': p(1); break; | |
71 | case 'x': x(1); break; | |
72 | case 'w': w(1); break; | |
73 | case 'n': nfo(1); break; | |
74 | case 'i': ie(1); break; | |
75 | case 'P': cp(1); break; | |
76 | case 'V': cv(1); break; | |
77 | case 'e': e(1); break; | |
78 | case 'L': lock(1); break; | |
79 | case 'v': valid_bit(1); break; | |
80 | case 'r': real_bit(1); break; | |
81 | default: fprintf(stderr,"Warning: Unknown character in TTE flags of snapshot %s\n",flg); | |
82 | } | |
83 | } | |
84 | ||
85 | adapt(); | |
86 | } | |
87 | } | |
88 | /*}}}*/ | |
89 | void SS_Tte::dump(FILE *fp)/*{{{*/ | |
90 | { | |
91 | char m[7]; | |
92 | ||
93 | m[0] = is_real() ? 'r' : (is_virt() ? 'v' : '-'); | |
94 | m[1] = p() ? 'p' : '-'; | |
95 | m[2] = x() ? 'x' : '-'; | |
96 | m[3] = w() ? 'w' : '-'; | |
97 | m[4] = e() ? 'e' : '-'; | |
98 | m[5] = nfo() ? 'f' : '-'; | |
99 | m[6] = 0; | |
100 | ||
101 | if (is_real()) | |
102 | fprintf(fp,"[%04x] %s %016llx(%016llx) %016llx %016llx ----\n",index,m,virt_page,tag(),virt_mask,phys_page); | |
103 | else | |
104 | fprintf(fp,"[%04x] %s %016llx(%016llx) %016llx %016llx %04x\n",index,m,virt_page,tag(),virt_mask,phys_page,context()); | |
105 | } | |
106 | /*}}}*/ | |
107 | ||
108 |