Files
ferglos/kernel.cpp
2020-06-04 23:42:52 +01:00

30 lines
825 B
C++

// yip - ya'boy is writing his own printf
// libc doesn't exist yet so got no choice
void printf(char* str) {
unsigned short* vid_mem = (unsigned short*)0xb8000;
for (int i = 0; str[i] != '\0'; i++) {
//high byte is colour, so just need to copy to text address
vid_mem[i] = (vid_mem[i] * 0xFF00) | str[i];
}
}
typedef void (*constructor)();
extern "C" constructor start_ctors;
extern "C" constructor end_ctors;
extern "C" void call_constructors() {
for (constructor* i = &start_ctors; i != (constructor*)end_ctors; i++) {
(*i)();
}
}
/*
take in the multiboot structure and the GRUB magic number
not sure I actually need magic_num though
*/
extern "C" void ferglos_Main(void* mb_struct, unsigned int magic_num) {
printf("Hello, Sailor!");
while (1)
;
}