class GetAttrError(Exception):
return "The TLB has no getable field member '"+self
.name
+"'"
class DelAttrError(Exception):
return "TLB attributes such as "+name
+" can not be deleted"
class SetAttrError(Exception):
return "The TLB has no setable field member '"+self
.name
+"'"
def __geterror_fun__(name
,strand
):
def __seterror_fun__(name
,strand
,value
):
return lambda strand
: __geterror_fun__(name
,strand
)
return lambda strand
,value
: __seterror_fun__(name
,strand
,value
)
PAGE_SIZE
= ['8K','64K','512K','4M','32M','256M','2G','16G']
def __init__(self
,tte_ref
=None,**args
):
# some N2 specific TTE fields
elif isinstance(tte_ref
,TlbTte
) or isinstance(tte_ref
,Tte
):
self
.valid
= tte_ref
.valid
self
.soft_flds
= tte_ref
.soft_flds
self
.diag7_3
= tte_ref
.diag7_3
if self
.__dict
__.has_key(arg
):
setattr(self
,arg
,args
[arg
])
raise AttributeError(arg
)
return a string of the most common looked at fields of the TTE
ctx
= ' 0x%04x' % self
.ctx
s
+= self
.p
and 'p' or '-'
s
+= self
.x
and 'x' or '-'
s
+= self
.w
and 'w' or '-'
s
+= self
.e
and 'e' or '-'
s
+= self
.nfo
and 'n' or '-'
s
+= self
.ie
and 'i' or '-'
tag
= 0x10000000000000000 + tag
addr
= 0x10000000000000000 + addr
size
= self
.PAGE_SIZE
[self
.size
]
s
+= '%4s 0x%016x 0x%016x 0x%02x' % (size
,tag
,addr
,self
.pid
)
PAGE_SIZE
= ['8K','64K','512K','4M','32M','256M','2G','16G']
__getfun__
= { 'xlate': __geterror__('xlate'), 'match': __geterror__('match') }
for field
in ['valid','real','pid','ctx','size','tag','ie','nfo',
'x','p','w','e','cv','cp','lock','addr''soft_flds',
__getfun__
[field
] = __geterror__(field
)
__setfun__
[field
] = __seterror__(field
)
def __init__(self
,tlb
,index_fun
,index_arg
):
self
.__dict
__['__tlb__'] = tlb
self
.__dict
__['__fun__'] = index_fun
self
.__dict
__['__arg__'] = index_arg
def __getattr__(self
,name
):
if TlbTte
.__getfun
__.has_key(name
):
return TlbTte
.__getfun
__[name
](self
.__fun
__(self
.__arg
__))
def __setattr__(self
,name
,value
):
if TlbTte
.__setfun
__.has_key(name
):
tte
= self
.__fun
__(self
.__arg
__)
TlbTte
.__setfun
__[name
](tte
,value
)
if 'flush' in dir(self
.__tlb
__):
return '<TlbTte instance>'
return a string of the most common looked at fields of the TTE
ctx
= ' 0x%04x' % self
.ctx
s
+= self
.p
and 'p' or '-'
s
+= self
.x
and 'x' or '-'
s
+= self
.w
and 'w' or '-'
s
+= self
.e
and 'e' or '-'
s
+= self
.nfo
and 'n' or '-'
s
+= self
.ie
and 'i' or '-'
tag
= 0x10000000000000000 + tag
addr
= 0x10000000000000000 + addr
size
= self
.PAGE_SIZE
[self
.size
]
s
+= '%4s 0x%016x 0x%016x 0x%02x' % (size
,tag
,addr
,self
.pid
)
index
= self
.tlb
.next_valid_index(self
.idx
)
self
.__dict
__['__tlb__'] = tlb
self
.__dict
__['tte'] = {}
for i
in range(0,self
.size()):
self
.tte
[i
] = TlbTte(tlb
,self
.index
,i
)
i
= self
.next_valid_index(0)
i
= self
.next_valid_index(i
+1)
return TlbIter(self
.__tlb
__)
i
= self
.__tlb
__.next_valid_index(0)
i
= self
.__tlb
__.next_valid_index(i
+1)
i
= self
.__tlb
__.next_valid_index(0)
s
+= '0x%03x: %s\n' % (i
,str(self
.tte
[i
]))
i
= self
.__tlb
__.next_valid_index(i
+1)
def __getitem__(self
,index
):
def __setitem__(self
,index
,tte
):
# size() returns the fixed size of the TLB in number of TTEs.
# index() returns the TTE currently at index i of the TLB.
# insert() inserts the TTE in the TLB.
# next_valid_index() returns the next valid TTE in the TLB
# starting from i. If none are found the -1 is returned.
def next_valid_index(self
,i
):
# return reference to the tte that got inserted
# tag_bits21_13 (0 .. 0x1ff) are the lower 9 bits of the tag
# real is 1 when the tsb needs to be a ra2 pa tte, 0 otherwise
def insert4v(self
,pid
,tag
,data
,tag_bits21_13
,real
):
def insert4u(self
,pid
,tag
,data
,va
,real
):