os/kernel/kernel.c
2025-07-01 12:48:05 +02:00

70 lines
1.5 KiB
C

#include <kernel/tty.h>
#include <kernel/idt.h>
#include <kernel/elf.h>
#include <kernel/pic.h>
#include <kernel/heap.h>
#include <kernel/task.h>
#include <kernel/paging.h>
#include <debugging.h>
/* Check if the compiler thinks you are targeting the wrong operating system. */
#if defined(__linux__)
#error "You are not using a cross-compiler, you will most certainly run into trouble"
#endif
uint8_t program[] = {
0xcd, 0x80, // int $0x80
0xff, 0xe1, // jmp *%ecx
};
uint8_t data[] = "Hello From Userspace\n";
uint8_t kernel_data[] = "Hello From Kernelspace\n";
// uint8_t data[] = {};
void kernel_main(void)
{
/* Initialize terminal interface */
terminal_initialize();
terminal_writestring("Hello from Kernelspace\n");
idt_init();
init_pic();
heap_init();
setup_tasks();
setup_paging();
terminal_writestring("Woaw\n");
struct Heap_Block* block;
void* code_page = alloc_page(1, &block);
void* data_page = alloc_page(1, &block);
set_page_table_entry(0, code_page);
set_page_table_entry(0x00400000, data_page);
*(int*)0 = 1;
while (true) { }
/* asm("cli");
run_program(program, sizeof(program), data, sizeof(data));
asm("sti");
asm("int $0x20");
int i = 0;
while (true) {
i += 1;
if (i == 1 << 16) {
asm("mov %0, %%eax" :: "r" (kernel_data) );
asm("mov $0, %ecx");
asm("int $0x80");
i = 0;
}
} */
}