summaryrefslogtreecommitdiffstats
path: root/utils/imxtools/sbtools
diff options
context:
space:
mode:
authorAmaury Pouly <amaury.pouly@gmail.com>2012-12-16 23:35:23 +0100
committerAmaury Pouly <amaury.pouly@gmail.com>2012-12-16 23:35:23 +0100
commitb748243d4fddd99c399cda31d844eb86d554468f (patch)
tree92de8fc3602ab3f0973f1fa32a9a26070df7ec81 /utils/imxtools/sbtools
parentfa1af088e9b7dd458776f682d85869d7be457aa2 (diff)
downloadrockbox-b748243d4fddd99c399cda31d844eb86d554468f.tar.gz
rockbox-b748243d4fddd99c399cda31d844eb86d554468f.tar.bz2
rockbox-b748243d4fddd99c399cda31d844eb86d554468f.zip
imxtools/sbtools: implement rom/product/component version switch
Change-Id: If3ebae2e60f324c93f85a4f1a6f30257cccb735d
Diffstat (limited to 'utils/imxtools/sbtools')
-rw-r--r--utils/imxtools/sbtools/elftosb1.c51
1 files changed, 51 insertions, 0 deletions
diff --git a/utils/imxtools/sbtools/elftosb1.c b/utils/imxtools/sbtools/elftosb1.c
index 417f7eeb46..b40b62f390 100644
--- a/utils/imxtools/sbtools/elftosb1.c
+++ b/utils/imxtools/sbtools/elftosb1.c
@@ -239,6 +239,31 @@ static void *load_file(const char *filename, int *size)
return data;
}
+static bool parse_sb_sub_version(uint16_t *ver, char *str)
+{
+ *ver = 0;
+ for(int i = 0; str[i]; i++)
+ {
+ if(i >= 4)
+ return false;
+ if(str[i] < '0' || str[i] > '9')
+ return false;
+ *ver = *ver << 4 | (str[i] - '0');
+ }
+ return true;
+}
+
+static bool parse_sb_version(struct sb1_version_t *ver, char *str)
+{
+ char *p = strchr(str, '.');
+ char *q = strchr(p + 1, '.');
+ if(p == NULL || q == NULL) return false;
+ *p = *q = 0;
+ return parse_sb_sub_version(&ver->major, str) &&
+ parse_sb_sub_version(&ver->minor, p + 1) &&
+ parse_sb_sub_version(&ver->revision, q + 1);
+}
+
/**
* Command line parsing
*/
@@ -421,6 +446,26 @@ CMD_FN(cmd_loadjumpreturn)
return load_elf(sb, args[0].str, SB1_INST_CALL);
}
+CMD_FN(cmd_rom)
+{
+ sb->rom_version = args[0].uint;
+ return 0;
+}
+
+CMD_FN(cmd_product)
+{
+ if(!parse_sb_version(&sb->product_ver, args[0].str))
+ bug("Invalid version string '%s'\n", args[0].str);
+ return 0;
+}
+
+CMD_FN(cmd_component)
+{
+ if(!parse_sb_version(&sb->component_ver, args[0].str))
+ bug("Invalid version string '%s'\n", args[0].str);
+ return 0;
+}
+
#define CMD(name,fn,nr_args,...) {name,nr_args,{__VA_ARGS__},fn},
struct cmd_entry_t g_cmds[] =
{
@@ -450,6 +495,12 @@ struct cmd_entry_t g_cmds[] =
CMD("-loadjumpreturn", cmd_loadjumpreturn, 1, ARG_STR)
CMD("-j", cmd_loadjump, 1, ARG_STR)
CMD("-loadjump", cmd_loadjump, 1, ARG_STR)
+ CMD("-R", cmd_rom, 1, ARG_UINT)
+ CMD("-rom", cmd_rom, 1, ARG_UINT)
+ CMD("-p", cmd_product, 1, ARG_STR)
+ CMD("-product", cmd_product, 1, ARG_STR)
+ CMD("-v", cmd_component, 1, ARG_STR)
+ CMD("-component", cmd_component, 1, ARG_STR)
};
#undef CMD