decomp(kbd): reconstruct asynchronous LED dispatch and completion #993

Merged
coah80 merged 1 commits from agent/bittle/kbd-async-reconstruction into main 2026-10-02 23:42:29 +00:00
coah80 commented 2026-10-02 23:41:55 +00:00 (Migrated from github.com)

Reconstruction

Replace raw byte-offset command-buffer casts with indexed typed command accesses. Recover separate channel views for validation, reservation and dispatch. In completion, retain the callback argument as the source of the unsigned dispatch index, distinct from the signed initial lookup. Indices originate from the bounded 0..11 slot reservation; channel is checked below4. Signed declaration choices are inferred from natural C lowering, not uniquely recovered declarations.

The existing callback-versus-cleared-device comparison is preserved, not newly introduced. Interrupt boundaries, reservation, callback registration and error translation remain in place. The obsolete flag helper is removed only after both callers use direct typed accesses.

Independent validation

Rebased and rebuilt on 654c65dd272216f5f9bf81623a2b229e101760cd; tested tree 17a1c8a82b.

  • KBDSetLedsAsync:86.234566%→99.44444%,81/81 instructions; eight r29/r30 allocation differences remain
  • kbd_led_handler:64.12%→97.92%,25/25 instructions; nine allocation/branch-layout differences remain
  • Unit fuzzy:98.54823%→99.87717%; exact functions remain16/21, exact code3404/5764
  • Data remains5296/5296 exact; all allocated non-text bytes and normalized relocations unchanged
  • All1027 source objects compared: only kbd_lib .text changes,5756→5764 bytes; no function/unit/data regressions
  • Sixteen exact functions retain ctxdiff zero, including the recently matched synchronous KBDSetLeds
  • Pool identical(no strings); literal audit clean; worktree/diff checks pass
  • Full43U all_source, report, progress and DOL build pass; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d

Partial reconstruction only; no new exact function, linking or configuration change. User requested decompilation first. No merge performed or requested by this author.

Note

Reconstruct async LED dispatch in KBDSetLedsAsync with typed field access

  • Replaces raw byte-offset and u32-pointer access to command-buffer fields in KBDSetLedsAsync with typed member access, and reads KBDChannel data directly instead of via the removed kbdChannelFlags helper.
  • Changes the callback index local in kbd_led_handler from unsigned to signed and indexes the callback record and command buffer via the handler argument's integer value.
  • Behavioral Change: no functional change intended — device reset, callback-address check, and success-to-error mapping in kbd_led_handler are unchanged.

Macroscope summarized a9eeafc.

## Reconstruction Replace raw byte-offset command-buffer casts with indexed typed command accesses. Recover separate channel views for validation, reservation and dispatch. In completion, retain the callback argument as the source of the unsigned dispatch index, distinct from the signed initial lookup. Indices originate from the bounded 0..11 slot reservation; channel is checked below4. Signed declaration choices are inferred from natural C lowering, not uniquely recovered declarations. The existing callback-versus-cleared-device comparison is preserved, not newly introduced. Interrupt boundaries, reservation, callback registration and error translation remain in place. The obsolete flag helper is removed only after both callers use direct typed accesses. ## Independent validation Rebased and rebuilt on 654c65dd272216f5f9bf81623a2b229e101760cd; tested tree 17a1c8a82b5f9ee6f37899fb538ab2f5aefc3e61. - KBDSetLedsAsync:86.234566%→99.44444%,81/81 instructions; eight r29/r30 allocation differences remain - kbd_led_handler:64.12%→97.92%,25/25 instructions; nine allocation/branch-layout differences remain - Unit fuzzy:98.54823%→99.87717%; exact functions remain16/21, exact code3404/5764 - Data remains5296/5296 exact; all allocated non-text bytes and normalized relocations unchanged - All1027 source objects compared: only kbd_lib .text changes,5756→5764 bytes; no function/unit/data regressions - Sixteen exact functions retain ctxdiff zero, including the recently matched synchronous KBDSetLeds - Pool identical(no strings); literal audit clean; worktree/diff checks pass - Full43U all_source, report, progress and DOL build pass; SHA1 26116613f624061ba99c8d1a299aaa6efa85670d Partial reconstruction only; no new exact function, linking or configuration change. User requested decompilation first. No merge performed or requested by this author. <!-- Macroscope's pull request summary starts here --> <!-- Macroscope will only edit the content between these invisible markers, and the markers themselves will not be visible in the GitHub rendered markdown. --> <!-- If you delete either of the start / end markers from your PR's description, Macroscope will append its summary at the bottom of the description. --> > [!NOTE] > ### Reconstruct async LED dispatch in `KBDSetLedsAsync` with typed field access > - Replaces raw byte-offset and u32-pointer access to command-buffer fields in `KBDSetLedsAsync` with typed member access, and reads `KBDChannel` data directly instead of via the removed `kbdChannelFlags` helper. > - Changes the callback index local in `kbd_led_handler` from unsigned to signed and indexes the callback record and command buffer via the handler argument's integer value. > - Behavioral Change: no functional change intended — device reset, callback-address check, and success-to-error mapping in `kbd_led_handler` are unchanged. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized a9eeafc.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
coah80 commented 2026-10-02 23:42:27 +00:00 (Migrated from github.com)

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.

Reviewed and merged: rebased on main, full build ok, DOL sha1 26116613f624061ba99c8d1a299aaa6efa85670d, 0 regressions, 0 forbidden patterns.
Sign in to join this conversation.