Subversion Repositories freemyipod

Rev

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

Rev 236 Rev 238
Line 391... Line 391...
391
    
391
    
392
    def execimage(self, addr):
392
    def execimage(self, addr):
393
        """ Runs the emBIOS app at 'addr' """
393
        """ Runs the emBIOS app at 'addr' """
394
        return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("excecimage", None, None))
394
        return self.lib.monitorcommand(struct.pack("IIII", 21, addr, 0, 0), "III", ("excecimage", None, None))
395
    
395
    
-
 
396
    def run(self, app):
-
 
397
        """ Uploads and runs the emBIOS app in the string 'app' """
-
 
398
        try:
-
 
399
            appheader = struct.unpack("<8sIIIIIIIIII", app[:48])
-
 
400
        except struct.error:
-
 
401
            raise ArgumentError("The specified file is not an emBIOS application")
-
 
402
        header = appheader[0]
-
 
403
        if header != "emBIexec":
-
 
404
            raise ArgumentError("The specified file is not an emBIOS application")
-
 
405
        baseaddr = appheader[2]
-
 
406
        threadnameptr = appheader[8]
-
 
407
        nameptr = threadnameptr - baseaddr
-
 
408
        name = ""
-
 
409
        while True:
-
 
410
            char = app[nameptr:nameptr+1]
-
 
411
            try:
-
 
412
                if ord(char) == 0:
-
 
413
                    break
-
 
414
            except TypeError:
-
 
415
                raise ArgumentError("The specified file is not an emBIOS application")
-
 
416
            name += char
-
 
417
            nameptr += 1
-
 
418
        usermem = self.getusermemrange()
-
 
419
        if usermem.lower > baseaddr or usermem.upper < baseaddr + len(app):
-
 
420
            raise ArgumentError("The baseaddress of the specified emBIOS application is out of range of the user memory range on the device. Are you sure that this application is compatible with your device?")
-
 
421
        self.write(baseaddr, app)
-
 
422
        self.execimage(baseaddr)
-
 
423
        return Bunch(baseaddr=baseaddr, name=name)
-
 
424
    
-
 
425
    
396
    def bootflashread(self, memaddr, flashaddr, size):
426
    def bootflashread(self, memaddr, flashaddr, size):
397
        """ Copies the data in the bootflash at 'flashaddr' of the specified size
427
        """ Copies the data in the bootflash at 'flashaddr' of the specified size
398
            to the memory at addr 'memaddr'
428
            to the memory at addr 'memaddr'
399
        """
429
        """
400
        return self.lib.monitorcommand(struct.pack("IIII", 22, memaddr, flashaddr, size), "III", (None, None, None))
430
        return self.lib.monitorcommand(struct.pack("IIII", 22, memaddr, flashaddr, size), "III", (None, None, None))