Files
termOS/kernel/src/kmain.c
T
2025-12-28 04:31:59 +04:00

61 lines
1.3 KiB
C

// SPDX-License-Identifier: GPL-3.0-or-later
// Copyright (c) 2025 0xKarinyash
#include "bootinfo.h"
#include "../data/logo.h"
#include "shell/ksh.h"
#include <types.h>
#include <drivers/shitgui.h>
#include <drivers/serial.h>
#include <drivers/console.h>
#include <core/panic.h>
#include <gdt.h>
#include <idt.h>
#include <pic.h>
#include <mm/pmm.h>
#include <mm/vmm.h>
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;
SG_Context sg_ctx = {0};
sg_ctx.fb = fb;
sg_ctx.height = info->framebuffer.height;
sg_ctx.width = info->framebuffer.width;
sg_ctx.pitch = info->framebuffer.pitch;
serial_init();
console_init(&sg_ctx);
console_clear(0xFFFFFF);
console_set_color(0x000000);
gdt_init();
idt_init();
pic_remap();
pmm_init(info->mem);
vmm_init(info);
greet(&sg_ctx);
ksh();
panic("Kernel main loop exited");
}