Xyris  0.5
paging.hpp
Go to the documentation of this file.
1 /**
2  * @file paging.hpp
3  * @author Keeton Feavel ([email protected])
4  * @brief
5  * @version 0.3
6  * @date 2019-11-22
7  *
8  * @copyright Copyright the Xyris Contributors (c) 2019
9  *
10  */
11 #pragma once
12 
13 #include <Arch/Memory.hpp>
14 #include <Memory/MemoryMap.hpp>
15 #include <stddef.h>
16 #include <stdint.h>
17 
18 namespace Memory {
19 
20 /**
21  * @brief Sets up the environment, page directories etc and enables paging.
22  *
23  */
24 void init(MemoryMap* map);
25 
26 /**
27  * @brief Returns a new page in memory for use.
28  * If less than one page is requested, exactly one page
29  * will be allocated and returned.
30  *
31  * @param size Page size in bytes
32  * @return void* Page memory address
33  */
34 void* newPage(size_t size);
35 
36 /**
37  * @brief Frees pages starting at a given page address.
38  *
39  * @param page Starting location of page(s) to be freed
40  * @param size Number of bytes to be freed
41  */
42 void freePage(void* page, size_t size);
43 
44 /**
45  * @brief Checks whether an address is mapped into memory.
46  *
47  * @param addr Address to be checked.
48  * @return true The address is mapped in and valid.
49  * @return false The address is not mapped into memory.
50  */
51 bool isPresent(uintptr_t addr);
52 
53 /**
54  * @brief Gets the physical address of the current page directory.
55  *
56  * @returns the physical address of the current page directory.
57  */
58 uintptr_t getPageDirPhysAddr();
59 
60 /**
61  * @brief Map a page into the kernel address space.
62  *
63  * @param vaddr Virtual address (in kernel space)
64  * @param paddr Physical address
65  */
66 void mapKernelPage(Arch::Memory::Address vaddr, Arch::Memory::Address paddr);
67 
68 /**
69  * @brief Map an address range into the kernel virtual address space.
70  *
71  * @param sect Memory section
72  */
73 void mapKernelRangeVirtual(Section sect);
74 
75 /**
76  * @brief Map a kernel address range into physical memory.
77  *
78  * @param sect Memory section
79  */
80 void mapKernelRangePhysical(Section sect);
81 
82 } // !namespace Paging
size
uint16_t size
Definition: regs.hpp:2
Memory
Definition: MemoryMap.hpp:15
Memory::mapKernelPage
void mapKernelPage(Arch::Memory::Address vaddr, Arch::Memory::Address paddr)
Map a page into the kernel address space.
Definition: paging.cpp:147
Memory::init
void init(MemoryMap *map)
Sets up the environment, page directories etc and enables paging.
Definition: paging.cpp:57
Memory::freePage
void freePage(void *page, size_t size)
Frees pages starting at a given page address.
Definition: paging.cpp:246
Memory::getPageDirPhysAddr
uintptr_t getPageDirPhysAddr()
Gets the physical address of the current page directory.
Definition: paging.cpp:272
MemoryMap.hpp
Memory map containing a number of Memory sections that describe the physical memory layout.
Memory::newPage
void * newPage(size_t size)
Returns a new page in memory for use. If less than one page is requested, exactly one page will be al...
Definition: paging.cpp:228
Memory::mapKernelRangePhysical
void mapKernelRangePhysical(Section sect)
Map a kernel address range into physical memory.
Definition: paging.cpp:199
Memory::isPresent
bool isPresent(uintptr_t addr)
Checks whether an address is mapped into memory.
Definition: paging.cpp:264
Memory.hpp
Architecture memory management & paging API.
Memory::mapKernelRangeVirtual
void mapKernelRangeVirtual(Section sect)
Map an address range into the kernel virtual address space.
Definition: paging.cpp:192