Compare commits

..

No commits in common. "b9e8030aacae5ee89ee0ca5cfd7c8edd360ac01d" and "8c72e9a49a63f0f6ed25a26656bb2ef0f11446b8" have entirely different histories.

4 changed files with 4 additions and 22 deletions

View File

@ -3,9 +3,7 @@
#include "arch/MMU.h"
#include "boot/bootboot.h"
#include "fs/VFS.h"
#include "memory/MemoryManager.h"
#include <bits/modes.h>
#include <luna/Alignment.h>
TarStream g_initrd;
extern const BOOTBOOT bootboot;
@ -45,9 +43,5 @@ Result<void> InitRD::populate_vfs()
TRY(vfs_create_dir_if_not_exists(entry.name, entry.mode));
}
}
// Now we don't need the original initrd anymore
MemoryManager::free_frames(bootboot.initrd_ptr, get_blocks_from_size(bootboot.initrd_size, ARCH_PAGE_SIZE));
return {};
}

View File

@ -170,17 +170,6 @@ namespace MemoryManager
return {};
}
Result<void> free_frames(u64 address, usize count)
{
while (count--)
{
TRY(free_frame(address));
address += ARCH_PAGE_SIZE;
}
return {};
}
Result<void> remap(u64 address, usize count, int flags)
{
CHECK_PAGE_ALIGNED(address);

View File

@ -11,7 +11,6 @@ namespace MemoryManager
Result<u64> alloc_frame();
Result<void> free_frame(u64 frame);
Result<void> free_frames(u64 address, usize count);
void lock_frame(u64 frame);
void lock_frames(u64 frames, usize count);

View File

@ -37,7 +37,7 @@ Result<u64> sys_mmap(Registers*, SyscallArgs args)
Thread* current = Scheduler::current();
u64 address;
if (!addr) address = TRY(current->vm_allocator->alloc_several_pages(get_blocks_from_size(len, ARCH_PAGE_SIZE)));
if (!addr) address = TRY(current->vm_allocator->alloc_several_pages(len / ARCH_PAGE_SIZE));
else
{
kwarnln("mmap: FIXME: tried to mmap at a given address, instead of letting us choose");
@ -51,7 +51,7 @@ Result<u64> sys_mmap(Registers*, SyscallArgs args)
kdbgln("mmap: mapping memory at %#lx, size=%zu", address, len);
return MemoryManager::alloc_at(address, get_blocks_from_size(len, ARCH_PAGE_SIZE), mmu_flags);
return MemoryManager::alloc_at(address, len / ARCH_PAGE_SIZE, mmu_flags);
}
Result<u64> sys_munmap(Registers*, SyscallArgs args)
@ -64,14 +64,14 @@ Result<u64> sys_munmap(Registers*, SyscallArgs args)
Thread* current = Scheduler::current();
bool ok = TRY(current->vm_allocator->free_several_pages(address, get_blocks_from_size(size, ARCH_PAGE_SIZE)));
bool ok = TRY(current->vm_allocator->free_several_pages(address, size / ARCH_PAGE_SIZE));
// POSIX says munmap should silently do nothing if the memory was not already mapped.
if (!ok) return 0;
kdbgln("munmap: unmapping memory at %#lx, size=%zu", address, size);
TRY(MemoryManager::unmap_owned(address, get_blocks_from_size(size, ARCH_PAGE_SIZE)));
TRY(MemoryManager::unmap_owned(address, size / ARCH_PAGE_SIZE));
return { 0 };
}