Subversion Repositories freemyipod

Rev

Rev 609 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 609 Rev 615
Line 568... Line 568...
568
        """
568
        """
569
        rc = self.lib.monitorcommand(struct.pack("<IIQIIII", 0xffff0002, type, sector, count, addr, 0, 0), "III", ("rc", None, None))
569
        rc = self.lib.monitorcommand(struct.pack("<IIQIIII", 0xffff0002, type, sector, count, addr, 0, 0), "III", ("rc", None, None))
570
        if (rc.rc > 0x80000000):
570
        if (rc.rc > 0x80000000):
571
            raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc.rc))
571
            raise DeviceError("HDD access (type=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (type, sector, count, addr, rc.rc))
572
    
572
    
-
 
573
    @command(timeout = 30000, target = 0x4c435049)
-
 
574
    def ipodclassic_reloadbbt(self):
-
 
575
        """ Target-specific function: ipodclassic
-
 
576
            Reload the ATA bbt
-
 
577
        """
-
 
578
        rc = self.lib.monitorcommand(struct.pack("<IIII", 0xffff0003, 0, 0, 0), "III", (None, None, None))
-
 
579
    
-
 
580
    @command(timeout = 30000, target = 0x4c435049)
-
 
581
    def ipodclassic_disablebbt(self):
-
 
582
        """ Target-specific function: ipodclassic
-
 
583
            Disable the ATA bbt
-
 
584
        """
-
 
585
        rc = self.lib.monitorcommand(struct.pack("<IIII", 0xffff0004, 0, 0, 0), "III", (None, None, None))
-
 
586
    
573
    @command(target = 0x4c435049)
587
    @command(target = 0x4c435049)
574
    def ipodclassic_writebbt(self, bbt, tempaddr = None):
588
    def ipodclassic_writebbt(self, bbt, tempaddr = None):
575
        """ Target-specific function: ipodclassic
589
        """ Target-specific function: ipodclassic
576
            Write hard drive bad block table
590
            Write hard drive bad block table
577
        """
591
        """
Line 588... Line 602...
588
            malloc = True
602
            malloc = True
589
        else:
603
        else:
590
            malloc = False
604
            malloc = False
591
        try:
605
        try:
592
            self.write(tempaddr, bbt)
606
            self.write(tempaddr, bbt)
-
 
607
	    self.disk_unmount(0)
593
            sector = 0
608
            sector = 0
594
            count = 1
609
            count = 1
595
            offset = 0
610
            offset = 0
596
            for i in range(bbtsectors):
611
            for i in range(bbtsectors):
597
                if bbtheader[5 + i] == sector + count:
612
                if bbtheader[5 + i] == sector + count:
Line 600... Line 615...
600
                    self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
615
                    self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
601
                    offset = offset + count * 4096
616
                    offset = offset + count * 4096
602
                    sector = bbtheader[5 +i]
617
                    sector = bbtheader[5 +i]
603
                    count = 1
618
                    count = 1
604
            self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
619
            self.ipodclassic_hddaccess(1, sector, count, tempaddr + offset)
-
 
620
	    self.ipodclassic_reloadbbt()
-
 
621
	    self.disk_mount(0)
605
        finally:
622
        finally:
606
            if malloc == True:
623
            if malloc == True:
607
                self.free(tempaddr)
624
                self.free(tempaddr)
608
    
625
    
609
    @command()
626
    @command()