[Yellowstone] Wireframe for moving yellowstone to rust.

This commit is contained in:
Drew Galbraith 2024-08-17 20:19:45 -07:00
parent 0aa4a1f5f1
commit c9b484089e
24 changed files with 265 additions and 25 deletions

View file

@ -7,4 +7,4 @@ edition = "2021"
mammoth = { path = "../../lib/mammoth" }
victoriafalls = { path = "../../lib/victoriafalls" }
voyageurs = { path = "../../lib/voyageurs" }
yellowstone = { path = "../../lib/yellowstone" }
yellowstone-yunq = { path = "../../lib/yellowstone" }

View file

@ -1,5 +1,5 @@
use mammoth::{mem::MemoryRegion, zion::ZError};
use yellowstone::FramebufferInfo;
use yellowstone_yunq::FramebufferInfo;
pub struct Framebuffer {
fb_info: FramebufferInfo,

View file

@ -20,7 +20,7 @@ define_entry!();
extern "C" fn main() -> z_err_t {
debug!("Teton Starting");
let yellowstone = yellowstone::from_init_endpoint();
let yellowstone = yellowstone_yunq::from_init_endpoint();
let framebuffer_info = yellowstone
.get_framebuffer_info()
.expect("Failed to get framebuffer info.");

View file

@ -0,0 +1,12 @@
[package]
name = "yellowstone"
version = "0.1.0"
edition = "2021"
[dependencies]
mammoth = { path = "../../lib/mammoth" }
denali = { path = "../../lib/denali" }
victoriafalls = { path = "../../lib/victoriafalls" }
voyageurs = { path = "../../lib/voyageurs" }
yellowstone-yunq = { path = "../../lib/yellowstone" }
yunq = { path = "../../lib/yunq" }

View file

@ -0,0 +1,48 @@
#![no_std]
#![no_main]
extern crate alloc;
use mammoth::{
cap::Capability,
define_entry, elf,
zion::{kZionPerm_Read, z_cap_t, z_err_t, ZError},
};
use yellowstone_yunq::YellowstoneServer;
use yunq::server::YunqServer;
mod server;
define_entry!();
fn spawn_from_vmmo(vmmo_cap: z_cap_t, server_cap: Capability) -> Result<(), ZError> {
let region = mammoth::mem::MemoryRegion::from_cap(Capability::take(vmmo_cap))?;
elf::spawn_process_from_elf_and_init(region.slice(), server_cap)?;
Ok(())
}
#[no_mangle]
extern "C" fn main() -> z_err_t {
let context = alloc::rc::Rc::new(
server::YellowstoneServerContext::new().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");
spawn_from_vmmo(
unsafe { mammoth::init::BOOT_DENALI_VMMO },
server
.create_client_cap()
.expect("Failed to create client cap for denali"),
)
.expect("Failed to spawn denali");
context.wait_denali().expect("Failed to wait for denali");
mammoth::debug!("Denali registered.");
server_thread.join().expect("Failed to join thread");
0
}

View file

@ -0,0 +1,58 @@
use alloc::rc::Rc;
use mammoth::zion::ZError;
use yellowstone_yunq::{
AhciInfo, DenaliInfo, Endpoint, FramebufferInfo, GetEndpointRequest, RegisterEndpointRequest,
XhciInfo, YellowstoneServerHandler,
};
pub struct YellowstoneServerContext {
denali_semaphore: mammoth::sync::Semaphore,
}
impl YellowstoneServerContext {
pub fn new() -> Result<Self, ZError> {
Ok(Self {
denali_semaphore: mammoth::sync::Semaphore::new()?,
})
}
pub fn wait_denali(&self) -> Result<(), ZError> {
self.denali_semaphore.wait()
}
}
pub struct YellowstoneServerImpl {
context: Rc<YellowstoneServerContext>,
}
impl YellowstoneServerImpl {
pub fn new(context: Rc<YellowstoneServerContext>) -> Self {
Self { context }
}
}
impl YellowstoneServerHandler for YellowstoneServerImpl {
fn register_endpoint(&self, req: &RegisterEndpointRequest) -> Result<(), ZError> {
todo!()
}
fn get_endpoint(&self, req: &GetEndpointRequest) -> Result<Endpoint, ZError> {
todo!()
}
fn get_ahci_info(&self) -> Result<AhciInfo, ZError> {
todo!()
}
fn get_xhci_info(&self) -> Result<XhciInfo, ZError> {
todo!()
}
fn get_framebuffer_info(&self) -> Result<FramebufferInfo, ZError> {
todo!()
}
fn get_denali(&self) -> Result<DenaliInfo, ZError> {
todo!()
}
}