|
|
@ -20,6 +20,8 @@ struct private_data {
|
|
|
|
ILzmaInCallback callback;
|
|
|
|
ILzmaInCallback callback;
|
|
|
|
uint8_t *buffer;
|
|
|
|
uint8_t *buffer;
|
|
|
|
struct file *fp;
|
|
|
|
struct file *fp;
|
|
|
|
|
|
|
|
uint32_t total_read;
|
|
|
|
|
|
|
|
uint32_t last;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
int read_data(void *object, const uint8_t **buffer, uint32_t *size)
|
|
|
|
int read_data(void *object, const uint8_t **buffer, uint32_t *size)
|
|
|
@ -30,11 +32,21 @@ int read_data(void *object, const uint8_t **buffer, uint32_t *size)
|
|
|
|
printf("FATAL: Attempt to read past end of file. Aborting.\n");
|
|
|
|
printf("FATAL: Attempt to read past end of file. Aborting.\n");
|
|
|
|
return LZMA_RESULT_DATA_ERROR;
|
|
|
|
return LZMA_RESULT_DATA_ERROR;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
*size = pvt->fp->file_len - cilo_tell(pvt->fp);
|
|
|
|
*size = pvt->fp->file_len - cilo_tell(pvt->fp);
|
|
|
|
*size = *size > 512 ? 512 : *size;
|
|
|
|
*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);
|
|
|
|
cilo_read(pvt->buffer, *size, 1, pvt->fp);
|
|
|
|
|
|
|
|
|
|
|
|
*buffer = pvt->buffer;
|
|
|
|
*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);
|
|
|
|
cilo_seek(fp, 4, SEEK_CUR);
|
|
|
|
|
|
|
|
|
|
|
|
uint16_t probs[LzmaGetNumProbs(&state.Properties)];
|
|
|
|
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 */
|
|
|
|
/* setup structs */
|
|
|
|
pvt.callback.Read = read_data;
|
|
|
|
pvt.callback.Read = read_data;
|
|
|
|
pvt.buffer = buffer;
|
|
|
|
pvt.buffer = buffer;
|
|
|
|
pvt.fp = fp;
|
|
|
|
pvt.fp = fp;
|
|
|
|
|
|
|
|
pvt.total_read = 0;
|
|
|
|
state.Probs = probs;
|
|
|
|
state.Probs = probs;
|
|
|
|
|
|
|
|
pvt.last = 100;
|
|
|
|
|
|
|
|
|
|
|
|
/* do the decoding */
|
|
|
|
/* do the decoding */
|
|
|
|
uint32_t out_processed = 0;
|
|
|
|
uint32_t out_processed = 0;
|
|
|
|
|
|
|
|
|
|
|
|
printf("Loading kernel at %08x\n", load_address);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int result = LzmaDecode(&state, (ILzmaInCallback *)&pvt,
|
|
|
|
int result = LzmaDecode(&state, (ILzmaInCallback *)&pvt,
|
|
|
|
(uint8_t *)load_address, out_size, &out_processed);
|
|
|
|
(uint8_t *)load_address, out_size, &out_processed);
|
|
|
|
|
|
|
|
|
|
|
|
if (result != LZMA_RESULT_OK) {
|
|
|
|
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;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* kick into kernel: */
|
|
|
|
/* 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))
|
|
|
|
((void (*)(uint32_t mem_sz, char *cmd_line))(load_address))
|
|
|
|
(c_memsz(), cmd_line);
|
|
|
|
(c_memsz(), cmd_line);
|
|
|
|
}
|
|
|
|
}
|
|
|
|