]> cvs.zerfleddert.de Git - rsbs2/blobdiff - firmware.c
use a struct for the property fields
[rsbs2] / firmware.c
index 7e5e112018e5c8d05c560f16deeb3372a45d0e99..a5bdfdb16eb6c795ec27ed8a1d1cd830ab3831fb 100644 (file)
@@ -5,9 +5,74 @@
 #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)))
+
+struct properties {
+       unsigned int magic;
+       unsigned char unknown0;
+       unsigned char unknown1;
+       unsigned char right_rw;
+       unsigned char rw_mask;
+       unsigned char type1;
+       unsigned char unknown5;
+       unsigned char unknown6;
+       unsigned char unknown7;
+       unsigned char type2;
+       unsigned char val[];
+};
+
+void show_properties(unsigned char *fw, int len)
+{
+       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/")) {
+                       struct properties *prop;
+                       unsigned char *pos = fw + i;
+
+                       printf("0x%08x: found setting: %s: ", i, pos);
+
+                       prop = (struct properties*)(pos + strlen((char*)pos) + 1);
+                       
+                       if (prop->magic != 0x83011111) {
+                               printf("ignoring...\n");
+                               continue;
+                       }
+
+                       if (prop->type1 == 0x00 && prop->type2 == 0x04) {
+                               printf("STRING: %s ", prop->val);
+                       } else if (prop->type1 == 0x01 && prop->type2 == 0x01) {
+                               printf("BOOL: %s ",(*prop->val ? "TRUE" : "FALSE"));
+                       } else if (prop->type1 == 0x04 && prop->type2 == 0x02) {
+                               printf("VAL: 0x%x ", *((unsigned int*)prop->val));
+                       } else {
+                               printf("0x%02x 0x%2x...ignoring\n", prop->type1, prop->type2);
+                               continue;
+                       }
+
+                       if (prop->right_rw == 0x00 && prop->rw_mask == 0x00) {
+                               printf("(R-) ");
+                       } else if (prop->right_rw == 0x01) {
+                               printf("(RW mask: 0x%02x) ", prop->rw_mask);
+                       } else {
+                               printf("(UNK 0x%02x 0x%02x) ", prop->right_rw, prop->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 +121,15 @@ int main(int argc, char **argv)
                crc,
                (ret ? "NOT OK" : "OK"),
                oldcrc);
+       
+       if (1) {
+               show_properties(fw, statbuf.st_size - 4);
+               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