sana2: pin the anxs2ext.h driver callbacks to stack arguments - #126
Merged
Merged
Conversation
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>
This was referenced Oct 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
-mregparm=3(#121) left the private driver→library callbacks ininclude/aminetxduo/anxs2ext.hunpinned (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 carryAMIGA_ASM_ARGS, andcmake/check-anxs2ext-abi.cmakestops 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):tools/ci.sh cross(default) green on playhouse3.🤖 Generated with Claude Code