Skip to content

sana2: pin the anxs2ext.h driver callbacks to stack arguments - #126

Merged
tinic merged 1 commit into
mainfrom
fix/a1200-d6b6-boot
Oct 1, 2026
Merged

tinic merged 1 commit into
mainfrom
fix/a1200-d6b6-boot

Conversation

@tinic

@tinic tinic commented Oct 1, 2026

Copy link
Copy Markdown
Owner

-mregparm=3 (#121) left the private driver→library callbacks in include/aminetxduo/anxs2ext.h unpinned (AnxdS2RxDirect, AnxdS2RxFilled, AnxdS2TxFlags). Released drivers push their arguments; the d6b6a7e library read registers, so RxDirect returned its own code bytes as the payload address and RxFilled wrote into library text. Neither interface came up on the PiStorm32 A1200 when the library was switched to d6b6a7e and the 144042c drivers were kept.

The typedefs now carry __stdargs (ANXD_S2_STDARGS), the three definitions carry AMIGA_ASM_ARGS, and cmake/check-anxs2ext-abi.cmake stops the configure unless calls through them pop 8/16/4 bytes (fails on d6b6a7e, passes here).

Proof, playhouse3 run-cardsweep.sh -c ne2000_pcmcia (emulated A1200; library + AddNetInterface from the tree, driver as listed):

library anxnet.device status tx / rx bytes
main d6b6a7e d6b6a7e 9eb260c4 pass 1354716 / 2367488
main d6b6a7e 144042c 969e61c8 (from the A1200) fail 0 / 0
this branch 144042c 969e61c8 pass 1354716 / 2310144
this branch rebuilt c5c8122f pass 1356176 / 2310144

tools/ci.sh cross (default) green on playhouse3.

🤖 Generated with Claude Code

RxDirect, RxFilled and TxFlags are called by a driver built separately
from the library.  Every release before -mregparm=3 (b6d86db) pushed
their arguments; the typedefs were left unpinned, so the d6b6a7e library
read a0/d0/d1/d2 for what a 144042c anxnet/anxgenet.device had pushed.

At the old driver's call site a0 holds the callback's own address, so
RxDirect returned a longword of its own code (0x00006718 in the d6b6a7e
image) as the payload address and RxFilled stored the length into the
library's text at fn+108.  No frame reached the stack, chip RAM was
overwritten on every receive, and on the PiStorm32 A1200 neither eth0 nor
genet came up.

The typedefs now carry __stdargs (ANXD_S2_STDARGS, empty where the
compiler has no such pin and already passes on the stack), and the three
library definitions carry AMIGA_ASM_ARGS, so an unpinned definition no
longer type-checks against the record.  cmake/check-anxs2ext-abi.cmake
compiles a call through each typedef with the tree's flags and stops the
configure unless the caller pops 8, 16 and 4 bytes: it fails on d6b6a7e
and passes here.  Rebuilt drivers push exactly as the 144042c images do;
the library reads 4(sp).  Resident sizes within budget.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tinic
tinic merged commit d6026ab into main Oct 1, 2026
5 checks passed
@tinic
tinic deleted the fix/a1200-d6b6-boot branch October 1, 2026 08:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant