freemyipod r119 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r118‎ | r119 | r120 >
Date:13:22, 13 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
hopefully fix libembios.py->getprocinfo, extend embios.py
Modified paths:
  • /embios/trunk/tools/embios.py (modified) (history)
  • /embios/trunk/tools/libembios.py (modified) (history)

Diff [purge]

Index: embios/trunk/tools/embios.py
@@ -112,6 +112,8 @@
113113 print " Optional params <offset> <length>: specify the range in <file> to write"
114114 print " writeusbconsole direct <i1> <i2> ... <iN>"
115115 print " Writes the integers <i1> ... <iN> to the USB console."
 116+ print " writeusbconsole string <str>"
 117+ print " Writes the string <str> to the USB console."
116118 print ""
117119 print " readdevconsole <bitmask> <size> <outtype> <file>"
118120 print " Reads data from one or more of the device's consoles."
@@ -130,6 +132,8 @@
131133 print " writedevconsole direct <bitmask> <i1> <i2> ... <iN>"
132134 print " Writes the integers <i1> ... <iN> to the device consoles specified"
133135 print " by <bitmask>"
 136+ print " writedevconsole string <bitmask> <str>"
 137+ print " Writes the string <str> to the device consoles specified by <bitmask>"
134138 print ""
135139 print " flushconsolebuffers <bitmask>"
136140 print " flushes one or more of the device consoles' buffers."
@@ -286,6 +290,12 @@
287291 data += struct.pack("<I", int(argv[ptr], 16))
288292 ptr += 1
289293 dev.writeusbcon(data)
 294+
 295+ if argv[2] == "string":
 296+ if len(argv) > 4: usage()
 297+ dev.writeusbcon(argv[3])
 298+
 299+ else: usage()
290300
291301 elif argv[1] == "readdevconsole":
292302 if len(argv) not in [5, 6]: usage()
@@ -318,6 +328,12 @@
319329 data += struct.pack("<I", int(argv[ptr], 16))
320330 ptr += 1
321331 dev.writeusbcon(int(argv[3], 16), data)
 332+
 333+ if argv[2] == "string":
 334+ if len(argv) > 5: usage()
 335+ dev.writedevcon(int(argv[3], 16), argv[4])
 336+
 337+ else: usage()
322338
323339 elif argv[1] == "flushconsolebuffers":
324340 if len(argv) != 3: usage()
Index: embios/trunk/tools/libembios.py
@@ -814,15 +814,15 @@
815815 processinfoprint = ""
816816 ptr = 0
817817 while structver == 1 and ptr < len(procinfolist): # Process information struct version == 1
818 - processinfoprint += "--------------------------------------------------------------------------------"
819 - processinfoprint += "R0: 0x%08x, R1: 0x%08x, R2: 0x%08x, R3: 0x%08x,\n\
820 - R4: 0x%08x, R5: 0x%08x, R6: 0x%08x, R7: 0x%08x,\n\
821 - R8: 0x%08x, R9: 0x%08x, R10: 0x%08x, R11: 0x%08x,\n\
822 - R12: 0x%08x, SP: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
823 - % (procinfolist[ptr]['regs'][0], procinfolist[ptr]['regs'][1], procinfolist[ptr]['regs'][2], procinfolist[ptr]['regs'][3], \
824 - procinfolist[ptr]['regs'][4], procinfolist[ptr]['regs'][5], procinfolist[ptr]['regs'][6], procinfolist[ptr]['regs'][7], \
825 - procinfolist[ptr]['regs'][8], procinfolist[ptr]['regs'][9], procinfolist[ptr]['regs'][10], procinfolist[ptr]['regs'][11], \
826 - procinfolist[ptr]['regs'][12], procinfolist[ptr]['regs'][13], procinfolist[ptr]['regs'][14], procinfolist[ptr]['regs'][15] )
 818+ processinfoprint += "--------------------------------------------------------------------------------\n"
 819+ processinfoprint += "R0: 0x%08x, R1: 0x%08x, R2: 0x%08x, R3: 0x%08x,\n"\
 820+ % (procinfolist[ptr]['regs'][0], procinfolist[ptr]['regs'][1], procinfolist[ptr]['regs'][2], procinfolist[ptr]['regs'][3])\
 821+ + "R4: 0x%08x, R5: 0x%08x, R6: 0x%08x, R7: 0x%08x,\n"\
 822+ % (procinfolist[ptr]['regs'][4], procinfolist[ptr]['regs'][5], procinfolist[ptr]['regs'][6], procinfolist[ptr]['regs'][7])\
 823+ + "R8: 0x%08x, R9: 0x%08x, R10: 0x%08x, R11: 0x%08x,\n"\
 824+ % (procinfolist[ptr]['regs'][8], procinfolist[ptr]['regs'][9], procinfolist[ptr]['regs'][10], procinfolist[ptr]['regs'][11])\
 825+ + "R12: 0x%08x, SP: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
 826+ % (procinfolist[ptr]['regs'][12], procinfolist[ptr]['regs'][13], procinfolist[ptr]['regs'][14], procinfolist[ptr]['regs'][15])
