Xyris  0.5
Memory.hpp
Go to the documentation of this file.
1 /**
2  * @file Memory.hpp
3  * @author Keeton Feavel ([email protected])
4  * @brief Architecture memory management & paging API
5  * @version 0.1
6  * @date 2021-09-18
7  *
8  * @copyright Copyright the Xyris Contributors (c) 2021
9  *
10  */
11 #pragma once
12 
13 #include <stdint.h>
14 #include <stddef.h>
15 #if defined(__i686__)
16 # include <Arch/i686/Memory.i686.hpp>
17 #endif
18 
19 #define B_TO_KB(b) ((b) / 1024)
20 #define KB_TO_MB(kb) ((kb) / 1024)
21 #define MB_TO_GB(mb) ((mb) / 1024)
22 
23 #define B_TO_MB(b) KB_TO_MB(B_TO_KB(b))
24 #define B_TO_GB(b) MB_TO_GB(B_TO_MB(b))
25 
26 #define ADDRESS_SPACE_SIZE 0x100000000
27 // TODO: Add this to memory class (#326)
28 #define ADDRESS_TO_PAGE_IDX(addr) ((addr) / ARCH_PAGE_SIZE)
29 #define MEM_BITMAP_SIZE ((ADDRESS_SPACE_SIZE / ARCH_PAGE_SIZE) / (sizeof(size_t) * CHAR_BIT))
30 
31 namespace Arch::Memory {
32 
33 /**
34  * @brief Enable hardware paging
35  *
36  */
37 void pagingEnable();
38 
39 /**
40  * @brief Disable hardware paging
41  *
42  */
43 void pagingDisable();
44 
45 } // !namespace Arch::Memory
Arch::Memory::pagingEnable
void pagingEnable()
Enable hardware paging.
Definition: Arch.i686.cpp:94
Arch::Memory
Definition: Arch.i686.cpp:92
Arch::Memory::pagingDisable
void pagingDisable()
Disable hardware paging.
Definition: Arch.i686.cpp:100
Memory.i686.hpp
i686 memory structures and definitions. C & C++ compatible header.