-
Notifications
You must be signed in to change notification settings - Fork 19
/
Mmio.h
59 lines (49 loc) · 1.04 KB
/
Mmio.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
#pragma once
#include "Ctu.h"
class MmioBase {
public:
MmioBase() {}
virtual ~MmioBase() {
for(auto entry : storedValues) {
free(entry.second);
}
}
void Setup();
virtual bool read(gptr addr, guint size, uint64_t &value) {
return false;
}
virtual bool write(gptr addr, guint size, uint64_t value) {
return false;
}
void setSize(guint _size) {
mmioSize = _size;
}
void setOffset(guint _offset) {
offsetFromMMIO = _offset;
}
guint offsetFromMMIO;
guint mmioSize;
private:
unordered_map<gptr, void *> storedValues;
};
class Mmio {
public:
Mmio(Ctu *ctu);
virtual ~Mmio() {}
gptr getVirtualAddressFromAddr(gptr addr);
gptr getPhysicalAddressFromVirtual(gptr addr);
MmioBase *getMMIOFromPhysicalAddress(gptr addr);
void MMIOInitialize();
gptr GetBase() {
return mmioBaseAddr;
}
guint GetSize() {
return mmioBaseSize;
}
private:
Ctu *ctu;
void MMIORegister(gptr base, guint size, MmioBase *mmioBase);
gptr mmioBaseAddr = 0x4000000;//1 << 58;
guint mmioBaseSize = 0;
unordered_map<gptr, MmioBase *> mmioBases;
};