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

46 lines
1.2 KiB

#include "kernel.h"
void init() {
3 years ago
vga_init(); // Initialize the screen first
// i.e. clear the screen et cetera.
3 years ago
println("Kernel loaded", SUCCESS_COLOR);
3 years ago
3 years ago
// Allocate VGA memory range
println("Allocating VGA memory...", DEFAULT_COLOR);
pm_malloc_range(VGA_ADDRESS, VGA_ADDRESS_MAX, true); // force alloc the VGA range
// ENABLE PAGING
// TODO: make this work
// enable_paging();
3 years ago
println("");
3 years ago
char* title = "eOS Version 0.4 2022";
println(title, DEFAULT_COLOR);
char* subtitle = "A x86 operating system, licenced under GPL-2.0";
println(subtitle, DEFAULT_COLOR);
// Memory allocation testing
3 years ago
printalign("-- PMM malloc Tests --", DEFAULT_COLOR, MIDDLE);
3 years ago
println("THESE MALLOC SHOULD WORK (no text => success):", 0xa0);
for(int i=0; i < 4; i++) {
3 years ago
pm_malloc(1);
}
println("(2) THIS ALLOC SHOULD FAIL:", 0xc0);
block_alloc(2); // this should fail
3 years ago
3 years ago
println("(2) Freeing 2nd block, alloc after should succeed", DEFAULT_COLOR);
3 years ago
block_free(2); // after this, allocation of 2nd block should work
3 years ago
block_alloc(2);
3 years ago
printalign("-- End of PMM malloc Tests --", DEFAULT_COLOR, MIDDLE);
3 years ago
char* strbuf = "Concat test: ";
char* str2 = "Works!";
3 years ago
strbuf = strcat(strbuf, str2);
println(strbuf, DEFAULT_COLOR);
}