#![no_std] #![no_main] extern crate alloc; use alloc::sync::Arc; use mammoth::{ define_entry, sync::Mutex, task::{Executor, Task}, zion::z_err_t, }; use denali::ahci::{identify_ports, spawn_irq_thread, AhciController}; use denali::{denali_server::DenaliServerImpl, AsyncDenaliServer}; use yellowstone_yunq::RegisterEndpointRequest; use yunq::server::AsyncYunqServer; define_entry!(); #[no_mangle] extern "C" fn main() -> z_err_t { mammoth::debug!("IN Denali!"); let yellowstone = yellowstone_yunq::from_init_endpoint(); let ahci_info = yellowstone .get_ahci_info() .expect("Failed to get ahci info"); let ahci_controller = Arc::new(AhciController::new(mammoth::cap::Capability::take( ahci_info.ahci_region, ))); let executor = Arc::new(Mutex::new(Executor::new())); executor .clone() .lock() .spawn(Task::new(identify_ports(ahci_controller.clone()))); let thread = spawn_irq_thread(ahci_controller.clone()); let denali_server = Arc::new(AsyncDenaliServer::new(DenaliServerImpl::new(ahci_controller.clone())).unwrap()); let server_thread = yunq::server::spawn_async_server_thread( denali_server.clone(), executor.lock().new_spawner(), ); let yellowstone = yellowstone_yunq::from_init_endpoint(); yellowstone .register_endpoint(&RegisterEndpointRequest { endpoint_name: "denali".into(), endpoint_capability: denali_server.create_client_cap().unwrap().release(), }) .unwrap(); executor.clone().lock().run(); thread.join().expect("Failed to wait on irq thread."); server_thread .join() .expect("Failed to wait on server thread."); 0 }