forked from Bananymous/banan-os
Kernel: Add helper to map pages with base address and size
This allows us to easily map enough pages for buffer with known size VESA driver can now allocate enough memory for whole framebuffer if it doesn't fit in a single page (1920x1080 for example)
This commit is contained in:
parent
086f0c7cf6
commit
531f470132
|
@ -85,4 +85,11 @@ namespace Paging
|
|||
asm volatile("invlpg (%0)" :: "r"(address) : "memory");
|
||||
}
|
||||
|
||||
void MapPages(uintptr_t address, size_t size)
|
||||
{
|
||||
address = (address >> 21) << 21;
|
||||
for (size_t offset = 0; offset < size; offset += 1 << 21)
|
||||
MapPage(address + offset);
|
||||
}
|
||||
|
||||
}
|
|
@ -98,7 +98,7 @@ namespace VESA
|
|||
s_height = framebuffer.height;
|
||||
s_mode = framebuffer.type;
|
||||
|
||||
Paging::MapPage(framebuffer.addr);
|
||||
Paging::MapPages(s_addr, s_pitch * s_height);
|
||||
|
||||
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS)
|
||||
{
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#pragma once
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
namespace Paging
|
||||
|
@ -8,5 +9,6 @@ namespace Paging
|
|||
void Initialize();
|
||||
|
||||
void MapPage(uintptr_t address);
|
||||
void MapPages(uintptr_t address, size_t size);
|
||||
|
||||
}
|
Loading…
Reference in New Issue