From 15e62510104bc0e2b9180b66e5845d985cac03cc Mon Sep 17 00:00:00 2001 From: Benji Dial Date: Wed, 10 Jan 2024 00:17:29 -0500 Subject: partial (largely untested) memory block device and tar file system support --- kernel/entry.cpp | 50 ++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 36 insertions(+), 14 deletions(-) (limited to 'kernel/entry.cpp') diff --git a/kernel/entry.cpp b/kernel/entry.cpp index c8f74c8..fb85ad2 100644 --- a/kernel/entry.cpp +++ b/kernel/entry.cpp @@ -1,4 +1,6 @@ #include +#include +#include #include #include #include @@ -177,9 +179,28 @@ extern "C" [[noreturn]] void entry() { } +[[noreturn]] static void halt() { + while (1) + ; +} + [[noreturn]] static void with_kernel_p4() { terminal::init_terminal(); + storage::init_storage(); + + storage::block_device *initfs_bd = new bd::memory(initfs, initfs_len); + storage::block_devices->insert_end(initfs_bd); + + storage::canon_path root; + storage::canonize_path("/", 1, root); + + if (storage::mount_device(initfs_bd, root, &fs::tarfs_mounter) != + storage::io_result::success) { + terminal::put_string_sz("failed to mount initfs."); + halt(); + } + terminal::put_string_sz("kernel initialization complete.\n"); int used_vram_kib = paging::get_used_vram_page_count() * 4; @@ -190,23 +211,24 @@ extern "C" [[noreturn]] void entry() { terminal::put_int_decimal(free_pram_kib); terminal::put_string_sz(" kiB physical memory free.\n"); - terminal::put_string_sz("initfs first sector:"); - for (int y = 0; y < 8; ++y) { - terminal::put_string_sz("\n "); - for (int x = 0; x < 64; ++x) - terminal::put_char((char)initfs[y * 64 + x]); - } + storage::canon_path test_path; + storage::canonize_path("/test.txt", 9, test_path); - terminal::put_string_sz("\ninitfs second sector:"); - for (int y = 0; y < 8; ++y) { - terminal::put_string_sz("\n "); - for (int x = 0; x < 64; ++x) - terminal::put_char((char)initfs[512 + y * 64 + x]); + storage::block_device *test_bd; + storage::node_id_t test_node_id; + storage::canon_path test_path_without_symlinks; + + if (storage::look_up_absolute_path( + test_path, test_bd, test_node_id, true, test_path_without_symlinks) != + storage::io_result::success) { + terminal::put_string_sz("failed to look up /test.txt in vfs."); + halt(); } - while (1) - ; + terminal::put_string_sz("/test.txt has node id "); + terminal::put_int_decimal(test_node_id); + terminal::put_string_sz(" in its file system."); - //TODO + halt(); } -- cgit v1.2.3