aboutsummaryrefslogtreecommitdiff
path: root/mirai/kernel/entry.zig
diff options
context:
space:
mode:
authorBobby <[email protected]>2026-03-30 15:02:42 +0530
committerBobby <[email protected]>2026-03-30 15:02:42 +0530
commit2324951126b542aeecfd8dd12b381265cce1566c (patch)
treea580fe97a13788fbe3b104e3a9553f551c2bff11 /mirai/kernel/entry.zig
parent3c2c5c419cae1b7f2d60e8a3dc6e2e8c157b5a2f (diff)
downloadakiba-main.tar.xz
akiba-main.zip
refactor: reorganize kernel structure and implement memory management zonesHEADmain
Diffstat (limited to 'mirai/kernel/entry.zig')
-rw-r--r--mirai/kernel/entry.zig111
1 files changed, 111 insertions, 0 deletions
diff --git a/mirai/kernel/entry.zig b/mirai/kernel/entry.zig
new file mode 100644
index 0000000..7d9c9f6
--- /dev/null
+++ b/mirai/kernel/entry.zig
@@ -0,0 +1,111 @@
+//! Kernel Entry
+
+const boot = @import("boot.zig");
+const asm_ops = @import("../asm/asm.zig");
+
+pub const BootParams = boot.BootParams;
+
+pub fn main(boot_params_ptr: *boot.BootParams) noreturn {
+ if (!boot_params_ptr.is_valid()) {
+ if (boot_params_ptr.framebuffer.base != 0) {
+ draw_error_screen(boot_params_ptr);
+ }
+ asm_ops.cpu.halt.halt_loop();
+ }
+
+ draw_boot_screen(boot_params_ptr);
+ asm_ops.cpu.halt.halt_loop();
+}
+
+fn draw_boot_screen(params: *boot.BootParams) void {
+ const fb = params.framebuffer;
+ const base: [*]u32 = @ptrFromInt(fb.base);
+ const stride = fb.stride;
+
+ const bg_color: u32 = switch (fb.pixel_format) {
+ .rgb => 0x1E0030,
+ .bgr => 0x30001E,
+ else => 0x1E0030,
+ };
+
+ var row: u32 = 0;
+ while (row < fb.height) : (row += 1) {
+ var col: u32 = 0;
+ while (col < fb.width) : (col += 1) {
+ base[row * stride + col] = bg_color;
+ }
+ }
+
+ const text_color: u32 = switch (fb.pixel_format) {
+ .rgb => 0x00FFFF,
+ .bgr => 0xFFFF00,
+ else => 0x00FFFF,
+ };
+
+ const banner = [_][]const u8{
+ " A K K III BBB A ",
+ " A A K K I B B A A ",
+ " AAAAA KK I BBB AAAAA ",
+ " A A K K I B B A A ",
+ " A A K K III BBB A A ",
+ };
+
+ const start_x = (fb.width - 29 * 8) / 2;
+ const start_y = fb.height / 3;
+
+ for (banner, 0..) |line, line_row| {
+ for (line, 0..) |char, line_col| {
+ if (char != ' ') {
+ draw_block(base, stride, start_x + @as(u32, @truncate(line_col)) * 8, start_y + @as(u32, @truncate(line_row)) * 12, text_color);
+ }
+ }
+ }
+
+ const subtitle = "AkibaOS Kernel Loaded Successfully";
+ const subtitle_x = (fb.width - @as(u32, @truncate(subtitle.len)) * 8) / 2;
+ const subtitle_y = start_y + 80;
+
+ for (0..subtitle.len) |idx| {
+ draw_small_block(base, stride, subtitle_x + @as(u32, @truncate(idx)) * 8, subtitle_y, 0xFF80C0);
+ }
+}
+
+fn draw_error_screen(params: *boot.BootParams) void {
+ const fb = params.framebuffer;
+ const base: [*]u32 = @ptrFromInt(fb.base);
+ const stride = fb.stride;
+
+ const error_color: u32 = switch (fb.pixel_format) {
+ .rgb => 0xFF0000,
+ .bgr => 0x0000FF,
+ else => 0xFF0000,
+ };
+
+ var row: u32 = 0;
+ while (row < fb.height) : (row += 1) {
+ var col: u32 = 0;
+ while (col < fb.width) : (col += 1) {
+ base[row * stride + col] = error_color;
+ }
+ }
+}
+
+fn draw_block(base: [*]u32, stride: u32, x_pos: u32, y_pos: u32, color: u32) void {
+ var dy: u32 = 0;
+ while (dy < 10) : (dy += 1) {
+ var dx: u32 = 0;
+ while (dx < 6) : (dx += 1) {
+ base[(y_pos + dy) * stride + x_pos + dx] = color;
+ }
+ }
+}
+
+fn draw_small_block(base: [*]u32, stride: u32, x_pos: u32, y_pos: u32, color: u32) void {
+ var dy: u32 = 0;
+ while (dy < 2) : (dy += 1) {
+ var dx: u32 = 0;
+ while (dx < 6) : (dx += 1) {
+ base[(y_pos + dy) * stride + x_pos + dx] = color;
+ }
+ }
+}