summaryrefslogtreecommitdiffstats
path: root/debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py
diff options
context:
space:
mode:
Diffstat (limited to 'debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py')
-rw-r--r--debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py21
1 files changed, 17 insertions, 4 deletions
diff --git a/debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py b/debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py
index 8dcf633..b278ec8 100644
--- a/debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py
+++ b/debug/risc-v-gsp-rm-vm/sim/devices/fwsec.py
@@ -25,6 +25,17 @@ WPR2_ADDR_HI = 0x1FA828
WPR2_ALIGNMENT = 12
WPR2_BLOCK = 0x20000
+#: Block-relative offsets (a profile window that starts at ``+0x1FA000``
+#: reaches the pair at ``0x824``/``0x828``; the device accepts both forms).
+WPR2_ADDR_LO_REL = WPR2_ADDR_LO & 0xFFF
+WPR2_ADDR_HI_REL = WPR2_ADDR_HI & 0xFFF
+_KEYS = {
+ WPR2_ADDR_LO: WPR2_ADDR_LO,
+ WPR2_ADDR_HI: WPR2_ADDR_HI,
+ WPR2_ADDR_LO_REL: WPR2_ADDR_LO,
+ WPR2_ADDR_HI_REL: WPR2_ADDR_HI,
+}
+
class Wpr2Block(Device):
"""WPR2 address pair as seen by the firmware (host/booter-written)."""
@@ -60,13 +71,15 @@ class Wpr2Block(Device):
self.regs: dict[int, int] = {}
def read(self, offset: int, size: int) -> int | None:
- if size == 4 and offset in self.regs:
- return self.regs[offset]
+ key = _KEYS.get(offset)
+ if size == 4 and key is not None and key in self.regs:
+ return self.regs[key]
return None
def write(self, offset: int, size: int, value: int) -> bool:
- if size == 4 and offset in (WPR2_ADDR_LO, WPR2_ADDR_HI):
- self.regs[offset] = value & 0xFFFFFFFF
+ key = _KEYS.get(offset)
+ if size == 4 and key is not None:
+ self.regs[key] = value & 0xFFFFFFFF
return True
return False