Skip to content

Commit 126ccdf

Browse files
committed
bluetooth: this is wrong, but one pipe has HCI commands
Signed-off-by: R <[email protected]>
1 parent 1288658 commit 126ccdf

1 file changed

Lines changed: 49 additions & 0 deletions

File tree

proxyclient/hv/trace_bt.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,33 @@
3737
CONTEXTSTRUCT_STR = "<HHIQQQQQHHQQHHHHHHBBBBHHQII"
3838

3939

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+
4067
class BTBAR0Regs(RegMap):
4168
IMG_DOORBELL = 0x140, Register32
4269
RTI_CONTROL = 0x144, Register32
@@ -243,6 +270,7 @@ def hook(name, iova, sz):
243270

244271
self._ctx = context
245272
self._last_ring_idx = {}
273+
self._open_pipes = {}
246274

247275
except Exception as e:
248276
print(e)
@@ -271,6 +299,27 @@ def w_DOORBELL_05(self, val):
271299
print(f"buf iova {buf_addr:016X}")
272300
data = self.dart_tracer.dart.ioread(STREAM, buf_addr, 0x34)
273301
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)
274323
except Exception as e:
275324
print(e)
276325

0 commit comments

Comments
 (0)