Move yunq to new thread spawn and remove old one.
This commit is contained in:
parent
79e1ea2791
commit
d777b8f4ab
7 changed files with 33 additions and 76 deletions
|
|
@ -1,10 +1,8 @@
|
|||
use alloc::boxed::Box;
|
||||
use alloc::sync::Arc;
|
||||
use core::ffi::c_void;
|
||||
use mammoth::sync::Mutex;
|
||||
use mammoth::thread;
|
||||
|
||||
use mammoth::{mem::MemoryRegion, thread::Thread, zion::ZError};
|
||||
use mammoth::{mem::MemoryRegion, zion::ZError};
|
||||
|
||||
use crate::ahci::command::FisType;
|
||||
use crate::ahci::port::{
|
||||
|
|
|
|||
|
|
@ -3,16 +3,16 @@
|
|||
|
||||
extern crate alloc;
|
||||
|
||||
use alloc::{string::ToString, vec::Vec};
|
||||
use alloc::{string::ToString, sync::Arc, vec::Vec};
|
||||
use mammoth::{
|
||||
cap::Capability,
|
||||
define_entry, elf,
|
||||
init::{BOOT_FRAMEBUFFER_INFO_VMMO, BOOT_PCI_VMMO},
|
||||
mem::MemoryRegion,
|
||||
zion::{z_cap_t, z_err_t, ZError},
|
||||
zion::{kZionPerm_All, z_cap_t, z_err_t, ZError},
|
||||
};
|
||||
use yellowstone_yunq::YellowstoneServer;
|
||||
use yunq::server::YunqServer;
|
||||
use yunq::server::{spawn_server_thread, YunqServer};
|
||||
|
||||
mod gpt;
|
||||
mod pci;
|
||||
|
|
@ -40,20 +40,19 @@ extern "C" fn main() -> z_err_t {
|
|||
.expect("Failed to create PCI region");
|
||||
let fb_region = MemoryRegion::from_cap(Capability::take(unsafe { BOOT_FRAMEBUFFER_INFO_VMMO }))
|
||||
.expect("Failed to create Framebuffer region");
|
||||
let context = alloc::rc::Rc::new(
|
||||
let context = Arc::new(
|
||||
server::YellowstoneServerContext::new(pci_region, fb_region)
|
||||
.expect("Failed to create yellowstone context"),
|
||||
);
|
||||
let handler = server::YellowstoneServerImpl::new(context.clone());
|
||||
let server = YellowstoneServer::new(handler).expect("Couldn't create yellowstone server");
|
||||
|
||||
let server_thread = server.run_server().expect("Failed to run server");
|
||||
let client_cap = server.create_client_cap().unwrap();
|
||||
let server_thread = spawn_server_thread(server);
|
||||
|
||||
spawn_from_vmmo(
|
||||
unsafe { mammoth::init::BOOT_DENALI_VMMO },
|
||||
server
|
||||
.create_client_cap()
|
||||
.expect("Failed to create client cap for denali"),
|
||||
client_cap.duplicate(kZionPerm_All).unwrap(),
|
||||
)
|
||||
.expect("Failed to spawn denali");
|
||||
|
||||
|
|
@ -62,7 +61,7 @@ extern "C" fn main() -> z_err_t {
|
|||
|
||||
spawn_from_vmmo(
|
||||
unsafe { mammoth::init::BOOT_VICTORIA_FALLS_VMMO },
|
||||
server.create_client_cap().unwrap(),
|
||||
client_cap.duplicate(kZionPerm_All).unwrap(),
|
||||
)
|
||||
.expect("Failed to spawn victoriafalls");
|
||||
|
||||
|
|
@ -87,7 +86,11 @@ extern "C" fn main() -> z_err_t {
|
|||
let path = "/bin/".to_string() + bin_name;
|
||||
|
||||
let bin_file = victoriafalls::file::File::open(&path).unwrap();
|
||||
spawn_from_mem_region(bin_file.memory(), server.create_client_cap().unwrap()).unwrap();
|
||||
spawn_from_mem_region(
|
||||
bin_file.memory(),
|
||||
client_cap.duplicate(kZionPerm_All).unwrap(),
|
||||
)
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
server_thread.join().expect("Failed to join thread");
|
||||
|
|
|
|||
|
|
@ -1,7 +1,9 @@
|
|||
use core::cell::RefCell;
|
||||
|
||||
use alloc::rc::Rc;
|
||||
use alloc::sync::Arc;
|
||||
use alloc::{collections::BTreeMap, string::String};
|
||||
use mammoth::sync::Mutex;
|
||||
use mammoth::{cap::Capability, mem::MemoryRegion, zion::ZError};
|
||||
use victoriafalls::VFSClient;
|
||||
use yellowstone_yunq::{
|
||||
|
|
@ -15,7 +17,7 @@ pub struct YellowstoneServerContext {
|
|||
registration_semaphore: mammoth::sync::Semaphore,
|
||||
pci_reader: PciReader,
|
||||
framebuffer_info_region: MemoryRegion,
|
||||
service_map: RefCell<BTreeMap<String, Capability>>,
|
||||
service_map: Mutex<BTreeMap<String, Capability>>,
|
||||
}
|
||||
|
||||
impl YellowstoneServerContext {
|
||||
|
|
@ -52,13 +54,13 @@ impl YellowstoneServerContext {
|
|||
registration_semaphore: mammoth::sync::Semaphore::new()?,
|
||||
pci_reader: PciReader::new(pci_region),
|
||||
framebuffer_info_region: fb_region,
|
||||
service_map: BTreeMap::new().into(),
|
||||
service_map: Mutex::new(BTreeMap::new()),
|
||||
})
|
||||
}
|
||||
|
||||
pub fn wait(&self, service: &str) -> Result<(), ZError> {
|
||||
loop {
|
||||
match self.service_map.borrow().get(service) {
|
||||
match self.service_map.lock().get(service) {
|
||||
Some(_) => return Ok(()),
|
||||
None => {}
|
||||
}
|
||||
|
|
@ -68,11 +70,11 @@ impl YellowstoneServerContext {
|
|||
}
|
||||
|
||||
pub struct YellowstoneServerImpl {
|
||||
context: Rc<YellowstoneServerContext>,
|
||||
context: Arc<YellowstoneServerContext>,
|
||||
}
|
||||
|
||||
impl YellowstoneServerImpl {
|
||||
pub fn new(context: Rc<YellowstoneServerContext>) -> Self {
|
||||
pub fn new(context: Arc<YellowstoneServerContext>) -> Self {
|
||||
Self { context }
|
||||
}
|
||||
}
|
||||
|
|
@ -87,7 +89,7 @@ impl YellowstoneServerHandler for YellowstoneServerImpl {
|
|||
|
||||
self.context
|
||||
.service_map
|
||||
.borrow_mut()
|
||||
.lock()
|
||||
.insert(req.endpoint_name, Capability::take(req.endpoint_capability));
|
||||
|
||||
self.context.registration_semaphore.signal()?;
|
||||
|
|
@ -95,7 +97,7 @@ impl YellowstoneServerHandler for YellowstoneServerImpl {
|
|||
}
|
||||
|
||||
fn get_endpoint(&mut self, req: GetEndpointRequest) -> Result<Endpoint, ZError> {
|
||||
match self.context.service_map.borrow().get(&req.endpoint_name) {
|
||||
match self.context.service_map.lock().get(&req.endpoint_name) {
|
||||
Some(cap) => Ok(Endpoint {
|
||||
endpoint: cap.duplicate(Capability::PERMS_ALL)?.release(),
|
||||
}),
|
||||
|
|
@ -122,7 +124,7 @@ impl YellowstoneServerHandler for YellowstoneServerImpl {
|
|||
}
|
||||
|
||||
fn get_denali(&mut self) -> Result<DenaliInfo, ZError> {
|
||||
match self.context.service_map.borrow().get("denali") {
|
||||
match self.context.service_map.lock().get("denali") {
|
||||
Some(ep_cap) => crate::gpt::read_gpt(denali::DenaliClient::new(
|
||||
ep_cap.duplicate(Capability::PERMS_ALL).unwrap(),
|
||||
))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue