feat(userspace): log server sole console holder; init boots from manifest; adapter loads only init+storage

This commit is contained in:
2026-10-27 15:40:19 +01:00
parent 4049ba5007
commit a4f467f45d
21 changed files with 510 additions and 325 deletions

View File

@@ -8,6 +8,7 @@ pub mod budget;
pub mod display;
pub mod generation;
pub mod id;
pub mod log;
pub mod macros;
pub mod mapping;
pub mod permission;

49
crates/types/src/log.rs Normal file
View File

@@ -0,0 +1,49 @@
//! The log protocol's text message, shared by the log server and
//! `libkos::io` so the two cannot drift apart: word 0 is `TEXT` with the
//! length in bits 8..16, words 1..4 carry up to `TEXT_BYTES` bytes.
pub const TEXT: usize = 3;
pub const TEXT_BYTES: usize = 24;
/// `chunk` past `TEXT_BYTES` is cut off.
pub fn text_words(chunk: &[u8]) -> [usize; 4] {
let len = chunk.len().min(TEXT_BYTES);
let mut bytes = [0u8; TEXT_BYTES];
bytes[..len].copy_from_slice(&chunk[..len]);
let mut words = [TEXT | (len << 8), 0, 0, 0];
for (w, b) in words[1..].iter_mut().zip(bytes.as_chunks::<8>().0) {
*w = u64::from_le_bytes(*b) as usize;
}
words
}
/// The bytes of a text message and how many of them count.
pub fn text_of(words: [usize; 4]) -> Option<([u8; TEXT_BYTES], usize)> {
if words[0] & 0xFF != TEXT {
return None;
}
let len = (words[0] >> 8) & 0xFF;
if len > TEXT_BYTES {
return None;
}
let mut bytes = [0u8; TEXT_BYTES];
for (b, w) in bytes.as_chunks_mut::<8>().0.iter_mut().zip(&words[1..]) {
*b = (*w as u64).to_le_bytes();
}
Some((bytes, len))
}
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn text_round_trips_and_is_cut_at_the_limit() {
let (bytes, len) = text_of(text_words(b"init: hello")).unwrap();
assert_eq!(&bytes[..len], b"init: hello");
let long = [b'x'; 30];
assert_eq!(text_of(text_words(&long)).unwrap().1, TEXT_BYTES);
assert_eq!(text_of([TEXT | (25 << 8), 0, 0, 0]), None);
assert_eq!(text_of([0, 0, 0, 0]), None);
}
}

View File

@@ -25,6 +25,8 @@ pub mod op {
pub const CREATE: usize = 7;
pub const DELETE: usize = 8;
pub const MKDIR: usize = 9;
/// Carries the log endpoint; only from the unbadged holder (init).
pub const SET_LOG: usize = 10;
}
/// Reply tags (word 0).