freemyipod r97 - Code Review

Jump to: navigation, search
Repository:freemyipod
Revision:r96‎ | r97 | r98 >
Date:16:54, 11 August 2010
Author:benedikt93
Status:new
Tags:
Comment:
tweak libembios.py and fix 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
@@ -360,12 +360,13 @@
361361
362362 elif argv[1] == "readrawbootflash":
363363 if len(argv) != 5: usage()
364 - dev.readrawbootflash(int(argv[2]), int(argv[3]), int(argv[4]))
 364+ dev.readrawbootflash(int(argv[2], 16), int(argv[3], 16), int(argv[4], 16))
365365
366366 elif argv[1] == "writerawbootflash":
367367 if len(argv) != 5: usage()
368 - dev.writerawbootflash(int(argv[2]), int(argv[3]), int(argv[4]))
369 -
 368+ dev.writerawbootflash(int(argv[2], 16), int(argv[3], 16), int(argv[4], 16))
 369+
 370+
370371 elif argv[1] == "flushcaches":
371372 if len(argv) != 2: usage()
372373 dev.flushcaches()
Index: embios/trunk/tools/libembios.py
@@ -258,13 +258,15 @@
259259
260260 # correct alignment
261261 while (offset & 0xF) != 0:
262 - blocklen = (0x10 - offset % 0x10)
263 -
 262+ blocklen = size
 263+
264264 if (blocklen > size):
265265 blocklen = size
266266 if (blocklen > self.cout_maxsize - 0x10):
267 - blocklen = self.cout_maxsize
 267+ blocklen = self.cout_maxsize - 0x10
268268
 269+ blocklen = (blocklen & 0xFFFFFFF0) + (offset & 0xF)
 270+
269271 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 5, offset, blocklen, 0) + data[boffset:boffset+blocklen])
270272 response = self.__getbulk(self.handle, self.__cinep, 0x10)
271273 self.__checkstatus(response)
@@ -274,11 +276,11 @@
275277 size -= blocklen
276278
277279 # write data with DMA, if it makes sense (-> much data) and isn't forbidden
278 - if (usedma):
 280+ if (usedma) and (size > 2 * (self.cout_maxsize - 16)):
279281 if (freezesched):
280 - self.freezescheduler(1)
 282+ self.freezescheduler(1, 0)
281283
282 - while (size > 0x1F):
 284+ while (size > (self.cout_maxsize - 16)):
283285 blocklen = size
284286
285287 if (blocklen > self.dout_maxsize):
@@ -295,7 +297,7 @@
296298 size -= blocklen
297299
298300 if (freezesched):
299 - self.freezescheduler(0)
 301+ self.freezescheduler(0, 0)
300302
301303 # write rest of data
302304 while (size > 0):
@@ -302,7 +304,7 @@
303305 blocklen = size
304306
305307 if (blocklen > self.cout_maxsize - 0x10):
306 - blocklen = self.cout_maxsize
 308+ blocklen = self.cout_maxsize - 0x10
307309
308310 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 5, offset, blocklen, 0) + data[boffset:boffset+blocklen])
309311 response = self.__getbulk(self.handle, self.__cinep, 0x10)
@@ -321,12 +323,14 @@
322324
323325 # correct alignment
324326 while (offset & 0xF) != 0:
325 - blocklen = (0x10 - offset % 0x10)
 327+ blocklen = size
326328
327329 if (blocklen > size):
328330 blocklen = size
329331 if (blocklen > self.cin_maxsize - 0x10):
330 - blocklen = self.cin_maxsize
 332+ blocklen = self.cin_maxsize - 0x10
 333+
 334+ blocklen = (blocklen & 0xFFFFFFF0) + (offset & 0xF)
331335
332336 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 4, offset, blocklen, 0))
333337 response = self.__getbulk(self.handle, self.__cinep, 0x10 + blocklen)
@@ -338,11 +342,11 @@
339343 size -= blocklen
340344
341345 # read data with DMA, if it makes sense (-> much data) and isn't forbidden
342 - if (usedma):
 346+ if (usedma) and (size > 2 * (self.cin_maxsize - 16)):
343347 if (freezesched):
344 - self.freezescheduler(1)
 348+ self.freezescheduler(1, 0)
345349
346 - while (size > 0x1F):
 350+ while (size > (self.cin_maxsize - 16)):
347351 blocklen = size
348352
349353 if (blocklen > self.din_maxsize):
@@ -358,7 +362,7 @@
359363 size -= blocklen
360364
361365 if (freezesched):
362 - self.freezescheduler(0)
 366+ self.freezescheduler(0, 0)
363367
364368 # read rest of data
365369 while (size > 0):
@@ -365,7 +369,7 @@
366370 blocklen = size
367371
368372 if (blocklen > self.cin_maxsize - 0x10):
369 - blocklen = self.cin_maxsize
 373+ blocklen = self.cin_maxsize - 0x10
370374
371375 self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 4, offset, blocklen, 0))
372376 response = self.__getbulk(self.handle, self.__cinep, 0x10 + blocklen)