diff options
Diffstat (limited to 'rbutil/mkimxboot/mkimxboot.c')
-rw-r--r-- | rbutil/mkimxboot/mkimxboot.c | 34 |
1 files changed, 34 insertions, 0 deletions
diff --git a/rbutil/mkimxboot/mkimxboot.c b/rbutil/mkimxboot/mkimxboot.c index d1a8722a21..436b3ebff4 100644 --- a/rbutil/mkimxboot/mkimxboot.c +++ b/rbutil/mkimxboot/mkimxboot.c | |||
@@ -220,6 +220,7 @@ static const struct imx_model_desc_t imx_models[] = | |||
220 | #define MAGIC_ROCK 0x726f636b /* 'rock' */ | 220 | #define MAGIC_ROCK 0x726f636b /* 'rock' */ |
221 | #define MAGIC_RECOVERY 0xfee1dead | 221 | #define MAGIC_RECOVERY 0xfee1dead |
222 | #define MAGIC_NORMAL 0xcafebabe | 222 | #define MAGIC_NORMAL 0xcafebabe |
223 | #define MAGIC_CHARGE 0x67726863 /* 'chrg' */ | ||
223 | 224 | ||
224 | static int rb_fw_get_sb_inst_count(struct rb_fw_t *fw) | 225 | static int rb_fw_get_sb_inst_count(struct rb_fw_t *fw) |
225 | { | 226 | { |
@@ -343,6 +344,39 @@ static enum imx_error_t patch_std_zero_host_play(int jump_before, int model, | |||
343 | 344 | ||
344 | return IMX_SUCCESS; | 345 | return IMX_SUCCESS; |
345 | } | 346 | } |
347 | else if(type == IMX_CHARGE) | ||
348 | { | ||
349 | /* throw away everything except the dualboot stub with a special argument */ | ||
350 | struct sb_inst_t *new_insts = xmalloc(sizeof(struct sb_inst_t) * 2); | ||
351 | /* first instruction is be a load */ | ||
352 | struct sb_inst_t *load = &new_insts[0]; | ||
353 | memset(load, 0, sizeof(struct sb_inst_t)); | ||
354 | load->inst = SB_INST_LOAD; | ||
355 | load->size = imx_models[model].dualboot_size; | ||
356 | load->addr = imx_models[model].dualboot_addr; | ||
357 | /* duplicate memory because it will be free'd */ | ||
358 | load->data = memdup(imx_models[model].dualboot, imx_models[model].dualboot_size); | ||
359 | /* second instruction is a call */ | ||
360 | struct sb_inst_t *call = &new_insts[1]; | ||
361 | memset(call, 0, sizeof(struct sb_inst_t)); | ||
362 | call->inst = SB_INST_CALL; | ||
363 | call->addr = imx_models[model].dualboot_addr; | ||
364 | call->argument = MAGIC_CHARGE; | ||
365 | /* free old instruction array */ | ||
366 | free(sec->insts); | ||
367 | sec->insts = new_insts; | ||
368 | sec->nr_insts = 2; | ||
369 | /* remove all other sections */ | ||
370 | for(int i = 1; i < sb_file->nr_sections; i++) | ||
371 | sb_free_section(sb_file->sections[i]); | ||
372 | struct sb_section_t *new_sec = xmalloc(sizeof(struct sb_section_t)); | ||
373 | memcpy(new_sec, &sb_file->sections[0], sizeof(struct sb_section_t)); | ||
374 | free(sb_file->sections); | ||
375 | sb_file->sections = new_sec; | ||
376 | sb_file->nr_sections = 1; | ||
377 | |||
378 | return IMX_SUCCESS; | ||
379 | } | ||
346 | else | 380 | else |
347 | { | 381 | { |
348 | printf("[ERR] Bad output type !\n"); | 382 | printf("[ERR] Bad output type !\n"); |