Luna/kernel/include/memory/MemoryManager.h

41 lines
1.3 KiB
C
Raw Normal View History

#pragma once
#include "utils/Result.h"
#include <stdint.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
2022-09-22 05:57:30 +00:00
#define MAP_READ_WRITE 1 << 0
#define MAP_USER 1 << 1
2022-09-23 14:41:43 +00:00
#define MAP_EXEC 1 << 2
#define MAP_AS_OWNED_BY_TASK 1 << 3
2022-09-22 05:57:30 +00:00
namespace MemoryManager
{
void init();
void protect_kernel_sections();
Result<void*> get_mapping(void* physicalAddress, int flags = MAP_READ_WRITE);
void release_mapping(void* mapping);
Result<void*> get_unaligned_mapping(void* physicalAddress, int flags = MAP_READ_WRITE);
Result<void*> get_unaligned_mappings(void* physicalAddress, uint64_t count, int flags = MAP_READ_WRITE);
2022-09-07 08:33:22 +00:00
void release_unaligned_mapping(void* mapping);
void release_unaligned_mappings(void* mapping, uint64_t count);
2022-09-07 08:33:22 +00:00
Result<void*> get_page(int flags = MAP_READ_WRITE);
Result<void*> get_pages(uint64_t count, int flags = MAP_READ_WRITE);
Result<void*> get_page_at(uint64_t addr, int flags = MAP_READ_WRITE);
Result<void*> get_pages_at(uint64_t addr, uint64_t count, int flags = MAP_READ_WRITE);
void release_page(void* page);
void release_pages(void* pages, uint64_t count);
void protect(void* page, uint64_t count, int flags);
2022-11-08 18:07:43 +00:00
void map_several_pages(uint64_t physicalAddress, uint64_t virtualAddress, uint64_t count,
int flags = MAP_READ_WRITE);
}