Subversion Repositories freemyipod

Rev

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

Rev 370 Rev 379
Line 823... Line 823...
823
        data = self.embios.ipodclassic_writebbt(f.read(), tempaddr)
823
        data = self.embios.ipodclassic_writebbt(f.read(), tempaddr)
824
        f.close()
824
        f.close()
825
        self.logger.info(" done\n")
825
        self.logger.info(" done\n")
826
 
826
 
827
    @command
827
    @command
-
 
828
    def getvolumeinfo(self, volume):
-
 
829
        """
-
 
830
            Gathers some information about a storage volume used
-
 
831
        """
-
 
832
        volume = self._hexint(volume)
-
 
833
        data = self.embios.storage_get_info(volume)
-
 
834
        self.logger.info("Sector size: "+str(data["sectorsize"])+"\n")
-
 
835
        self.logger.info("Number of sectors: "+str(data["numsectors"])+"\n")
-
 
836
        self.logger.info("Vendor: "+data["vendor"]+"\n")
-
 
837
        self.logger.info("Product: "+data["product"]+"\n")
-
 
838
        self.logger.info("Revision: "+data["revision"])
-
 
839
 
-
 
840
    @command
-
 
841
    def readrawstorage(self, volume, sector, count, addr):
-
 
842
        """
-
 
843
            Reads <count> sectors starting at <sector> from storage <volume> to memory at <addr>.
-
 
844
        """
-
 
845
        volume = self._hexint(volume)
-
 
846
        sector = self._hexint(sector)
-
 
847
        count = self._hexint(count)
-
 
848
        addr = self._hexint(addr)
-
 
849
        self.logger.info("Reading volume %s sectors %X - %X to %08X..." % (volume, sector, sector + count - 1, addr))
-
 
850
        self.embios.lib.dev.timeout = 50000
-
 
851
        self.embios.storage_read_sectors_md(volume, sector, count, addr)
-
 
852
        self.logger.info("done\n")
-
 
853
 
-
 
854
    @command
-
 
855
    def writerawstorage(self, volume, sector, count, addr):
-
 
856
        """
-
 
857
            Writes memory contents at <addr> to <count> sectors starting at <sector> on storage <volume>.
-
 
858
        """
-
 
859
        volume = self._hexint(volume)
-
 
860
        sector = self._hexint(sector)
-
 
861
        count = self._hexint(count)
-
 
862
        addr = self._hexint(addr)
-
 
863
        self.logger.info("Writing %08X to volume %s sectors %X - %X..." % (addr, volume, sector, sector + count - 1))
-
 
864
        self.embios.lib.dev.timeout = 50000
-
 
865
        self.embios.storage_write_sectors_md(volume, sector, count, addr)
-
 
866
        self.logger.info("done\n")
-
 
867
 
-
 
868
    @command
-
 
869
    def readrawstoragefile(self, volume, sector, count, file, buffer = False, buffsize = "100000"):
-
 
870
        """
-
 
871
            Reads <count> sectors starting at <sector> from storage <volume> to file <file>,
-
 
872
            buffering them in memory at <buffer> in chunks of <buffsize> bytes (both optional).
-
 
873
        """
-
 
874
        volume = self._hexint(volume)
-
 
875
        sector = self._hexint(sector)
-
 
876
        count = self._hexint(count)
-
 
877
        if buffer == False: buffer = self.embios.lib.dev.usermem.lower
-
 
878
        else: buffer = self._hexint(buffer)
-
 
879
        buffsize = self._hexint(buffsize)
-
 
880
        try:
-
 
881
            f = open(file, 'wb')
-
 
882
        except IOError:
-
 
883
            raise ArgumentError("Could not open local file for writing.")
-
 
884
        self.logger.info("Reading volume %s sectors %X - %X to %s..." % (volume, sector, sector + count - 1, file))
-
 
885
        self.embios.lib.dev.timeout = 50000
-
 
886
        storageinfo = self.embios.storage_get_info(volume)
-
 
887
        while count > 0:
-
 
888
            sectors = min(count, int(buffsize / storageinfo.sectorsize))
-
 
889
            self.embios.storage_read_sectors_md(volume, sector, sectors, buffer)
-
 
890
            f.write(self.embios.read(buffer, storageinfo.sectorsize * sectors))
-
 
891
            sector = sector + sectors
-
 
892
            count = count - sectors
-
 
893
        f.close()
-
 
894
        self.logger.info("done\n")
-
 
895
 
-
 
896
    @command
-
 
897
    def writerawstoragefile(self, volume, sector, count, file, buffer = False, buffsize = "100000"):
-
 
898
        """
-
 
899
            Writes contents of <file> to <count> sectors starting at <sector> on storage <volume>,
-
 
900
            buffering them in memory at <buffer> in chunks of <buffsize> bytes (both optional).
-
 
901
        """
-
 
902
        volume = self._hexint(volume)
-
 
903
        sector = self._hexint(sector)
-
 
904
        count = self._hexint(count)
-
 
905
        if buffer == False: buffer = self.embios.lib.dev.usermem.lower
-
 
906
        else: buffer = self._hexint(buffer)
-
 
907
        buffsize = self._hexint(buffsize)
-
 
908
        try:
-
 
909
            f = open(file, 'rb')
-
 
910
        except IOError:
-
 
911
            raise ArgumentError("Could not open local file for reading.")
-
 
912
        self.logger.info("Writing %s to volume %s sectors %X - %X..." % (file, volume, sector, sector + count - 1))
-
 
913
        self.embios.lib.dev.timeout = 50000
-
 
914
        storageinfo = self.embios.storage_get_info(volume)
-
 
915
        while count > 0:
-
 
916
            sectors = min(count, int(buffsize / storageinfo.sectorsize))
-
 
917
            bytes = storageinfo.sectorsize * sectors
-
 
918
            data = f.read(bytes)
-
 
919
            if len(data) == 0: break
-
 
920
            while len(data) < bytes: data = data + f.read(bytes - len(data))
-
 
921
            self.embios.write(buffer, data)
-
 
922
            self.embios.storage_write_sectors_md(volume, sector, sectors, buffer)
-
 
923
            sector = sector + sectors
-
 
924
            count = count - sectors
-
 
925
        f.close()
-
 
926
        self.logger.info("done\n")
-
 
927
 
-
 
928
    @command
828
    def mkdir(self, dirname):
929
    def mkdir(self, dirname):
829
        """
930
        """
830
            Creates a directory
931
            Creates a directory
831
        """
932
        """
832
        self.embios.lib.dev.timeout = 30000
933
        self.embios.lib.dev.timeout = 30000