// fether os kernel. #include #include // protecting compilation. #if defined(__linux__) #error "You should compile all with a cross-compiler. See project wiki." #elif !defined(__i386__) #error "This is an 32bit kernel. Please use i386 target." #endif volatile uint16_t* vga_buffer = (uint16_t*)0xB8000; // defining VGA text mode. // vga(2) settings const int VGA_COLS = 80; const int VGA_ROWS = 25; // terminal settings int term_col = 0; int term_row = 0; uint8_t term_color = 0x0F; // clearing the terminal void term_init() { for(int col = 0; col < VGA_COLS; col++) { for(int row = 0; row < VGA_ROWS; row++) { const size_t index = (VGA_COLS * row) + col; vga_buffer[index] = ((uint16_t)term_color << 8) | ' '; } } } void term_put(char c) { switch(c) { case '\n': // newline implemintation { term_col = 0; term_row++; break; } default: // if char doesn't match any special symbol { const size_t index = (VGA_COLS * term_row) + term_col; vga_buffer[index] = ((uint16_t)term_color << 8) | c; break; } } if(term_col >= VGA_COLS) { term_col = 0; term_row++; } if(term_row >= VGA_ROWS) { term_col = 0; term_row = 0; } } void term_print(const char* str) { for(size_t i = 0; str[i] != '\0'; i++) { term_put(str[i]); } } void kmain() { term_init(); term_print("Kernel loaded.\nFether."); }