// Copyright 2026 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include #include #include "Common/CommonTypes.h" #include "StarOSPanicCheck.h" // The text of StarOS's SBR1 ring (StarOS crates/boot-contract, report.rs), which --sbr1-record // prints after the run, as StarOS's Broadway loader prints it over the Gecko on the console // (SBL:RING BEGIN/END). Bytes come through a callback, so the formatting is tested without a CPU. namespace StarletBootstrapProbe { constexpr u32 SBR1_RING = 0x40; constexpr u32 SBR1_RING_BYTES = SBR1_SIZE - SBR1_RING; // The ring's first `length` bytes (at most SBR1_RING_BYTES), read at their record offsets. A // byte outside printable ASCII and '\n', and the backslash itself, is written \xHH, so the text // stays printable and reads back unambiguously. inline std::string RingText(const std::function& read_byte, u32 length) { std::string text; const u32 end = std::min(length, SBR1_RING_BYTES); for (u32 index = 0; index < end; ++index) { const u8 byte = read_byte(SBR1_RING + index); if (byte == '\n' || (byte >= 0x20 && byte < 0x7f && byte != '\\')) text += static_cast(byte); else text += fmt::format("\\x{:02x}", byte); } return text; } } // namespace StarletBootstrapProbe