os/kernel/kernel.c

43 lines
1 KiB
C
Raw Normal View History

2024-07-11 08:56:52 +02:00
#include <kernel/tty.h>
#include <kernel/idt.h>
#include <debugging.h>
#include <kernel/elf.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
2024-07-11 08:56:52 +02:00
uint8_t program[] = {
2024-08-08 21:34:30 +02:00
0xB8, 0x00, 0x00, 0x00, 0x00, // mov eax, 0x0 (Just a simple NOP-like instruction)
0xF4 // hlt (halts the CPU, should trap to kernel if interrupts enabled)
};
2024-07-11 08:56:52 +02:00
void kernel_main(void)
{
/* Initialize terminal interface */
// terminal_initialize();
idt_init();
2024-07-11 08:56:52 +02:00
2024-08-08 21:34:30 +02:00
// asm("int $13");
// asm("ljmp $0x18, $0x00c00100"); // Example: Far jump to user code segment with selector 0x18
print_hex_bytes(idt_init, 4);
terminal_putchar('\n');
run_program(program, 15);
/*
char buf[100];
2024-07-11 08:56:52 +02:00
while (true) {
asm("mov %0, %%edx" :: "r" (buf));
asm("int $0x81");
terminal_writestring("newline");
terminal_putchar('\n');
2024-07-11 08:56:52 +02:00
}
*/
2024-07-11 08:56:52 +02:00
}