Index: embios/trunk/tools/libembios.py |
— | — | @@ -498,7 +498,7 @@ |
499 | 499 | response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
|
500 | 500 | self.__checkstatus(response)
|
501 | 501 |
|
502 | | - readbytes, buffersize, bytesleft = struct.unpack("<III", response[4:16])
|
| 502 | + readbytes, buffersize, bytesleft = struct.unpack("<III", response[4:])
|
503 | 503 | out_data += response[0x10:0x10+readbytes]
|
504 | 504 | size -= blocklen
|
505 | 505 |
|
— | — | @@ -565,7 +565,7 @@ |
566 | 566 | response = self.__getbulk(self.handle, self.__cinep, 0x10)
|
567 | 567 | self.__checkstatus(response)
|
568 | 568 |
|
569 | | - sendbytes = struct.unpack("<I", response[4:8])[0]
|
| 569 | + sendbytes = struct.unpack("<I", response[4:])[0]
|
570 | 570 | if sendbytes < blocklen: # not everything has been written, need to resent some stuff but wait a bit before doing so
|
571 | 571 | time.sleep(0.1)
|
572 | 572 | timeoutcounter += 1
|
— | — | @@ -617,7 +617,7 @@ |
618 | 618 | response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
|
619 | 619 | self.__checkstatus(response)
|
620 | 620 |
|
621 | | - readbytes = struct.unpack("<III", response[4:8])[0]
|
| 621 | + readbytes = struct.unpack("<III", response[4:])[0]
|
622 | 622 | out_data += response[0x10:0x10+readbytes]
|
623 | 623 | size -= blocklen
|
624 | 624 |
|
— | — | @@ -764,45 +764,45 @@ |
765 | 765 |
|
766 | 766 | def procinfotolist(processinfo, structver):
|
767 | 767 | if (structver == 1): # Process information struct version == 1
|
768 | | - ptr = 0x10
|
| 768 | + ptr = 0
|
769 | 769 | process_n = 0
|
770 | 770 | retval = []
|
771 | 771 | while ptr < len(processinfo):
|
772 | 772 | retval.append({})
|
773 | 773 |
|
774 | | - retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:ptr+64])
|
| 774 | + retval[process_n]['regs'] = struct.unpack("<IIIIIIIIIIIIIIII", processinfo[ptr:ptr + 64])
|
775 | 775 | ptr += 16 * 0x4
|
776 | | - retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 776 | + retval[process_n]['cpsr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
777 | 777 | ptr += 1 * 0x4
|
778 | | - retval[process_n]['state'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 778 | + retval[process_n]['state'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
779 | 779 | ptr += 1 * 0x4
|
780 | | - retval[process_n]['name_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 780 | + retval[process_n]['name_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
781 | 781 | ptr += 1 * 0x4
|
782 | | - retval[process_n]['cputime_current'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 782 | + retval[process_n]['cputime_current'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
783 | 783 | ptr += 1 * 0x4
|
784 | | - retval[process_n]['cputime_total'] = struct.unpack("<Q", processinfo[ptr:ptr+8])[0]
|
| 784 | + retval[process_n]['cputime_total'] = struct.unpack("<Q", processinfo[ptr:ptr + 8])[0]
|
785 | 785 | ptr += 1 * 0x8
|
786 | | - retval[process_n]['startusec'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 786 | + retval[process_n]['startusec'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
787 | 787 | ptr += 1 * 0x4
|
788 | | - retval[process_n]['queue_next_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 788 | + retval[process_n]['queue_next_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
789 | 789 | ptr += 1 * 0x4
|
790 | | - retval[process_n]['timeout'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 790 | + retval[process_n]['timeout'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
791 | 791 | ptr += 1 * 0x4
|
792 | | - retval[process_n]['blocked_since'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 792 | + retval[process_n]['blocked_since'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
793 | 793 | ptr += 1 * 0x4
|
794 | | - retval[process_n]['blocked_by_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 794 | + retval[process_n]['blocked_by_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
795 | 795 | ptr += 1 * 0x4
|
796 | | - retval[process_n]['stack_ptr'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 796 | + retval[process_n]['stack_ptr'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
797 | 797 | ptr += 1 * 0x4
|
798 | | - retval[process_n]['err_no'] = struct.unpack("<I", processinfo[ptr:ptr+4])[0]
|
| 798 | + retval[process_n]['err_no'] = struct.unpack("<I", processinfo[ptr:ptr + 4])[0]
|
799 | 799 | ptr += 1 * 0x4
|
800 | | - retval[process_n]['block_type'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
|
| 800 | + retval[process_n]['block_type'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
801 | 801 | ptr += 1 * 0x1
|
802 | | - retval[process_n]['thread_type'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
|
| 802 | + retval[process_n]['thread_type'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
803 | 803 | ptr += 1 * 0x1
|
804 | | - retval[process_n]['priority'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
|
| 804 | + retval[process_n]['priority'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
805 | 805 | ptr += 1 * 0x1
|
806 | | - retval[process_n]['cpuload'] = struct.unpack("<B", processinfo[ptr:ptr+1])[0]
|
| 806 | + retval[process_n]['cpuload'] = struct.unpack("<B", processinfo[ptr:ptr + 1])[0]
|
807 | 807 | ptr += 1 * 0x1
|
808 | 808 |
|
809 | 809 | process_n += 1
|
— | — | @@ -818,12 +818,12 @@ |
819 | 819 | processinfoprint += "R0: 0x%08x, R1: 0x%08x, R2: 0x%08x, R3: 0x%08x,\n\
|
820 | 820 | R4: 0x%08x, R5: 0x%08x, R6: 0x%08x, R7: 0x%08x,\n\
|
821 | 821 | R8: 0x%08x, R9: 0x%08x, R10: 0x%08x, R11: 0x%08x,\n\
|
822 | | - R12: 0x%08x, R13: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
|
| 822 | + R12: 0x%08x, SP: 0x%08x, LR: 0x%08x, PC: 0x%08x\n" \
|
823 | 823 | % (procinfolist[ptr]['regs'][0], procinfolist[ptr]['regs'][1], procinfolist[ptr]['regs'][2], procinfolist[ptr]['regs'][3], \
|
824 | 824 | procinfolist[ptr]['regs'][4], procinfolist[ptr]['regs'][5], procinfolist[ptr]['regs'][6], procinfolist[ptr]['regs'][7], \
|
825 | 825 | procinfolist[ptr]['regs'][8], procinfolist[ptr]['regs'][9], procinfolist[ptr]['regs'][10], procinfolist[ptr]['regs'][11], \
|
826 | 826 | procinfolist[ptr]['regs'][12], procinfolist[ptr]['regs'][13], procinfolist[ptr]['regs'][14], procinfolist[ptr]['regs'][15] )
|
827 | | - processinfoprint += "cpsr: 0b%032b " % (procinfolist[ptr]['cpsr'])
|
| 827 | + processinfoprint += "cpsr: 0x%08x " % (procinfolist[ptr]['cpsr'])
|
828 | 828 | states = ("THREAD_FREE", "THREAD_SUSPENDED", "THREAD_READY", "THREAD_RUNNING", "THREAD_BLOCKED", "THREAD_DEFUNCT", "THREAD_DEFUNCT_ACK")
|
829 | 829 | processinfoprint += "state: %s " % (states[procinfolist[ptr]['state']])
|
830 | 830 | processinfoprint += "nameptr: 0x%08x\n" % (procinfolist[ptr]['name_ptr'])
|
— | — | @@ -853,33 +853,28 @@ |
854 | 854 | self.__myprint("Retrieving process information...", silent)
|
855 | 855 |
|
856 | 856 | offset = 0
|
857 | | - blocklen = size = self.cin_maxsize - 0x10
|
| 857 | + blocklen = tablesize = self.cin_maxsize - 0x10
|
858 | 858 | procinfo = ""
|
859 | 859 | structversion = 0
|
860 | | - tablesize = 0
|
861 | 860 |
|
862 | 861 | # reading loop
|
863 | | - while (offset < size):
|
| 862 | + while (offset < tablesize):
|
864 | 863 | self.handle.bulkWrite(self.__coutep, struct.pack("<IIII", 15, offset, blocklen, 0))
|
865 | 864 | response = self.__getbulk(self.handle, self.__cinep, blocklen + 0x10)
|
866 | 865 | self.__checkstatus(response)
|
867 | 866 |
|
868 | | - size = struct.unpack("<I", response[8:12])[0]
|
| 867 | + tablesize = struct.unpack("<I", response[8:12])[0]
|
| 868 | + procinfo += response[0x10:0x10 + blocklen]
|
869 | 869 |
|
870 | | - if size <= offset + blocklen:
|
871 | | - procinfo += response[0x10:0x10 + size]
|
| 870 | + if tablesize <= offset + blocklen:
|
872 | 871 | structversion = struct.unpack("<I", response[4:8])[0]
|
873 | 872 | tablesize = struct.unpack("<I", response[8:12])[0]
|
874 | | - break
|
875 | | - else:
|
876 | | - procinfo += response[0x10:0x10 + blocklen]
|
877 | 873 |
|
878 | | - size -= blocklen
|
879 | 874 | offset += blocklen
|
880 | 875 |
|
881 | 876 | blocklen = self.cin_maxsize - 0x10
|
882 | | - if blocklen > size:
|
883 | | - blocklen = size
|
| 877 | + if blocklen > tablesize - offset:
|
| 878 | + blocklen = tablesize - offset
|
884 | 879 |
|
885 | 880 |
|
886 | 881 | out = (structversion, tablesize, procinfotolist(procinfo, structversion))
|