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>
1.9 KiB
Emulator architecture
The normal emulator is a model of a Courier, not a firmware-discovery probe.
Recovered facts therefore belong in courier_emu.machine_map; instruction and
memory tracing remain optional tools used to establish those facts.
Layers
- The CPU executes ordinary 80186 instructions.
CourierMachineMapassigns address ranges and service vectors to devices.- Device models own UART, timers, ASIC, EEPROM, flash and DSP behavior.
- An exact-digest
FirmwareProfilesupplies only facts that move between ROM releases. - The scheduler advances devices after bounded amounts of guest execution.
An optimization may skip or replace firmware code only when its profile is selected by an exact digest and the relevant entry bytes have also been validated. Unknown ROMs continue through the general interpreter.
Migration rule
Newly recovered addresses must be named in the machine map or a firmware profile before normal execution depends on them. Do not add another anonymous literal to the CPU dispatch loop. Discovery scripts may use raw addresses, but their promoted result must include its image identity and evidence.
The first mapped ranges are the 80186 peripheral block, DSP host queue and serial callback cell. The two Australian flash captures are the first explicit firmware profiles. Existing literals should move here incrementally, with a behavioral regression test for each move.
Performance direction
The Python interpreter keeps the next device-service deadline inside its dispatch loop and calls the machine once per bounded interval, rather than installing a Python code hook for every instruction. The next execution change is a block API: execute until a mapped device deadline, mapped watchpoint, interrupt boundary or block exit, then advance the scheduler once. Known idle and polling loops can subsequently yield to the next device event through profile rules guarded by code anchors.