donnm / mtk_fw_tools

Mediatek firmware unpacking/repacking tools
GNU General Public License v3.0
38 stars 15 forks source link

Registers #4

Closed Mi81 closed 6 years ago

Mi81 commented 6 years ago

I will try to describe the algorithm for calculating the values of registers.

The header of ALICE file after dictionary start address contains data about bit-length. For example: 0x04, 0x06, 0x07, 0x09, x0A, 0x0B, 0x0C ( as L1, L2, L3 ... L7 )

r0 = 0 (аlways) r1 = r0 + bL1 + 1 , where bL1 = binary number in which the L1 lower digits contain one, ie 0b1111 = 0x0F. Thus we obtain r1 = 0 + 0b1111 + 1 = 0x10 r2 = r1 + bL2 + 1, ie r2 = 0x10 + 0b111111 + 1 = 0x50 r3 = r2 + 0b1111111 + 1 = 0xD0 r4 = r3 + 0b111111111 +1 = 0x2D0 r5 = r4 + 0b1111111111 + 1 = 0x6D0 r6 = r5 + 0b11111111111 +1 = 0xED0 r7 = r6 + 0b111111111111 +1 = 0x1ED0

donnm commented 6 years ago

Fixed. Now I understand that the range registers are the lengths of the instructions for each range interval. This is now done dynamically and even fixes decoding ALICE_1 (from my tests).