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
|
"""PMU stub.
Evidence kind: **none yet** (no PMU register has been observed in the
570.144 boot runs, and no PMU register semantics are needed to reach the
rungs achieved so far). The class exists so a profile can attach a PMU
window without inventing behaviour: every access stays unhandled and is
reported by the machine's unknown log, and the stub records the accesses it
saw for later identification.
When PMU accesses are observed, each register is added here with its header
field evidence and a test, exactly like the falcon block.
"""
from __future__ import annotations
from .base import Device
class PmuStub(Device):
"""A PMU window with no proven semantics: observe, never fake."""
name = "pmu"
def __init__(self, *, base: int = 0, size: int = 0x1000):
super().__init__(base=base, size=size)
self.reset()
def reset(self) -> None:
self.seen: dict[str, int] = {}
def read(self, offset: int, size: int) -> int | None:
self._note(offset, size, "r")
return None
def write(self, offset: int, size: int, value: int) -> bool:
self._note(offset, size, "w")
return False
def peek(self, offset: int, size: int) -> int | None:
return None
def _note(self, offset: int, size: int, rw: str) -> None:
key = f"{rw}:{offset:#x}:{size}"
self.seen[key] = self.seen.get(key, 0) + 1
def state(self) -> dict:
return {"seen": dict(sorted(self.seen.items()))}
|