#include #include #include #include #include #include #include #include /* 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 data1[] = "Hello From Userspace 1\n\0"; uint8_t data2[] = "Hello 2\n\0"; uint8_t kernel_data[] = "Hello From Kernelspace\n\0"; // uint8_t data[] = {}; void kernel_main(void) { asm("cli"); /* 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* code_block_1; struct Heap_Block* data_block_1; alloc_page(2, &code_block_1); alloc_page(2, &data_block_1); struct Heap_Block* code_block_2; struct Heap_Block* data_block_2; alloc_page(2, &code_block_2); alloc_page(2, &data_block_2); // set_page_table_entry(0, code_page); // set_page_table_entry(0x00400000, data_page); run_program(program, sizeof(program), data1, sizeof(data1), code_block_1, data_block_1); run_program(program, sizeof(program), data2, sizeof(data2), code_block_2, data_block_2); asm("sti"); int i = 0; while (true) { i += 1; if (i == 1 << 1) { asm("mov $0, %%ecx; int $0x80" :: "a" (kernel_data), "b" (sizeof(kernel_data))); i = 0; } } }