-
Notifications
You must be signed in to change notification settings - Fork 0
/
PMMU.cpp
executable file
·58 lines (54 loc) · 1.48 KB
/
PMMU.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
//
// PMMU.cpp
// MIPS_Emulator
//
// Created by Matt on 1/6/16.
// Copyright © 2016 Matt. All rights reserved.
//
#include "PMMU.h"
// Default Constructor
// Ram Size in blocks of 4096 bytes
PMMU::PMMU(size_t ramSize) {
frameTableRamLimit = ramSize;
for (size_t i=0; i<frameTableMax; i++) {
frameTable[i] = nullptr;
frameBoolTable[i] = false;
}
frameTableSize = 0;
mmioAddressTableSize = 0;
// Init TLB
for (size_t i=0; i<MAXCPUS; i++) {
for (size_t j=0; j<TLBMAXENTRIES; j++) {
TLBTable[i][j].V1 = false;
TLBTable[i][j].V0 = false;
}
}
}
// Destructor
// Cleans up frame table
PMMU::~PMMU() {
// Clean up frame table
for (size_t i=0; i<frameTableMax; i++) {
if (frameTable[i] != nullptr) {
delete[] frameTable[i];
frameTable[i] = nullptr;
}
frameBoolTable[i] = false;
}
// Invalidate all TLB entries
for (size_t i=0; i<MAXCPUS; i++) {
for (size_t j=0; j<TLBMAXENTRIES; j++) {
TLBTable[i][j].V1 = false;
TLBTable[i][j].V0 = false;
}
}
}
// Static members
size_t PMMU::frameTableSize;
size_t PMMU::frameTableRamLimit;
uint8_t* PMMU::frameTable[frameTableMax];
bool PMMU::frameBoolTable[frameTableMax];
uint32_t PMMU::mmioAddressTable[MMIOADDRESSTABLEMAX];
uint32_t PMMU::mmioAddressTableSize;
MMIO_Device* PMMU::mmioDeviceTable[MMIOADDRESSTABLEMAX];
PMMU::TLBEntry_t PMMU::TLBTable[MAXCPUS][TLBMAXENTRIES];