32 setup_mm(MockRepository &mocks)
43 memory_manager_ut::test_page_table_x64_add_remove_page_success_without_setting()
51 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
53 pml4->add_page_4k(
virt);
55 this->
expect_true(pml4->global_capacity() == 512 * 3);
57 pml4->add_page_4k(
virt + 0x1000);
59 this->
expect_true(pml4->global_capacity() == 512 * 3);
61 pml4->add_page_4k(
virt + 0x10000);
63 this->
expect_true(pml4->global_capacity() == 512 * 3);
65 pml4->remove_page(
virt);
67 this->
expect_true(pml4->global_capacity() == 512 * 1);
69 pml4->remove_page(
virt + 0x1000);
71 this->
expect_true(pml4->global_capacity() == 512 * 1);
73 pml4->remove_page(
virt + 0x10000);
75 this->
expect_true(pml4->global_capacity() == 512 * 1);
80 memory_manager_ut::test_page_table_x64_add_remove_page_1g_success()
88 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
90 auto &&entry1 = pml4->add_page_1g(
virt);
91 entry1.set_present(
true);
93 this->
expect_true(pml4->global_capacity() == 512 * 1);
95 auto &&entry2 = pml4->add_page_1g(
virt + 0x100);
96 entry2.set_present(
true);
98 this->
expect_true(pml4->global_capacity() == 512 * 1);
100 auto &&entry3 = pml4->add_page_1g(
virt + 0x40000000);
101 entry3.set_present(
true);
103 this->
expect_true(pml4->global_capacity() == 512 * 1);
105 auto &&entry4 = pml4->add_page_1g(
virt + 0x400000000);
106 entry4.set_present(
true);
108 this->
expect_true(pml4->global_capacity() == 512 * 1);
110 pml4->remove_page(
virt);
112 this->
expect_true(pml4->global_capacity() == 512 * 1);
114 pml4->remove_page(
virt + 0x40000000);
116 this->
expect_true(pml4->global_capacity() == 512 * 1);
118 pml4->remove_page(
virt + 0x400000000);
120 this->
expect_true(pml4->global_capacity() == 512 * 1);
125 memory_manager_ut::test_page_table_x64_add_remove_page_2m_success()
127 MockRepository mocks;
133 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
135 auto &&entry1 = pml4->add_page_2m(
virt);
136 entry1.set_present(
true);
138 this->
expect_true(pml4->global_capacity() == 512 * 2);
140 auto &&entry2 = pml4->add_page_2m(
virt + 0x100);
141 entry2.set_present(
true);
143 this->
expect_true(pml4->global_capacity() == 512 * 2);
145 auto &&entry3 = pml4->add_page_2m(
virt + 0x200000);
146 entry3.set_present(
true);
148 this->
expect_true(pml4->global_capacity() == 512 * 2);
150 auto &&entry4 = pml4->add_page_2m(
virt + 0x2000000);
151 entry4.set_present(
true);
153 this->
expect_true(pml4->global_capacity() == 512 * 2);
155 pml4->remove_page(
virt);
157 this->
expect_true(pml4->global_capacity() == 512 * 2);
159 pml4->remove_page(
virt + 0x200000);
161 this->
expect_true(pml4->global_capacity() == 512 * 2);
163 pml4->remove_page(
virt + 0x2000000);
165 this->
expect_true(pml4->global_capacity() == 512 * 1);
170 memory_manager_ut::test_page_table_x64_add_remove_page_4k_success()
172 MockRepository mocks;
178 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
180 auto &&entry1 = pml4->add_page_4k(
virt);
181 entry1.set_present(
true);
183 this->
expect_true(pml4->global_capacity() == 512 * 3);
185 auto &&entry2 = pml4->add_page_4k(
virt + 0x100);
186 entry2.set_present(
true);
188 this->
expect_true(pml4->global_capacity() == 512 * 3);
190 auto &&entry3 = pml4->add_page_4k(
virt + 0x1000);
191 entry3.set_present(
true);
193 this->
expect_true(pml4->global_capacity() == 512 * 3);
195 auto &&entry4 = pml4->add_page_4k(
virt + 0x10000);
196 entry4.set_present(
true);
198 this->
expect_true(pml4->global_capacity() == 512 * 3);
200 pml4->remove_page(
virt);
202 this->
expect_true(pml4->global_capacity() == 512 * 3);
204 pml4->remove_page(
virt + 0x1000);
206 this->
expect_true(pml4->global_capacity() == 512 * 3);
208 pml4->remove_page(
virt + 0x10000);
210 this->
expect_true(pml4->global_capacity() == 512 * 1);
215 memory_manager_ut::test_page_table_x64_add_remove_page_swap_success()
217 MockRepository mocks;
223 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
225 auto &&entry1 = pml4->add_page_4k(
virt);
226 entry1.set_present(
true);
228 this->
expect_true(pml4->global_capacity() == 512 * 3);
230 pml4->remove_page(
virt);
232 this->
expect_true(pml4->global_capacity() == 512 * 1);
234 auto &&entry2 = pml4->add_page_2m(
virt);
235 entry2.set_present(
true);
237 this->
expect_true(pml4->global_capacity() == 512 * 2);
239 pml4->remove_page(
virt);
241 this->
expect_true(pml4->global_capacity() == 512 * 1);
243 auto &&entry3 = pml4->add_page_4k(
virt);
244 entry3.set_present(
true);
246 this->
expect_true(pml4->global_capacity() == 512 * 3);
248 auto &&entry4 = pml4->add_page_2m(
virt);
249 entry4.set_present(
true);
251 this->
expect_true(pml4->global_capacity() == 512 * 2);
253 auto &&entry5 = pml4->add_page_4k(
virt);
254 entry5.set_present(
true);
256 this->
expect_true(pml4->global_capacity() == 512 * 3);
258 pml4->remove_page(
virt);
260 this->
expect_true(pml4->global_capacity() == 512 * 1);
265 memory_manager_ut::test_page_table_x64_add_page_twice_success()
267 MockRepository mocks;
273 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
275 pml4->add_page_4k(
virt);
281 memory_manager_ut::test_page_table_x64_remove_page_twice_success()
283 MockRepository mocks;
289 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
291 pml4->add_page_4k(
virt);
292 pml4->add_page_4k(
virt + 0x1000);
294 pml4->remove_page(
virt);
296 pml4->remove_page(
virt + 0x1000);
303 memory_manager_ut::test_page_table_x64_remove_page_unknown_success()
305 MockRepository mocks;
311 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
317 memory_manager_ut::test_page_table_x64_virt_to_pte_invalid()
319 MockRepository mocks;
325 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
327 pml4->add_page_4k(
virt);
331 pml4->remove_page(
virt);
337 memory_manager_ut::test_page_table_x64_virt_to_pte_success()
339 MockRepository mocks;
345 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
347 pml4->add_page_4k(
virt);
350 pml4->remove_page(
virt);
356 memory_manager_ut::test_page_table_x64_pt_to_mdl_success()
358 MockRepository mocks;
364 auto &&pml4 = std::make_unique<page_table_x64>(&scr3);
367 pml4->add_page_1g(0x1000);
369 pml4->add_page_2m(0x1000);
371 pml4->add_page_4k(0x1000);
374 pml4->remove_page(0x1000);
#define expect_exception(f, e)
#define RUN_UNITTEST_WITH_MOCKS(a, b)
virtual integer_pointer virtint_to_physint(integer_pointer virt) const
#define expect_no_exception(f)
virtual integer_pointer virtptr_to_physint(pointer virt) const
static memory_manager_x64 * instance() noexcept
constexpr page_table_x64::integer_pointer virt
bool virt_to_phys_return_nullptr
uintptr_t integer_pointer