// Copyright 2026 Dolphin Emulator Project // SPDX-License-Identifier: GPL-2.0-or-later #pragma once #include #include #include "Common/CommonTypes.h" // How long StarletBootstrapProbe runs an image: whole slices of SLICE_CYCLES ARM cycles, between // which it checks for a fault, a panic or a terminal trace line. --cycles sets the budget; // without it, the probe runs DEFAULT_CYCLES, as it always has. StarOS's EXP-003 images hash MEM2 // and time series of operations, which take more than that (StarOS // experiments/proposals/mmu-console.md, P-7 and P-8). namespace StarletBootstrapProbe { constexpr u32 SLICE_CYCLES = 4096; constexpr u64 DEFAULT_CYCLES = 512 * SLICE_CYCLES; // 2^30 cycles: 262,144 slices. constexpr u64 MAX_CYCLES = u64{1} << 30; // The budget --cycles asks for: a decimal number of cycles, a whole number of slices, from one // slice to MAX_CYCLES. Anything else is refused (nullopt), never rounded. inline std::optional ParseCycles(std::string_view text) { // Twelve digits cannot overflow a u64; MAX_CYCLES has ten. if (text.empty() || text.size() > 12) return std::nullopt; u64 value = 0; for (const char digit : text) { if (digit < '0' || digit > '9') return std::nullopt; value = value * 10 + static_cast(digit - '0'); } if (value == 0 || value % SLICE_CYCLES != 0 || value > MAX_CYCLES) return std::nullopt; return value; } } // namespace StarletBootstrapProbe