diff options
Diffstat (limited to 'boot/load.c')
-rw-r--r-- | boot/load.c | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/boot/load.c b/boot/load.c index 69024c0..b243629 100644 --- a/boot/load.c +++ b/boot/load.c @@ -136,7 +136,8 @@ void serial_print(const char *data); int main(void *data) { serial_install(); - heap = 0xf000; + serial_print("Loaded bootloader!\n"); + heap = 0xf00000; void (*entry)(void *); *(void **)(&entry) = read_inode(get_inode(find_inode("kernel.bin", 2))); if (entry) { @@ -329,7 +330,7 @@ void *read_inode(struct inode *in) if (!in) return 0; - int num_blocks = in->blocks / (BLOCK_SIZE / SECTOR_SIZE); + u32 num_blocks = in->blocks / (BLOCK_SIZE / SECTOR_SIZE); //assert(num_blocks != 0); if (!num_blocks) @@ -341,24 +342,20 @@ void *read_inode(struct inode *in) int indirect; int blocknum; - char *data; - for (int i = 0; i < num_blocks; i++) { + for (u32 i = 0; i < num_blocks; i++) { if (i < 12) { blocknum = in->block[i]; - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } else if (i < BLOCK_COUNT + 12) { indirect = in->block[12]; blocknum = read_indirect(indirect, i - 12); - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } else { indirect = in->block[13]; blocknum = read_indirect(indirect, (i - (BLOCK_COUNT + 12)) / BLOCK_COUNT); blocknum = read_indirect(blocknum, (i - (BLOCK_COUNT + 12)) % BLOCK_COUNT); - data = buffer_read(blocknum); - memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } + + char *data = buffer_read(blocknum); + memcpy((u32 *)((u32)buf + i * BLOCK_SIZE), data, BLOCK_SIZE); } return buf; |