]> git.zerfleddert.de Git - rsbs2/commitdiff
decode settings in firmware
authorMichael Gernoth <michael@gernoth.net>
Wed, 28 Jan 2009 19:51:41 +0000 (20:51 +0100)
committerMichael Gernoth <michael@gernoth.net>
Wed, 28 Jan 2009 19:51:41 +0000 (20:51 +0100)
firmware.c

index 7e5e112018e5c8d05c560f16deeb3372a45d0e99..0361634b4131e1342c2bb7c740ccb4cc57def415 100644 (file)
@@ -5,9 +5,75 @@
 #include <fcntl.h>
 #include <unistd.h>
 #include <errno.h>
+#include <string.h>
 #include <strings.h>
 #include "rsb-crc.h"
 
+#define FINDSTR(addr, str) (!strncmp((char*)addr, str, strlen(str)))
+
+void handle_defaults(unsigned char *fw, int len, int patch)
+{
+       int i;
+
+       for (i = 0; i < (len-100 /* XXX */); i++) {
+               if (FINDSTR(fw+i, "/default/fw_prop/") ||
+                   FINDSTR(fw+i, "/default/fw_setup/") ||
+                   FINDSTR(fw+i, "/default/oem_prop/")) {
+                       unsigned char *pos = fw + i;
+                       unsigned char type1, type2;
+                       unsigned char right_rw, rw_mask;
+                       unsigned char *val;
+
+                       printf("0x%08x: found setting: %s: ", i, pos);
+                       
+                       pos += strlen((char*)pos) + 1;
+
+                       if ((pos[0] != 0x11) ||
+                           (pos[1] != 0x11) ||
+                           (pos[2] != 0x01) ||
+                           (pos[3] != 0x83)) {
+                               printf("ignoring...\n");
+                               continue;
+                       }
+
+
+                       pos += 4;
+
+                       right_rw = pos[2];
+                       rw_mask = pos[3];
+
+                       type1 = pos[4];
+                       type2 = pos[8];
+                       val = pos + 9;
+
+                       if (type1 == 0x00 && type2 == 0x04) {
+                               printf("STRING: %s ", val);
+                       } else if (type1 == 0x01 && type2 == 0x01) {
+                               printf("BOOL: %s ",(*val ? "TRUE" : "FALSE"));
+                       } else if (type1 == 0x04 && type2 == 0x02) {
+                               printf("VAL: 0x%x ", *((unsigned int*)val));
+                       } else {
+                               printf("0x%02x 0x%2x...ignoring\n", type1, type2);
+                               continue;
+                       }
+
+                       if (right_rw == 0x00 && rw_mask == 0x00) {
+                               printf("(R-) ");
+                       } else if (right_rw == 0x01) {
+                               printf("(RW mask: 0x%02x) ", rw_mask);
+                       } else {
+                               printf("(UNK 0x%02x 0x%02x) ", right_rw, rw_mask);
+                       }
+                       printf("\n");
+               }
+       }
+}
+
+void handle_boarddescription(unsigned char *fw, int len, int patch)
+{
+       /* 0x01 0x01 0x50 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x00 0x88 0x02 0xac 0x01 0xd0 0x05 0x00 0x00 0x6a 0x3a 0x00 0x00 0x06 0x00 0x01 0x00 0x00 0x00 0x00 0x00 */
+}
+
 int main(int argc, char **argv)
 {
        struct stat statbuf;
@@ -56,6 +122,15 @@ int main(int argc, char **argv)
                crc,
                (ret ? "NOT OK" : "OK"),
                oldcrc);
+       
+       if (1) {
+               handle_defaults(fw, statbuf.st_size - 4, 0);
+               handle_boarddescription(fw, statbuf.st_size - 4, 0);
+               if (0) {
+                       ret = rsb_crc2(fw, statbuf.st_size, 0x55335053, &crc);
+                       printf("Checksum: 0x%08x\n", crc);
+               }
+       }
 
        exit(0);
 }
Impressum, Datenschutz