-
Notifications
You must be signed in to change notification settings - Fork 22
/
mmio.py
84 lines (67 loc) · 1.72 KB
/
mmio.py
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from util import *
mmioClasses = []
def register(base, size):
def sub(cls):
cls.physbase = base
cls.size = size
mmioClasses.append(cls)
return cls
return sub
class MmioBase(object):
def __init__(self, ctu):
self.ctu = ctu
self.stored = {}
self.setup()
def setup(self):
pass
def sread(self, addr, size):
pass
def swrite(self, addr, size, value):
return False
def read(self, addr, size):
pc = raw(self.ctu.threads.current.lastinsn)
print '[%s:%s] MMIO Read %x -- %i bytes' % (self.ctu.threadId, pc, addr, size)
val = self.sread(addr, size)
if val is None:
print 'Unknown MMIO read from %x' % addr
if addr in self.stored:
print 'Had stored value'
return self.stored[addr]
else:
return 0
else:
return val
def write(self, addr, size, value):
pc = raw(self.ctu.threads.current.lastinsn)
print '[%s:%s] MMIO Write %x -- %x -- %i bytes' % (self.ctu.threadId, pc, addr, value, size)
if self.swrite(addr, size, value) is False:
print 'Unhandled MMIO write to %x' % addr
self.stored[addr] = value
@register(0x70000000, 0x1000)
class Apb(MmioBase):
pass
@register(0x7000f800, 0x400)
class Fuses(MmioBase):
pass
@register(0x700e3000, 0x100)
class MipiCal(MmioBase):
pass
@register(0x70019000, 0x1000)
class Mc(MmioBase):
def sread(self, addr, size):
if addr == 0x70019670:
return 0xfff00000
elif addr == 0x70019674:
return 0x1000
@register(0x50000000, 0x24000)
class Host1x(MmioBase):
pass
@register(0x54200000, 0x400000)
class Display(MmioBase):
pass
@register(0x57000000, 0x1000000)
class GpuRegs(MmioBase):
pass
@register(0x58000000, 0x100000)
class GpuBar1(MmioBase):
pass