Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions config/boot/config.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: config.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

pub const options: type = @import("options.zig");
9 changes: 9 additions & 0 deletions config/boot/options.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: options.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

pub const VerboseMode: bool = true;
pub const MultiBootScreen: bool = true;
pub const SaturnLogo: bool = true;
pub const RecoveryModeEnable: bool = true;
1 change: 0 additions & 1 deletion config/modules/options.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,4 @@

pub const UseMenuconfigAsRef: bool = true;
pub const IgnoreModuleWithArchNotSupported: bool = false;
pub const DinamicModulesLoad: bool = true;
pub const AllowDynamicModulesLoad: bool = true;
Empty file removed kernel/init/kprint.zig
Empty file.
9 changes: 9 additions & 0 deletions kernel/kernel.zig
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ pub const userspace: type = saturn.lib.userspace;
pub const utils: type = saturn.lib.utils;
pub const config: type = saturn.config;
pub const modules: type = saturn.modules;
pub const stage: type = struct {
pub const get = saturn.stage.stageGet;
};

const loader: type = saturn.loader;

Expand Down Expand Up @@ -67,8 +70,14 @@ fn @"saturn.main"() callconv(.c) void {
// ou usando somente loader.SaturnArch, isso evita de criar um possivel .never_inline
// implicito
@call(.always_inline, loader.SaturnArch, .{});
@call(.always_inline, saturn.stage.stageSwitch, .{
.init
});

// Depois da arquitetura resolver todos os seus detalhes, podemos iniciar
// os modulos linkados ao kernel
@call(.always_inline, loader.SaturnModules, .{});
@call(.always_inline, saturn.stage.stageSwitch, .{
.runtime
});
}
16 changes: 16 additions & 0 deletions kernel/stage/stage.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: stage.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

const Stage_T: type = @import("stage.zig").Stage_T;

var saturnStage: Stage_T = .boot;

pub fn stageSwitch(stage: Stage_T) void {
saturnStage = stage;
}

pub fn stageGet() Stage_T {
return saturnStage;
}
10 changes: 10 additions & 0 deletions kernel/stage/type.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: types.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

pub const Stage_T: type = enum {
boot,
init,
runtime,
};
20 changes: 20 additions & 0 deletions lib/saturn/kernel/x86/io/console/console.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: console.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

const impl: type = @import("impl.zig");
const stage: type = @import("root").stage;

const vtable = [_]*const fn([]u8) void {
&impl.boot.kprint,
&impl.init.kprint,
&impl.runtime.kprint,
};

// Global kprint
pub fn kprint(str: []u8) void {
@call(.never_inline, vtable[@intFromEnum(stage.get)], .{
str
});
}
34 changes: 34 additions & 0 deletions lib/saturn/kernel/x86/io/console/impl.zig
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
// ┌──────────────────────────────────────────────┐
// │ (c) 2025 Linuxperoxo • FILE: impl.zig │
// │ Author: Linuxperoxo │
// └──────────────────────────────────────────────┘

pub const init: type = struct {
pub fn kprint(str: []u8) void {
@call(.never_inline, boot.kprint, .{
str
});
}
};
pub const boot: type = struct {
const ScreenContext_T: type = struct {
fb: []u8,
row: usize,
col: usize,
};

var screenContext: ScreenContext_T = .{
.fb = @as([*]u8, @ptrFromInt(0xB8000))[0..80 * 25],
.row = 0,
.col = 0,
};

pub fn kprint(str: []u8) void {

}
};
pub const runtime: type = struct {
pub fn kprint(str: []u8) void {

}
};
1 change: 1 addition & 0 deletions lib/saturn/kernel/x86/io/io.zig
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@

pub const ports: type = @import("ports.zig");
pub const pci: type = @import("pci.zig");
pub const console: type = @import("console.zig");
2 changes: 2 additions & 0 deletions saturn.zig
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ pub const core: type = struct {
pub const fs: type = @import("kernel/core/fs/fs.zig");
pub const drivers: type = @import("kernel/core/drivers/drivers.zig");
};
pub const stage: type = @import("kernel/stage/stage.zig");
pub const loader: type = @import("kernel/loader.zig");
pub const modules: type = @import("modules.zig");
pub const memory: type = @import("kernel/memory/memory.zig");
Expand All @@ -107,4 +108,5 @@ pub const lib: type = struct {
pub const config: type = struct {
pub const modules: type = @import("config/modules/config.zig");
pub const arch: type = @import("config/arch/config.zig");
pub const boot: type = @import("config/boot/config.zig");
};