[codex] Match BS2 title loading helpers #22

Merged
coah80 merged 1 commits from codex/worker-bs2mach-20260921 into main 2026-09-21 20:20:35 +00:00
coah80 commented 2026-09-21 20:19:13 +00:00 (Migrated from github.com)

What changed

Adds the missing BS2Mach title-loading helpers and the ticket-view buffer pointer in src/BS2/BS2Mach.c.

Match results

  • BS2Mach: 13/29 exact functions, 7.4440517% code -> 16/29, 14.723204% code
  • Matched code: 1264 -> 2500 bytes
  • Exact functions: BS2GetLockedTitles, BS2GetTicketFromNand, BS2StartLoadingTitle
  • pool_diff: identical through the existing 11-string prefix; later divergence is from still-missing BS2Mach functions
  • ctxdiff: all three added functions report identical instruction counts and diffs 0

Validation

  • 43U full Ninja build passed
  • DOL SHA1: 26116613f624061ba99c8d1a299aaa6efa85670d
  • decomp_status.py: 59.23% decompiled, 44.80% fully linked on current main plus this leaf
  • check_decomp_complete.py: still fails globally on unrelated incomplete units and the remaining BS2Mach functions

Note

Add BS2 title loading helpers: BS2GetLockedTitles, BS2GetTicketFromNand, BS2StartLoadingTitle

  • Adds a global ticket-view pointer initialized to the existing TicketViewsBuf and a string library dependency for title-ID construction.
  • BS2GetLockedTitles validates BS2 state, counts qualifying game/data partitions (whose type high byte is nonzero) when the caller passes a null buffer, and fills a caller buffer with derived title IDs up to the given capacity.
  • BS2GetTicketFromNand queries NAND ticket count, rejects missing or >64-count tickets, retrieves ticket views into the shared buffer, selects one via __OSGetValidTicketIndex, copies it to the caller, and flushes the destination.
  • BS2StartLoadingTitle validates state, searches game/data partitions for a matching low 32-bit title ID, records the partition and ticket-view pointer, selects cache or locked-disk state via BS2BootFromCache, clears BS2BootFromCache/BS2BootCaching, and returns whether a match was found.
  • Behavioral Change: BS2StartLoadingTitle now transitions to state 8 or BS2_STT_LOCKED_DISK and clears cache control flags; callers expecting prior no-op behavior will see different state transitions.

Macroscope summarized dec2988.

## What changed Adds the missing BS2Mach title-loading helpers and the ticket-view buffer pointer in `src/BS2/BS2Mach.c`. ## Match results - BS2Mach: 13/29 exact functions, 7.4440517% code -> 16/29, 14.723204% code - Matched code: 1264 -> 2500 bytes - Exact functions: BS2GetLockedTitles, BS2GetTicketFromNand, BS2StartLoadingTitle - pool_diff: identical through the existing 11-string prefix; later divergence is from still-missing BS2Mach functions - ctxdiff: all three added functions report identical instruction counts and `diffs 0` ## Validation - 43U full Ninja build passed - DOL SHA1: `26116613f624061ba99c8d1a299aaa6efa85670d` - `decomp_status.py`: 59.23% decompiled, 44.80% fully linked on current main plus this leaf - `check_decomp_complete.py`: still fails globally on unrelated incomplete units and the remaining BS2Mach functions <!-- 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] > ### Add BS2 title loading helpers: `BS2GetLockedTitles`, `BS2GetTicketFromNand`, `BS2StartLoadingTitle` > - Adds a global ticket-view pointer initialized to the existing `TicketViewsBuf` and a string library dependency for title-ID construction. > - `BS2GetLockedTitles` validates BS2 state, counts qualifying game/data partitions (whose type high byte is nonzero) when the caller passes a null buffer, and fills a caller buffer with derived title IDs up to the given capacity. > - `BS2GetTicketFromNand` queries NAND ticket count, rejects missing or >64-count tickets, retrieves ticket views into the shared buffer, selects one via `__OSGetValidTicketIndex`, copies it to the caller, and flushes the destination. > - `BS2StartLoadingTitle` validates state, searches game/data partitions for a matching low 32-bit title ID, records the partition and ticket-view pointer, selects cache or locked-disk state via `BS2BootFromCache`, clears `BS2BootFromCache`/`BS2BootCaching`, and returns whether a match was found. > - Behavioral Change: `BS2StartLoadingTitle` now transitions to state 8 or `BS2_STT_LOCKED_DISK` and clears cache control flags; callers expecting prior no-op behavior will see different state transitions. > > <!-- Macroscope's review summary starts here --> > > <sup><a href="https://app.macroscope.com">Macroscope</a> summarized dec2988.</sup> > <!-- Macroscope's review summary ends here --> > <!-- Macroscope's pull request summary ends here -->
Sign in to join this conversation.