spz3/MMU.cpp

21 lines
648 B
C++

#include "MMU.h"
#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;
if (type == WRITE)
(*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;
}
}