A poorly written OS for the x86 arch. (WIP)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
eOS/kernel/kernel.c

103 lines
2.4 KiB

#include "kernel.h"
3 years ago
void print_kernel_motd() {
3 years ago
set_cursor_pos(0, 0);
3 years ago
printalign(" ___ ____ ", BANNER_COLOR, MIDDLE);
printalign(" ___ / _ \\/ ___| ", BANNER_COLOR, MIDDLE);
printalign(" / _ \\ | | \\___ \\ ", BANNER_COLOR, MIDDLE);
printalign("| __/ |_| |___) | A x86 operating system,", BANNER_COLOR, MIDDLE);
printalign(" \\___|\\___/|____/ licenced under GPL-2.0", BANNER_COLOR, MIDDLE);
3 years ago
new_line();
printalign("e = lim[h->0] (1+h)^(1/h)", DEFAULT_COLOR, MIDDLE);
3 years ago
printalign("Created by E. Almqvist", DEFAULT_COLOR, MIDDLE);
3 years ago
new_line();
3 years ago
}
3 years ago
/*
3 years ago
void print_kernel_stats() {
char* buf;
set_cursor_pos(0, 12);
3 years ago
// GDT stuff
print("GDT Code Seg: ", 0x0f);
uint* code_ptr = 0xee88;
uint8 code = *code_ptr;
buf = itoa(code, buf, 16);
println(buf, DEFAULT_COLOR);
print("GDT Data Seg: ", 0x0f);
uint* data_ptr = 0xee89;
uint8 data = *data_ptr;
buf = itoa(data, buf, 16);
println(buf, DEFAULT_COLOR);
new_line();
3 years ago
// Memory stats
print("MEMORY BITMAP: ", 0x0f);
buf = itoa(get_bitmap(), buf, 2);
println(buf, DEFAULT_COLOR);
3 years ago
new_line();
3 years ago
3 years ago
println("BIOS E820", 0x0f);
3 years ago
print("Loaded Entries: ", DEFAULT_COLOR);
uint entries = get_phys_mem_size();
buf = itoa(entries, buf, 10);
println(buf, DEFAULT_COLOR);
print("Physical Memory Size: ");
println("?", DEFAULT_COLOR);
3 years ago
new_line();
3 years ago
// VGA stats
println("Display (VGA)", 0x0f);
print("Memory Range: ", DEFAULT_COLOR);
buf = itoa(VGA_ADDRESS, buf, 16);
print(buf, DEFAULT_COLOR);
print(" - ");
buf = itoa(VGA_ADDRESS_MAX, buf, 16);
println(buf, DEFAULT_COLOR);
print("Screen Dimensions: ", DEFAULT_COLOR);
buf = itoa(MAX_COLS, buf, 10);
print(buf, DEFAULT_COLOR);
print("x");
buf = itoa(MAX_ROWS, buf, 10);
println(buf, DEFAULT_COLOR);
3 years ago
3 years ago
}
3 years ago
*/
3 years ago
void kernel_init() {
3 years ago
pic_init(); // Init the PIC and remap it
3 years ago
idt_init(); // Enable interupts
3 years ago
//enable_paging();
3 years ago
vga_init(); // Initialize the screen
3 years ago
// Allocate VGA memory range
pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range
// ENABLE PAGING
// TODO: make this work
3 years ago
3 years ago
clear_screen();
print_kernel_motd();
3 years ago
//print_kernel_stats();
3 years ago
char* buf;
uint i = 0;
set_cursor_pos(0, 9);
printalign("[Ticks since boot]", 0xf0, MIDDLE);
while(true) {
set_cursor_pos(0, 10);
buf = itoa(i, buf, 10);
printalign(buf, 0x0f, MIDDLE);
++i;
}
3 years ago
//while(true) { __asm__("hlt"); } // never escape this function
}