mirror of
https://github.com/D-Modem/courier-emu.git
synced 2026-11-28 20:38:07 -08:00
The card spends its whole run streaming DSP code. This decodes that transport from QF060003 and captures what it sends. Eight 16-bit lanes at ports 0xc0, 0xc4 ... 0xdc, low byte at the port and high byte at the port + 2. [0x9d38] picks the lane group - 0xc0 for the path at 0xced05, 0xd0 for the one at 0xced12 - and [0x9d37] is that group's strobe, 1 or 2, written to 0x98 after each four-word burst and waited on at 0xced9e. The final word comes from [0x9d3a], strobed with 4 and acknowledged on bit 2. 0xcec72 writes 0xffff to 0x98/0x9a and 0x9c/0x9e and polls both pairs back as a reset presence check. Captured over four million instructions the stream is five complete copies of the resident, byte for byte, each preceded by the eight 0x0083 lane-init words: 62,544 bytes at a 62,560-byte stride, matching row one of the load table in docs/quad-c50-overlay-loader.md - source paragraph 0x2000, length 0xf450, destination 0x8000. It repeats because nothing answers. The transfer is not failing: across a twelve million instruction run 0xced12 returns carry-clear on 23 of 24 loads, with no timeout and no give-up, because the unmodelled 0x98 floats high and every readiness poll passes. A supervisor at 0xede01/0xeddb1 then drives the load again. The missing direction is DSP to CPU. This is the tap, not the endpoint. It is fed from a run's recorded port writes rather than wired into the machine's port handlers, so it cannot change timing, and it neither executes the captured image nor answers on the DSP's behalf. Making the link answer means running the resident on the C5x core, and the 0x57/0x58 request and acknowledge protocol that needs is still open in quad-c50-overlay-loader.md. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
42 lines
2.0 KiB
Python
42 lines
2.0 KiB
Python
"""Capture what the Quad streams to its C50 datapumps, without perturbing it.
|
|
|
|
Runs the modem and reassembles the DSP download from the machine's own recorded
|
|
port writes, so the tap cannot change timing. Prints what was captured and how
|
|
it compares with the source region the supervisor streams from.
|
|
"""
|
|
import json
|
|
from pathlib import Path
|
|
|
|
from courier_emu.machine import CourierMachine
|
|
from courier_emu.quad_image import QuadImage
|
|
from courier_emu.quad_c50 import QuadC50Link
|
|
from courier_emu.nvram import CourierNvram, IDSDL403_NVRAM
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
IN = ROOT / 'artifacts/quad-identify-20260910'
|
|
OUT = ROOT / 'artifacts/quad-c50-20260910'
|
|
|
|
if __name__ == '__main__':
|
|
OUT.mkdir(parents=True, exist_ok=True)
|
|
image = QuadImage.modem((IN/'flash.bin').read_bytes(), (IN/'ram.bin').read_bytes())
|
|
machine = CourierMachine(image, quad_terminal=True, tick_ms=5,
|
|
max_io_events=4_000_000,
|
|
nvram=CourierNvram(data=bytearray(IDSDL403_NVRAM)),
|
|
serial_input=b'ATQ0V1\r')
|
|
result = machine.run(4_000_000)
|
|
link = QuadC50Link.from_io_events(machine.io_events)
|
|
payload = link.image()
|
|
(OUT/'stream.bin').write_bytes(payload)
|
|
# The supervisor streams from es:si with es = 0x2000, ax = 0 and cx = 0xf450
|
|
# (0xced12), so the source is physical 0x20000..0x2f450.
|
|
source = bytes(machine.uc.mem_read(0x20000, 0xF450))
|
|
report = dict(status=result.status, instructions=result.instructions,
|
|
link=link.status(), stream_bytes=len(payload),
|
|
source_bytes=len(source),
|
|
stream_is_prefix_of_source=source.startswith(payload[:len(source)]),
|
|
first_pass_matches_source=payload[:len(source)] == source,
|
|
source_nonzero=sum(1 for b in source if b),
|
|
stream_head=payload[:32].hex(' '), source_head=source[:32].hex(' '))
|
|
(OUT/'results.json').write_text(json.dumps(report, indent=1)+'\n')
|
|
print(json.dumps(report, indent=1))
|