freemyipod r94 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r93‎ | r94 | r95 >
Date:12:56, 11 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
add execimage command to libembios.py/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
@@ -168,7 +168,10 @@
169169 print " <priority> the priority of the thread, from 1 to 255"
170170 print " <state> the thread's initial state, valid are: 1 => ready, 0 => suspended"
171171 print ""
 172+ print " execimage <offset>"
 173+ print " Executes the emBIOS executable image at <offset>."
172174 print ""
 175+ print ""
173176 print " flushcaches"
174177 print " Flushes the CPUs data and instruction caches."
175178 print ""
@@ -338,7 +341,11 @@
339342 if len(argv) != 9: usage()
340343 dev.createthread(int(argv[2], 16), int(argv[3], 16), int(argv[4], 16), int(argv[5], 16), int(argv[6], 16), int(argv[7], 16), int(argv[8], 16))
341344
 345+ elif argv[1] == "execimage":
 346+ if len(argv) != 3: usage
 347+ dev.execimage(int(argv[2], 16))
342348
 349+
343350 elif argv[1] == "flushcaches":
344351 if len(argv) != 2: usage()
345352 dev.flushcaches()
@@ -345,6 +352,5 @@
346353
347354 else: usage()
348355
349 -
350356 dev = libembios.embios()
351357 parsecommand(dev, sys.argv)
Index: embios/trunk/tools/libembios.py
@@ -380,7 +380,7 @@
381381
382382
383383 def uploadfile(self, offset, file, usedma = 1, freezesched = 0, silent = 0):
384 - self.__myprint("Uploading %s to 0x%8x..." % (file, offset), silent)
 384+ self.__myprint("Uploading %s to 0x%08x..." % (file, offset), silent)
385385 f = open(file, "rb")
386386
387387 while True:
@@ -394,7 +394,7 @@
395395
396396
397397 def downloadfile(self, offset, size, file, usedma = 1, freezesched = 0, silent = 0):
398 - self.__myprint("Downloading 0x%x bytes from 0x%8x to %s..." % (size, offset, file), silent)
 398+ self.__myprint("Downloading 0x%x bytes from 0x%08x to %s..." % (size, offset, file), silent)
399399 f = open(file, "wb")
400400
401401 while True:
@@ -410,15 +410,15 @@
411411
412412
413413 def uploadint(self, offset, data, silent = 0):
414 - self.__myprint("Uploading 0x%8x to 0x%8x..." % (data, offset), silent)
 414+ self.__myprint("Uploading 0x%08x to 0x%08x..." % (data, offset), silent)
415415 self.write(offset, data, 0, 0)
416416 self.__myprint(" done\n", silent)
417417
418418
419419 def downloadint(self, offset, silent = 0):
420 - self.__myprint("Downloading 0x%8x from 0x%8x..." % (data, offset), silent)
 420+ self.__myprint("Downloading 0x%08x from 0x%08x..." % (data, offset), silent)
421421 data = self.read(offset, data, 0, 0)
422 - self.__myprint(" done\nValue was: 0x%8x\n" % (data), silent)
 422+ self.__myprint(" done\nValue was: 0x%08x\n" % (data), silent)
423423
424424 return data
425425
@@ -715,10 +715,10 @@
716716
717717 def suspendthread(self, suspend, threadid, silent = 0):
718718 if (suspend):
719 - self.__myprint("Suspending thread 0x%8x...", silent) % threadid
 719+ self.__myprint("Suspending thread 0x%08x..." % threadid, silent)
720720 suspend = 1
721721 else:
722 - self.__myprint("Unsuspending thread 0x%8x...", silent) % threadid
 722+ self.__myprint("Unsuspending thread 0x%08x..." % threadid, silent)
723723 suspend = 0
724724
725725 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 17, suspend, threadid, 0))
@@ -729,7 +729,7 @@
730730
731731
732732 def killthread(self, threadid, silent = 0):
733 - self.__myprint("Killing thread 0x%8x...", silent) % threadid
 733+ self.__myprint("Killing thread 0x%08x..." % threadid, silent)
734734
735735 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 18, threadid, 0, 0))
736736 response = self.__getbulk(self.handle, self.__cinep, 0x10)
@@ -1002,8 +1002,8 @@
10031003 processinfoprint += "--------------------------------------------------------------------------------"
10041004
10051005 self.__myprint(" done\n\
1006 - Process information struct version: 0x%8x\n\
1007 - Total size of process information table: 0x%8x\n\
 1006+ Process information struct version: 0x%08x\n\
 1007+ Total size of process information table: 0x%08x\n\
10081008 %s"
10091009 % (out[0], out[1], procinfoprint)
10101010 , silent)
@@ -1011,7 +1011,18 @@
10121012 return out
10131013
10141014
 1015+ def execimage(self, offset):
 1016+ self.__myprint("Executing emBIOS executable image at 0x%08x..." % offset, silent)
 1017+
 1018+ self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 18, threadid, 0, 0))
 1019+ response = self.__getbulk(self.handle, self.__cinep, 0x10)
 1020+ self.__checkstatus(response)
10151021
 1022+ self.__myprint(" done\n execimage() return code: 0x%08x\n" % struct.unpack("<I", response[4:8]), silent)
 1023+
 1024+ return struct.unpack("<I", response[4:8])
 1025+
 1026+
10161027 #=====================================================================================
10171028
10181029