im honestly dont remember

This commit is contained in:
Karina
2025-12-28 04:31:59 +04:00
parent caf4f7a055
commit 0cf509856e
4 changed files with 59 additions and 26 deletions
+10 -10
View File
@@ -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() {
+14 -11
View File
@@ -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();
+4 -1
View File
@@ -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");
}
+31 -4
View File
@@ -1,15 +1,25 @@
// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2025 0xKarinyash
#include "core/panic.h"
#include <shell/ksh.h>
#include <shell/kfetch.h>
#include <drivers/console.h>
#include <core/string.h>
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;
}
}
}