diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/sbtools/elftosb.c | 18 | ||||
-rw-r--r-- | utils/sbtools/sbtoelf.c | 10 |
2 files changed, 21 insertions, 7 deletions
diff --git a/utils/sbtools/elftosb.c b/utils/sbtools/elftosb.c index 3d53fb76d5..58665da16d 100644 --- a/utils/sbtools/elftosb.c +++ b/utils/sbtools/elftosb.c | |||
@@ -185,6 +185,7 @@ struct cmd_inst_t | |||
185 | { | 185 | { |
186 | enum cmd_inst_type_t type; | 186 | enum cmd_inst_type_t type; |
187 | char *identifier; | 187 | char *identifier; |
188 | uint32_t argument; | ||
188 | struct cmd_inst_t *next; | 189 | struct cmd_inst_t *next; |
189 | }; | 190 | }; |
190 | 191 | ||
@@ -485,6 +486,17 @@ static struct cmd_file_t *read_command_file(const char *file) | |||
485 | if(find_source_by_id(cmd_file, inst->identifier) == NULL) | 486 | if(find_source_by_id(cmd_file, inst->identifier) == NULL) |
486 | bug("invalid command file: undefined reference to source '%s'", inst->identifier); | 487 | bug("invalid command file: undefined reference to source '%s'", inst->identifier); |
487 | next(); | 488 | next(); |
489 | if((inst->type == CMD_CALL || inst->type == CMD_JUMP) && lexem.type == LEX_LPAREN) | ||
490 | { | ||
491 | next(); | ||
492 | if(lexem.type != LEX_NUMBER) | ||
493 | bug("invalid command file: expected numeral expression after ("); | ||
494 | inst->argument = lexem.num; | ||
495 | next(); | ||
496 | if(lexem.type != LEX_RPAREN) | ||
497 | bug("invalid command file: expected closing brace"); | ||
498 | next(); | ||
499 | } | ||
488 | if(lexem.type != LEX_SEMICOLON) | 500 | if(lexem.type != LEX_SEMICOLON) |
489 | bug("invalid command file: expected ';' after command"); | 501 | bug("invalid command file: expected ';' after command"); |
490 | 502 | ||
@@ -529,6 +541,7 @@ struct sb_inst_t | |||
529 | uint32_t pattern; | 541 | uint32_t pattern; |
530 | uint32_t addr; | 542 | uint32_t addr; |
531 | // </union> | 543 | // </union> |
544 | uint32_t argument; // for call and jump | ||
532 | /* for production use */ | 545 | /* for production use */ |
533 | uint32_t padding_size; | 546 | uint32_t padding_size; |
534 | uint8_t *padding; | 547 | uint8_t *padding; |
@@ -665,6 +678,7 @@ static struct sb_file_t *apply_cmd_file(struct cmd_file_t *cmd_file) | |||
665 | } | 678 | } |
666 | else if(cinst->type == CMD_JUMP || cinst->type == CMD_CALL) | 679 | else if(cinst->type == CMD_JUMP || cinst->type == CMD_CALL) |
667 | { | 680 | { |
681 | sec->insts[idx].argument = cinst->argument; | ||
668 | sec->insts[idx].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL; | 682 | sec->insts[idx].inst = (cinst->type == CMD_JUMP) ? SB_INST_JUMP : SB_INST_CALL; |
669 | sec->insts[idx++].addr = elf->start_addr; | 683 | sec->insts[idx++].addr = elf->start_addr; |
670 | } | 684 | } |
@@ -722,7 +736,7 @@ static void compute_sb_offsets(struct sb_file_t *sb) | |||
722 | { | 736 | { |
723 | if(g_debug) | 737 | if(g_debug) |
724 | printf("%s | addr=0x%08x | arg=0x%08x\n", | 738 | printf("%s | addr=0x%08x | arg=0x%08x\n", |
725 | inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, 0); | 739 | inst->inst == SB_INST_CALL ? "CALL" : "JUMP", inst->addr, inst->argument); |
726 | sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; | 740 | sb->image_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; |
727 | sec->sec_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; | 741 | sec->sec_size += sizeof(struct sb_instruction_call_t) / BLOCK_SIZE; |
728 | } | 742 | } |
@@ -844,7 +858,7 @@ void produce_sb_instruction(struct sb_inst_t *inst, | |||
844 | case SB_INST_CALL: | 858 | case SB_INST_CALL: |
845 | case SB_INST_JUMP: | 859 | case SB_INST_JUMP: |
846 | cmd->len = 0; | 860 | cmd->len = 0; |
847 | cmd->data = 0; | 861 | cmd->data = inst->argument; |
848 | break; | 862 | break; |
849 | case SB_INST_FILL: | 863 | case SB_INST_FILL: |
850 | cmd->data = inst->pattern; | 864 | cmd->data = inst->pattern; |
diff --git a/utils/sbtools/sbtoelf.c b/utils/sbtools/sbtoelf.c index 7e6b77055b..851189f05e 100644 --- a/utils/sbtools/sbtoelf.c +++ b/utils/sbtools/sbtoelf.c | |||
@@ -355,15 +355,16 @@ static void extract(unsigned long filesize) | |||
355 | bugp("File size mismatch"); | 355 | bugp("File size mismatch"); |
356 | if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t)) | 356 | if(sb_header->header_size * BLOCK_SIZE != sizeof(struct sb_header_t)) |
357 | bugp("Bad header size"); | 357 | bugp("Bad header size"); |
358 | if((sb_header->major_ver != IMAGE_MAJOR_VERSION || | ||
359 | sb_header->minor_ver != IMAGE_MINOR_VERSION) && strcasecmp(s_getenv("SB_IGNORE_VER"), "YES")) | ||
360 | bugp("Bad file format version"); | ||
361 | if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t)) | 358 | if(sb_header->sec_hdr_size * BLOCK_SIZE != sizeof(struct sb_section_header_t)) |
362 | bugp("Bad section header size"); | 359 | bugp("Bad section header size"); |
363 | 360 | ||
364 | color(BLUE); | 361 | color(BLUE); |
365 | printf("Basic info:\n"); | 362 | printf("Basic info:\n"); |
366 | color(GREEN); | 363 | color(GREEN); |
364 | printf(" SB version: "); | ||
365 | color(YELLOW); | ||
366 | printf("%d.%d\n", sb_header->major_ver, sb_header->minor_ver); | ||
367 | color(GREEN); | ||
367 | printf(" Header SHA-1: "); | 368 | printf(" Header SHA-1: "); |
368 | byte *hdr_sha1 = sb_header->sha1_header; | 369 | byte *hdr_sha1 = sb_header->sha1_header; |
369 | color(YELLOW); | 370 | color(YELLOW); |
@@ -716,7 +717,6 @@ int main(int argc, const char **argv) | |||
716 | { | 717 | { |
717 | printf("Usage: %s <firmware> <key file> [<out prefix>]\n",*argv); | 718 | printf("Usage: %s <firmware> <key file> [<out prefix>]\n",*argv); |
718 | printf("To use raw command mode, set environment variable SB_RAW_CMD to YES\n"); | 719 | printf("To use raw command mode, set environment variable SB_RAW_CMD to YES\n"); |
719 | printf("To ignore the file version check, set environment variable SB_IGNORE_VER to YES\n"); | ||
720 | return 1; | 720 | return 1; |
721 | } | 721 | } |
722 | 722 | ||