-
Notifications
You must be signed in to change notification settings - Fork 0
/
pageTable.h
66 lines (47 loc) · 1.61 KB
/
pageTable.h
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
59
60
61
62
63
64
65
66
#ifndef PAGETABLE
#define PAGETABLE
#include "level.h"
#include "tlb.h"
#include "tracereader.h"
#define MEMORY_SPACE_SIZE 32
class PageTable
{
public:
// constructor
PageTable(unsigned int, unsigned int*, int);
// ptr to root level
Level* rootLevel;
// bit arrays and entryCountArr
unsigned int* maskArr;
unsigned int* shiftArr;
unsigned int* entryCountArr;
unsigned int* bitsInLevel;
unsigned int offsetMask; // to append onto PFN
unsigned int offsetShift;
// pageTable information
unsigned int levelCount;
unsigned int addressCount;
unsigned int numBytesSize;
unsigned int frameCount;
unsigned int vpnNumBits;
unsigned int pageSizeBytes;
unsigned int currFrameNum; // for the pageInsert function to know what frameNum to use
// hit counts
unsigned int countPageTableHits;
unsigned int countTlbHits;
// set array, mask and shift methods
void setMaskArr();
void shiftMaskArr(); // helper fuction for setMaskArr
void setShiftArr();
void setEntryCountArr();
void setOffsetMask(unsigned int vpnNumBits);
void setOffsetShift(unsigned int vpnNumBits);
// calculation methods
unsigned int getOffsetOfAddress(unsigned int virtAddr);
unsigned int virtualAddressToPageNum(unsigned int virtualAddress, unsigned int mask, unsigned int shift);
unsigned int appendOffset(unsigned int frameNum, unsigned int virtualAddress);
// page walk methods
void pageInsert(Level* lvlPtr, unsigned int virtualAddress);
Map* pageLookup(Level* lvlPtr, unsigned int virtualAddress);
};
#endif