mirror of
https://git.rtems.org/rtems-tools/
synced 2025-10-16 22:22:39 +08:00
Add sparc PSR
- added a class to print SPARC status register
This commit is contained in:

committed by
Chris Johns

parent
7a415d4e43
commit
788a71578f
76
tools/gdb/python/sparc.py
Normal file
76
tools/gdb/python/sparc.py
Normal file
@@ -0,0 +1,76 @@
|
||||
#
|
||||
# RTEMS gdb extensions
|
||||
# sparc archetecture specific abstractions
|
||||
|
||||
from helper import test_bit
|
||||
|
||||
class psr:
|
||||
'''status register'''
|
||||
|
||||
sv_table = {
|
||||
0 : 'user',
|
||||
1 : 'superviser'
|
||||
}
|
||||
|
||||
|
||||
def __init__(self, psr):
|
||||
self.psr = psr
|
||||
|
||||
def current_window(self):
|
||||
return int(self.psr & 0xf)
|
||||
|
||||
def traps(self):
|
||||
return test_bit(self.psr, 5)
|
||||
|
||||
def prev_superviser(self):
|
||||
return int(test_bit(self.psr,6))
|
||||
|
||||
def superviser(self):
|
||||
return int(test_bit(self.psr,7))
|
||||
|
||||
def interrupt_level(self):
|
||||
# bits 8 to 11
|
||||
return (self.spr & 0x780) >> 7
|
||||
|
||||
def floating_point_status(self):
|
||||
return test_bit(self.psr, 12)
|
||||
|
||||
def coproc_status(self):
|
||||
return test_bit(self.psr,13)
|
||||
|
||||
def carry(self):
|
||||
return test_bit(self.psr, 20)
|
||||
|
||||
def overflow(self):
|
||||
return test_bit(self.psr, 21)
|
||||
|
||||
def zero(self):
|
||||
return test_bit(self.psr, 22)
|
||||
|
||||
def icc(self):
|
||||
n = test_bit(self.psr,23)
|
||||
z = test_bit(self.psr,22)
|
||||
v = test_bit(self.psr,21)
|
||||
c = test_bit(self.psr,20)
|
||||
return (n,z,v,c)
|
||||
|
||||
def to_string(self):
|
||||
val = " Status Register"
|
||||
val += "\n R Window : " + str(self.current_window())
|
||||
val += "\n Traps Enabled : " + str(self.traps())
|
||||
val += "\n Flaoting Point : " + str(self.floating_point_status())
|
||||
val += "\n Coprocessor : " + str(self.coproc_status())
|
||||
val += "\n Processor Mode : " + self.sv_table[self.superviser()]
|
||||
val += "\n Prev. Mode : " + self.sv_table[self.superviser()]
|
||||
val += "\n Carry : " + str(int(self.carry()))
|
||||
val += "\n Overflow : " + str(int(self.overflow()))
|
||||
val += "\n Zero : " + str(int(self.zero()))
|
||||
|
||||
return val
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user