KERNEL: Cleanup
Removing quite a few unnecessary parts.
This commit is contained in:
@ -21,7 +21,7 @@ extern "C" void early_main()
|
||||
* Show a little banner for cuteness
|
||||
*/
|
||||
printf("|=== BarinkOS ===|\n");
|
||||
printf("Kernel End Addr: 0x%x\n" , &kernel_end + KERNEL_BASE_ADDR);
|
||||
printf("Kernel End Addr: 0x%x\n" , &kernel_end );
|
||||
|
||||
uint32_t PageDirectoryEntryIndex = ((uint32_t)&kernel_end + KERNEL_BASE_ADDR ) >> 22 ;
|
||||
|
||||
@ -93,16 +93,7 @@ extern "C" void early_main()
|
||||
|
||||
// Setup PhysicalMemoryManagement
|
||||
SetupPhysicalMemoryManager(BootInfo);
|
||||
// Small test!
|
||||
|
||||
void* block = allocate_block();
|
||||
void* block2 = allocate_block();
|
||||
printf("Allocated addresss 1: 0x%x 2: 0x%x\n", (uint32_t)block ,(uint32_t)block2);
|
||||
free_block(block);
|
||||
free_block(block2);
|
||||
void* block3 = allocate_block();
|
||||
printf("Allocated addresss 3: 0x%x\n", (uint32_t)block3);
|
||||
free_block(block3);
|
||||
|
||||
}
|
||||
|
||||
asm volatile("mov %cr0, %eax ");
|
||||
@ -112,57 +103,23 @@ extern "C" void early_main()
|
||||
|
||||
}
|
||||
|
||||
|
||||
void map_multiboot_info_structure(unsigned long addr){
|
||||
// map the multiboot structure into virtual memory
|
||||
// so we can gather the necessary data from it.
|
||||
|
||||
uint32_t pageDirectoryIndex = (addr ) >> 22;
|
||||
printf("pageDirectoryIndex: %d\n", pageDirectoryIndex);
|
||||
|
||||
uint32_t pageTableIndex = (addr >> 12) & 0x1FFF;
|
||||
printf("PagTableIndex: %d\n", pageTableIndex);
|
||||
|
||||
|
||||
printf("boot_page_directory addr: 0x%x\n", &boot_page_directory);
|
||||
printf("boot_page_table addr: 0x%x\n", &multiboot_page_table);
|
||||
|
||||
uint32_t* current_page_directory = &boot_page_directory;
|
||||
uint32_t* needed_page_table = &multiboot_page_table - KERNEL_BASE_ADDR;
|
||||
// set the page tabel reference;
|
||||
current_page_directory[pageDirectoryIndex] = (uint32_t)&multiboot_page_table - KERNEL_BASE_ADDR + 0x003;
|
||||
|
||||
// set the page reference;
|
||||
needed_page_table[ pageTableIndex ] = addr | 0x003;
|
||||
|
||||
|
||||
// Reload CR3 to force a flush
|
||||
asm("movl %cr3, %ecx;" "movl %ecx, %cr3" );
|
||||
}
|
||||
|
||||
void PhysicalMemoryAllocatorTest(){
|
||||
|
||||
#ifdef UNIT_TESTS
|
||||
// test alloc_block
|
||||
uint8_t* memory = (uint8_t*) memAlloc.allocate_block();
|
||||
printf("Got a new pointer: 0x%x\n", memory);
|
||||
|
||||
uint8_t* memory2 = (uint8_t*) memAlloc.allocate_block();
|
||||
printf("Got a new pointer: 0x%x\n", memory2);
|
||||
|
||||
memAlloc.free_block((void*) memory);
|
||||
uint8_t* newBlockPlse = (uint8_t*) memAlloc.allocate_block();
|
||||
#endif
|
||||
#ifdef UNIT_TESTS
|
||||
// Small test!
|
||||
void* block = allocate_block();
|
||||
void* block2 = allocate_block();
|
||||
printf("Allocated addresss 1: 0x%x 2: 0x%x\n", (uint32_t)block ,(uint32_t)block2);
|
||||
free_block(block);
|
||||
free_block(block2);
|
||||
void* block3 = allocate_block();
|
||||
printf("Allocated addresss 3: 0x%x\n", (uint32_t)block3);
|
||||
free_block(block3);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
extern "C" void kernel_main () {
|
||||
pit_initialise();
|
||||
|
||||
// Create a dummy BootInfo object
|
||||
// TODO: This should be done properly or the dependency should
|
||||
// be removed from the SuperVisorTerminal.
|
||||
BootInfo* bootinfo = {};
|
||||
|
||||
startSuperVisorTerminal(bootinfo);
|
||||
startSuperVisorTerminal();
|
||||
}
|
Reference in New Issue
Block a user