diff --git a/drivers/Pic.h b/drivers/Pic.h index 0080902..cc477b6 100644 --- a/drivers/Pic.h +++ b/drivers/Pic.h @@ -1,7 +1,7 @@ #ifndef PIC_H #define PIC_H -#define PIT_FREQUENCY_HZ 100 +#define PIT_FREQUENCY_HZ 200 int PicInstall(); void PitInstall(); diff --git a/kernel/core/Kernel.c b/kernel/core/Kernel.c index 6d46077..d5e4061 100644 --- a/kernel/core/Kernel.c +++ b/kernel/core/Kernel.c @@ -16,6 +16,8 @@ #include "AsmHelpers.h" #include "MemOps.h" #include "VMem.h" +#include "Splash.h" + void KernelMainHigherHalf(void); extern uint8_t _kernel_phys_start[]; extern uint8_t _kernel_phys_end[]; @@ -238,33 +240,7 @@ void PrintKernelAt(const char* str, uint32_t line, uint32_t col) { console.column = saved_col; } -// Modern splash screen with better formatting -void AsciiSplash(void) { - ClearScreen(); - - const char* splash_lines[] = { - "+-----------------------------------------------------------------------------+", - "| >> VoidFrameKernel Version 0.0.1-alpha << |", - "| |", - "| Copyright (C) 2025 VoidFrame Project - Atheria |", - "| Licensed under GNU General Public License v2.0 |", - "| |", - "| This program is free software; you can redistribute it and/or modify |", - "| it under the terms of the GNU General Public License as published by |", - "| the Free Software Foundation; either version 2 of the License. |", - "| |", - "+-----------------------------------------------------------------------------+", - "", - NULL - }; - - ConsoleSetColor(VGA_COLOR_SUCCESS); - for (int i = 0; splash_lines[i]; i++) { - PrintKernel(splash_lines[i]); - PrintKernel("\n"); - } - ConsoleSetColor(VGA_COLOR_DEFAULT); -} + // Global variable to store the Multiboot2 info address static uint32_t g_multiboot_info_addr = 0; @@ -391,7 +367,7 @@ void KernelMain(uint32_t magic, uint32_t info) { PrintKernelHex(magic); Panic("Unrecognized Multiboot2 magic."); } - AsciiSplash(); + ShowSplashScreen(); PrintKernelSuccess("[SYSTEM] VoidFrame Kernel - Version 0.0.1-alpha loaded\n"); PrintKernel("Magic: "); PrintKernelHex(magic); diff --git a/kernel/etc/Splash.c b/kernel/etc/Splash.c new file mode 100644 index 0000000..64a31ef --- /dev/null +++ b/kernel/etc/Splash.c @@ -0,0 +1,50 @@ +#include "Splash.h" +#include "stdbool.h" +#include "Kernel.h" +#include "stdint.h" + +#define VIDEO_MEMORY (0xB8000) +#define SCREEN_WIDTH 80 +#define SCREEN_HEIGHT 25 + +void DrawBox(int x, int y, int width, int height) { + uint16_t* video_memory = (uint16_t*)VIDEO_MEMORY; + uint16_t color = (0x0F << 8); + + // Corners + video_memory[y * SCREEN_WIDTH + x] = color | 201; // Top-left + video_memory[y * SCREEN_WIDTH + x + width - 1] = color | 187; // Top-right + video_memory[(y + height - 1) * SCREEN_WIDTH + x] = color | 200; // Bottom-left + video_memory[(y + height - 1) * SCREEN_WIDTH + x + width - 1] = color | 188; // Bottom-right + + // Horizontal lines + for (int i = 1; i < width - 1; i++) { + video_memory[y * SCREEN_WIDTH + x + i] = color | 205; + video_memory[(y + height - 1) * SCREEN_WIDTH + x + i] = color | 205; + } + + // Vertical lines + for (int i = 1; i < height - 1; i++) { + video_memory[(y + i) * SCREEN_WIDTH + x] = color | 186; + video_memory[(y + i) * SCREEN_WIDTH + x + width - 1] = color | 186; + } +} + +void PrintString(int x, int y, const char* str) { + uint16_t* video_memory = (uint16_t*)VIDEO_MEMORY; + uint16_t color = (0x0F << 8); + int i = 0; + while (str[i] != '\0') { + video_memory[y * SCREEN_WIDTH + x + i] = color | str[i]; + i++; + } +} + +void ShowSplashScreen() { + ClearScreen(); + DrawBox(10, 5, 60, 15); + PrintString(28, 7, "MKernel - v0.0.1-beta"); + PrintString(24, 9, "A lightweight 64-bit kernel"); + PrintString(25, 11, "Copyright (c) 2025, Atheria"); + for (volatile int i = 0; i < 3000000000; i ++); +} \ No newline at end of file diff --git a/kernel/etc/Splash.h b/kernel/etc/Splash.h new file mode 100644 index 0000000..11aef2c --- /dev/null +++ b/kernel/etc/Splash.h @@ -0,0 +1,6 @@ +#ifndef SPLASH_H +#define SPLASH_H + +void ShowSplashScreen(); + +#endif //SPLASH_H \ No newline at end of file diff --git a/kernel/memory/AsmHelpers.asm b/kernel/memory/AsmHelpers.asm index 7f8bb33..a69178c 100644 --- a/kernel/memory/AsmHelpers.asm +++ b/kernel/memory/AsmHelpers.asm @@ -2,5 +2,5 @@ section .text global EnablePagingAndJump EnablePagingAndJump: - mov rdi, cr3 + mov cr3, rdi jmp rsi \ No newline at end of file diff --git a/meson.build b/meson.build index ea8ca52..ac411b0 100644 --- a/meson.build +++ b/meson.build @@ -40,6 +40,7 @@ inc_dirs = [ src_root + '/kernel/ipc', src_root + '/kernel/memory', src_root + '/kernel/process', + src_root + '/kernel/etc', src_root + '/drivers', arch_root + '/cpu', arch_root + '/gdt', @@ -75,7 +76,8 @@ c_sources = [ src_root + '/drivers/Pic.c', arch_root + '/cpu/Cpu.c', src_root + '/kernel/atomic/Atomics.c', - src_root + '/kernel/ipc/Ipc.c' + src_root + '/kernel/ipc/Ipc.c', + src_root + '/kernel/etc/Splash.c' ] # Build include flags