| Line 540... |
Line 540... |
| 540 |
def ipodclassic_hddaccess(self, type, sector, count, addr):
|
540 |
def ipodclassic_hddaccess(self, type, sector, count, addr):
|
| 541 |
""" Target-specific function: ipodclassic
|
541 |
""" Target-specific function: ipodclassic
|
| 542 |
Access the hard disk, type = 0 (read) / 1 (write)
|
542 |
Access the hard disk, type = 0 (read) / 1 (write)
|
| 543 |
"""
|
543 |
"""
|
| 544 |
rc = self.lib.monitorcommand(struct.pack("<IIQIIII", 0xffff0002, type, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
544 |
rc = self.lib.monitorcommand(struct.pack("<IIQIIII", 0xffff0002, type, sector, count, addr, 0, 0), "III", ("rc", None, None))
|
| 545 |
if (rc > 0x80000000):
|
545 |
if (rc.rc > 0x80000000):
|
| 546 |
raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc))
|
546 |
raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc.rc))
|
| 547 |
|
547 |
|
| 548 |
@command(target = 0x4c435049)
|
548 |
@command(target = 0x4c435049)
|
| 549 |
def ipodclassic_writebbt(self, bbt, tempaddr):
|
549 |
def ipodclassic_writebbt(self, bbt, tempaddr = None):
|
| 550 |
""" Target-specific function: ipodclassic
|
550 |
""" Target-specific function: ipodclassic
|
| 551 |
Write hard drive bad block table
|
551 |
Write hard drive bad block table
|
| 552 |
"""
|
552 |
"""
|
| 553 |
try:
|
553 |
try:
|
| 554 |
bbtheader = struct.unpack("<8s2024sQII512I", bbt[:4096])
|
554 |
bbtheader = struct.unpack("<8s2024sQII512I", bbt[:4096])
|
| Line 556... |
Line 556... |
| 556 |
raise ArgumentError("The specified file is not an emCORE hard disk BBT")
|
556 |
raise ArgumentError("The specified file is not an emCORE hard disk BBT")
|
| 557 |
if bbtheader[0] != "emBIbbth":
|
557 |
if bbtheader[0] != "emBIbbth":
|
| 558 |
raise ArgumentError("The specified file is not an emCORE hard disk BBT")
|
558 |
raise ArgumentError("The specified file is not an emCORE hard disk BBT")
|
| 559 |
virtualsectors = bbtheader[2]
|
559 |
virtualsectors = bbtheader[2]
|
| 560 |
bbtsectors = bbtheader[3]
|
560 |
bbtsectors = bbtheader[3]
|
| - |
|
561 |
if tempaddr is None:
|
| - |
|
562 |
tempaddr = self.malloc(len(bbt))
|
| - |
|
563 |
malloc = True
|
| - |
|
564 |
else:
|
| - |
|
565 |
malloc = False
|
| - |
|
566 |
try:
|
| 561 |
self.write(tempaddr, bbt)
|
567 |
self.write(tempaddr, bbt)
|
| 562 |
sector = 0
|
568 |
sector = 0
|
| 563 |
count = 1
|
569 |
count = 1
|
| 564 |
offset = 0
|
570 |
offset = 0
|
| 565 |
for i in range(bbtsectors):
|
571 |
for i in range(bbtsectors):
|
| 566 |
if bbtheader[4][i] == sector + count:
|
572 |
if bbtheader[4][i] == sector + count:
|
| 567 |
count = count + 1
|
573 |
count = count + 1
|
| 568 |
else:
|
574 |
else:
|
| 569 |
self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
575 |
self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
| 570 |
offset = offset + count * 4096
|
576 |
offset = offset + count * 4096
|
| 571 |
sector = bbtheader[4][i]
|
577 |
sector = bbtheader[4][i]
|
| 572 |
count = 1
|
578 |
count = 1
|
| 573 |
self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
579 |
self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
|
| - |
|
580 |
except:
|
| - |
|
581 |
if malloc == True:
|
| - |
|
582 |
self.free(tempaddr)
|
| - |
|
583 |
raise
|
| 574 |
|
584 |
|
| 575 |
@command()
|
585 |
@command()
|
| 576 |
def storage_get_info(self, volume):
|
586 |
def storage_get_info(self, volume):
|
| 577 |
""" Get information about a storage device """
|
587 |
""" Get information about a storage device """
|
| 578 |
self.logger.debug("Getting storage information\n")
|
588 |
self.logger.debug("Getting storage information\n")
|