39 lines
1.2 KiB
C++
39 lines
1.2 KiB
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
|
|
#define MAP_AS_OWNED_BY_TASK 1 << 3
|
|
|
|
namespace MemoryManager
|
|
{
|
|
void init();
|
|
|
|
void protect_kernel_sections();
|
|
|
|
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);
|
|
|
|
void protect(void* page, uint64_t count, int flags);
|
|
|
|
void map_several_pages(uint64_t physicalAddress, uint64_t virtualAddress, uint64_t count, int flags = MAP_READ_WRITE);
|
|
} |