spz3/MMU.cpp

21 lines
648 B
C++
Raw Normal View History

2025-03-31 17:19:43 +03:00
#include "MMU.h"
2025-04-01 16:29:33 +03:00
#include <iostream>
void MMU::access(Kernel &kernel, std::vector<PTE> *page_table, const unsigned int index, const AccessType type) {
if (!(*page_table)[index].P)
kernel.page_fault(page_table, index);
(*page_table)[index].R = true;
2025-03-31 17:19:43 +03:00
if (type == WRITE)
2025-04-01 16:29:33 +03:00
(*page_table)[index].M = true;
switch (type) {
case READ:
std::cout << std::format("[mmu:read] pt[{}] -> ppn {}", index, (*page_table)[index].PPN) << std::endl;
break;
case WRITE:
std::cout << std::format("[mmu:write] pt[{}] -> ppn {}", index, (*page_table)[index].PPN) << std::endl;
}
2025-03-31 17:19:43 +03:00
}