Luna/kernel/include/memory/MemoryManager.h

32 lines
980 B
C++

#pragma once
#include <stdint.h>
#ifndef PAGE_SIZE
#define PAGE_SIZE 4096
#endif
#define MAP_READ_WRITE 1 << 0
#define MAP_USER 1 << 1
#define MAP_EXEC 1 << 2
namespace MemoryManager
{
void init();
void* get_mapping(void* physicalAddress, int flags = MAP_READ_WRITE);
void release_mapping(void* mapping);
void* get_unaligned_mapping(void* physicalAddress, int flags = MAP_READ_WRITE);
void* get_unaligned_mappings(void* physicalAddress, uint64_t count, int flags = MAP_READ_WRITE);
void release_unaligned_mapping(void* mapping);
void release_unaligned_mappings(void* mapping, uint64_t count);
void* get_page(int flags = MAP_READ_WRITE);
void* get_pages(uint64_t count, int flags = MAP_READ_WRITE);
void* get_page_at(uint64_t addr, int flags = MAP_READ_WRITE);
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);
}