Commit | Line | Data |
---|---|---|
86530b38 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: Niagara2.pm | |
4 | # Copyright (C) 1995-2007 Sun Microsystems, Inc. All Rights Reserved | |
5 | # 4150 Network Circle, Santa Clara, California 95054, U.S.A. | |
6 | # | |
7 | # * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | |
8 | # | |
9 | # This program is free software; you can redistribute it and/or modify | |
10 | # it under the terms of the GNU General Public License as published by | |
11 | # the Free Software Foundation; version 2 of the License. | |
12 | # | |
13 | # This program is distributed in the hope that it will be useful, | |
14 | # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | # GNU General Public License for more details. | |
17 | # | |
18 | # You should have received a copy of the GNU General Public License | |
19 | # along with this program; if not, write to the Free Software | |
20 | # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
21 | # | |
22 | # For the avoidance of doubt, and except that if any non-GPL license | |
23 | # choice is available it will apply instead, Sun elects to use only | |
24 | # the General Public License version 2 (GPLv2) at this time for any | |
25 | # software where a choice of GPL license versions is made | |
26 | # available with the language indicating that GPLv2 or any later version | |
27 | # may be used, or where a choice of which version of the GPL is applied is | |
28 | # otherwise unspecified. | |
29 | # | |
30 | # Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, | |
31 | # CA 95054 USA or visit www.sun.com if you need additional information or | |
32 | # have any questions. | |
33 | # | |
34 | # ========== Copyright Header End ============================================ | |
35 | # -*- perl -*- | |
36 | ||
37 | package Midas::MMU::Niagara2; | |
38 | use strict; | |
39 | ||
40 | use Midas::Command; | |
41 | use Midas::Error; | |
42 | use Midas::Configure; | |
43 | use Midas::Globals; | |
44 | use Midas::Segment; | |
45 | ||
46 | use TRELoad 'BitFieldTie'; | |
47 | ||
48 | use base qw(Midas::MMU); | |
49 | use fields qw( | |
50 | rasize | |
51 | ); | |
52 | ||
53 | ############################################################################## | |
54 | ||
55 | sub new { | |
56 | my $class = shift; | |
57 | my %args = @_; | |
58 | my $this = fields::new($class); | |
59 | $this->SUPER::new(); | |
60 | ||
61 | foreach my $key (keys %args) { | |
62 | $this->{$key} = $args{$key}; | |
63 | } | |
64 | ||
65 | $this->set_defaults(); | |
66 | ||
67 | $this->{mapattr_type} = 'Midas::MMU::Niagara2::SectionAttrs'; | |
68 | $this->{tsb_type} = 'Midas::MMU::Niagara2::TSB'; | |
69 | ||
70 | return $this; | |
71 | } | |
72 | ||
73 | ############################################################################## | |
74 | ||
75 | sub set_defaults { | |
76 | my $this = shift; | |
77 | ||
78 | $this->{vasize} = 64 unless defined $this->{vasize}; | |
79 | $this->{pasize} = 40 unless defined $this->{pasize}; | |
80 | $this->{rasize} = 40 unless defined $this->{rasize}; | |
81 | $this->{type} = 'niagara2' unless defined $this->{type}; | |
82 | ||
83 | ||
84 | $this->SUPER::set_defaults(); | |
85 | } | |
86 | ||
87 | ############################################################################## | |
88 | ||
89 | sub mmu_cpp_args { | |
90 | my $this = shift; | |
91 | my $list = ['-DNIAGARA2']; | |
92 | push @$list, '-DALLOW_TSB_COL' if $CONFIG{allow_tsb_conflicts}; | |
93 | return $list; | |
94 | } | |
95 | ||
96 | ############################################################################## | |
97 | ||
98 | ############################################################################## | |
99 | ############################################################################## | |
100 | ||
101 | { | |
102 | package Midas::MMU::Niagara2::SectionAttrs; | |
103 | use strict; | |
104 | ||
105 | use Carp; | |
106 | use Midas::Command; | |
107 | use Midas::Globals; | |
108 | use Midas::Error; | |
109 | use Midas::MMU::SunSectionAttrs; | |
110 | use Midas::MMU::TTEFormat; | |
111 | use BitFieldTie; | |
112 | ||
113 | ||
114 | use base qw(Midas::MMU::SunHyperAttrs); | |
115 | use fields (qw(), | |
116 | ( | |
117 | # Hard-code MMU type because 'use fields' directive needs | |
118 | # to happen at compile-time | |
119 | keys %{ get_union_tte_field_hash('niagara2') } | |
120 | ) | |
121 | ); | |
122 | ||
123 | our @Settable = qw(); | |
124 | ||
125 | our %Settable = map { $_ => 1} Midas::MMU::Niagara2::SectionAttrs->settable(); | |
126 | our %FieldSizes =( ); | |
127 | ||
128 | ############################################################################ | |
129 | ||
130 | sub new { | |
131 | my $this = shift; | |
132 | my %args = @_; | |
133 | ||
134 | unless (ref $this) { | |
135 | $this = fields::new($this); | |
136 | } | |
137 | ||
138 | $this->{settable} = \%Settable; | |
139 | foreach my $key (keys %args) { | |
140 | $this->{$key} = $args{$key}; | |
141 | } | |
142 | ||
143 | return $this; | |
144 | } | |
145 | ||
146 | ############################################################################ | |
147 | ||
148 | sub set_defaults { | |
149 | my $this = shift; | |
150 | ||
151 | $this->SUPER::set_defaults(); | |
152 | ||
153 | foreach my $field (keys %FieldSizes) { | |
154 | $this->{$field} = 0 unless defined $this->{$field}; | |
155 | } | |
156 | } | |
157 | ||
158 | ############################################################################# | |
159 | ||
160 | sub settable { | |
161 | my $this = shift; | |
162 | my @settable = $this->SUPER::settable(); | |
163 | push @settable, @Settable; | |
164 | return @settable; | |
165 | } | |
166 | ||
167 | ############################################################################# | |
168 | ||
169 | sub get_field_size_hash { | |
170 | my $this = shift; | |
171 | my $sizes = $this->SUPER::get_field_size_hash(); | |
172 | ||
173 | foreach my $field (keys %FieldSizes) { | |
174 | $sizes->{$field} = $FieldSizes{$field}; | |
175 | } | |
176 | ||
177 | return $sizes; | |
178 | } | |
179 | ||
180 | ############################################################################ | |
181 | ||
182 | sub legal_page_bits { | |
183 | my $this = shift; | |
184 | return (0, 1, 3, 5); | |
185 | } | |
186 | ||
187 | ########################################################################### | |
188 | ||
189 | } | |
190 | ||
191 | ############################################################################## | |
192 | ############################################################################## | |
193 | ||
194 | { | |
195 | package Midas::MMU::Niagara2::TSB; | |
196 | ||
197 | use Midas::Globals; | |
198 | use Midas::Command; | |
199 | use Midas::Error; | |
200 | use BitFieldTie; | |
201 | ||
202 | use base 'Midas::TSB'; | |
203 | use fields qw(); | |
204 | ||
205 | ||
206 | ||
207 | ############################################################################ | |
208 | ||
209 | sub new { | |
210 | my $this = shift; | |
211 | my %args = @_; | |
212 | ||
213 | unless (ref $this) { | |
214 | $this = fields::new($this); | |
215 | } | |
216 | ||
217 | $this->{touched} = 0; | |
218 | $this->{force_ctx_zero} = undef; | |
219 | $this->{page_size} = undef; | |
220 | ||
221 | foreach my $key (keys %args) { | |
222 | $this->{$key} = $args{$key}; | |
223 | } | |
224 | ||
225 | return $this; | |
226 | } | |
227 | ||
228 | ############################################################################ | |
229 | ||
230 | sub config_from_register { | |
231 | my $this = shift; | |
232 | my $mmu = shift; | |
233 | ||
234 | my $config = BitFieldTie->new(64, $this->{config_register}); | |
235 | my $base = BitFieldTie->new($PASIZE, 0); | |
236 | ||
237 | tie my %config, 'BitFieldTie', $config; | |
238 | tie my %base, 'BitFieldTie', $base; | |
239 | ||
240 | $base{'39:13'} = $config{'39:13'}; | |
241 | ||
242 | $this->{base} = $base; | |
243 | $this->{page_size} = $config{'6:4'}; | |
244 | $this->{ttefmt} = $config{7} ? 'sun4v' : 'sun4u'; | |
245 | $this->{sizebits} = $config{'3:0'}; | |
246 | $this->{is_split} = 0; | |
247 | $this->{numentries} = 512 * (1 << $this->{sizebits}); | |
248 | ||
249 | my $base_lo = 13 + $this->{sizebits}; | |
250 | if($base_lo > 13) { | |
251 | my $overlap = $base->extract($base_lo, 13); | |
252 | ||
253 | if($overlap) { | |
254 | if($CONFIG{allow_misaligned_tsb_base}) { | |
255 | $base->store($base_lo, 13, 0); | |
256 | } else { | |
257 | fatal "TSB '$this->{name}' has base $base, which\n". | |
258 | " is misaligned for size=$this->{sizebits}\n" . | |
259 | " Illegal unless -allow_misalgined_tsb_base is defined.\n" . | |
260 | " line=$this->{srcline}, file=$this->{srcfile}\n", | |
261 | M_TSBSYNTAX; | |
262 | } | |
263 | } | |
264 | ||
265 | } | |
266 | } | |
267 | ||
268 | ############################################################################ | |
269 | ||
270 | } | |
271 | ||
272 | ############################################################################## | |
273 | ############################################################################## | |
274 | ||
275 | 1; |