summaryrefslogtreecommitdiff
path: root/kernel/entry.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'kernel/entry.cpp')
-rw-r--r--kernel/entry.cpp50
1 files changed, 36 insertions, 14 deletions
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 <mercury/kernel/framebuffer.hpp>
+#include <mercury/kernel/bd/memory.hpp>
+#include <mercury/kernel/fs/tarfs.hpp>
#include <mercury/kernel/terminal.hpp>
#include <mercury/kernel/limine.hpp>
#include <mercury/kernel/paging.hpp>
@@ -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();
}