mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-13 06:29:47 -04:00
Prepare architecture for later
This commit is contained in:
parent
a1c4e56a56
commit
2e2861c813
@ -10,8 +10,14 @@
|
|||||||
|
|
||||||
#include "stl/types.hpp"
|
#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
|
#endif
|
||||||
|
@ -33,8 +33,9 @@ void kernel_main(){
|
|||||||
interrupt::setup_interrupts();
|
interrupt::setup_interrupts();
|
||||||
|
|
||||||
//Prepare memory
|
//Prepare memory
|
||||||
init_physical_allocator();
|
physical_allocator::early_init();
|
||||||
paging::init();
|
paging::init();
|
||||||
|
physical_allocator::init();
|
||||||
init_memory_manager();
|
init_memory_manager();
|
||||||
|
|
||||||
//Install drivers
|
//Install drivers
|
||||||
|
@ -106,7 +106,7 @@ uintptr_t max_address; //Address of the next block being allocated
|
|||||||
uintptr_t current_virtual = 0x400000;
|
uintptr_t current_virtual = 0x400000;
|
||||||
|
|
||||||
uint64_t* allocate_block(uint64_t blocks){
|
uint64_t* allocate_block(uint64_t blocks){
|
||||||
auto memory = allocate_physical_memory(blocks);
|
auto memory = physical_allocator::allocate(blocks);
|
||||||
|
|
||||||
if(!memory){
|
if(!memory){
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
@ -45,7 +45,7 @@ void paging::init(){
|
|||||||
|
|
||||||
auto pd = reinterpret_cast<pd_t>(0x72000);
|
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);
|
pt[256] = reinterpret_cast<page_entry>(physical | PRESENT | WRITE | USER);
|
||||||
flush_tlb(reinterpret_cast<void*>(0x100000));
|
flush_tlb(reinterpret_cast<void*>(0x100000));
|
||||||
@ -60,7 +60,7 @@ void paging::init(){
|
|||||||
|
|
||||||
for(size_t pd_index = 2; pd_index < 512; ++pd_index){
|
for(size_t pd_index = 2; pd_index < 512; ++pd_index){
|
||||||
//1. Allocate space for the new Page Table
|
//1. Allocate space for the new Page Table
|
||||||
physical = allocate_physical_memory(1);
|
physical = physical_allocator::early_allocate(1);
|
||||||
|
|
||||||
//2. Compute logical address
|
//2. Compute logical address
|
||||||
uint64_t logical = 0x200000 + (pd_index - 2) * paging::PAGE_SIZE;
|
uint64_t logical = 0x200000 + (pd_index - 2) * paging::PAGE_SIZE;
|
||||||
|
@ -16,11 +16,19 @@ uintptr_t current_mmap_entry_position = 0;
|
|||||||
|
|
||||||
} //End of anonymous namespace
|
} //End of anonymous namespace
|
||||||
|
|
||||||
void init_physical_allocator(){
|
void physical_allocator::early_init(){
|
||||||
e820::finalize_memory_detection();
|
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){
|
if(!current_mmap_entry){
|
||||||
for(uint64_t i = 0; i < e820::mmap_entry_count(); ++i){
|
for(uint64_t i = 0; i < e820::mmap_entry_count(); ++i){
|
||||||
auto& entry = e820::mmap_entry(i);
|
auto& entry = e820::mmap_entry(i);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user