Prepare architecture for later

This commit is contained in:
Baptiste Wicht 2014-01-22 16:54:44 +01:00
parent a1c4e56a56
commit 2e2861c813
5 changed files with 23 additions and 8 deletions

View File

@ -10,8 +10,14 @@
#include "stl/types.hpp"
void init_physical_allocator();
namespace physical_allocator {
size_t allocate_physical_memory(size_t pages);
void early_init();
void init();
size_t early_allocate(size_t pages);
size_t allocate(size_t pages);
} //end of physical_allocator namespace
#endif

View File

@ -33,8 +33,9 @@ void kernel_main(){
interrupt::setup_interrupts();
//Prepare memory
init_physical_allocator();
physical_allocator::early_init();
paging::init();
physical_allocator::init();
init_memory_manager();
//Install drivers

View File

@ -106,7 +106,7 @@ uintptr_t max_address; //Address of the next block being allocated
uintptr_t current_virtual = 0x400000;
uint64_t* allocate_block(uint64_t blocks){
auto memory = allocate_physical_memory(blocks);
auto memory = physical_allocator::allocate(blocks);
if(!memory){
return nullptr;

View File

@ -45,7 +45,7 @@ void paging::init(){
auto pd = reinterpret_cast<pd_t>(0x72000);
auto physical = allocate_physical_memory(1);
auto physical = physical_allocator::early_allocate(1);
pt[256] = reinterpret_cast<page_entry>(physical | PRESENT | WRITE | USER);
flush_tlb(reinterpret_cast<void*>(0x100000));
@ -60,7 +60,7 @@ void paging::init(){
for(size_t pd_index = 2; pd_index < 512; ++pd_index){
//1. Allocate space for the new Page Table
physical = allocate_physical_memory(1);
physical = physical_allocator::early_allocate(1);
//2. Compute logical address
uint64_t logical = 0x200000 + (pd_index - 2) * paging::PAGE_SIZE;

View File

@ -16,11 +16,19 @@ uintptr_t current_mmap_entry_position = 0;
} //End of anonymous namespace
void init_physical_allocator(){
void physical_allocator::early_init(){
e820::finalize_memory_detection();
}
size_t allocate_physical_memory(size_t blocks){
void physical_allocator::init(){
//TODO
}
size_t physical_allocator::early_allocate(size_t blocks){
return allocate(blocks);
}
size_t physical_allocator::allocate(size_t blocks){
if(!current_mmap_entry){
for(uint64_t i = 0; i < e820::mmap_entry_count(); ++i){
auto& entry = e820::mmap_entry(i);