op_sath shifted ACC left by TREG1(3:0) and saturated. SPRU056D 6-229: it
shifts right 16 when TREG1 bit 4 is set and otherwise leaves ACC alone,
SXM picking the fill; SATL is the 0-15 half of the same 0-31 bit shift.
Overlay 6's V.34 phase-3 transmit sequencer (0xb0c5) takes its next state
as nibble[state] of 0x00102540 through samm @0d / sath / satl. From state
3 it must reach 2; the left shift saturated to 0x7fffffff and gave 15, so
the answerer's TRN never ended and its control code at 0x9d5d, waiting for
state 5, waited for the rest of the call. With the fix the answerer leaves
TRN after about 1.7 s; the caller still misses J, so training now retrains
instead of hanging.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Two stand-ins in the bridge broke the dialled 403 call between them. The
bridge queued 0x47,6 the moment the far end went off hook, so the
supervisor downloaded overlay 6 over 0x9d00 while the call-progress task
(@1b = 0x9bf4, started by tag 0x15) was still running out of that range.
The loader returns every codec frame, so the task ran half-written code,
the FFT at 0x8bf0 took a garbage AR3 and the block ack timed out. And it
held host tag 0x17 until overlay 8, but 0x17 (0x9ba1) is what arms answer
tone qualification: without it the caller never started V.8.
With both gone the resident does it itself: 0x17 arms @6d = 0x9cf3, 65
passes of tone status bit 2 reach 0x9d2a, and the caller sends CM. The
only 0x47,6 in the resident is 0x8e3e, dispatched from the JM decoder at
0xd514, after the code overlay 6 replaces is finished with.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The third bit in IMR = 0x002a was unaccounted for, and it is the one that
matters for the transfer paths.
The mask ROM's whole vector table is `lamm @6x ; bacc`, and the resident fills
those cells from the table at 0x812d. Of the three enabled bits, XINT gets the
frame ISR at 0x8178 and TINT gets 0x81fb - and INT2 is enabled with @61
pointing at 0x819d, which is a bare `rete`. INT1 has the same shape at 0x81ba
and is masked: an armed second doorbell.
A handler that only returns is the point. The CPU-to-DSP path is polled, not
vectored: 0x80ea reads PA7 through the 0x80e8 gadget, tests bit 9, and sleeps
in the IDLE at 0x80fa when there is nothing; 0x80fc walks the ASIC's four-word
window from port 0x58, BLDPs each group into *program* memory at BMAR, acks
with 0x0300 into PA7 and raises INTR 17. That is the firmware download, and
the command path has the same shape. The pin's only job is to end that IDLE.
And the board has the pin: ASIC 109 to DSP 39, which is INT2, measured in
asic-pinout.md, which already named it "the mailbox's CPU-to-DSP direction".
Nothing in the emulator ever raised it. The ready flag in PA7 was set and the
DSP was left to notice on whatever next woke it - the codec frame or the timer
- so a transfer advanced at the frame rate rather than when the host had a
group ready.
Both sites that raise a PA7 ready bit now go through one helper that sets the
flag and asserts the pin, because on the board they are one event. Checked
against the 403 resident: parked in the host poll's IDLE, an INT2 edge ends
it, vectors to 0x0004, dispatches through @61 to 0x819d, and RETEs back into
the loop.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Every Courier-family C5x resident programs the primary port identically - 403
and 302 at 0x8090, 2.1.1 at 0x80bd, 2.3.31 at 0x109d - and the sequence says
what the model has to do. SPC goes 0x0008 then 0x40c8, so MCM = 0 and TXM = 0
and the frame edge is external; DXR is primed and the part spins on XRDY
waiting for that edge; IFR is write-1-cleared; and then IMR is written with
0x002a: INT2, TINT and XINT. RINT, bit 4, is not enabled, and `samm @04` - the
only write certain to reach IMR, since `splk @04` is DP-relative - appears
exactly once in each of the 403 and 302 residents.
A cold start confirms it. Parked at 0x813c the 403 has IMR = 002a, SPC = 40c8,
and the mask ROM's dispatch cells hold @65 = 8178 for XINT against @64 = 819d
for RINT, the same unused stub @6a holds for NMI. Only XINT has a handler.
So `serial_receive_interrupt` was raising the right IFR bit for the wrong
reason and gating it on SPC.RRST, the receiver's reset bit, which the 403
never consults. The 2.x residents then show why naming one bit is wrong at
all: they test data 0x012f and, if set, `lamm @04 ; and #ffcf ; or #0010 ;
samm @04` - same frame, service moved to RINT. One edge now latches both, each
behind its own half of the port's reset, and IMR and INTM decide recognition
where the part leaves them.
Three more things the residents reach that the core did not do:
- Recognition ran only from `interrupt()` and the INTM controls, so a flag
that became eligible without a fresh source edge waited for the next one.
The 2.x rewrite of IMR above happens with INTM already clear, and RETE
clears INTM on its way out of a handler. It is checked at every instruction
boundary now, and taking a vector is its own step.
- A repeated instruction was interruptible. RPTC and the repeat pointers are
not in the context shadow, so a vector out of the middle of a block lost the
rest of it; check_nmi has always refused for that reason.
- NMI vectored to a literal 0x0024. Its slot is offset 0x24 inside the same
IPTR-relocated table as every other vector; 0x0024 is only right because the
mask ROM runs with IPTR zero.
And the timer ignored TCR.TSS, so a stopped timer still raised TINT - which
matters here because TINT is the other thing 0x002a enables, and it is what
wakes the IDLE at 0x813b when no frame has arrived yet.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The gate array is the only thing on the 80186's I/O bus and is also the
DSP's entire external interface, so it has a decoder on each side and
they number independently. Only eight CPU data lines reach the package,
so one 16-bit DSP register is two 8-bit CPU ports. The two spaces
collide on 0x5e, where the CPU means the high byte of the word and the
DSP means the tag.
Nothing in the harness said so. `panel.py` models its corner of the chip
properly - pin, port, bit, and the firmware address each meaning came
from - but the mailbox was four constants and a hand-written mirror in
bridge.py, with the DSP half living in the C5x core's own port array. No
single place recorded that a CPU port and a DSP register are the same
piece of silicon, which is how `set_io(0x5E, 0x229E)` came to publish a
CPU-side latch into the part's tag register.
`asic.py` is that place. `bridge.py` derives DSP_TAG_PORT,
DSP_WORD_PORT, DSP_STREAM_PORT, HOST_STATUS_CELL, HOST_TAG_CELL,
HOST_WORD_CELL, DSP_RUNTIME_PORTS and MIRROR from it instead of
restating them, and `dsp_register()` raises for a register the DSP has
no path to rather than handing back an address to write into the part.
MIRROR is `asic.mirror("tag", "word")`, which is the four entries it
always had: the whole table also carries the status and stream, and
taking it wholesale would have started mirroring both. The panel rows
are recorded for completeness but `panel.py` is not driven from here.
Byte-identical on the leased ROM pair - mailbox log, messages taken, rx
peak, runtime messages and overlay downloads all unchanged on both ends.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
AT&N1&T1 on 302 crashed with "C51 ROM loader did not acknowledge strobe 1":
_commit_rom_group wrote @56 and stepped 4096 instructions waiting for the
acknowledgement, and nothing answered.
Port 0x18 is not the loader's alone. A supervisor routine at 0x95a54-0x95a6c
walks a single bit along it and mirrors it to 0x1a - ..0x20, 0, 1, 0, 2, 0,
4, 8, 0x10, 0x20.. - so three of its six values collide with the transfer
strobes. Every collision was being taken for a reload request.
The recovered mask ROM says exactly when the C51 is listening. Its download
loop is 0638-0652: bit 2/@56 for the finish strobe, bit 0/@56 then rpt #3 /
bldp *+ / lacl #01 / samm @56 for group 1, bit 1/@56 and the same for group
2, then bd 0638. Outside that span - resident code at 810a, a mask-ROM
vector at 0008 after a restart, the 0653 exit that branches into the
downloaded program - nothing polls @56 and no acknowledgement can come.
So arm a strobe only when the DSP pc is inside that loop, or when the loader
has not been started at all, which is the case the first commit synchronizes.
Real downloads acknowledge from 0642 and 064c, both inside it.
The crashing run now completes and reports CONNECT. Checked inert elsewhere:
a linked 302 pair with the DSP on both sides produces a byte-identical report
with the gate forced open, and the standalone AT&T1 run makes the same 13874
commit decisions as before.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
`65` and `db` were stopping two of the flash captures, and neither is a
missing instruction.
`65` is the 386's GS prefix and is undefined on this part. The 80C186EB
manual says what the CPU does with one: "Execution of an undefined opcode
causes an Invalid Opcode trap" (Type 6). That trap has a handler waiting for
it - the Australian captures install a stub at 8000:0f83 that loads a fault
code and jumps to the common reporter - so the faithful model is to vector
it, not to end the run. 0f, 63, 64, 66, 67, d6 and f1 are undefined on the
186 for the same reason and take the same path; the 386ex profile keeps them.
`db` is ESC, a real encoding. Whether it faults depends on RELREG's ET bit,
which resets to zero and which nothing in these firmwares sets, so on this
16-bit part it goes out to an 80C187 instead. There is no 80C187 on the
board, so the operand cycle is read and execution carries on. ET is
modelled as a flag and takes the Type 7 path when set, which is what the
8-bit 80C188 would always do.
A trap restarts its instruction rather than resuming past it, so it cannot
go out as a software interrupt: `Uc.fault` marks which it is and the machine
dispatches it with the faulting address. A fault is also not a controller
request, so it stays out of the EOI stack that a hardware interrupt enters.
Going past those two exposed the next stop, which was a real gap rather than
a fault: SAHF, LAHF, INT3, INTO, WAIT, DAS, AAA, AAS and 82 as the
documented alias of 80 are all defined 80186 instructions that were simply
missing. They are implemented, and the line is kept deliberately - BOUND and
INS/OUTS are still absent and still raise, because a gap in the model must
not be swallowed by a trap that would hide it.
Both 20.16 MHz captures now run a 60,000,000 instruction boot without
error where they used to stop at about 6.2M. Neither reaches its ATI7: the
divergence that sent them there is upstream of any opcode. In both, the last
instruction fetched from flash is the `cb` ending the routine at 9e8cb, and
that far return lands two bytes before the entry its own caller targets
(`9a 39 07 00 80`, CALL FAR 8000:0739, against a return to 7ff8:07b7). One
board then decodes a misaligned stream and the other runs into cleared RAM.
That is the thing to chase next.
The 2806's boot is byte-identical and still prints its profile, and the three
XMF images are identical against a matched baseline.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Two strands, joined because machine.py carries both.
`machine_map` is the canonical description of the hardware: address ranges,
service vectors and the DSP reset port, which used to sit as module constants
beside whichever code happened to use them. An exact-digest `FirmwareProfile`
supplies only what moves between ROM revisions, so profile selection is
evidence rather than a revision-string guess.
`timebase` does the same for the clock. Three constants carried it between
them - pit's 5 cycles an instruction, timers' 5.93, and timers'
INSTRUCTIONS_PER_SECOND at 4,348,000 - and each described a different part
while being imported by whatever needed a rate. The 5 is the 386EX I-modem's;
the 5.93 is the 80C186EB's; the 4,348,000 is the 186's rate on main211's
25.8048 MHz crystal, and it was serving the 20.16 MHz 302/403 as well.
Cycles per instruction is a property of the part and the code mix, so both
186 boards share it. The crystal is a property of the board. Keeping them
apart is what lets one model serve all three:
courier-20.16 20.1600 MHz 5.93 3,399,663 insn/s dsp/x86 5.93
courier-25.8048 25.8048 MHz 5.93 4,351,568 insn/s dsp/x86 4.6328
imodem-386ex 25.0000 MHz 5.00 5,000,000 insn/s
That separation fixes two things. The DSP ratio is not shared by the two 186
boards: docs/asic-pinout.md traces the C5x's CLKIN to the ASIC, which runs
from the shared 40.320 MHz can either way, so the 2806's faster crystal is
the CPU's alone and the DSP does not speed up with it. And timers.py's note
that the crystal cancels is right about the timers - the ratio is CPI/4 on
both boards - but did not cover what takes INSTRUCTIONS_PER_SECOND as an
absolute rate. FRAME_HZ was measured on the live 403 at 20.16 MHz and then
divided into main211's figure, 28% fast on the board it was measured on.
The board is taken from the timer constant the firmware writes: 25,200 counts
is 5.000 ms only at 20.16 MHz and 32,256 only at 25.8048, and the 7.4.16
board checks its own value back at 0x4a83b. Anything unrecognised leaves the
assumed 302/403 in place rather than guessing from it. All three flash
captures identify themselves in agreement with their own ATI7.
The 2806's 60M-instruction boot is byte-identical and still prints its
profile. Elsewhere only timer counts and event instants shift, by the 0.08%
between the rounded 4,348,000 and an exact 5.93/4. Note that every XMF here
programs 0x7e00 - they are all 25.8048 builds - so the 20.16 correction bites
only on the flash captures, and both stall on unimplemented x87 opcodes
before reaching it. It is argued from the documentation and from the boards'
own ATI7, not yet demonstrated by a run that gets that far.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The scheduler used to reach the devices through a UC_HOOK_CODE the
interpreter fired on every instruction, which made ordinary ROM execution
cost what a tracing run costs. The deadline moves inside the dispatch loop
instead: `instruction_clock_add` sets a period, and the loop calls out only
when the count reaches it. Crossing into Python is now bounded by that
interval rather than by the guest's instruction rate.
Two costs in the loop itself go with it.
`_fetch` built a `range` per call to read what is almost always one or two
bytes - it is the most called helper here, 6.4M times per 12M instructions -
so both widths are written out and the general loop kept for the 386ex
profile's wider immediates.
The `group` dispatch is a 65-block if/elif chain that was in group-number
order, which is not frequency order: Jcc is 23% of the instructions a boot
executes and sat eleventh, RET nineteenth, CALL twentieth. Measured over 20M
instructions the chain averaged 16.0 comparisons an instruction; reordering
the blocks by that measurement gives 5.6. Each block moved verbatim - they
test exact equality on one local, so the order is free - and the re-emitted
chain was checked to be a permutation of the original.
Together 15.54s to 14.19s over 20M instructions, with byte-identical output
on MAIN_2.3.31, MAIN_2.3.15 and main2205. The chain reorder is worth less
than its comparison count suggests: CPython 3.14 specialises these well, and
the loop prologue, not the chain, is what sets the floor at 294ns for a NOP.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The +1 was applied to all three top-edge absolute readings on the
assumption the miscount covered the session. It covered one reading. 74
stands for the flash address pin; 71 and 70 go back as given.
Flash DQ11 on CPU AD11 closes the data side: flash pin 22 to CPU pin 20,
a data line straight onto the multiplexed bus with nothing in between.
Every finding so far had been about address, and none of them said how
data reaches the memories - it does not go anywhere, the parts hang
directly on AD0-AD15 and separate address from data with the strobes.
Which also bounds the ASIC: it has AD0-AD7 as an input for latching
while the memories have all sixteen as data, so its own 8-bit I/O window
shares the bus with the memory system rather than fronting it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The low-byte latch is the ASIC. Pin 70 drives RAM pin 10 and flash pin
11, which is A0 at both, so AD0-AD7 on pins 84-77 and ALE on pin 57 are
a latch's inputs rather than just self-decoding for the I/O window - the
reading the file had proposed and could not show.
The memory address bus comes from three places: A0-A7 from the ASIC,
A8-A15 from the '573, A16-A19 from the CPU except A17, which is the ASIC
again on pin 73. A17 needs no latch, so that one still looks like
remapping rather than buffering; A16 and A18 decide it.
Location correction: the outputs are on the top edge, not the 28-46 run
the last revision predicted. That edge is now the address side end to
end, with thirteen unread pins for the seven remaining low bits.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The owner read the parts off the units: AC01 on the 20 MHz boards, AC03
on the 25 MHz 2806, and an Si3021/Si3014 pair with no TI codec on the
3453C, which is taken to be main211.xmf. board-parts.md asked for
exactly this datum and listed two possibilities for it; the answer is
three generations with one part each, which retires the "one board, two
parts in two roles" option and confirms TI first, Silicon Labs last.
That costs us the section titled "the codec is a TLC320AC0x, and the
firmware proves it". The control table at program 0x019c is in
main211.xmf and nowhere else - that part was measured correctly - but
main211's board is the one with no TI codec on it, so the table is the
Silicon Labs bring-up and the attribution is backwards. The
secondary-frame protocol cannot carry the claim either: it appears both
in main211 and in the ID_SDL 4.03 build for an AC01 board, so it
describes the serial framing rather than the silicon. One thing is
recovered rather than lost - CodecBringUp running an SI3038 sequence is
the right family for that build after all, and only the part number is
still in doubt.
My previous commit called that table "the AC0x codec path" and had it
arriving with the newest generation. The offsets were right and the name
was wrong; it is corrected here rather than left standing.
Measured alongside: stock 7.3.14's DSP payload is byte-identical between
a 20.16 MHz AC01 board and the 25 MHz AC03 board - 126,851 consecutive
bytes from the shared anchor, covering the payload and all three
overlays. The AC01 to AC03 change is invisible to the DSP, which is what
an ASIC-fronted codec predicts, and it means an AC03 board cannot be
recognised from its DSP code.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
board-parts.md called the middle generation untested because the shared
DSP anchor could not be found in SV25.XMD, and concluded from that the
.XMD container is record-framed rather than flat. It is flat. Strip the
128-byte header and run the payload through the XOR block transform the
recovery harness already carries, and the anchor is at 0x296e0. The
search failed because the bytes were still encoded, not because the
framing differs.
The decode is confirmed against the board captured in the previous
commit: decoded SV25.XMD matches that 512 KiB image in every byte but
four. So the 25 MHz TARGETS anchors are no longer self-derived, and
their comment now says where they independently come from.
The four are the checksum words at 0x77ffc and 0x77ffe, blank in the
distributed image and programmed on a real board. IDSDL302.ROM differs
from decoded IDSDL302.XMD in exactly the same four, which makes this the
container's normal condition. That is the measured form of the caveat
sv25-recovery.md already carried: the 0xffff the harness compares
against is the unprogrammed state, so the recovery path it selects is an
artefact of the distributed image. Since 0x77ffc lies inside the CRC'd
range, a board's CRC input is not the image's; the algorithm is still
unidentified, with sum-8, sum-16 and five common CRC-16s all missing.
Testing the middle generation settles a question the doc left open, in
the opposite direction to the guess that drove it: the AC0x codec
initialisation table is in main211.xmf alone. It is absent from the
25 MHz build, from both 20.16 MHz builds and from IDSDL302.ROM. The
AC0x path does not separate 20.16 MHz hardware from 25 MHz hardware; it
arrives with the later 25.8048 MHz / 736 KiB generation.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The board at /dev/cu.usbserial-FT4TQOFT is a 25 MHz V.Everything
reporting supervisor 7.3.14 / DSP 3.0.13 - the same revision pair the
flash dumper already knew from the 20.16 MHz board, and a different
image. Its leading jump displacement is 0f93 rather than 0f7c, and its
reset vector enters at fc00:1bbf rather than fc00:11e9, so the recorded
anchors rejected it.
So the clock frequency joins the key rather than being asserted: TARGETS
is now (supervisor, dsp, clock) and validate_identity reads the reported
frequency instead of requiring 20.16. The clock goes last so every
caller's target[0]/target[1] keeps meaning what it did.
The new entry's anchors come from this same board, which makes them a
self-consistency check across the sweep rather than independent
confirmation of the build; the comment says so.
512 KiB captured, 2048 pages, two agreeing reads each, no failed
attempts, anchors unchanged on the recheck. Note that every page
terminated with ERROR rather than OK on this build, consistently and
with well-formed rows; that is unexplained and not yet modelled.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
A B channel carries 8000 octets a second of G.711 and RTP's PCMU payload is
8000 octets a second of G.711, so --bri-sip puts a SIP call at the far end of
the bearer with nothing in between: no resampling, both sides being 8 kHz, and
no companding conversion.
The second one earns its place. SipSession's linear path decodes each codeword
and re-encodes it, which is identity for 255 of the 256 codewords and not for
7f. One in 256 is inaudible in speech and a defect here - V.90 and x2 are built
on exact codewords, the digital end of the call places them on the wire itself,
and this board is that end. send_pcmu/receive_pcmu sit beside send_audio and
the analogue path is untouched.
BearerSipLine satisfies the same start/stop/exchange contract V120Link does,
so BriNetwork carries either without knowing which. It does not pretend to
solve pacing: the emulator runs on an instruction budget and RTP on a clock,
so it returns as many octets as it was handed, fills the rest with mu-law
silence, and counts every octet of the fill.
Run end to end against tools/sip_answer_sink.py, the modem's ANSam arrives as
94,080 octets of RTP at 2100 Hz - the B channel's own octets, unchanged.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
courier_emu/v120.py is a V.120 far end on the same terms as the Q.921/Q.931
peer beside it: it reaches the modem only as octets on the B channel and sends
nothing the standards do not say to send. HDLC with zero-bit insertion and ISO
3309's FCS, the 13-bit logical link identifier across both address octets with
the C/R asymmetry LAPD gives it, and Q.921's procedures - SABME/UA, I frames
modulo 128, RR, DISC, DM, T200 counted in octets so a second of bearer means a
second whatever the harness is doing.
bri.py carries it: with --bri-v120 the media path stops being a recording and
becomes a conversation, one octet back for every octet the modem sends.
The bearer carries it and the modem does not answer it. Frames go out framed
and checked, flags come back - 8321 of them, no FCS errors, no runts - and the
modem never sends a frame of its own, in either bit order. What does change
its mind is offering V.120 in the SETUP's low layer compatibility element: the
firmware parses that, and clears the call with MISC_INFO rather than answering
it. So the element is off by default and --bri-v120-llc offers it as the probe
it is. docs/imodem-v120.md has the evidence and the three threads left.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
_tx_program wrote DXR without ever releasing the serial port, so it asserted
one octet per frame from a port whose word format it had not chosen. Now that
the core reads FO out of SPC rather than assuming it, an unprogrammed port
reads as FO=0 and the test saw sixteen-bit words.
splk @22, #40cc first - the Quad's own value, FO set for eight-bit bytes,
matching what _dsp_square_tone_program already does in the test beside it.
The expectation is then earned rather than inherited: the 302 writes 40c8 to
the same register and gets sixteen-bit words.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The chip model was wrong, as suspected. LSR's low three bits are the
LIU's state in the chip's own numbering, and this model reported 6 for
an activated line. The firmware stores (LSR & 7) + 2 and compares that
byte in seven places; six of them want 7, including the D-channel
transmit gate at 0x71c9b and the TEI entity at 0x6a932. Storing 8 means
every queued frame is silently dropped, which is what had been
happening in every run since the S interface was first brought up.
Driving the line to 5 instead changes nothing else and the whole stack
runs:
ID_REQUEST ref 11883: assigning TEI 64
SABME from TEI 64, answering UA
layer 2: multiple-frame-established
three frames transmitted where there had been none, and ATI12 in the
firmware's own words:
Physical Interface: Active
Data Link Layer : Active
The firmware takes the call - LINE_ACTIVE, --SETUP, START_ALERT - and
RING arrives on the AT interface.
This also explains the LINE_NOT_ACTIVE that was recorded as an
unexplained teardown and briefly blamed on this repository's own peer.
It was neither the peer nor the frame: 8 is a state the part does not
use for an active interface, so the firmware reported the line up and
then immediately down.
The mapping is a table rather than a formula, because the chip has fewer
LIU states than I.430 has F-states and a formula would invent the gaps.
Each entry carries whether it is shown or assumed; F7 -> 5 is the one
that is proven and the one everything depends on.
What is left is a call-level question, not a layer-2 one: the firmware
rings and then logs "SETUP not compatible INTL, release call".
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The chip model was answering LIU_LSR's low three bits - the F-state - and
zero for everything above, and two of those bits carry something. The
decode at 0x70e6f shows the shape without saying what it means: bit 7
gates a whole branch that logs "liu_stat.C : sending a LIU_STATUS", and
`and ax, 0x40 ; sar ax, 6` lifts bit 6 out as a 0/1 value the message
carries.
The firmware names them. Answering LSR with those bits set and reading
its own trace log back gives
0x80 -> STAT_OFFHOOK Detected>>>
0xc0 -> STAT_ONHOOK Detected
so bit 7 is a change indication and bit 6 is the handset hook state, 0
being off hook. That fits the board rather than being incidental: the
I-modem has an analogue phone port, the ADP whose directory number *P1
holds, and its hook switch is sensed here.
set_hook moves the switch, raises the part's interrupt the way a
line-state change does, and LSR reports both bits; reading LSR
acknowledges the change, because it is an indication and not a level.
The handset rests on hook, so a run that does not ask sees what it saw
before - only the bit-6 level changes and nothing reads it without bit
7. isdn-run --offhook-at N lifts it, and the firmware answers
LINE_ACTIVE Detected / STAT_OFFHOOK Detected>>>.
This is not what stops layer 2: the modem transmits nothing with the
handset either way. It is a part of the chip that was answering zero and
now answers what the part does.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Asked why it will not request a TEI. It does - two pages here saying
otherwise were wrong, and the distinction matters, because "has not
decided to ask" points at configuration and "has asked and the frame is
stuck" points at the transmit path.
Present an incoming call on the broadcast data link and the TEI entity
at 0x69b70 runs on event 0, finds the per-interface TEI state at
es:[bx+0x85] clear, sets the N202 retry counter at es:[bx+0x8e] to 1 -
the counter whose exhaustion the firmware logs as "N202 Cnt Exceeded -
no TEI assigned!!!" - and calls the builder at 0x6a755. That writes
message type 1 and Ai 0xff a byte at a time, and reading the assembled
buffer out of memory gives
0f 2e 6b 01 ff MEI, Ri, Identity Request, Ai = TEI 127
a textbook Q.921 Annex D request, exactly the shape courier_emu/bri.py
has been able to answer all along and has never been asked.
It is queued through 652e:000d and never transmitted: the chip
transmits 0 frames, the peer sees 0, and nothing in 0x71a00-0x72000
executes after the queue. Some 5,600 instructions later the stack raises
LINE_NOT_ACTIVE and abandons the procedure - and that verdict is not the
line. In the same window the chip is touched three times, and the
LIU_LSR read returns 0x06, which through the firmware's own (LSR & 7) + 2
is 8, F7, active. It reads the line as up and reports it as down.
One real fix fell out. The Ri above is 0x2e6b because the firmware reads
it from the Am79C30's random number generator, DLC_RNGR1/RNGR2, and
am79c30.py was answering those out of the register file - so they gave
back what had been written, 0. Every Identity Request this harness ever
built carried Ri 0000. Legal, not the cause, but not what the part does:
Ri exists so two terminals asking at once can tell their answers apart.
They are a generator now, seeded per instance with an LCG so runs stay
reproducible.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The last commit recorded the LINE_NOT_ACTIVE seen during an incoming call
as a defect in courier_emu/bri.py. It is not, and ruling that out is the
substance here, because "our peer must be breaking it" was the
comfortable answer.
The peer never touches the line after activation: a watch on
set_liu_state records exactly three changes in the run, F1->F2->F6->F7,
all during activation. The chip model is not mangling the frame: 35
bytes delivered, 35 read back, DRCR 35. The firmware re-reads the line
itself at 0x71b3d, computes (LSR & 7) + 2 = 8, stores F7, and raises the
status anyway - its own stored state says up while it reports down.
Injecting four frames separates the cause completely. A TEI identity
check on SAPI 63, and a UI on SAPI 0 / TEI 127 carrying 00 00 00, both
leave the log at LINE_ACTIVE only. A bare SETUP with no information
elements, and the full one, both produce LINE_NOT_ACTIVE and 001A. So it
is not the broadcast data link and not the IEs - only a valid Q.931
SETUP does it, and this is the firmware's layer 3 reacting to an
incoming call it owns no TEI for. 001A has no arm in its n_stat_in
dispatcher and falls to the default at 0x774ac.
Chasing it did find two real peer defects, both of which obscured the
firmware's behaviour rather than causing it:
- No T303. One SETUP went out and the peer then reported call-present
for the rest of the run, so a call nobody took looked like a call in
progress. Q.931 retransmits once after four seconds and then clears;
it does that now and says so in its events.
- No notion of the line going down underneath it. The peer only read
back the state it had set, so a firmware-side deactivation would have
left it reporting a data link that could not exist. It now notices,
drops its layer-2 and call state, and does not walk the line back up -
re-activating would hide exactly what is worth seeing.
Both covered by tests. Neither changes the trace, which is the point.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Traced ATD as asked. It does reach the ISDN stack - and the stack turns
out to be instrumented in English, which answers the question outright.
There is a printer at 0x77fc2 that packs a caller's string two
characters to a word into a ring at ds:0xa79a with the word count at
ds:0xb79a, appending CRLF per entry. ds is ce0, the segment the
initialiser relocates 0x41c0 bytes into from image 0x98d50, and
resolving the pushed string offsets against that block is what turned
`push 0x1594` into text. It is fill-once rather than wrap-around: the
guards at 0x78039 and 0x78051 stop appending at 0x7fd/0x7ef, so a long
run's log ends rather than losing its start. 2048 words.
courier_emu/imodem_trace.py reads it and every isdn-run report now
carries it as firmware_trace - two memory reads, so it costs nothing.
An index outside the ring reads as empty rather than decoding whatever
is at the address.
What it says about ATD:
LINE_ACTIVE Detected
l4_DISCONN : modem primitive
The dial reaches layer 3 and arrives as a DISCONNECT, not a setup. The
handler at 0x75882 dispatches a "modem primitive" on a character - '@'
logs l4_SETUP, 'B' logs l4_DISCONN - and ATD takes 'B'. So the question
shrinks from "why does the ISDN stack ignore ATD" to "why does the AT
layer hand it 'B'", which is one dispatch on one character.
465 symbolic strings sit in that block, and they confirm work done the
hard way: the layer-2 arms at 0x7743c/0x7744f/0x77468/0x77481 are
SPID_ERR, LINE_ACTIVE, LINE_NOT_ACTIVE and MISC_INFO, so 0x7744f setting
ce0:8d7c is exactly what its name says.
It also found a defect in this repository's own peer. Dialling with an
incoming broadcast call in flight logs LINE_ACTIVE then LINE_NOT_ACTIVE
plus `default of n_stat_in detected` / `001A`, and nothing in bri.py
deactivates the line in that run - so the peer is either disturbing the
S interface as it delivers the frame, or provoking the firmware into
dropping layer 1.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The switches are read through the same board-signal abstraction as the
rest of the board, and the firmware's own DIPSWITCH printer at 0xc7924
names them: a two-entry id table at 0xc79a3 holding 0x4023 and 0x1023,
whose low byte indexes the input-port table at a5f97 - entry 3 is port
0x12 - and whose high byte is the mask. So two switches, both bits of
one port, a sibling of the enclosure latch at 0x14. The table has
exactly two entries; what follows them is code, so two is all the
firmware reads.
The sense is the inversion the modem-status lines carry: a switch reads
present when its bit is 0, and the printer calls that ON. An unmodelled
port answering 0 therefore always read as both switches ON, which is the
default kept here so existing runs are unchanged. --dipswitch 1=off sets
one, and an explicit --port 0x12= still wins over the bank.
What they do is partly established. Switch 2 is read at boot by 0xa5fb4,
which sets [ca3f] bit 7 with [ca38] bit 2 clear when ON and the reverse
when OFF; five sites test that flag. Switch 1 is observable from
outside: with it OFF the modem stops answering the AT interface at all -
ATDT gets no response rather than NO CARRIER - which is what a Courier's
result-code or dumb-mode strap does.
It is not the answer to ATD, though. All four combinations of the two
switches leave ATDT transmitting no layer-2 frame.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Diffing runs was the cheap way to map this block and it got two fields
wrong, including one this branch "corrected" in the wrong direction.
There is a better source that needs no runs: ATI12's display is table
driven, and the table at 0xc4570-0xc4700 names each row's address. A
settings row's descriptor is `01 <lo> d4`, the RAM address 2600:d4<lo>
that row shows; subtracting the block base d476 turns each into an
index, and the spacings give the widths.
*W 0 *M 1 *S1 2 *S2 23 *P1 44 *P2 65 *T1 86 *T2 88 *O 90
with 21 bytes for each of the four number fields and 2 for each TEI.
The total is the check on the whole reading: 1+1+21+21+21+21+2+2+1 = 91,
exactly the length the checksum at c4ecb covers, so a wrong offset
anywhere would leave a gap or an overlap. tests/test_bri.py asserts the
tiling.
Two corrections fall out. *P1 is 21 bytes, not 8. And *T1/*T2 are 86 and
88, each two ASCII digits - not the 86/87 originally recorded, and not
the 88/89 this branch changed them to a commit ago. A run that sets only
*T2 leaves ff ff at 86 and 30 30 at 88, and ATI12 says exactly that:
*T1 Invalid fixed TEI, *T2 00 Automatic TEI.
*O, the field ATI12 has always called Invalid Value, is index 90, and
its renderer at 0xc3304 is the whole specification in four instructions:
clamp anything outside '0'..'1' to '2' and index a three-entry table of
En-Bloc mode, Overlap Sending mode, Invalid Value. So it is ASCII with
two valid values, and an unset 0xff is why it never read back. Sealed to
'0' it prints En-Bloc mode.
Also recorded, because both cost runs: the bearer capabilities *V1 and
*V2 are not in this block - it is full - and AT*V1=1, AT*V2=3, AT&W
changes one byte at page offset 0x25f. And the AT interface answers NO
CARRIER to everything from roughly 40,000,000 instructions in, ATI12
included, so settings have to be sent early or they silently do nothing.
None of it moves ATD. With every field ATI12 shows valid - NET3,
multipoint, En-Bloc, both TEIs automatic, a directory number - ATD still
answers NO CARRIER immediately and never touches the D channel.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The peer spoke Q.921 and Q.931 but did not terminate the S bus: layer 1
was still walked by the machine's own scripted --line-activate, so the
"network" was half a network. An NT owns activation, so it owns it here
now - the peer walks the terminal through F2, F6 and F7 the way INFO2
and INFO4 do, and the machine's walk stands down when a peer is
present rather than racing it. --line-activate still names when,
--no-bri-activate stands the NT down, and --bri-deactivate-at drops the
line back to F3, which is the only way to ask the firmware what it does
when the network goes away. F2 leads the walk for the firmware's
reason, not I.430's: its layer-1 machine dispatches on the state it is
already in and drops an event that skips ahead.
What terminating the bus properly bought is a way past the dead end in
the last commit. A point-to-point SABME is discarded because the modem
owns no TEI, but a network end has another door, and it is the one
Q.931 specifies for an incoming call on a multipoint bus: the network
does not know which terminal wants the call, so the SETUP goes on the
broadcast data link as a UI frame to TEI 127. That needs nothing of the
terminal in advance, which makes it the only path that can reach a
modem that has never transmitted. The peer takes it automatically when
it has no data link.
It gets in. The broadcast SETUP is accepted at 0x66814, marked with the
0xfa wildcard at 0x6685e, raises event 0x16 at 0x66882, and 0x6724d
walks the data-link entries and posts message 0x35 to layer 3 - the
body at 0x672bd executes, so the firmware's own call control is handed
the call. It then does nothing: no answer, no RING on the AT interface,
no frame out. Offering speech instead of unrestricted digital
(--bri-bearer speech) changes nothing, so it is not the bearer being
refused.
So the open question is no longer "the modem never transmits and
nothing is known about why". It is "call control has a SETUP and does
not act on it", with ATI12 still reporting Dialing Mode *O Invalid
Value as the leading suspect.
Terminal-initiated activation is deliberately absent: INFO1 would be
the firmware writing LIU_LMR1, and it writes that once at init, 0x40,
and never again in any run observed here. There is no request to
answer, and inventing a bit that means one would assert something the
image has not shown.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The D channel has had nobody on it. A BRI terminal does not open a data
link unprompted - point to point it waits for the network's SABME,
multipoint it asks for a TEI when it has traffic - so a harness with no
far end leaves the modem correctly silent, and that silence has been
read here as a missing transmit path.
courier_emu/bri.py is the far end: Q.921 and Q.931, built from the
standards, reaching the board only through the Am79C30A's own receive
and transmit buffers. It never writes the modem's memory and never
pokes a register, which is what keeps what it produces evidence. It
carries address decoding for SAPI and TEI, the U/S/I formats, TEI
assignment on SAPI 63, SABME/UA establishment with N(S)/N(R), RR and
REJ, T200 with N200 retransmissions, and enough call control to answer
a call the modem places or place one at it. isdn-run gains
--bri-network, --bri-establish, --bri-tei, --bri-call-at and
--bri-call-from, and reports what the peer did.
It answered its first question immediately. The modem does not ignore
the network's SABME: the chip counts the frames, the ISR reads every
byte, the DER check at 0x72eac passes and the frame is posted up as
message 0x33 to the Q.921 entity at 0x6674c. That entity validates the
address - EA bit, length, SAPI one of 0, 2, 0x10, 0x3f - and then looks
the data link up in the table at [0x6b88] through 6757:2fe. Nothing
matches SAPI 0 / TEI 0, so the frame is discarded. The modem is right:
it is configured for automatic TEI assignment, it does not own TEI 0,
and a network addressing TEI 0 is addressing nobody. So the transmit
path at 0x71cb0 is not unreachable through a missing pointer, which was
the standing hypothesis - it is never asked.
Still open, and both on the configuration side: the modem does not
request a TEI on its own even configured multipoint with an automatic
TEI, and ATD answers NO CARRIER before any D-channel activity while
ATI12 still reports Dialing Mode *O Invalid Value.
One correction on the way: the ISDN block's TEI field is at index 88,
two ASCII characters, not the 86 docs/imodem-config-sector.md lists.
AT*T1=0 then AT&W stores 30 30 there and ATI12 reads back Automatic
TEI.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
[d2c6] is the field-absent mask, established outright from the unpacker at
a4465..a44ab: bit 0 skips the d2c7 options walk, bit 1 skips d2c8 -> c8e4,
bit 2 skips d2c9 -> d2c5, bit 3 skips d2ca -> d2c4.
[d2c7] is modulation capability, mapped through the five-entry table at
a400:04ac - bits 0..4 setting e358 0x04, 0x08, 0x40, 0x80 and 0x20.
[d2c9] -> [d2c5] bit 0 is fax capability, and ATI7's own formatter names it:
c0d70..c0d92 picks between "Fax Options Class 1", "Class 2.0" and
"Class 1/Class 2.0", printing no line at all when the bit is clear. All three
tests read bit 0 - checked against raw bytes - so only the third is reachable.
[d2ca] -> [d2c4] bit 0 appends " MODEM" to the product type, at c0c17.
[d2c8] is left unidentified rather than guessed: its one consumer at bd1a1
splits it into a quotient at d2b0 and an xlatb'd remainder at d2b1, a grouped
code of some kind.
Two things this retires. The ALL_OPTIONS forcing was dead - the firmware writes
e358 again at a4446 after the hook and leaves it 0x23, and sweeping the forced
value changes ATI7's Options line not at all - so the write and the test that
asserted the constant are gone.
And it corrects the last commit's conclusion. [e770] bit 2 is gated on the fax
bit, and the command that sets it parses =0/=1/=2 and =? at c822c, which is the
shape of +FCLASS. Opening that branch would put the modem in fax mode, not fix
the result code. NO CARRIER remains open, at the same place it was.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
[d2c5] has one computed write, at a449b, inside a routine that unpacks a block
of capability bytes at d2c6..d2ca: [d2c9] becomes [d2c5] unless [d2c6] bit 2
says the field is absent. And d2c6 onwards is not computed - it is a 4 KiB
record copied out of flash. The loader at c532b walks four 0x1000-byte pages
from segment f800, validates each at c53fd with a CRC-16 seeded ffff whose
residue must be f0b8, prefers the highest version word at 0xffc, and copies the
winner verbatim to 2600:d2c6. When none validates, c5312 fills that 4 KiB with
ff instead - which is what happens here.
So the chain is: no record -> shadow blanked to ff -> d2c6 bit 2 set -> d2c5
stays 0 -> c83d0 gated off so [e770] bit 2 is never set -> adc63 falls through
to the call-termination epilogue -> cause 0 -> result code 3 for every command.
tools/imodem_capability_record.py builds a record and the firmware accepts it:
it validates, wins on version, stops the blank path running, and lands its
bytes with d2c9 copied on to d2c5. That is what verifies the CRC transcription
and the layout, and the test checks it against the firmware rather than against
our own arithmetic.
The field values are not recovered and are not guessed at. Setting d2c9 bit 0
leaves the firmware masking IRQ3 and silent, and an all-zero record silences it
too, so those bytes mean something specific. Nothing in this repository holds a
page the loader accepts.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The rewrite in isdn.py substituted a DTR-dropped cause when the recorded cause
was Keypress Abort with no flags, so that a plain AT would answer OK. It never
fired: the cause is 0, not 0x17, because the receive callback that recorded
0x17 is not the one [c922] holds any more. Removed, along with the unit test
that exercised the function without the run ever calling it.
What is actually true is broader than a bare AT. Watching AL at acf8c across
AT, ATZ, AT&F, ATE1, ATH, ATQ0, ATV1, ATX0 and AT&V, every command emits result
code 3 and code 0 is never emitted at all.
That also retires this page's argument that the result table cannot be
mis-indexed because ATI2 answers OK. ATI2's OK is its own text; the result code
after it is NO CARRIER like all the others.
The reason table starts at c194a, not c1abb which lands mid-string. Indexed
from there, 1 is DTR dropped and 23 = 0x17 lands exactly on Keypress Abort,
which cross-checks the indexing - so index 0 means no disconnect was recorded,
and that is what the firmware is answering NO CARRIER for.
Commands reach the decision through adc82, taken only when [e78e] bit 0,
[e78f] bit 0 and [e770] bit 2 are all clear. They are, all run; [e770] bit 2
has one setter at c83d0 gated on [d2c5] bit 0, which is also 0. Ruled out:
--line-activate to F7 changes nothing, and a sealed all-zero config record
makes the modem silent rather than fixing it.
Not fixed. The test now pins the current behaviour so a real fix fails loudly.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
The board latch at port 0x14 is modelled, so the firmware's probe completes
and reaches its own verdict instead of abandoning at its first sense. The
sense wiring is what --product-type now selects: external straps it to the
0x08 drive and the probe stores 0x22, internal to the 0x80 drive and it stores
0x28, undefined leaves it dead. Nothing is written into d2c3 by the harness
any more - the previous forcing both never ran and, once it did, dropped the
probe's bit 5.
That also retires an earlier wrong conclusion. Comparing "External" against
"Internal" with the forcing hook active compared two Internal runs, which is
why both looked like the 0x80 UART. Left alone, External uses SIO0 at 0xf8f8
on IRQ3 - the part the harness already had - and only the internal card moves
the command port to 0x80 on IRQ0.
TERMINAL_PRESENT was backwards. The signal query masks the MSR and does sete,
so a signal is present when its bit reads 0, and the set/clear routines drive
the MCR the same way. With DSR reading 1 the firmware decides no terminal is
attached and goes silent on anything longer than a bare AT: ATI7 printed
nothing at all. With it reading 0, ATI7 prints its whole profile - and now
reports Product type External rather than Undefined, and ATI3 answers OK.
The internal card is wired up but unfinished: its UART at 0x80 and the tick on
IRQ0 bring the handler at b2f1a to life and all received characters are
dispatched, but the transmit routine finds nothing to send, so it does not
answer yet.
Rackmount is dropped from --product-type: ATI7 can name the bit but the board
probe has no verdict that produces it.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>