diff options
Diffstat (limited to 'utils/imxtools/sbtools/sb.c')
-rw-r--r-- | utils/imxtools/sbtools/sb.c | 30 |
1 files changed, 9 insertions, 21 deletions
diff --git a/utils/imxtools/sbtools/sb.c b/utils/imxtools/sbtools/sb.c index 33961d41bc..a642af5945 100644 --- a/utils/imxtools/sbtools/sb.c +++ b/utils/imxtools/sbtools/sb.c | |||
@@ -45,7 +45,7 @@ static void fill_gaps(struct sb_file_t *sb) | |||
45 | } | 45 | } |
46 | } | 46 | } |
47 | 47 | ||
48 | static void compute_sb_offsets(struct sb_file_t *sb, void *u, sb_color_printf cprintf) | 48 | static void compute_sb_offsets(struct sb_file_t *sb, void *u, generic_printf_t cprintf) |
49 | { | 49 | { |
50 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) | 50 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) |
51 | sb->image_size = 0; | 51 | sb->image_size = 0; |
@@ -283,7 +283,7 @@ static void produce_section_tag_cmd(struct sb_section_t *sec, | |||
283 | } | 283 | } |
284 | 284 | ||
285 | void produce_sb_instruction(struct sb_inst_t *inst, | 285 | void produce_sb_instruction(struct sb_inst_t *inst, |
286 | struct sb_instruction_common_t *cmd, void *u, sb_color_printf cprintf) | 286 | struct sb_instruction_common_t *cmd, void *u, generic_printf_t cprintf) |
287 | { | 287 | { |
288 | memset(cmd, 0, sizeof(struct sb_instruction_common_t)); | 288 | memset(cmd, 0, sizeof(struct sb_instruction_common_t)); |
289 | cmd->hdr.opcode = inst->inst; | 289 | cmd->hdr.opcode = inst->inst; |
@@ -318,7 +318,7 @@ void produce_sb_instruction(struct sb_inst_t *inst, | |||
318 | } | 318 | } |
319 | 319 | ||
320 | enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename, void *u, | 320 | enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename, void *u, |
321 | sb_color_printf cprintf) | 321 | generic_printf_t cprintf) |
322 | { | 322 | { |
323 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) | 323 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) |
324 | struct crypto_key_t real_key; | 324 | struct crypto_key_t real_key; |
@@ -475,7 +475,7 @@ enum sb_error_t sb_write_file(struct sb_file_t *sb, const char *filename, void * | |||
475 | } | 475 | } |
476 | 476 | ||
477 | static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf, | 477 | static struct sb_section_t *read_section(bool data_sec, uint32_t id, byte *buf, |
478 | int size, const char *indent, void *u, sb_color_printf cprintf, enum sb_error_t *err) | 478 | int size, const char *indent, void *u, generic_printf_t cprintf, enum sb_error_t *err) |
479 | { | 479 | { |
480 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) | 480 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) |
481 | #define fatal(e, ...) \ | 481 | #define fatal(e, ...) \ |
@@ -640,13 +640,13 @@ static uint32_t guess_alignment(uint32_t off) | |||
640 | } | 640 | } |
641 | 641 | ||
642 | struct sb_file_t *sb_read_file(const char *filename, bool raw_mode, void *u, | 642 | struct sb_file_t *sb_read_file(const char *filename, bool raw_mode, void *u, |
643 | sb_color_printf cprintf, enum sb_error_t *err) | 643 | generic_printf_t cprintf, enum sb_error_t *err) |
644 | { | 644 | { |
645 | return sb_read_file_ex(filename, 0, -1, raw_mode, u, cprintf, err); | 645 | return sb_read_file_ex(filename, 0, -1, raw_mode, u, cprintf, err); |
646 | } | 646 | } |
647 | 647 | ||
648 | struct sb_file_t *sb_read_file_ex(const char *filename, size_t offset, size_t size, bool raw_mode, void *u, | 648 | struct sb_file_t *sb_read_file_ex(const char *filename, size_t offset, size_t size, bool raw_mode, void *u, |
649 | sb_color_printf cprintf, enum sb_error_t *err) | 649 | generic_printf_t cprintf, enum sb_error_t *err) |
650 | { | 650 | { |
651 | #define fatal(e, ...) \ | 651 | #define fatal(e, ...) \ |
652 | do { if(err) *err = e; \ | 652 | do { if(err) *err = e; \ |
@@ -681,7 +681,7 @@ struct sb_file_t *sb_read_file_ex(const char *filename, size_t offset, size_t si | |||
681 | struct printer_t | 681 | struct printer_t |
682 | { | 682 | { |
683 | void *user; | 683 | void *user; |
684 | sb_color_printf cprintf; | 684 | generic_printf_t cprintf; |
685 | const char *color; | 685 | const char *color; |
686 | bool error; | 686 | bool error; |
687 | }; | 687 | }; |
@@ -698,7 +698,7 @@ static void sb_printer(void *user, const char *fmt, ...) | |||
698 | } | 698 | } |
699 | 699 | ||
700 | struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, void *u, | 700 | struct sb_file_t *sb_read_memory(void *_buf, size_t filesize, bool raw_mode, void *u, |
701 | sb_color_printf cprintf, enum sb_error_t *err) | 701 | generic_printf_t cprintf, enum sb_error_t *err) |
702 | { | 702 | { |
703 | struct sb_file_t *sb_file = NULL; | 703 | struct sb_file_t *sb_file = NULL; |
704 | uint8_t *buf = _buf; | 704 | uint8_t *buf = _buf; |
@@ -1158,7 +1158,7 @@ void sb_free(struct sb_file_t *file) | |||
1158 | free(file); | 1158 | free(file); |
1159 | } | 1159 | } |
1160 | 1160 | ||
1161 | void sb_dump(struct sb_file_t *file, void *u, sb_color_printf cprintf) | 1161 | void sb_dump(struct sb_file_t *file, void *u, generic_printf_t cprintf) |
1162 | { | 1162 | { |
1163 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) | 1163 | #define printf(c, ...) cprintf(u, false, c, __VA_ARGS__) |
1164 | struct printer_t printer = {.user = u, .cprintf = cprintf, .color = OFF, .error = false }; | 1164 | struct printer_t printer = {.user = u, .cprintf = cprintf, .color = OFF, .error = false }; |
@@ -1284,15 +1284,3 @@ void sb_get_zero_key(struct crypto_key_t *key) | |||
1284 | key->method = CRYPTO_KEY; | 1284 | key->method = CRYPTO_KEY; |
1285 | memset(key->u.key, 0, sizeof(key->u.key)); | 1285 | memset(key->u.key, 0, sizeof(key->u.key)); |
1286 | } | 1286 | } |
1287 | |||
1288 | void sb_std_printf(void *user, bool error, color_t c, const char *fmt, ...) | ||
1289 | { | ||
1290 | (void)user; | ||
1291 | if(!g_debug && !error) | ||
1292 | return; | ||
1293 | va_list args; | ||
1294 | va_start(args, fmt); | ||
1295 | color(c); | ||
1296 | vprintf(fmt, args); | ||
1297 | va_end(args); | ||
1298 | } | ||