Skip to content

Commit

Permalink
Align the initialization of anon memory address
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamos82 committed May 6, 2024
1 parent 7238d35 commit 4847d1a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions src/kernel/framebuffer/framebuffer.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ uint32_t number_of_lines;

void map_framebuffer(struct framebuffer_info fbdata) {
uint32_t fb_entries = fbdata.memory_size / PAGE_SIZE_IN_BYTES;
uint32_t fb_entries_mod = fbdata.memory_size % PAGE_SIZE_IN_BYTES;

uint64_t phys_address = (uint64_t) fbdata.phys_address;

Expand All @@ -45,7 +44,7 @@ void map_framebuffer(struct framebuffer_info fbdata) {
uint32_t pml4 = PML4_ENTRY(_FRAMEBUFFER_MEM_START);
#if SMALL_PAGES == 1
uint32_t fb_pd_entries = fb_entries / VM_PAGES_PER_TABLE;
uint32_t pt = PT_ENTRY(_FRAMEBUFFER_MEM_START);
//uint32_t pt = PT_ENTRY(_FRAMEBUFFER_MEM_START);
#endif

if(p4_table[pml4] == 0x00l || p3_table_hh[pdpr] == 0x00l){
Expand Down Expand Up @@ -78,14 +77,15 @@ void map_framebuffer(struct framebuffer_info fbdata) {

}
#elif SMALL_PAGES == 0
uint32_t fb_entries_mod = fbdata.memory_size % PAGE_SIZE_IN_BYTES;
if(fb_entries_mod != 0){
fb_entries++;
}
for(int j=0; fb_entries > 0; j++){
fb_entries--;
if((p2_table[pd+j] < phys_address
|| p2_table[pd+j] > (phys_address + fbdata.memory_size))
|| p2_table[pd+j] == 0x00l){
if( (p2_table[pd+j] < phys_address
|| p2_table[pd+j] > (phys_address + fbdata.memory_size) )
|| p2_table[pd+j] == 0x00l ) {
p2_table[pd+j] = (phys_address + (j * PAGE_SIZE_IN_BYTES)) | PAGE_ENTRY_FLAGS;
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/kernel/mem/pmm.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ void pmm_setup(uint64_t addr, uint32_t size){
// addr = address of multiboot structre
// size = size of the structure
pretty_logf(Verbose, "addr: 0x%x, size: 0x%x", addr,size);
anon_memory_loc = (uint64_t) (&_kernel_end + PAGE_SIZE_IN_BYTES);
anon_physical_memory_loc = (uint64_t) (&_kernel_physical_end + PAGE_SIZE_IN_BYTES) ;
anon_memory_loc = (uint64_t) align_up( (size_t) (&_kernel_end + PAGE_SIZE_IN_BYTES), PAGE_SIZE_IN_BYTES);
anon_physical_memory_loc = (uint64_t) align_up( (size_t) (&_kernel_physical_end + PAGE_SIZE_IN_BYTES), PAGE_SIZE_IN_BYTES );

pretty_logf(Verbose, "anon_memory_loc: 0x%x, anon_physical_memory_loc: 0x%x", anon_memory_loc, anon_physical_memory_loc);

Expand Down

0 comments on commit 4847d1a

Please sign in to comment.