Files
courier-emu/docs/flash-addressing.md
T
Cryan209andClaude Opus 5 89b6fa6e79 Find how the overlays reach the DSP: a second, table-driven loader
The resident downloader could never have sent them - its source segment is
hard-coded, so it can only ever send the resident bank. A second routine pushes
words through the same eight data ports but handshakes on 1e rather than 18, one
acknowledgement per half-block, and takes its source from a table: four-bit code,
six bytes per row, start and end offsets and the C52 address to load at, with the
same code selecting the source segment.

The resident payload is a row of that table, which is what identifies it -
`dsp_overlays` returns nothing unless one row reproduces what the download call
site independently says. That leaves four images: 8000 resident, then 9d00, b000
and dc00. All three 512 KiB builds agree on those addresses, differing only in
length. Overlays 6 and 7 overlap in program space, so they are alternatives, and
every overlay lands inside the resident bank's range rather than extending it.

The codec picture does not change. The overlays hold no host sender and no DXR
write at all - algorithm code fed by the resident ISR - and the single codec
write among them is register 4 again. Every write this firmware makes after reset
targets register 4; the dividers are set once and never touched.

This also corrects driving-the-tones.md's third blocker, whose addresses do not
survive measurement: the 3.0.13 resident bank runs 8000..ec3e rather than ending
at d9ef, daaf holds instructions rather than zeros, and the payload has no zero
run longer than 32 words anywhere.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 23:24:47 +12:00

71 lines
3.2 KiB
Markdown

# There is no flash banking
The captures address the board as `A000:9200`, and the image's own pointers are
segmented, which made the flash look banked. It is not. The mapping is flat and
the notation is ordinary 80186 real mode.
`physical_start` in every flash capture manifest is **`0x80000`**, and the length
is `0x80000`. So the 512 KiB flash occupies CPU physical `0x80000..0xfffff`
contiguously, and
```text
physical = (segment << 4) + offset
file offset = physical - 0x80000
```
`ATGLK2=A000:9200` reads physical `0xa9200`, which is file `0x29200`. Segment
`8000` is the base of the window, so within it an offset *is* a file offset -
which is why `9a ed 1e 00 80`, a far call to `8000:1eed`, targets file `0x1eed`.
`courier_emu.flash_dump.physical` and `.file_offset` implement this, and refuse
an address outside the window, which is what a pointer into RAM or the relocated
peripheral block at `ff00` looks like.
## What it was blocking
Near calls need no mapping - source and target share a segment, so a `E8`
displacement is the same in file offsets as in segment offsets, and scanning for
them works. Far calls do, and scanning for the *offset* field alone finds
nothing, because the same physical address has many encodings: the mailbox
thunk at file `0xf644` is reached as `8f46:01e4`, not as `8000:f644`.
Resolving them properly turns 23 visible mailbox send sites into 137. See
[codec-rate-312.md](codec-rate-312.md), where that is what located the tag `2c`
sends.
## What this does not establish
The capture manifests record the assumption behind the window - "CPU addresses
`80000..fffff` expose the 512 KiB flash at runtime" - and note that identical
repeated reads establish capture consistency, **not the absence of bank
aliases**. Nothing here changes that. What is established is that the image's
own far pointers resolve consistently under the flat mapping, across 1,400 of
them, and that the two mailbox routines' call graphs close under it. A bank
register that selects between whole 512 KiB images would be invisible to both
that capture and this analysis.
DSP program addresses are a separate mapping again. This image's payload places
program `0x8000` at file `0x29140`, so `program = 0x8000 + (file - 0x29140) / 2`.
Note that [board-parts.md](board-parts.md) numbers the same code from a payload
origin `0x8000` lower.
## What the 512 KiB holds
Scored in 8 KiB blocks by instruction fingerprints - C5x forms against x86 ones -
and cross-checked against the download site the supervisor actually uses:
| range | contents |
|---|---|
| `00000..17fff` | supervisor code and data |
| `18000..19fff` | a C5x-looking block inside the supervisor region |
| `1a000..27fff` | supervisor code and data |
| `29140..36e8e` | **the DSP payload that is downloaded**, 28,327 words at program `8000` |
| `36e90..44634` | three DSP overlay images, loaded at program `9d00`, `b000` and `dc00` - see [dsp-overlays.md](dsp-overlays.md) |
| `44634..4bfff` | blank, then a small x86 block at `48000` |
| `4c000..7bfff` | blank |
| `7c000..7dfff` | x86 code or data |
| `7e000..7ffff` | blank |
The DSP payload's own origin follows from the download: program `0x8000` sits at
file `0x29140`, so `program = 0x8000 + (file - 0x29140) / 2`.