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:
Bananymous 2023-01-05 03:44:41 +02:00
parent 086f0c7cf6
commit 531f470132
3 changed files with 10 additions and 1 deletions

View File

@ -85,4 +85,11 @@ namespace Paging
asm volatile("invlpg (%0)" :: "r"(address) : "memory"); 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);
}
} }

View File

@ -98,7 +98,7 @@ namespace VESA
s_height = framebuffer.height; s_height = framebuffer.height;
s_mode = framebuffer.type; s_mode = framebuffer.type;
Paging::MapPage(framebuffer.addr); Paging::MapPages(s_addr, s_pitch * s_height);
if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS) if (s_mode == MULTIBOOT_FRAMEBUFFER_TYPE_GRAPHICS)
{ {

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include <stddef.h>
#include <stdint.h> #include <stdint.h>
namespace Paging namespace Paging
@ -8,5 +9,6 @@ namespace Paging
void Initialize(); void Initialize();
void MapPage(uintptr_t address); void MapPage(uintptr_t address);
void MapPages(uintptr_t address, size_t size);
} }