Subversion Repositories freemyipod

Rev

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

Rev 452 Rev 472
Line 616... Line 616...
616
        result.product = self.readstring(result.productptr)
616
        result.product = self.readstring(result.productptr)
617
        result.revision = self.readstring(result.revisionptr)
617
        result.revision = self.readstring(result.revisionptr)
618
        return result
618
        return result
619
    
619
    
620
    @command(timeout = 50000)
620
    @command(timeout = 50000)
621
    def storage_read_sectors_md(self, volume, sector, count, addr):
621
    def storage_read_sectors_md(self, volume, sector, count, size = 100000, addr = None):
622
        """ Read sectors from as storage device """
622
        """ Read sectors from as storage device. If addr is not given it allocates a buffer itself. """
-
 
623
        if addr is None:
-
 
624
            addr = self.malloc(size)
-
 
625
            malloc = True
-
 
626
        else:
-
 
627
            malloc = False
-
 
628
        try:
623
        result = self.lib.monitorcommand(struct.pack("IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
629
            result = self.lib.monitorcommand(struct.pack("IIQIIII", 28, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
-
 
630
        finally:
-
 
631
            if malloc == True:
-
 
632
                self.free(addr)
624
        if result.rc > 0x80000000:
633
        if result.rc > 0x80000000:
625
            raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
634
            raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
626
    
635
    
627
    @command(timeout = 50000)
-
 
628
    def storage_write_sectors_md(self, volume, sector, count, addr):
636
    def storage_write_sectors_md(self, volume, sector, count, size = 100000, addr = None):
629
        """ Read sectors from as storage device """
637
        """ Read sectors from as storage device. If addr is not given it allocates a buffer itself. """
-
 
638
        if addr is None:
-
 
639
            addr = self.malloc(size)
-
 
640
            malloc = True
-
 
641
        else:
-
 
642
            malloc = False
-
 
643
        try:
630
        result = self.lib.monitorcommand(struct.pack("IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
644
            result = self.lib.monitorcommand(struct.pack("IIQIIII", 29, volume, sector, count, addr, 0, 0), "III", ("rc", None, None))
-
 
645
        finally:
-
 
646
            if malloc == True:
-
 
647
                self.free(addr)
631
        if result.rc > 0x80000000:
648
        if result.rc > 0x80000000:
632
            raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
649
            raise DeviceError("storage_read_sectors_md(volume=%d, sector=%d, count=%d, addr=0x%08X) failed with RC 0x%08X" % (volume, sector, count, addr, rc))
633
    
650
    
634
    @command(timeout = 30000)
651
    @command(timeout = 30000)
635
    def file_open(self, filename, mode):
652
    def file_open(self, filename, mode):
Line 646... Line 663...
646
        if result.size > 0x80000000:
663
        if result.size > 0x80000000:
647
            raise DeviceError("file_size(fd=%d) failed with RC=0x%08X, errno=%d" % (fd, result.size, self.errno()))
664
            raise DeviceError("file_size(fd=%d) failed with RC=0x%08X, errno=%d" % (fd, result.size, self.errno()))
648
        return result.size
665
        return result.size
649
    
666
    
650
    @command(timeout = 30000)
667
    @command(timeout = 30000)
651
    def file_read(self, fd, addr, size):
668
    def file_read(self, fd, size = 100000, addr = None):
652
        """ Reads data from a file referenced by a handle """
669
        """ Reads data from a file referenced by a handle. If addr is not given it allocates a buffer itself. """
-
 
670
        if addr is None:
-
 
671
            addr = self.malloc(size)
-
 
672
            malloc = True
-
 
673
        else:
-
 
674
            malloc = False
-
 
675
        try:
653
        result = self.lib.monitorcommand(struct.pack("IIII", 32, fd, addr, size), "III", ("rc", None, None))
676
            result = self.lib.monitorcommand(struct.pack("IIII", 32, fd, addr, size), "III", ("rc", None, None))
-
 
677
        finally:
-
 
678
            if malloc == True:
-
 
679
                self.free(addr)
654
        if result.rc > 0x80000000:
680
        if result.rc > 0x80000000:
655
            raise DeviceError("file_read(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
681
            raise DeviceError("file_read(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
656
        return result.rc
682
        return result.rc
657
    
683
    
658
    @command(timeout = 30000)
684
    @command(timeout = 30000)
659
    def file_write(self, fd, addr, size):
685
    def file_write(self, fd, size = 100000, addr = None):
660
        """ Writes data from a file referenced by a handle """
686
        """ Writes data from a file referenced by a handle. If addr is not given it allocates a buffer itself. """
-
 
687
        if addr is None:
-
 
688
            addr = self.malloc(size)
-
 
689
            malloc = True
-
 
690
        else:
-
 
691
            malloc = False
-
 
692
        try:
661
        result = self.lib.monitorcommand(struct.pack("IIII", 33, fd, addr, size), "III", ("rc", None, None))
693
            result = self.lib.monitorcommand(struct.pack("IIII", 33, fd, addr, size), "III", ("rc", None, None))
-
 
694
        finally:
-
 
695
            if malloc == True:
-
 
696
                self.free(addr)
662
        if result.rc > 0x80000000:
697
        if result.rc > 0x80000000:
663
            raise DeviceError("file_write(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
698
            raise DeviceError("file_write(fd=%d, addr=0x%08X, size=0x%08X) failed with RC=0x%08X, errno=%d" % (fd, addr, size, result.rc, self.errno()))
664
        return result.rc
699
        return result.rc
665
    
700
    
666
    @command(timeout = 30000)
701
    @command(timeout = 30000)