StarletBootstrapProbe: --broadway-h1a
The probe stands in for Broadway with StarOS's own bench loader code, so that StarOS's H-1A bench (docs/architecture/h-1a.md, D-H1A-7) runs whole: its Starlet image on the ARM core, its Broadway side from StarOS's boot/wii/loader hw0c.c, hw0d.c and h1a.c, vendored unchanged in Tools/StarletBootstrapProbe/StarOSLoader (StarOS 480119d, stored -text so their bytes stay StarOS's) with their contract headers, and built over a host HAL in BroadwayHAL/. CMake computes the nine files' SHA-256s at configure; the probe prints them when the mode starts. As StarOS's loader around the jump: hw0c_setup() before the Starlet's first instruction, one hw0c_step() between each two slices, the timebase 243 MHz / 4 from the Starlet's cycles, until it says 1; once the image's trace is terminal and the bench is done, the trace, then the report between main.c's status and END lines on stdout. If the budget runs out, the report under SBL:TIMEOUT, and the run fails. The client reaches PPC memory only in the bench window 0x13500000..0x13510000, by whole words: the first access outside fails the run, and is not made. Dolphin's memory is coherent: the run rehearses the protocol, the capture and the judge, not the console's caches. --cycles may reach 2^34 in this mode only (MAX_CLIENT_CYCLES), 2^30 as before otherwise. --broadway-h1a takes neither --ipc-script nor --stage-spk, whose behaviour is unchanged. StarletProbeBroadwayTest: the window's bounds, the clock, Gecko's number formats, the budgets, the built-in sources; and, each in a death test's own process (the loader's state is global), the real loader code against a scripted Starlet: 3000 rounds and a COHERENT record, no READY, no Starlet END, a budget too short; a second client refused. Co-Authored-By: Claude Opus 5.5 <[email protected]>
This commit is contained in:
1 parent
a709fddfa8
commit
f391ae6c85
19 files changed
+2217
-15
No files matched your search
@@ -18,6 +18,7 @@
|
||||
#include "Core/IOS/Starlet/BootstrapELF.h"
|
||||
#include "Core/IOS/Starlet/StarletMemory.h"
|
||||
#include "Core/System.h"
|
||||
#include "ProbeBroadway.h"
|
||||
#include "ProbeBudget.h"
|
||||
#include "ProbeRing.h"
|
||||
#include "ProbeScript.h"
|
||||
@@ -131,8 +132,23 @@ private:
|
||||
IOS::WiiIPC& m_ipc;
|
||||
};
|
||||
|
||||
// What the Broadway client reaches: PPC memory, by whole words (ProbeBroadway.h bounds it to the
|
||||
// bench window).
|
||||
class ProbeMemory final : public BroadwayMemory
|
||||
{
|
||||
public:
|
||||
explicit ProbeMemory(Memory::MemoryManager& memory) : m_memory(memory) {}
|
||||
|
||||
u32 LoadWord(u32 address) override { return m_memory.Read_U32(address); }
|
||||
void StoreWord(u32 address, u32 word) override { m_memory.Write_U32(word, address); }
|
||||
|
||||
private:
|
||||
Memory::MemoryManager& m_memory;
|
||||
};
|
||||
|
||||
bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
ExpectedOutcome expected, u64 cycles, const std::vector<u8>* package, ScriptRunner* script)
|
||||
ExpectedOutcome expected, u64 cycles, const std::vector<u8>* package, ScriptRunner* script,
|
||||
BroadwayClient* client)
|
||||
{
|
||||
std::ifstream file(path, std::ios::binary | std::ios::ate);
|
||||
if (!file || file.tellg() <= 0 || file.tellg() > 16 * 1024 * 1024)
|
||||
@@ -178,6 +194,19 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
<< SPK_WINDOW_BASE << std::dec << '\n';
|
||||
}
|
||||
|
||||
// --broadway-h1a: StarOS's loader sets the bench window up before the jump; so does the client,
|
||||
// before the Starlet's first instruction.
|
||||
ProbeMemory client_memory(system.GetMemory());
|
||||
if (client)
|
||||
{
|
||||
std::cerr << "--broadway-h1a: StarOS loader sources built in:\n" << BroadwayClient::Sources();
|
||||
if (!client->Start(client_memory) || client->Failed())
|
||||
{
|
||||
std::cerr << "--broadway-h1a: " << client->Failure() << '\n';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
IOS::LLE::ARMCore core(memory);
|
||||
// Declared after memory, so destroyed first.
|
||||
memory.AttachInterruptLines(&core);
|
||||
@@ -207,6 +236,12 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
std::cerr << "Starlet panic state " << memory.Read32(info.panic_state) << " code "
|
||||
<< memory.Read32(info.panic_code) << '\n';
|
||||
};
|
||||
// The client's capture on stdout, after the trace, and its counts on stderr.
|
||||
const auto report_client = [&](std::string_view status) {
|
||||
std::cout << client->Report(status);
|
||||
std::cerr << "--broadway-h1a: " << client->Steps() << " steps, timebase 0x" << std::hex
|
||||
<< client->Timebase() << std::dec << ", done " << client->Done() << '\n';
|
||||
};
|
||||
ProbeBus script_bus(mem1, system.GetWiiIPC());
|
||||
// The model's own line raises the IPC cause: the probe has no Starlet object (ProbeScript.h).
|
||||
if (script)
|
||||
@@ -223,6 +258,16 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (client)
|
||||
{
|
||||
// As the loader's monitor: one step of the bench a turn, the first at the jump.
|
||||
client->Advance(slice == 0 ? 0 : SLICE_CYCLES);
|
||||
if (client->Failed())
|
||||
{
|
||||
std::cerr << "--broadway-h1a: " << client->Failure() << '\n';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
core.SetIRQLine(system.GetWiiIPC().IsStarletIRQAsserted());
|
||||
core.SetFIQLine(system.GetWiiIPC().IsStarletFIQAsserted());
|
||||
core.RunCycles(SLICE_CYCLES);
|
||||
@@ -272,6 +317,9 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
{
|
||||
continue;
|
||||
}
|
||||
// The loader reports once the Starlet is done and its bench has ended (main.c's monitor).
|
||||
if (client && !client->Done())
|
||||
continue;
|
||||
std::cout << trace;
|
||||
std::cout << "PC=0x" << std::hex << core.GetRegister(15) << std::dec
|
||||
<< " instructions=" << core.GetExecutedInstructions() << '\n';
|
||||
@@ -280,6 +328,8 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
std::cerr << "--ipc-script: script unfinished at line " << script->Line() << '\n';
|
||||
return false;
|
||||
}
|
||||
if (client)
|
||||
report_client(CLIENT_STATUS_DONE);
|
||||
const bool early_startup_ok = trace.find("REV:BOOT:ENTRY\n") != std::string::npos &&
|
||||
trace.find("REV:BOOT:BSS_OK\n") != std::string::npos;
|
||||
if (expected == ExpectedOutcome::FatalData)
|
||||
@@ -320,6 +370,9 @@ bool Run(const std::string& path, bool jit, bool mmu_faults, SBR1Mode sbr1,
|
||||
}
|
||||
std::cerr << "No terminal bootstrap marker after " << cycles << " ARM cycles, PC=0x" << std::hex
|
||||
<< core.GetRegister(15) << std::dec << '\n';
|
||||
// As main.c's monitor at its own timeout: the report anyway, under SBL:TIMEOUT.
|
||||
if (client)
|
||||
report_client(CLIENT_STATUS_TIMEOUT);
|
||||
return false;
|
||||
}
|
||||
} // namespace
|
||||
@@ -332,7 +385,7 @@ int main(int argc, char** argv)
|
||||
std::cerr << "Usage: StarletBootstrapProbe <ELF> [--jit] [--mmu-faults] "
|
||||
"[--sbr1-record|--sbr1-absent] "
|
||||
"[--expect-panic|--expect-fatal-data|--expect-undefined-fault|--expect-phase2] "
|
||||
"[--cycles <n>] [--stage-spk <file>] [--ipc-script <file>]\n";
|
||||
"[--cycles <n>] [--stage-spk <file>] [--ipc-script <file>|--broadway-h1a]\n";
|
||||
return 2;
|
||||
}
|
||||
bool jit = false;
|
||||
@@ -340,7 +393,8 @@ int main(int argc, char** argv)
|
||||
SBR1Mode sbr1 = SBR1Mode::None;
|
||||
ExpectedOutcome expected = ExpectedOutcome::Idle;
|
||||
bool outcome_selected = false;
|
||||
std::optional<u64> cycles;
|
||||
std::optional<std::string_view> cycles_text;
|
||||
bool broadway_h1a = false;
|
||||
std::optional<std::string> package_path;
|
||||
std::optional<std::string> script_path;
|
||||
for (int index = 2; index < argc; ++index)
|
||||
@@ -366,16 +420,25 @@ int main(int argc, char** argv)
|
||||
}
|
||||
package_path = argv[++index];
|
||||
}
|
||||
else if (option == "--cycles")
|
||||
else if (option == "--broadway-h1a")
|
||||
{
|
||||
// A whole number of slices, at most MAX_CYCLES (ProbeBudget.h); given once.
|
||||
if (cycles || index + 1 == argc || !(cycles = ParseCycles(argv[index + 1])))
|
||||
// StarOS's H-1A bench loader as Broadway (ProbeBroadway.h), once.
|
||||
if (broadway_h1a)
|
||||
{
|
||||
std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most "
|
||||
<< MAX_CYCLES << ", once\n";
|
||||
std::cerr << "--broadway-h1a is given once\n";
|
||||
return 2;
|
||||
}
|
||||
++index;
|
||||
broadway_h1a = true;
|
||||
}
|
||||
else if (option == "--cycles")
|
||||
{
|
||||
// Given once; read below, once the mode, which bounds it, is known.
|
||||
if (cycles_text || index + 1 == argc)
|
||||
{
|
||||
std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", once\n";
|
||||
return 2;
|
||||
}
|
||||
cycles_text = argv[++index];
|
||||
}
|
||||
else if (option == "--jit")
|
||||
jit = true;
|
||||
@@ -411,6 +474,23 @@ int main(int argc, char** argv)
|
||||
}
|
||||
}
|
||||
|
||||
// The client drives Broadway's side alone: no script, no staged package with it.
|
||||
if (broadway_h1a && (script_path || package_path))
|
||||
{
|
||||
std::cerr << "--broadway-h1a takes neither --ipc-script nor --stage-spk\n";
|
||||
return 2;
|
||||
}
|
||||
// A whole number of slices, at most MAX_CYCLES, or MAX_CLIENT_CYCLES with the client
|
||||
// (ProbeBudget.h).
|
||||
const u64 max_cycles = broadway_h1a ? MAX_CLIENT_CYCLES : MAX_CYCLES;
|
||||
std::optional<u64> cycles;
|
||||
if (cycles_text && !(cycles = ParseCycles(*cycles_text, max_cycles)))
|
||||
{
|
||||
std::cerr << "--cycles takes one decimal multiple of " << SLICE_CYCLES << ", at most "
|
||||
<< max_cycles << ", once\n";
|
||||
return 2;
|
||||
}
|
||||
|
||||
// The package file read and checked before anything is set up: a refused file ends the run
|
||||
// before StarOS starts.
|
||||
std::optional<std::vector<u8>> package;
|
||||
@@ -438,8 +518,10 @@ int main(int argc, char** argv)
|
||||
memory.Write_U32(SBR1_RELAY_JUMPING, SBR1_BASE + SBR1_RELAY_STATUS);
|
||||
memory.Write_U32(SBR1_MAGIC, SBR1_BASE);
|
||||
}
|
||||
BroadwayClient client;
|
||||
const bool passed = Run(argv[1], jit, mmu_faults, sbr1, expected, cycles.value_or(DEFAULT_CYCLES),
|
||||
package ? &*package : nullptr, script ? &*script : nullptr);
|
||||
package ? &*package : nullptr, script ? &*script : nullptr,
|
||||
broadway_h1a ? &client : nullptr);
|
||||
if (sbr1 != SBR1Mode::None)
|
||||
{
|
||||
// The record's summary after the run; with --sbr1-absent every word must still be zero (an
|
||||
|
||||
Reference in new issue
Block a user