Skip to content

Commit d94f918

Browse files
povikmarcan
authored andcommitted
m1n1.adt: Add to_bus_addr() method
So that one knows what to put in reg properties. Signed-off-by: Martin Povišer <[email protected]>
1 parent 6f460b1 commit d94f918

1 file changed

Lines changed: 17 additions & 0 deletions

File tree

proxyclient/m1n1/adt.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -601,6 +601,23 @@ def translate(self, addr):
601601

602602
return addr
603603

604+
def to_bus_addr(self, addr):
605+
node = self._parent
606+
607+
descend = []
608+
while node is not None:
609+
if "ranges" not in node._properties:
610+
break
611+
descend.append(node)
612+
node = node._parent
613+
614+
for node in reversed(descend):
615+
for r in node.ranges:
616+
if r.parent_addr <= addr < (r.parent_addr + r.size):
617+
addr = addr - r.parent_addr + r.bus_addr
618+
break
619+
return addr
620+
604621
def tostruct(self):
605622
properties = []
606623
for k,v in itertools.chain(self._properties.items()):

0 commit comments

Comments
 (0)