aboutsummaryrefslogtreecommitdiff
path: root/src/kernel/kernel.c
diff options
context:
space:
mode:
authorMarvin Borner2019-10-30 21:18:08 +0100
committerMarvin Borner2019-10-30 21:18:08 +0100
commit836e4eba09e73612b00f268e124750e78aeaa225 (patch)
treeee0876bc2ba05498f87afb6a7b625bf652cb6708 /src/kernel/kernel.c
parent118898807865ba11f5d7754f6f0572a0403f8512 (diff)
Added kind of working initrd support
Diffstat (limited to 'src/kernel/kernel.c')
-rw-r--r--src/kernel/kernel.c30
1 files changed, 25 insertions, 5 deletions
diff --git a/src/kernel/kernel.c b/src/kernel/kernel.c
index cba4f6e..dd49949 100644
--- a/src/kernel/kernel.c
+++ b/src/kernel/kernel.c
@@ -30,16 +30,36 @@ void init() {
void kernel_main(struct multiboot *mboot_ptr) {
init();
- info("Kernel size in KiB: ");
- vesa_draw_number((int) end >> 10);
-
assert(mboot_ptr->mods_count > 0);
uint32_t initrd_location = *((uint32_t *) mboot_ptr->mods_addr);
uint32_t initrd_end = *(uint32_t *) (mboot_ptr->mods_addr + 4);
- // Don't trample our module with placement accesses, please!
- // placement_address = initrd_end;
+ paging_set_used(0, (initrd_end >> 12) + 1);
+
fs_root = initialise_initrd(initrd_location);
+ int i = 0;
+ struct dirent *node = 0;
+ vesa_draw_string("\n");
+ while ((node = readdir_fs(fs_root, i)) != 0) {
+ vesa_draw_string("Found file: ");
+ vesa_draw_string(node->name);
+ vesa_draw_string("\n");
+ fs_node_t *fsnode = finddir_fs(fs_root, node->name);
+
+ if ((fsnode->flags & 0x7) == FS_DIRECTORY)
+ vesa_draw_string("\t (directory)\n");
+ else {
+ vesa_draw_string("\t contents: \"");
+ uint8_t buf[fsnode->length];
+ uint32_t sz = read_fs(fsnode, 0, fsnode->length, buf);
+ for (uint32_t j = 0; j < sz; j++)
+ vesa_draw_char(buf[j]);
+
+ vesa_draw_string("\"\n");
+ }
+ i++;
+ }
+
// asm volatile ("div %0" :: "r"(0)); // Exception testing x/0
loop:
asm volatile ("hlt");