From 090441ad04ec9d19d44ae9e218b66ee588717323 Mon Sep 17 00:00:00 2001 From: Drew Galbraith Date: Sat, 17 Aug 2024 22:05:52 -0700 Subject: [PATCH] [Yellowstone] Spawn VFS and handle GetEndpoint. --- rust/sys/yellowstone/src/main.rs | 10 +++++++++- rust/sys/yellowstone/src/server.rs | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 2 deletions(-) diff --git a/rust/sys/yellowstone/src/main.rs b/rust/sys/yellowstone/src/main.rs index 6bbb339..2a62a1a 100644 --- a/rust/sys/yellowstone/src/main.rs +++ b/rust/sys/yellowstone/src/main.rs @@ -46,9 +46,17 @@ extern "C" fn main() -> z_err_t { .expect("Failed to spawn denali"); context.wait_denali().expect("Failed to wait for denali"); - mammoth::debug!("Denali registered."); + spawn_from_vmmo( + unsafe { mammoth::init::BOOT_VICTORIA_FALLS_VMMO }, + server.create_client_cap().unwrap(), + ) + .expect("Failed to spawn victoriafalls"); + + context.wait_victoria_falls().unwrap(); + mammoth::debug!("VFS Registered"); + server_thread.join().expect("Failed to join thread"); 0 } diff --git a/rust/sys/yellowstone/src/server.rs b/rust/sys/yellowstone/src/server.rs index 037fb57..8af4673 100644 --- a/rust/sys/yellowstone/src/server.rs +++ b/rust/sys/yellowstone/src/server.rs @@ -10,6 +10,7 @@ use crate::pci::PciReader; pub struct YellowstoneServerContext { denali_semaphore: mammoth::sync::Semaphore, + victoria_falls_semaphore: mammoth::sync::Semaphore, pci_reader: PciReader, } @@ -17,6 +18,7 @@ impl YellowstoneServerContext { pub fn new(pci_region: MemoryRegion) -> Result { Ok(Self { denali_semaphore: mammoth::sync::Semaphore::new()?, + victoria_falls_semaphore: mammoth::sync::Semaphore::new()?, pci_reader: PciReader::new(pci_region), }) } @@ -24,6 +26,10 @@ impl YellowstoneServerContext { pub fn wait_denali(&self) -> Result<(), ZError> { self.denali_semaphore.wait() } + + pub fn wait_victoria_falls(&self) -> Result<(), ZError> { + self.victoria_falls_semaphore.wait() + } } pub struct YellowstoneServerImpl { @@ -43,17 +49,27 @@ impl YellowstoneServerImpl { impl YellowstoneServerHandler for YellowstoneServerImpl { fn register_endpoint(&mut self, req: RegisterEndpointRequest) -> Result<(), ZError> { let signal_denali = req.endpoint_name == "denali"; + let signal_vfs = req.endpoint_name == "victoriafalls"; + self.service_map .insert(req.endpoint_name, Capability::take(req.endpoint_capability)); if signal_denali { self.context.denali_semaphore.signal()? } + if signal_vfs { + self.context.victoria_falls_semaphore.signal()? + } Ok(()) } fn get_endpoint(&mut self, req: GetEndpointRequest) -> Result { - todo!() + match self.service_map.get(&req.endpoint_name) { + Some(cap) => Ok(Endpoint { + endpoint: cap.duplicate(Capability::PERMS_ALL)?.release(), + }), + None => Err(ZError::NOT_FOUND), + } } fn get_ahci_info(&mut self) -> Result {