//! K2115 client: leaves requests pending at shell, file and console, stays //! alive while PID1 performs its stop sequence one action per STEP call, //! collects an answer for every request, and finally checks that a request //! to a stopped service is refused with the defined Shutdown answer. #![no_std] #![no_main] use turkos_os_feature_user::{call, exit}; const REQUEST: u64 = 16; const STEP: u64 = 17; const ANSWER: u64 = 18; const SHELL: u64 = 2; const FILE: u64 = 1; const CONSOLE: u64 = 0; const DONE: u64 = 0xff; const SERVED: u64 = 1; const SHUTDOWN: u64 = 2; const REFUSED: u64 = 1 << 63; #[unsafe(no_mangle)] #[unsafe(link_section = ".text._start")] pub extern "C" fn _start(_: u64, _: u64) -> ! { let mut sent = 0; for (service, tag) in [(SHELL, 1), (SHELL, 2), (FILE, 3), (CONSOLE, 4)] { if call(REQUEST, service, tag, 0) != 0 { exit(0x10 + tag) } sent += 1; } let (mut served, mut shutdown) = (0u64, 0u64); loop { let step = call(STEP, 0, 0, 0); loop { let a = call(ANSWER, 0, 0, 0); if a == 0 { break } match a & 0xff { SERVED => served += 1, SHUTDOWN => shutdown += 1, _ => exit(0x20) } } if step == DONE { break } } if served + shutdown != sent { exit(0x30) } if call(REQUEST, SHELL, 5, 0) != REFUSED | 7 { exit(0x40) } exit(served << 8 | shutdown) }