m1n1.trace: Support HOOK mode

Signed-off-by: Hector Martin <marcan@marcan.st>
This commit is contained in:
Hector Martin 2021-10-15 23:43:07 +09:00
parent f49428bb65
commit 0255831153

View file

@ -74,6 +74,12 @@ class Tracer(Reloadable):
def init_state(self): def init_state(self):
pass pass
def hook_w(self, addr, val, width, **kwargs):
self.hv.u.write(addr, val, width)
def hook_r(self, addr, width, **kwargs):
return self.hv.u.read(addr, width)
def evt_rw(self, evt, regmap=None, prefix=None): def evt_rw(self, evt, regmap=None, prefix=None):
self._cache.update(evt.addr, evt.data) self._cache.update(evt.addr, evt.data)
reg = rcls = None reg = rcls = None
@ -112,8 +118,12 @@ class Tracer(Reloadable):
def trace(self, start, size, mode, read=True, write=True, **kwargs): def trace(self, start, size, mode, read=True, write=True, **kwargs):
zone = irange(start, size) zone = irange(start, size)
self.hv.add_tracer(zone, self.ident, mode, self.evt_rw if read else None, if mode == TraceMode.HOOK:
self.evt_rw if write else None, **kwargs) self.hv.add_tracer(zone, self.ident, mode, self.hook_r if read else None,
self.hook_w if write else None, **kwargs)
else:
self.hv.add_tracer(zone, self.ident, mode, self.evt_rw if read else None,
self.evt_rw if write else None, **kwargs)
def trace_regmap(self, start, size, cls, mode=None, name=None, prefix=None): def trace_regmap(self, start, size, cls, mode=None, name=None, prefix=None):
if mode is None: if mode is None: