From ec820475f407ab29f5e57bee5d491dd340976ac8 Mon Sep 17 00:00:00 2001 From: coah <100182500+coah80@users.noreply.github.com> Date: Tue, 6 Oct 2026 18:24:31 +0000 Subject: [PATCH] refactor(BS2): BS2Reboot uses the ES work-buffer idiom (swe2-reboot) (worker 14e4a4eb) --- src/BS2/BS2Mach.c | 6 ++---- tools/decomp-assist/swe2-reboot.attempts.md | 22 +++++++++++++++++++++ 2 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 tools/decomp-assist/swe2-reboot.attempts.md diff --git a/src/BS2/BS2Mach.c b/src/BS2/BS2Mach.c index 7ce86707..332f450e 100644 --- a/src/BS2/BS2Mach.c +++ b/src/BS2/BS2Mach.c @@ -531,9 +531,7 @@ ESError BS2ESGetTicketViews(IOSFd *descriptor, ESTitleId titleId, ESTicketView * } void BS2Reboot(void) { ESTicketView ticket ALIGN32; - struct { - ESTitleId title[32]; - } launchWork ALIGN32; + u8 work[256] ALIGN32; OSStateFlags flags ALIGN32; IOSIoVector vectors[4] ALIGN32; IOSFd descriptor; @@ -580,7 +578,7 @@ void BS2Reboot(void) { { s32 launchResult; IOSIoVector *request = vectors; - ESTitleId *title = launchWork.title; + ESTitleId *title = (ESTitleId *)work; if (descriptor < 0) { launchResult = -0x3f9; } else if ((u32)&ticket % 32 != 0) { diff --git a/tools/decomp-assist/swe2-reboot.attempts.md b/tools/decomp-assist/swe2-reboot.attempts.md new file mode 100644 index 00000000..80741a8d --- /dev/null +++ b/tools/decomp-assist/swe2-reboot.attempts.md @@ -0,0 +1,22 @@ +# swe2-reboot attempts — BS2Reboot (src/BS2/BS2Mach.c) + +Integrity task: function already exact; replace dishonest +`struct { ESTitleId title[32]; } launchWork` carrier with honest storage. + +Target disasm layout (0x280 frame): +- 0x20 ticketCount, 0x24 descriptor +- 0x40 vectors[4] +- 0x60 OSStateFlags flags (0x20) +- 0x80 title (ESTitleId, 8 bytes used of a 0x100 region) +- 0x180 ESTicketView ticket (0xD8) + +The 0x100 title region matches the SDK ES work-buffer size. es.c uses +`u8 __esWork[256] ALIGN32` (DECLARE_ES_WORK) with the title at +0x00 for +ES_LaunchTitle; BS2ESGetTicketViews in the same file already uses the same +`u8 work[256] ALIGN32` idiom. + +| # | Change | differing | +|---|--------|-----------| +| 1 | `u8 work[256] ALIGN32` in place of launchWork; `ESTitleId *title = (ESTitleId *)work` | 0 / 137 | + +Exact on first attempt. pool_diff: no divergence. -- 2.49.1