os/kernel/kernel.c
2024-11-27 21:57:18 +01:00

50 lines
1.1 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[] = {
// 0xba, 0x01, 0x00, 0x00, 0x00, // mov 1, %edx
0xb8, 0x00, 0x00, 0xC0, 0x00, // mov $buffer, %eax
// 0xcd, 0x80, // int 0x80
0xb9, 0x00, 0x00, 0x00, 0x00, // mov 0, %ecx
0xcd, 0x80, // int 0x80
0xb9, 0x00, 0x00, 0x80, 0x00, // mov $start, %ecx
0xff, 0xe1, // jmp *%ecx
};
uint8_t data[] = "Hello From Userspace\n";
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();
asm("sti");
run_program(program, sizeof(program), data, sizeof(data));
while (true) {
terminal_writestring("Hello from Kernelspace\n");
}
}