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

@@ -31,6 +31,7 @@ pub struct StorageServer<F: FileSystem, B: Buffers> {
clients: [Option<Client>; MAX_CLIENTS],
/// The badge of the client that opened each handle.
owners: [Option<usize>; MAX_HANDLES],
log: Option<CapSlot>,
}
impl<F: FileSystem, B: Buffers> StorageServer<F, B> {
@@ -40,6 +41,26 @@ impl<F: FileSystem, B: Buffers> StorageServer<F, B> {
buffers,
clients: [const { None }; MAX_CLIENTS],
owners: [None; MAX_HANDLES],
log: None,
}
}
/// Where this server prints, once init has said.
pub fn log(&self) -> Option<CapSlot> {
self.log
}
/// Clients hold badged copies of the endpoint, so the unbadged sender is
/// whoever was given the endpoint itself: init.
fn set_log(&mut self, badge: usize, cap: Option<CapSlot>) -> StorageResponse {
match (badge, cap, self.log) {
(0, Some(cap), None) => {
self.log = Some(cap);
libkos::start::set_log(Some(cap));
libkos::println!("storage: printing through the log server");
StorageResponse::Ok
}
_ => StorageResponse::Error,
}
}
@@ -117,7 +138,7 @@ impl<F: FileSystem, B: Buffers> StorageServer<F, B> {
None => R::NotFound,
};
let response = match request {
Attach => R::Error,
Attach | SetLog => R::Error,
Open { path_len } => {
let h = fs.open(&buf[path(path_len)]);
opened(owners, h)
@@ -195,9 +216,10 @@ impl<F: FileSystem, B: Buffers> Server for StorageServer<F, B> {
&mut self,
badge: usize,
words: [usize; 4],
_cap: Option<CapSlot>,
cap: Option<CapSlot>,
) -> ([usize; 4], Option<CapSlot>) {
match StorageRequest::decode(words) {
Some(StorageRequest::SetLog) => (self.set_log(badge, cap).encode(), None),
Some(request) => {
let (response, cap) = self.serve(badge, request);
(response.encode(), cap)