2024-07-11 08:56:52 +02:00
|
|
|
#include <kernel/tty.h>
|
2024-08-05 00:59:07 +02:00
|
|
|
#include <kernel/idt.h>
|
2024-07-16 22:51:41 +02:00
|
|
|
#include <debugging.h>
|
2024-08-05 00:59:07 +02:00
|
|
|
#include <kernel/elf.h>
|
2024-07-16 22:51:41 +02:00
|
|
|
|
|
|
|
/* 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
|
|
|
|
2024-08-05 00:59:07 +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-08-05 00:59:07 +02:00
|
|
|
};
|
|
|
|
|
2024-07-11 08:56:52 +02:00
|
|
|
void kernel_main(void)
|
|
|
|
{
|
|
|
|
/* Initialize terminal interface */
|
2024-08-05 00:59:07 +02:00
|
|
|
// 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');
|
|
|
|
|
2024-08-05 00:59:07 +02:00
|
|
|
run_program(program, 15);
|
2024-07-16 22:51:41 +02:00
|
|
|
|
2024-08-05 00:59:07 +02:00
|
|
|
/*
|
|
|
|
char buf[100];
|
2024-07-11 08:56:52 +02:00
|
|
|
|
2024-08-05 00:59:07 +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-08-05 00:59:07 +02:00
|
|
|
|
|
|
|
*/
|
2024-07-11 08:56:52 +02:00
|
|
|
}
|