827827 processinfoprint += "cpsr: 0x%08x " % (procinfolist[ptr]['cpsr'])
828828 states = ("THREAD_FREE", "THREAD_SUSPENDED", "THREAD_READY", "THREAD_RUNNING", "THREAD_BLOCKED", "THREAD_DEFUNCT", "THREAD_DEFUNCT_ACK")
829829 processinfoprint += "state: %s " % (states[procinfolist[ptr]['state']])
@@ -835,7 +835,6 @@
836836 processinfoprint += "blocked since: 0x%08x " % (procinfolist[ptr]['blocked_since'])
837837 processinfoprint += "blocked by ptr: 0x%08x\n" % (procinfolist[ptr]['blocked_by_ptr'])
838838 processinfoprint += "err_no: 0x%08x " % (procinfolist[ptr]['err_no'])
839 - processinfoprint += "nameptr: 0x%08x\n" % (procinfolist[ptr]['namepointer'])
840839 blocktype = ("THREAD_NOT_BLOCKED", "THREAD_BLOCK_SLEEP", "THREAD_BLOCK_MUTEX", "THREAD_BLOCK_WAKEUP", "THREAD_DEFUNCT_STKOV", "THREAD_DEFUNCT_PANIC")
841840 processinfoprint += "block type: %s\n" % (blocktype[procinfolist[ptr]['block_type']])
842841 threadtype = ("USER_THREAD", "SYSTEM_THREAD")
@@ -842,11 +841,11 @@
843842 processinfoprint += "thread type: %s\n" % (threadtype[procinfolist[ptr]['thread_type']])
844843 processinfoprint += "priority: 0x%02x " % (procinfolist[ptr]['priority'])
845844 processinfoprint += "cpu load: 0x%02x\n" % (procinfolist[ptr]['cpuload'])
 845+
 846+ ptr += 1
846847
847 - ptr += 1
848 -
849 - processinfoprint += "--------------------------------------------------------------------------------"
850 -
 848+ processinfoprint += "--------------------------------------------------------------------------------\n"
 849+
851850 return processinfoprint
852851
853852
@@ -864,11 +863,14 @@
865864 self.__checkstatus(response)
866865
867866 tablesize = struct.unpack("<I", response[8:12])[0]
868 - procinfo += response[0x10:0x10 + blocklen]
869867
870868 if tablesize <= offset + blocklen:
 869+ blocklen = tablesize - offset
 870+ procinfo += response[0x10:0x10 + blocklen]
871871 structversion = struct.unpack("<I", response[4:8])[0]
872872 tablesize = struct.unpack("<I", response[8:12])[0]
 873+ else:
 874+ procinfo += response[0x10:0x10 + blocklen]
873875
874876 offset += blocklen
875877
@@ -879,12 +881,11 @@
880882
881883 out = (structversion, tablesize, procinfotolist(procinfo, structversion))
882884
883 - self.__myprint(" done\n\
884 - Process information struct version: 0x%08x\n\
885 - Total size of process information table: 0x%08x\n\
886 - %s\n\n"
887 - % (out[0], out[1], procinfotostring(out[2], structversion))
888 - , silent)
 885+ self.__myprint(" done\n"\
 886+ + "Process information struct version: 0x%08x\n" % out[0]\
 887+ + "Total size of process information table: 0x%08x\n" % out[1]\
 888+ + procinfotostring(out[2], 1)\
 889+ + "\n\n")
889890
890891 return out
891892