Kernel: kmalloc has now somewhat dynamic storage
Allocations bigger than PAGE_SIZE and those not forced to be identity mapped are now done on a GeneralAllocator. This allows us to use kmalloc for big allocations; bigger than the fixed 1 MiB storage. This is still a hack and the whole kmalloc will have to be rewritten at some point, but for now this does the job :D
This commit is contained in:
@@ -137,6 +137,21 @@ namespace IDT
|
||||
|
||||
extern "C" void cpp_isr_handler(uint64_t isr, uint64_t error, const Registers* regs)
|
||||
{
|
||||
if (isr == ISR::PageFault)
|
||||
{
|
||||
using namespace Kernel;
|
||||
|
||||
vaddr_t vaddr = regs->cr2 & PAGE_ADDR_MASK;
|
||||
|
||||
if (!PageTable::kernel().is_page_free(vaddr))
|
||||
{
|
||||
auto paddr = kmalloc_paddr_of(vaddr);
|
||||
ASSERT(paddr.has_value());
|
||||
PageTable::current().map_page_at(paddr.value(), vaddr, PageTable::Flags::ReadWrite | PageTable::Flags::Present);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
pid_t tid = Kernel::Scheduler::current_tid();
|
||||
pid_t pid = tid ? Kernel::Process::current().pid() : 0;
|
||||
|
||||
|
||||
@@ -65,7 +65,7 @@ namespace Kernel
|
||||
|
||||
static uint64_t* allocate_page_aligned_page()
|
||||
{
|
||||
void* page = kmalloc(PAGE_SIZE, PAGE_SIZE);
|
||||
void* page = kmalloc(PAGE_SIZE, PAGE_SIZE, true);
|
||||
ASSERT(page);
|
||||
memset(page, 0, PAGE_SIZE);
|
||||
return (uint64_t*)page;
|
||||
|
||||
Reference in New Issue
Block a user