BarinkOS/src/kernel/kernel.cpp

52 lines
1.5 KiB
C++
Raw Normal View History

#include "kernel.h"
#define GB4 524288
#define GB2 262144
extern "C" void early_main(unsigned long magic, unsigned long addr){
2021-07-22 19:02:47 +00:00
/** initialize terminal interface */
kterm_init();
2021-10-23 11:26:15 +00:00
2021-07-22 19:02:47 +00:00
if (magic != MULTIBOOT_BOOTLOADER_MAGIC){
2021-10-23 11:26:15 +00:00
printf("Invalid magic number: 0x%x\n", magic);
2021-07-22 19:02:47 +00:00
return;
}
2021-10-23 11:26:15 +00:00
CheckMBT( (multiboot_info_t *) addr);
2021-07-22 19:02:47 +00:00
2021-10-23 11:26:15 +00:00
multiboot_info_t* mbt = (multiboot_info_t*) addr;
2021-07-22 19:02:47 +00:00
/* Are mmap_* valid? */
2021-10-23 11:26:15 +00:00
if (CHECK_FLAG(mbt->flags, 6)){
PhysicalMemoryManager_initialise( mbt->mmap_addr, GB2/* Seriously dangerous hardcoded memory value*/);
PhysicalMemoryManager_initialise_available_regions(mbt->mmap_addr, mbt->mmap_addr + mbt->mmap_length);
PhysicalMemoryManager_deinitialise_kernel();
extern uint8_t* kernel_begin;
extern uint8_t* kernel_end;
printf("Kernel MemoryMap:\n");
printf("kernel: 0x%x - 0x%x\n", &kernel_begin , &kernel_end);
2021-07-22 19:02:47 +00:00
}
2021-11-06 20:56:42 +00:00
printf("Call to setupGdt!\n");
setupGdt();
2021-05-12 22:03:00 +00:00
}
extern "C" void kernel_main (void) {
2021-05-12 22:03:00 +00:00
2021-11-06 20:56:42 +00:00
printf("call to init serial\n");
2021-07-22 19:02:47 +00:00
init_serial();
2021-11-06 20:56:42 +00:00
while (true){
//Read time indefinetely
read_rtc();
2021-07-22 19:02:47 +00:00
printf( "UTC time: %02d-%02d-%02d %02d:%02d:%02d [ Formatted as YY-MM-DD h:mm:ss]\r" ,year, month, day, hour, minute, second);
delay(1000);
}
}