From 0cf509856e75482ada6b2327eef1ba269d905567 Mon Sep 17 00:00:00 2001 From: Karina Date: Sun, 28 Dec 2025 04:31:59 +0400 Subject: [PATCH] im honestly dont remember --- kernel/src/core/panic.c | 20 ++++++++++---------- kernel/src/kmain.c | 25 ++++++++++++++----------- kernel/src/shell/kfetch.c | 5 ++++- kernel/src/shell/ksh.c | 35 +++++++++++++++++++++++++++++++---- 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/kernel/src/core/panic.c b/kernel/src/core/panic.c index fb54141..ffba314 100644 --- a/kernel/src/core/panic.c +++ b/kernel/src/core/panic.c @@ -63,7 +63,7 @@ const char* exception_messages[] = { "Into Detected Overflow", "Out of Bounds", "Invalid Opcode", - "No Coprocessor", + "Device Not Available", "Double Fault", "Coprocessor Segment Overrun", "Bad TSS", @@ -71,23 +71,23 @@ const char* exception_messages[] = { "Stack Fault", "General Protection Fault", "Page Fault", - "Unknown Interrupt", - "Coprocessor Fault", + "Reserved", + "x87 Floating-Point Exception", "Alignment Check", "Machine Check", + "SIMD Floating-Point Exception", + "Virtualization Exception", + "Control Protection Exception", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved", - "Reserved" + "Hypervisor Injection Exception", + "VMM Communication Exception", + "Security Exception", + "Reserved" }; __attribute__((noreturn)) void die() { diff --git a/kernel/src/kmain.c b/kernel/src/kmain.c index 3e77145..84e7b2f 100644 --- a/kernel/src/kmain.c +++ b/kernel/src/kmain.c @@ -21,6 +21,17 @@ extern u64 _kernel_end; +void greet(SG_Context *sg_ctx) { + SG_Point logo_point = {0, 10}; + sg_put_img(sg_ctx, &logo_point, &logo_img); + SG_Point start_pos = {75, 55}; // greeting + console_set_cursor_pos(&start_pos); + kprintf("Welcome to ^ptermOS^0!!!\n"); + + SG_Point text_normal_point = {0, 120}; // not nice to hardcode nums like that but we have what we have + console_set_cursor_pos(&text_normal_point); +} + void kmain(Bootinfo* info) { u32 *fb = (u32*)info->framebuffer.base; if (!fb) return; @@ -33,6 +44,8 @@ void kmain(Bootinfo* info) { serial_init(); console_init(&sg_ctx); + console_clear(0xFFFFFF); + console_set_color(0x000000); gdt_init(); idt_init(); @@ -40,17 +53,7 @@ void kmain(Bootinfo* info) { pmm_init(info->mem); vmm_init(info); - SG_Point start_pos = {75, 55}; // greeting - console_clear(0xFFFFFF); - console_set_cursor_pos(&start_pos); - console_set_color(0x000000); - - SG_Point logo_point = {0, 10}; - sg_put_img(&sg_ctx, &logo_point, &logo_img); - - kprintf("Welcome to ^ptermOS^0!!!\n"); - SG_Point text_normal_point = {0, 120}; // not nice to hardcode nums like that but we have what we have - console_set_cursor_pos(&text_normal_point); + greet(&sg_ctx); ksh(); diff --git a/kernel/src/shell/kfetch.c b/kernel/src/shell/kfetch.c index 6be001e..ae137cd 100644 --- a/kernel/src/shell/kfetch.c +++ b/kernel/src/shell/kfetch.c @@ -19,6 +19,9 @@ const char* ascii_logo[] = { void kfetch() { + char cpu_brand[49]; + //cpu_get_brand_string(cpu_brand); + kprintf("\n\n"); kprintf("^p %s ^0\t\t^g kernel^0@^gtermos\n^0", ascii_logo[0]); kprintf("^p %s ^0\t\t^0-------------\n^0", ascii_logo[1]); @@ -27,6 +30,6 @@ void kfetch() { kprintf("^p %s ^0\t\t^gUptime^0: 0h 0m\n^0", ascii_logo[4]); kprintf("^p %s ^0\t\t^gShell^0: termosh\n^0", ascii_logo[5]); kprintf("^p %s ^p\t\t^gDE^0: shitgui\n^0", ascii_logo[6]); - kprintf("^p %s ^p\t\t^gCPU^0: cool one\n^0", ascii_logo[7]); + kprintf("^p %s ^p\t\t^gCPU^0: %s\n^0", ascii_logo[7], cpu_brand); kprintf("\n\n"); } \ No newline at end of file diff --git a/kernel/src/shell/ksh.c b/kernel/src/shell/ksh.c index 1d0d029..fd16359 100644 --- a/kernel/src/shell/ksh.c +++ b/kernel/src/shell/ksh.c @@ -1,15 +1,25 @@ // SPDX-License-Identifier: GPL-3.0-or-later // Copyright (c) 2025 0xKarinyash +#include "core/panic.h" #include +#include #include #include typedef enum { + TOKEN_EMPTY, + TOKEN_NULL, TOKEN_ILLEGAL, TOKEN_HELP, + TOKEN_KFETCH, + + TOKEN_PANIC, + TOKEN_PANIC_UD2, + TOKEN_PANIC_PF, + TOKEN_QUIT, TOKEN_CLEAR } ksh_token; @@ -20,12 +30,21 @@ typedef struct { } ksh_command_map; static const ksh_command_map token_map[] = { + {"", TOKEN_EMPTY}, {"q", TOKEN_QUIT}, {"quit", TOKEN_QUIT}, {"exit", TOKEN_QUIT}, - + {"cls", TOKEN_CLEAR}, {"clear", TOKEN_CLEAR}, + + {"kfetch", TOKEN_KFETCH}, + {"fastfetch", TOKEN_KFETCH}, + {"neofetch", TOKEN_KFETCH}, + + {"panic", TOKEN_PANIC}, + {"ud2", TOKEN_PANIC_UD2}, + {"pf", TOKEN_PANIC_PF}, {"help", TOKEN_HELP}, {nullptr, TOKEN_NULL} @@ -40,19 +59,27 @@ ksh_token char2token(char* token) { static void print_help() { kprintf("\tWelcome to ^ptermOS^0's kernel shell!\n"); - kprintf("\tIt can almost nothing! yet."); + kprintf("\tIt can almost nothing! yet.\n"); } void ksh() { while (true) { - kprintf("\nksh_> "); + kprintf("ksh_> "); char cmdbuff[256]; kgets(cmdbuff, 256); switch(char2token(cmdbuff)) { + case TOKEN_EMPTY: continue; + case TOKEN_QUIT: return; // that'll cause panic lol + case TOKEN_PANIC: panic("Manually initiated panic"); + case TOKEN_PANIC_UD2: __asm__ volatile ("ud2"); + case TOKEN_PANIC_PF: u64* bad_ptr = (u64*)0xDEADBEEF; *bad_ptr = 666; + case TOKEN_CLEAR: console_clear((u32) console_get_colors() & 0xFFFFFFFF); break; case TOKEN_HELP: print_help(); break; - default: kprintf("Unknown command!!"); break; + case TOKEN_KFETCH: kfetch(); break; + + default: kprintf("Unknown command!!\n"); break; } } } \ No newline at end of file