Implement yunq server in rust.

This commit is contained in:
Drew Galbraith 2024-07-31 19:59:46 -07:00
parent dbc4e7e2ad
commit 76f8795a46
12 changed files with 312 additions and 23 deletions

View file

@ -8,11 +8,46 @@ use mammoth::debug;
use mammoth::define_entry;
use mammoth::thread;
use mammoth::zion::z_err_t;
use mammoth::zion::ZError;
use yellowstone::GetEndpointRequest;
use yellowstone::YellowstoneClient;
use yellowstone::YellowstoneServer;
use yunq::server::YunqServer;
define_entry!();
struct YellowstoneImpl {}
impl yellowstone::YellowstoneServerHandler for YellowstoneImpl {
fn register_endpoint(&self, req: &yellowstone::RegisterEndpointRequest) -> Result<(), ZError> {
debug!("{}", req.endpoint_name);
Ok(())
}
fn get_endpoint(&self, req: &GetEndpointRequest) -> Result<yellowstone::Endpoint, ZError> {
debug!("{}", req.endpoint_name);
Ok(yellowstone::Endpoint {
endpoint: unsafe { mammoth::init::SELF_PROC_CAP },
})
}
fn get_ahci_info(&self) -> Result<yellowstone::AhciInfo, ZError> {
todo!()
}
fn get_xhci_info(&self) -> Result<yellowstone::XhciInfo, ZError> {
todo!()
}
fn get_framebuffer_info(&self) -> Result<yellowstone::FramebufferInfo, ZError> {
todo!()
}
fn get_denali(&self) -> Result<yellowstone::DenaliInfo, ZError> {
todo!()
}
}
#[no_mangle]
pub extern "C" fn main() -> z_err_t {
debug!("Testing!");
@ -33,9 +68,25 @@ pub extern "C" fn main() -> z_err_t {
let e: thread::ThreadEntry = |_| {
debug!("Testing 1 2 3");
};
let t = thread::Thread::spawn(&e, core::ptr::null()).expect("Failed to spawn thread");
let t = thread::Thread::spawn(e, core::ptr::null()).expect("Failed to spawn thread");
t.join().expect("Failed to wait.");
let server = YellowstoneServer::new(YellowstoneImpl {}).expect("Failed to create server");
let mut yellowstone = YellowstoneClient::new(server.endpoint_cap());
let t = server.run_server().expect("Failed to start server");
let endpoint = yellowstone
.get_endpoint(&GetEndpointRequest {
endpoint_name: "test".to_string(),
})
.expect("Failed to get endpoint");
debug!("{:#x}", endpoint.endpoint);
t.join().expect("Failed to wait");
0
}