From e092fa4ae53f38475554fc8e9a7307b4fa02c83c Mon Sep 17 00:00:00 2001 From: Gabriel Kaszewski Date: Sun, 18 Oct 2026 04:01:39 +0200 Subject: [PATCH] fix: disable test harness for no_std binaries, fix shutdown to best-effort notify-and-halt, use CapSlot newtypes --- crates/adapter-riscv/Cargo.toml | 5 +++++ crates/apps/hello/Cargo.toml | 5 +++++ crates/apps/snake/Cargo.toml | 5 +++++ crates/init/src/shutdown.rs | 26 +++++++++++++------------- 4 files changed, 28 insertions(+), 13 deletions(-) diff --git a/crates/adapter-riscv/Cargo.toml b/crates/adapter-riscv/Cargo.toml index 0a651ed..9b2d511 100644 --- a/crates/adapter-riscv/Cargo.toml +++ b/crates/adapter-riscv/Cargo.toml @@ -3,6 +3,11 @@ name = "adapter-riscv" version = "0.1.0" edition = "2024" +[[bin]] +name = "adapter-riscv" +test = false +bench = false + [dependencies] types = { workspace = true } domain = { workspace = true } diff --git a/crates/apps/hello/Cargo.toml b/crates/apps/hello/Cargo.toml index 1be785e..117cce2 100644 --- a/crates/apps/hello/Cargo.toml +++ b/crates/apps/hello/Cargo.toml @@ -3,6 +3,11 @@ name = "hello" version = "0.1.0" edition = "2024" +[[bin]] +name = "hello" +test = false +bench = false + [dependencies] userspace = { workspace = true } diff --git a/crates/apps/snake/Cargo.toml b/crates/apps/snake/Cargo.toml index f362f5a..2b2a97c 100644 --- a/crates/apps/snake/Cargo.toml +++ b/crates/apps/snake/Cargo.toml @@ -3,6 +3,11 @@ name = "snake" version = "0.1.0" edition = "2024" +[[bin]] +name = "snake" +test = false +bench = false + [dependencies] types = { workspace = true } userspace = { workspace = true } diff --git a/crates/init/src/shutdown.rs b/crates/init/src/shutdown.rs index 2b4833d..ae42fde 100644 --- a/crates/init/src/shutdown.rs +++ b/crates/init/src/shutdown.rs @@ -1,23 +1,23 @@ -const SHUTDOWN_TIMEOUT_TICKS: usize = 50_000_000; +use types::bounded::CapSlot; -pub fn shutdown(server_endpoints: &[usize], endpoint_count: usize) -> ! { +const SHUTDOWN_TIMEOUT_TICKS: usize = 50_000_000; +const SHUTDOWN_SIGNAL: usize = 0xFFFF_FFFF; + +/// Best-effort shutdown: notify all servers, wait briefly for them to flush, then halt. +/// +/// Servers that receive the shutdown signal should flush state to storage and exit. +/// We can't block on individual acks because a crashed server would deadlock us. +/// Instead, we yield repeatedly until the timeout expires, giving servers time to finish. +pub fn shutdown(server_endpoints: &[CapSlot], endpoint_count: usize) -> ! { for i in 0..endpoint_count { - let ep = server_endpoints[i]; - if ep != 0 { - userspace::syscall::send(ep, 0xFFFF_FFFF, 0, 0, 0); - } + let ep = server_endpoints[i].value() as usize; + userspace::syscall::send(ep, SHUTDOWN_SIGNAL, 0, 0, 0); } let start = userspace::syscall::get_time(); let deadline = start + SHUTDOWN_TIMEOUT_TICKS; - let mut acks = 0usize; - while acks < endpoint_count { - let now = userspace::syscall::get_time(); - if now >= deadline { - break; - } - acks += 1; + while userspace::syscall::get_time() < deadline { userspace::syscall::yield_now(); }