From 7f88d2b64892658d7fbc6e68b6fed4273526a465 Mon Sep 17 00:00:00 2001 From: Michael Gernoth Date: Wed, 28 Jan 2009 20:51:41 +0100 Subject: [PATCH] decode settings in firmware --- firmware.c | 75 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) diff --git a/firmware.c b/firmware.c index 7e5e112..0361634 100644 --- a/firmware.c +++ b/firmware.c @@ -5,9 +5,75 @@ #include #include #include +#include #include #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); } -- 2.39.2