|
37 | 37 | CONTEXTSTRUCT_STR = "<HHIQQQQQHHQQHHHHHHBBBBHHQII" |
38 | 38 |
|
39 | 39 |
|
| 40 | +OpenPipeMessage = namedtuple('OpenPipeMessage', [ |
| 41 | + 'type', |
| 42 | + 'head_size', |
| 43 | + 'foot_size', |
| 44 | + 'pad_0x3_', |
| 45 | + 'pipe_idx', |
| 46 | + 'pipe_idx_', |
| 47 | + 'ring_iova', |
| 48 | + 'pad_0x10_', |
| 49 | + 'ring_count', |
| 50 | + 'completion_ring_index', |
| 51 | + 'doorbell_idx', |
| 52 | + 'flags', |
| 53 | + 'pad_0x20_', |
| 54 | +]) |
| 55 | +OPENPIPE_STR = "<BBB1sHHQ8sHHHH20s" |
| 56 | + |
| 57 | + |
| 58 | +ClosePipeMessage = namedtuple('ClosePipeMessage', [ |
| 59 | + 'type', |
| 60 | + 'pad_0x1_', |
| 61 | + 'pipe_idx', |
| 62 | + 'pad_0x4_' |
| 63 | +]) |
| 64 | +CLOSEPIPE_STR = "<B1sH48s" |
| 65 | + |
| 66 | + |
40 | 67 | class BTBAR0Regs(RegMap): |
41 | 68 | IMG_DOORBELL = 0x140, Register32 |
42 | 69 | RTI_CONTROL = 0x144, Register32 |
@@ -243,6 +270,7 @@ def hook(name, iova, sz): |
243 | 270 |
|
244 | 271 | self._ctx = context |
245 | 272 | self._last_ring_idx = {} |
| 273 | + self._open_pipes = {} |
246 | 274 |
|
247 | 275 | except Exception as e: |
248 | 276 | print(e) |
@@ -271,6 +299,27 @@ def w_DOORBELL_05(self, val): |
271 | 299 | print(f"buf iova {buf_addr:016X}") |
272 | 300 | data = self.dart_tracer.dart.ioread(STREAM, buf_addr, 0x34) |
273 | 301 | chexdump(data) |
| 302 | + |
| 303 | + msg_type = data[0] |
| 304 | + if msg_type == 1: |
| 305 | + open_pipe = OpenPipeMessage._make(struct.unpack(OPENPIPE_STR, data)) |
| 306 | + print(open_pipe) |
| 307 | + |
| 308 | + self._open_pipes[open_pipe.pipe_idx] = open_pipe |
| 309 | + elif msg_type == 3: |
| 310 | + close_pipe = ClosePipeMessage._make(struct.unpack(CLOSEPIPE_STR, data)) |
| 311 | + print(close_pipe) |
| 312 | + |
| 313 | + del self._open_pipes[close_pipe.pipe_idx] |
| 314 | + elif pipe in self._open_pipes: |
| 315 | + tr_iova = self._open_pipes[pipe].ring_iova |
| 316 | + |
| 317 | + for i in range(self._last_ring_idx[pipe], ring_idx): |
| 318 | + # FIXME XXX what's going on here? |
| 319 | + tr_data_addr = tr_iova |
| 320 | + print(f"TR idx {i} @ iova {tr_data_addr:016X}") |
| 321 | + tr_data = self.dart_tracer.dart.ioread(STREAM, tr_data_addr, 0x200) |
| 322 | + chexdump(tr_data) |
274 | 323 | except Exception as e: |
275 | 324 | print(e) |
276 | 325 |
|
|
0 commit comments