[rtems-tools commit] Add sparc PSR

Chris Johns chrisj at rtems.org
Sun Aug 24 23:45:35 UTC 2014


Module:    rtems-tools
Branch:    master
Commit:    788a71578f394f1938b455385da75f722373232a
Changeset: http://git.rtems.org/rtems-tools/commit/?id=788a71578f394f1938b455385da75f722373232a

Author:    Dhananjay Balan <mb.dhananjay at gmail.com>
Date:      Sun Aug 25 15:14:57 2013 +0530

Add sparc PSR
 - added a class to print SPARC status register

---

 tools/gdb/python/sparc.py |   76 +++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 76 insertions(+), 0 deletions(-)

diff --git a/tools/gdb/python/sparc.py b/tools/gdb/python/sparc.py
new file mode 100644
index 0000000..fa7b037
--- /dev/null
+++ b/tools/gdb/python/sparc.py
@@ -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
+
+
+
+
+
+
+



More information about the vc mailing list