Files
Yaya48andClaude Opus 5.5 9d66381b3d StarletBootstrapProbe: --stage-spk
StarOS's I2-C image admits its User services from an SPK1 package that
the loader stages in MEM2 before the Starlet's first instruction (StarOS
docs/contracts/spk-staging.md). --stage-spk <file> places the file at
the package window's base, 0x13720000, once the image is loaded: the
address is the contract's, never an argument. The bytes are copied as
the file holds them (big-endian words) and read back before the first
instruction; a window that does not read back fails the run.

The file is read and checked before anything is set up. A missing or
unreadable file, an empty one, one whose length is not whole 32-bit
words or that exceeds the 128 KiB window ends the run with its reason on
stderr and exit status 4, before StarOS starts. The option given twice
or without its file is a usage error (exit 2). The probe checks none of
SPK1's fields or digests: that is StarOS's job.

The size rule and the window are in ProbeStaging.h, tested by
StarletProbeStagingTest. Without the option the probe runs as before.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-11-01 18:36:14 +01:00

38 lines
1.3 KiB
C++

// Copyright 2026 Dolphin Emulator Project
// SPDX-License-Identifier: GPL-2.0-or-later
#pragma once
#include <optional>
#include <string_view>
#include "Common/CommonTypes.h"
// StarletBootstrapProbe's --stage-spk <file>: StarOS's SPK1 service package, placed in MEM2 at
// the package window's base once the image is loaded, before the first ARM instruction (StarOS
// docs/contracts/spk-staging.md). The window is the contract's, never an argument, so that a run
// cannot stage elsewhere. The probe only places bytes: SPK1's fields and digests are StarOS's to
// check.
namespace StarletBootstrapProbe
{
constexpr u32 SPK_WINDOW_BASE = 0x13720000;
constexpr u32 SPK_WINDOW_SIZE = 0x20000;
// Exit status of a run whose package file is refused before StarOS starts (1: failed
// expectation, 2: usage, 3: Dolphin alert).
constexpr int STAGING_EXIT_STATUS = 4;
// Why a package file of `size` bytes cannot be staged, or nullopt when it can: not empty, whole
// 32-bit words, at most the window.
inline std::optional<std::string_view> StagingRefusal(u64 size)
{
if (size == 0)
return "it is empty";
if (size % 4 != 0)
return "its length is not a whole number of 32-bit words";
if (size > SPK_WINDOW_SIZE)
return "it is larger than the 128 KiB package window";
return std::nullopt;
}
} // namespace StarletBootstrapProbe