freemyipod r129 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r128‎ | r129 | r130 >
Date:23:30, 13 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
work around the libembios bug
Modified paths:
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/libembios.py
@@ -810,8 +810,32 @@
811811 process_n += 1
812812
813813 return retval
814 -
815 -
 814+
 815+
 816+ def state2name(state):
 817+ if state == 0: return "THREAD_FREE"
 818+ elif state == 1: return "THREAD_SUSPENDED"
 819+ elif state == 2: return "THREAD_READY"
 820+ elif state == 3: return "THREAD_RUNNING"
 821+ elif state == 4: return "THREAD_BLOCKED"
 822+ elif state == 5: return "THREAD_DEFUNCT"
 823+ elif state == 6: return "THREAD_DEFUNCT_ACK"
 824+ else: return "UNKNOWN"
 825+
 826+ def blocktype2name(blocktype):
 827+ if blocktype == 0: return "THREAD_NOT_BLOCKED"
 828+ elif blocktype == 1: return "THREAD_BLOCK_SLEEP"
 829+ elif blocktype == 2: return "THREAD_BLOCK_MUTEX"
 830+ elif blocktype == 3: return "THREAD_BLOCK_WAKEUP"
 831+ elif blocktype == 4: return "THREAD_DEFUNCT_STKOV"
 832+ elif blocktype == 5: return "THREAD_DEFUNCT_PANIC"
 833+ else: return "UNKNOWN"
 834+
 835+ def threadtype2name (threadtype):
 836+ if threadtype == 0: return "USER_THREAD"
 837+ elif threadtype == 1: return "SYSTEM_THREAD"
 838+ else: return "UNKNOWN"
 839+
816840 def procinfotostring(procinfolist, structver):
817841 processinfoprint = ""
818842 ptr = 0
@@ -826,8 +850,7 @@
827851 + "R12: 0x%08x, SP: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
828852 % (procinfolist[ptr]['regs'][12], procinfolist[ptr]['regs'][13], procinfolist[ptr]['regs'][14], procinfolist[ptr]['regs'][15])
829853 processinfoprint += "cpsr: 0x%08x " % (procinfolist[ptr]['cpsr'])
830 - states = ("THREAD_FREE", "THREAD_SUSPENDED", "THREAD_READY", "THREAD_RUNNING", "THREAD_BLOCKED", "THREAD_DEFUNCT", "THREAD_DEFUNCT_ACK")
831 - processinfoprint += "state: %s " % (states[procinfolist[ptr]['state']])
 854+ processinfoprint += "state: %s " % (state2name([procinfolist[ptr]['state']]))
832855 processinfoprint += "nameptr: 0x%08x\n" % (procinfolist[ptr]['name_ptr'])
833856 processinfoprint += "current cpu time: 0x%08x " % (procinfolist[ptr]['cputime_current'])
834857 processinfoprint += "total cpu time: 0x%016x\n" % (procinfolist[ptr]['cputime_total'])
@@ -837,10 +860,8 @@
838861 processinfoprint += "blocked since: 0x%08x " % (procinfolist[ptr]['blocked_since'])
839862 processinfoprint += "blocked by ptr: 0x%08x\n" % (procinfolist[ptr]['blocked_by_ptr'])
840863 processinfoprint += "err_no: 0x%08x " % (procinfolist[ptr]['err_no'])
841 - blocktype = ("THREAD_NOT_BLOCKED", "THREAD_BLOCK_SLEEP", "THREAD_BLOCK_MUTEX", "THREAD_BLOCK_WAKEUP", "THREAD_DEFUNCT_STKOV", "THREAD_DEFUNCT_PANIC")
842 - processinfoprint += "block type: %s\n" % (blocktype[procinfolist[ptr]['block_type']])
843 - threadtype = ("USER_THREAD", "SYSTEM_THREAD")
844 - processinfoprint += "thread type: %s\n" % (threadtype[procinfolist[ptr]['thread_type']])
 864+ processinfoprint += "block type: %s\n" % (blocktype2name([procinfolist[ptr]['block_type']]))
 865+ processinfoprint += "thread type: %s\n" % (threadtype2name([procinfolist[ptr]['thread_type']]))
845866 processinfoprint += "priority: 0x%02x " % (procinfolist[ptr]['priority'])
846867 processinfoprint += "cpu load: 0x%02x\n" % (procinfolist[ptr]['cpuload'])
847868