Commit | Line | Data |
---|---|---|
920dae64 AT |
1 | # ========== Copyright Header Begin ========================================== |
2 | # | |
3 | # OpenSPARC T2 Processor File: SS_Model.py | |
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 | ### @-ARCH-@_Model.py is automatically generated from | |
23 | ### ss/api/pfe/bin/Bl_Model.py, do not modify @-ARCH-@_Model.py, | |
24 | ### make necessary changes in ss/api/pfe/bin/Bl_Model.py instead. | |
25 | ||
26 | import Pfe_Tlb | |
27 | import Pfe_Model | |
28 | ||
29 | from SS_Break import * | |
30 | from Pfe_Tlb import Tte | |
31 | from Pfe_Conversion import * | |
32 | from Pfe_Assembler import asm | |
33 | ||
34 | import @-ARCH-@_Python | |
35 | import SS_Strand | |
36 | from SS_Strand import AsiState | |
37 | ||
38 | dis = @-ARCH-@_Python.dis | |
39 | ||
40 | SS_Strand.__asi_va__ = {} | |
41 | for i in range(0,8): | |
42 | SS_Strand.__asi_va__['scratch'+chr(i+ord('0'))] = AsiState(0x20,i*8) | |
43 | SS_Strand.__asi_va__['hscratch'+chr(i+ord('0'))] = AsiState(0x4f,i*8) | |
44 | ||
45 | SS_Strand.__asi_va__['strand_available'] = AsiState(0x41,0x00) | |
46 | SS_Strand.__asi_va__['strand_enable_status'] = AsiState(0x41,0x10) | |
47 | SS_Strand.__asi_va__['strand_enable'] = AsiState(0x41,0x20) | |
48 | SS_Strand.__asi_va__['strand_running'] = AsiState(0x41,0x50) | |
49 | SS_Strand.__asi_va__['strand_running_status'] = AsiState(0x41,0x58) | |
50 | SS_Strand.__asi_va__['strand_running_w1s'] = AsiState(0x41,0x60) | |
51 | SS_Strand.__asi_va__['strand_running_w1c'] = AsiState(0x41,0x68) | |
52 | SS_Strand.__asi_va__['xir_steering'] = AsiState(0x41,0x30) | |
53 | SS_Strand.__asi_va__['tick_enable'] = AsiState(0x41,0x38) | |
54 | ||
55 | SS_Strand.__asi_va__['intr_w'] = AsiState(0x73,0x0) | |
56 | ||
57 | SS_Strand.__asi_va__['pri_ctx0'] = AsiState(0x21,0x008) | |
58 | SS_Strand.__asi_va__['pri_ctx1'] = AsiState(0x21,0x010) | |
59 | SS_Strand.__asi_va__['sec_ctx0'] = AsiState(0x21,0x108) | |
60 | SS_Strand.__asi_va__['sec_ctx1'] = AsiState(0x21,0x110) | |
61 | ||
62 | SS_Strand.__asi_va__['lsu_ctr'] = AsiState(0x45,0x0) | |
63 | ||
64 | SS_Strand.__asi_va__['inst_tag_target'] = AsiState(0x50,0x00) | |
65 | SS_Strand.__asi_va__['inst_sfsr'] = AsiState(0x50,0x18) | |
66 | SS_Strand.__asi_va__['inst_tag_access'] = AsiState(0x50,0x30) | |
67 | SS_Strand.__asi_va__['inst_tlb_data_in_v'] = AsiState(0x54,0x000) | |
68 | SS_Strand.__asi_va__['inst_tlb_data_in_r'] = AsiState(0x54,0x400) | |
69 | ||
70 | SS_Strand.__asi_va__['data_tag_target'] = AsiState(0x58,0x00) | |
71 | SS_Strand.__asi_va__['data_sfsr'] = AsiState(0x58,0x18) | |
72 | SS_Strand.__asi_va__['data_sfar'] = AsiState(0x58,0x20) | |
73 | SS_Strand.__asi_va__['data_tag_access'] = AsiState(0x58,0x30) | |
74 | SS_Strand.__asi_va__['data_tlb_data_in_v'] = AsiState(0x5c,0x000) | |
75 | SS_Strand.__asi_va__['data_tlb_data_in_r'] = AsiState(0x5c,0x400) | |
76 | ||
77 | SS_Strand.__asi_va__['partition_id'] = AsiState(0x58,0x80) | |
78 | ||
79 | SS_Strand.__asi_va__['real_range0'] = AsiState(0x52,0x108) | |
80 | SS_Strand.__asi_va__['real_range1'] = AsiState(0x52,0x110) | |
81 | SS_Strand.__asi_va__['real_range2'] = AsiState(0x52,0x118) | |
82 | SS_Strand.__asi_va__['real_range3'] = AsiState(0x52,0x120) | |
83 | ||
84 | SS_Strand.__asi_va__['phys_offset0'] = AsiState(0x52,0x208) | |
85 | SS_Strand.__asi_va__['phys_offset1'] = AsiState(0x52,0x210) | |
86 | SS_Strand.__asi_va__['phys_offset2'] = AsiState(0x52,0x218) | |
87 | SS_Strand.__asi_va__['phys_offset3'] = AsiState(0x52,0x220) | |
88 | ||
89 | SS_Strand.__asi_va__['nuc_tsb_cfg0'] = AsiState(0x54,0x010) | |
90 | SS_Strand.__asi_va__['nuc_tsb_cfg1'] = AsiState(0x54,0x018) | |
91 | SS_Strand.__asi_va__['nuc_tsb_cfg2'] = AsiState(0x54,0x020) | |
92 | SS_Strand.__asi_va__['nuc_tsb_cfg3'] = AsiState(0x54,0x028) | |
93 | ||
94 | SS_Strand.__asi_va__['non_nuc_tsb_cfg0'] = AsiState(0x54,0x030) | |
95 | SS_Strand.__asi_va__['non_nuc_tsb_cfg1'] = AsiState(0x54,0x038) | |
96 | SS_Strand.__asi_va__['non_nuc_tsb_cfg2'] = AsiState(0x54,0x040) | |
97 | SS_Strand.__asi_va__['non_nuc_tsb_cfg3'] = AsiState(0x54,0x048) | |
98 | ||
99 | SS_Strand.__asi_va__['inst_tsb_ptr0'] = AsiState(0x54,0x050) | |
100 | SS_Strand.__asi_va__['inst_tsb_ptr1'] = AsiState(0x54,0x058) | |
101 | SS_Strand.__asi_va__['inst_tsb_ptr2'] = AsiState(0x54,0x060) | |
102 | SS_Strand.__asi_va__['inst_tsb_ptr3'] = AsiState(0x54,0x068) | |
103 | ||
104 | SS_Strand.__asi_va__['data_tsb_ptr0'] = AsiState(0x54,0x070) | |
105 | SS_Strand.__asi_va__['data_tsb_ptr1'] = AsiState(0x54,0x078) | |
106 | SS_Strand.__asi_va__['data_tsb_ptr2'] = AsiState(0x54,0x080) | |
107 | SS_Strand.__asi_va__['data_tsb_ptr3'] = AsiState(0x54,0x088) | |
108 | ||
109 | ||
110 | def __tte_getvalid__(tte): return bool(tte.valid_bit()) | |
111 | def __tte_setvalid__(tte,val): tte.valid_bit(val) | |
112 | def __tte_getreal__(tte): return bool(tte.real_bit()) | |
113 | def __tte_setreal__(tte,val): tte.real_bit(val) | |
114 | def __tte_getpid__(tte): return tte.pid() | |
115 | def __tte_setpid__(tte,val): tte.pid(val) | |
116 | def __tte_getctx__(tte): return tte.context() | |
117 | def __tte_setctx__(tte,val): tte.context(val) | |
118 | def __tte_gettag__(tte): return tte.tag() | |
119 | def __tte_settag__(tte,val): tte.tag(val) | |
120 | def __tte_getsize__(tte): return tte.page_size() | |
121 | def __tte_setsize__(tte,val): tte.page_size(val) | |
122 | def __tte_getnfo__(tte): return bool(tte.nfo()) | |
123 | def __tte_setnfo__(tte,val): tte.nfo(val) | |
124 | def __tte_getie__(tte): return bool(tte.ie()) | |
125 | def __tte_setie__(tte,val): tte.ie(val) | |
126 | def __tte_getw__(tte): return bool(tte.w()) | |
127 | def __tte_setw__(tte,val): tte.w(val) | |
128 | def __tte_getx__(tte): return bool(tte.x()) | |
129 | def __tte_setx__(tte,val): tte.x(val) | |
130 | def __tte_getp__(tte): return bool(tte.p()) | |
131 | def __tte_setp__(tte,val): tte.p(val) | |
132 | def __tte_gete__(tte): return bool(tte.e()) | |
133 | def __tte_sete__(tte,val): tte.e(val) | |
134 | def __tte_getaddr__(tte): return tte.taddr() | |
135 | def __tte_setaddr__(tte,val): tte.taddr(val) | |
136 | ||
137 | # for unused fields in the TTE | |
138 | ||
139 | def __tte_getfalse__(tte): return False | |
140 | def __tte_setpass__(tte,val): pass | |
141 | ||
142 | class __tte_xlate__: | |
143 | def __init__(self,tte): | |
144 | self.tte = tte | |
145 | def __call__(self,addr): | |
146 | return self.tte.trans(addr) | |
147 | ||
148 | class __tte_match__: | |
149 | def __init__(self,tte): | |
150 | self.tte = tte | |
151 | def __call__(self,addr,ctx=0,pid=0,real=False,page_size_mask=0xff): | |
152 | if real: | |
153 | self.tte.match_real(addr,pid,page_size_mask) | |
154 | else: | |
155 | self.tte.match_virt(addr,ctx,pid,page_size_mask) | |
156 | ||
157 | Pfe_Tlb.TlbTte.__getfun__['xlate'] = __tte_xlate__ | |
158 | Pfe_Tlb.TlbTte.__getfun__['match'] = __tte_match__ | |
159 | ||
160 | Pfe_Tlb.TlbTte.__getfun__['valid'] = __tte_getvalid__ | |
161 | Pfe_Tlb.TlbTte.__setfun__['valid'] = __tte_setvalid__ | |
162 | Pfe_Tlb.TlbTte.__getfun__['real'] = __tte_getreal__ | |
163 | Pfe_Tlb.TlbTte.__setfun__['real'] = __tte_setreal__ | |
164 | Pfe_Tlb.TlbTte.__getfun__['pid'] = __tte_getpid__ | |
165 | Pfe_Tlb.TlbTte.__setfun__['pid'] = __tte_setpid__ | |
166 | Pfe_Tlb.TlbTte.__getfun__['ctx'] = __tte_getctx__ | |
167 | Pfe_Tlb.TlbTte.__setfun__['ctx'] = __tte_setctx__ | |
168 | Pfe_Tlb.TlbTte.__getfun__['size'] = __tte_getsize__ | |
169 | Pfe_Tlb.TlbTte.__setfun__['size'] = __tte_setsize__ | |
170 | Pfe_Tlb.TlbTte.__getfun__['tag'] = __tte_gettag__ | |
171 | Pfe_Tlb.TlbTte.__setfun__['tag'] = __tte_settag__ | |
172 | Pfe_Tlb.TlbTte.__getfun__['ie'] = __tte_getie__ | |
173 | Pfe_Tlb.TlbTte.__setfun__['ie'] = __tte_setie__ | |
174 | Pfe_Tlb.TlbTte.__getfun__['nfo'] = __tte_getnfo__ | |
175 | Pfe_Tlb.TlbTte.__setfun__['nfo'] = __tte_setnfo__ | |
176 | Pfe_Tlb.TlbTte.__getfun__['x'] = __tte_getx__ | |
177 | Pfe_Tlb.TlbTte.__setfun__['x'] = __tte_setx__ | |
178 | Pfe_Tlb.TlbTte.__getfun__['p'] = __tte_getp__ | |
179 | Pfe_Tlb.TlbTte.__setfun__['p'] = __tte_setp__ | |
180 | Pfe_Tlb.TlbTte.__getfun__['w'] = __tte_getw__ | |
181 | Pfe_Tlb.TlbTte.__setfun__['w'] = __tte_setw__ | |
182 | Pfe_Tlb.TlbTte.__getfun__['e'] = __tte_gete__ | |
183 | Pfe_Tlb.TlbTte.__setfun__['e'] = __tte_sete__ | |
184 | Pfe_Tlb.TlbTte.__getfun__['addr'] = __tte_getaddr__ | |
185 | Pfe_Tlb.TlbTte.__setfun__['addr'] = __tte_setaddr__ | |
186 | ||
187 | Pfe_Tlb.TlbTte.__getfun__['cv'] = __tte_getfalse__ | |
188 | Pfe_Tlb.TlbTte.__setfun__['cv'] = __tte_setpass__ | |
189 | Pfe_Tlb.TlbTte.__getfun__['cp'] = __tte_getfalse__ | |
190 | Pfe_Tlb.TlbTte.__setfun__['cp'] = __tte_setpass__ | |
191 | Pfe_Tlb.TlbTte.__getfun__['lock'] = __tte_getfalse__ | |
192 | Pfe_Tlb.TlbTte.__setfun__['lock'] = __tte_setpass__ | |
193 | ||
194 | ||
195 | class Tlb(Pfe_Tlb.Tlb): | |
196 | def __init__(self,tlb): | |
197 | Pfe_Tlb.Tlb.__init__(self,tlb) | |
198 | ||
199 | def size(self): | |
200 | return self.__tlb__.size() | |
201 | ||
202 | def index(self,index): | |
203 | if index < 0 or index >= self.size(): | |
204 | raise IndexError | |
205 | else: | |
206 | return self.__tlb__.get(index) | |
207 | ||
208 | def insert(self,tte): | |
209 | if isinstance(tte,Tte): | |
210 | ss_tte = @-ARCH-@_Python.SS_Tte() | |
211 | __tte_setr__(ss_tte,tte.r) | |
212 | __tte_setvalid__(ss_tte,tte.valid) | |
213 | __tte_setctx__(ss_tte,tte.ctx) | |
214 | __tte_setpid__(ss_tte,tte.pid) | |
215 | __tte_settag__(ss_tte,tte.tag) | |
216 | __tte_setsize__(ss_tte,tte.size) | |
217 | __tte_setie__(ss_tte,tte.ie) | |
218 | __tte_setnfo__(ss_tte,tte.nfo) | |
219 | __tte_setx__(ss_tte,tte.x) | |
220 | __tte_setp__(ss_tte,tte.p) | |
221 | __tte_setw__(ss_tte,tte.w) | |
222 | __tte_setaddr__(ss_tte,tte.addr) | |
223 | self.__tlb__.insert(ss_tte) | |
224 | else: | |
225 | raise TypeError | |
226 | ||
227 | ||
228 | class Core(Pfe_Model.Core): | |
229 | def __init__(self,core,ref): | |
230 | Pfe_Model.Core.__init__(self) | |
231 | self.inst_tlb = Tlb(core.inst_tlb) | |
232 | self.data_tlb = Tlb(core.data_tlb) | |
233 | for i in range(0,core.strand_cnt()): | |
234 | strand_ref = 's'+str(i) | |
235 | strand_ptr = core.strand_ptr(i) | |
236 | strand = SS_Strand.Strand(strand_ptr,ref+'.'+strand_ref,@-ARCH-@_Python) | |
237 | self.__dict__[strand_ref] = strand | |
238 | self.s.append(strand) | |
239 | strand.__dict__['inst_tlb'] = self.inst_tlb | |
240 | strand.__dict__['data_tlb'] = self.data_tlb | |
241 | ||
242 | ||
243 | class Cpu(Pfe_Model.Cpu): | |
244 | def __init__(self,cpu,ref): | |
245 | Pfe_Model.Cpu.__init__(self) | |
246 | self.hard_reset = cpu.hard_reset | |
247 | for i in range(0,cpu.core_cnt()): | |
248 | core_ref = 'c'+str(i) | |
249 | core_ptr = cpu.core_ptr(i) | |
250 | core = Core(core_ptr,ref+'.'+core_ref) | |
251 | self.__dict__[core_ref] = core | |
252 | self.c.append(core) | |
253 | ||
254 | ||
255 | class Model(Pfe_Model.Model): | |
256 | def __init__(self,mem,io,model=None): | |
257 | Pfe_Model.Model.__init__(self) | |
258 | self.mem = mem | |
259 | self.io = io | |
260 | self.__model__ = model | |
261 | mem.__flush__ = model.flush | |
262 | if model: | |
263 | for i in range(0,model.cpu_cnt()): | |
264 | cpu_ref = 'p'+str(i) | |
265 | cpu_ptr = model.cpu_ptr(i) | |
266 | cpu = Cpu(cpu_ptr,cpu_ref) | |
267 | self.p.append(cpu) | |
268 | self.__dict__[cpu_ref] = cpu | |
269 | self.__populate__() | |
270 | ||
271 | def __create_cpu__(self,count,cpu_lst=[]): | |
272 | for i in range(0,count): | |
273 | cpu_ref = 'p'+str(i) | |
274 | if i < len(cpu_lst): | |
275 | cpu_ptr = cpu_lst[i] | |
276 | else: | |
277 | cpu_ptr = @-ARCH-@_Python.@-ARCH-VF-@_Cpu(cpu_ref) | |
278 | cpu = Cpu(cpu_ptr,cpu_ref) | |
279 | self.p.append(cpu) | |
280 | self.__dict__[cpu_ref] = cpu | |
281 | self.__populate__() | |
282 | return True | |
283 | ||
284 | def ras_enable(self,cmd=''): | |
285 | return self.__model__.ras_enable(cmd) |