diff --git a/config/boot/config.zig b/config/boot/config.zig new file mode 100644 index 0000000..88d4384 --- /dev/null +++ b/config/boot/config.zig @@ -0,0 +1,6 @@ +// ┌──────────────────────────────────────────────┐ +// │ (c) 2025 Linuxperoxo • FILE: config.zig │ +// │ Author: Linuxperoxo │ +// └──────────────────────────────────────────────┘ + +pub const options: type = @import("options.zig"); diff --git a/config/boot/options.zig b/config/boot/options.zig new file mode 100644 index 0000000..953f823 --- /dev/null +++ b/config/boot/options.zig @@ -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; diff --git a/config/modules/options.zig b/config/modules/options.zig index 4554b76..99b9fe8 100644 --- a/config/modules/options.zig +++ b/config/modules/options.zig @@ -5,5 +5,4 @@ pub const UseMenuconfigAsRef: bool = true; pub const IgnoreModuleWithArchNotSupported: bool = false; -pub const DinamicModulesLoad: bool = true; pub const AllowDynamicModulesLoad: bool = true; diff --git a/kernel/init/kprint.zig b/kernel/init/kprint.zig deleted file mode 100644 index e69de29..0000000 diff --git a/kernel/kernel.zig b/kernel/kernel.zig index a94aa31..d8a026a 100644 --- a/kernel/kernel.zig +++ b/kernel/kernel.zig @@ -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; @@ -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 + }); } diff --git a/kernel/stage/stage.zig b/kernel/stage/stage.zig new file mode 100644 index 0000000..f33725a --- /dev/null +++ b/kernel/stage/stage.zig @@ -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; +} diff --git a/kernel/stage/type.zig b/kernel/stage/type.zig new file mode 100644 index 0000000..3990943 --- /dev/null +++ b/kernel/stage/type.zig @@ -0,0 +1,10 @@ +// ┌──────────────────────────────────────────────┐ +// │ (c) 2025 Linuxperoxo • FILE: types.zig │ +// │ Author: Linuxperoxo │ +// └──────────────────────────────────────────────┘ + +pub const Stage_T: type = enum { + boot, + init, + runtime, +}; diff --git a/lib/saturn/kernel/x86/io/console/console.zig b/lib/saturn/kernel/x86/io/console/console.zig new file mode 100644 index 0000000..9d234f8 --- /dev/null +++ b/lib/saturn/kernel/x86/io/console/console.zig @@ -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 + }); +} diff --git a/lib/saturn/kernel/x86/io/console/impl.zig b/lib/saturn/kernel/x86/io/console/impl.zig new file mode 100644 index 0000000..2c32d34 --- /dev/null +++ b/lib/saturn/kernel/x86/io/console/impl.zig @@ -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 { + + } +}; diff --git a/lib/saturn/kernel/x86/io/io.zig b/lib/saturn/kernel/x86/io/io.zig index 01be429..9d0573c 100644 --- a/lib/saturn/kernel/x86/io/io.zig +++ b/lib/saturn/kernel/x86/io/io.zig @@ -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"); diff --git a/saturn.zig b/saturn.zig index 0b0ca5d..844bc3b 100644 --- a/saturn.zig +++ b/saturn.zig @@ -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"); @@ -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"); };