Created ramdisk build step
Refactored tests for the scheduler and task Revert "Refactored tests for the scheduler and task" This reverts commit 2bf56a368bc18f2bd2d33c385e3672d07e4431d9. Refactored tests for the scheduler and task Task fmt Task fmt again >:( Ramdisk Added NotOpened error for file read and write Added vfs init to initialise the root node Added the ramdisk.initrd file to grub Update makeiso to copy the ramdisk to the modules folder Add a ramdisk step to create a ramdisk to be leaded by grub and parsed by the kernel Add test files for runtime tests of ramdisk vfs.init => vfs.setRoot Improved ramdisk step Also spelling Changed name for the initrd Rename RamdiskFS => InitrdFS Add deinit for initrd Fixed VMM unmap {}
This commit is contained in:
parent
7b4a5e97aa
commit
bcc1712737
11 changed files with 900 additions and 36 deletions
|
@ -15,6 +15,8 @@ const panic_root = if (is_test) @import(mock_path ++ "panic_mock.zig") else @imp
|
|||
const task = if (is_test) @import(mock_path ++ "task_mock.zig") else @import("task.zig");
|
||||
const heap = @import("heap.zig");
|
||||
const scheduler = @import("scheduler.zig");
|
||||
const vfs = @import("vfs.zig");
|
||||
const initrd = @import("initrd.zig");
|
||||
|
||||
comptime {
|
||||
if (!is_test) {
|
||||
|
@ -67,7 +69,7 @@ export fn kmain(boot_payload: arch.BootPayload) void {
|
|||
var fixed_allocator = mem_profile.fixed_allocator;
|
||||
|
||||
panic_root.init(&mem_profile, &fixed_allocator.allocator) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to initialise panic: {}", .{e});
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to initialise panic: {}\n", .{e});
|
||||
};
|
||||
|
||||
pmm.init(&mem_profile, &fixed_allocator.allocator);
|
||||
|
@ -92,9 +94,35 @@ export fn kmain(boot_payload: arch.BootPayload) void {
|
|||
tty.init(&kernel_heap.allocator, boot_payload);
|
||||
|
||||
scheduler.init(&kernel_heap.allocator) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to initialise scheduler: {}", .{e});
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to initialise scheduler: {}\n", .{e});
|
||||
};
|
||||
|
||||
// Get the ramdisk module
|
||||
const rd_module = for (mem_profile.modules) |module| {
|
||||
if (std.mem.eql(u8, module.name, "initrd.ramdisk")) {
|
||||
break module;
|
||||
}
|
||||
} else null;
|
||||
|
||||
if (rd_module) |module| {
|
||||
// Load the ram disk
|
||||
var ramdisk_filesystem = initrd.InitrdFS.init(module, &kernel_heap.allocator) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to initialise ramdisk: {}\n", .{e});
|
||||
};
|
||||
defer {
|
||||
ramdisk_filesystem.deinit();
|
||||
// Free the raw ramdisk module as we are done
|
||||
kernel_vmm.free(module.region.start) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to free ramdisk: {}\n", .{e});
|
||||
};
|
||||
}
|
||||
|
||||
// Need to init the vfs after the ramdisk as we need the root node from the ramdisk filesystem
|
||||
vfs.setRoot(ramdisk_filesystem.root_node);
|
||||
|
||||
// Load all files here
|
||||
}
|
||||
|
||||
// Initialisation is finished, now does other stuff
|
||||
std.log.info(.kmain, "Init\n", .{});
|
||||
|
||||
|
@ -105,10 +133,10 @@ export fn kmain(boot_payload: arch.BootPayload) void {
|
|||
|
||||
// Create a init2 task
|
||||
var idle_task = task.Task.create(initStage2, &kernel_heap.allocator) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to create init stage 2 task: {}", .{e});
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to create init stage 2 task: {}\n", .{e});
|
||||
};
|
||||
scheduler.scheduleTask(idle_task, &kernel_heap.allocator) catch |e| {
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to schedule init stage 2 task: {}", .{e});
|
||||
panic_root.panic(@errorReturnTrace(), "Failed to schedule init stage 2 task: {}\n", .{e});
|
||||
};
|
||||
|
||||
// Can't return for now, later this can return maybe
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue