diff --git a/ciloio.c b/ciloio.c index f11c703..fd290ba 100644 --- a/ciloio.c +++ b/ciloio.c @@ -38,7 +38,7 @@ int32_t cilo_seek(struct file *fp, uint32_t offset, uint8_t whence) else fp->file_pos += offset; break; case SEEK_END: - /* unimplemented */ + fp->file_pos = fp->file_len; break; default: return 0; diff --git a/lzma_loader.c b/lzma_loader.c index 6cbff82..6803a7e 100644 --- a/lzma_loader.c +++ b/lzma_loader.c @@ -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) @@ -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"); 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); } diff --git a/mach/c3600/promlib.c b/mach/c3600/promlib.c index 5b58ce4..e400e8a 100644 --- a/mach/c3600/promlib.c +++ b/mach/c3600/promlib.c @@ -62,7 +62,7 @@ void c_putsn(const char *s, int n) */ char c_getc(void) { - char c; + volatile char c; asm ( ".set noreorder\n " "li $a0, %[syscall]\n" @@ -94,7 +94,7 @@ int c_gets(char *b, int n) if (b[i - 1] == '\n' || b[i-1] == '\r') { break; } - else if (b[i - 1] == 0x8) { + else if (b[i - 1] == 0x8 || b[i - 1] == 0x7f) { i--; } } while (i < n); diff --git a/main.c b/main.c index d340ed3..510dbc4 100644 --- a/main.c +++ b/main.c @@ -108,7 +108,7 @@ enter_filename: struct file kernel_file = cilo_open(kernel); - if (kernel_file.code == 0) { + if (kernel_file.code == -1) { printf("Unable to find \"%s\" on the specified filesystem.\n", kernel); goto enter_filename; @@ -119,16 +119,13 @@ enter_filename: printf("Loading LZMA-compressed kernel image.\n"); load_lzma(&kernel_file, LOADADDR, cmd_line); } else { - + printf("Booting %s.\n", kernel); struct elf32_header hdr; cilo_read(&hdr, sizeof(struct elf32_header), 1, &kernel_file); - cilo_seek(&kernel_file, 0, SEEK_SET); /* check if this is a 32-bit or 64-bit kernel image. */ - - printf("Booting %s.\n", kernel); if (load_elf32_file(&kernel_file, cmd_line) < 0) {