|
|
|
@ -20,6 +20,8 @@ struct private_data {
|
|
|
|
|
ILzmaInCallback callback;
|
|
|
|
|
uint8_t *buffer;
|
|
|
|
|
struct file *fp;
|
|
|
|
|
uint32_t total_read;
|
|
|
|
|
uint32_t last;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
int read_data(void *object, const uint8_t **buffer, uint32_t *size)
|
|
|
|
@ -31,10 +33,20 @@ int read_data(void *object, const uint8_t **buffer, uint32_t *size)
|
|
|
|
|
return LZMA_RESULT_DATA_ERROR;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*size = pvt->fp->file_len - cilo_tell(pvt->fp);
|
|
|
|
|
*size = *size > 512 ? 512 : *size;
|
|
|
|
|
|
|
|
|
|
pvt->total_read += *size;
|
|
|
|
|
|
|
|
|
|
uint32_t done = (pvt->total_read * 100)/pvt->fp->file_len;
|
|
|
|
|
if (done % 10 == 0 && done != pvt->last) {
|
|
|
|
|
printf("%d", done);
|
|
|
|
|
pvt->last = done;
|
|
|
|
|
} else if (done != pvt->last && done % 2 == 0) {
|
|
|
|
|
printf(".");
|
|
|
|
|
pvt->last = done;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
cilo_read(pvt->buffer, *size, 1, pvt->fp);
|
|
|
|
|
|
|
|
|
|
*buffer = pvt->buffer;
|
|
|
|
@ -74,32 +86,28 @@ void load_lzma(struct file *fp, uint32_t load_address, char *cmd_line)
|
|
|
|
|
cilo_seek(fp, 4, SEEK_CUR);
|
|
|
|
|
|
|
|
|
|
uint16_t probs[LzmaGetNumProbs(&state.Properties)];
|
|
|
|
|
printf("Number of probability table entries: %d\n",
|
|
|
|
|
LzmaGetNumProbs(&state.Properties));
|
|
|
|
|
|
|
|
|
|
printf("Size of uncompressed file: %08x.\n", out_size);
|
|
|
|
|
|
|
|
|
|
/* setup structs */
|
|
|
|
|
pvt.callback.Read = read_data;
|
|
|
|
|
pvt.buffer = buffer;
|
|
|
|
|
pvt.fp = fp;
|
|
|
|
|
pvt.total_read = 0;
|
|
|
|
|
state.Probs = probs;
|
|
|
|
|
pvt.last = 100;
|
|
|
|
|
|
|
|
|
|
/* do the decoding */
|
|
|
|
|
uint32_t out_processed = 0;
|
|
|
|
|
|
|
|
|
|
printf("Loading kernel at %08x\n", load_address);
|
|
|
|
|
|
|
|
|
|
int result = LzmaDecode(&state, (ILzmaInCallback *)&pvt,
|
|
|
|
|
(uint8_t *)load_address, out_size, &out_processed);
|
|
|
|
|
|
|
|
|
|
if (result != LZMA_RESULT_OK) {
|
|
|
|
|
printf("Error in decoding LZMA-compressed kernel image. Aborting.\n");
|
|
|
|
|
printf("\nError in decoding LZMA-compressed kernel image. Aborting.\n");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* kick into kernel: */
|
|
|
|
|
printf("Starting LZMA decompressed kernel at %16x.\n", load_address);
|
|
|
|
|
printf("\nStarting kernel at 0x%016x.\n", load_address);
|
|
|
|
|
((void (*)(uint32_t mem_sz, char *cmd_line))(load_address))
|
|
|
|
|
(c_memsz(), cmd_line);
|
|
|
|
|
}
|
|
|
|
|