diff --git a/rust/lib/yellowstone/build.rs b/rust/lib/yellowstone/build.rs new file mode 100644 index 0000000..a072a3a --- /dev/null +++ b/rust/lib/yellowstone/build.rs @@ -0,0 +1,18 @@ +use std::process::Command; + +fn main() { + let out = std::env::var("OUT_DIR").unwrap() + "/yunq.rs"; + + let status = Command::new("cargo") + .current_dir("../../../yunq/rust") + .arg("run") + .arg("--") + .arg("--input-path") + .arg("../../sys/yellowstone/lib/yellowstone/yellowstone.yunq") + .arg("--output-path") + .arg(out) + .status() + .expect("Failed to start execution"); + + assert!(status.success()); +} diff --git a/rust/lib/yellowstone/src/lib.rs b/rust/lib/yellowstone/src/lib.rs index 5e255b3..3cec9d6 100644 --- a/rust/lib/yellowstone/src/lib.rs +++ b/rust/lib/yellowstone/src/lib.rs @@ -1,105 +1,5 @@ #![no_std] -extern crate alloc; -use alloc::string::String; -use alloc::string::ToString; -use mammoth::syscall::z_cap_t; -use mammoth::syscall::ZError; -use yunq::ByteBuffer; -use yunq::YunqMessage; -use yunq_derive::YunqMessage; -#[derive(YunqMessage)] -pub struct RegisterEndpointRequest { - pub endpoint_name: String, - pub endpoint_capability: z_cap_t, -} -#[derive(YunqMessage)] -pub struct GetEndpointRequest { - pub endpoint_name: String, -} -#[derive(YunqMessage)] -pub struct Endpoint { - pub endpoint: z_cap_t, -} -#[derive(YunqMessage)] -pub struct AhciInfo { - pub ahci_region: z_cap_t, - pub region_length: u64, -} -#[derive(YunqMessage)] -pub struct XhciInfo { - pub xhci_region: z_cap_t, - pub region_length: u64, -} -#[derive(YunqMessage)] -pub struct FramebufferInfo { - pub address_phys: u64, - pub width: u64, - pub height: u64, - pub pitch: u64, - pub bpp: u64, - pub memory_model: u64, - pub red_mask_size: u64, - pub red_mask_shift: u64, - pub green_mask_size: u64, - pub green_mask_shift: u64, - pub blue_mask_size: u64, - pub blue_mask_shift: u64, -} -#[derive(YunqMessage)] -pub struct DenaliInfo { - pub denali_endpoint: z_cap_t, - pub device_id: u64, - pub lba_offset: u64, -} -pub struct YellowstoneClient { - endpoint_cap: z_cap_t, - byte_buffer: ByteBuffer<0x1000>, -} -impl YellowstoneClient { - pub fn new(endpoint_cap: z_cap_t) -> Self { - Self { - endpoint_cap, - byte_buffer: ByteBuffer::new(), - } - } - pub fn register_endpoint( - &mut self, - req: &RegisterEndpointRequest, - ) -> Result { - yunq::client::call_endpoint(req, &mut self.byte_buffer, self.endpoint_cap) - } - pub fn get_endpoint( - &mut self, - req: &GetEndpointRequest, - ) -> Result { - yunq::client::call_endpoint(req, &mut self.byte_buffer, self.endpoint_cap) - } - pub fn get_ahci_info(&mut self) -> Result { - yunq::client::call_endpoint( - &yunq::message::Empty {}, - &mut self.byte_buffer, - self.endpoint_cap, - ) - } - pub fn get_xhci_info(&mut self) -> Result { - yunq::client::call_endpoint( - &yunq::message::Empty {}, - &mut self.byte_buffer, - self.endpoint_cap, - ) - } - pub fn get_framebuffer_info(&mut self) -> Result { - yunq::client::call_endpoint( - &yunq::message::Empty {}, - &mut self.byte_buffer, - self.endpoint_cap, - ) - } - pub fn get_denali(&mut self) -> Result { - yunq::client::call_endpoint( - &yunq::message::Empty {}, - &mut self.byte_buffer, - self.endpoint_cap, - ) - } -} + +use core::include; + +include!(concat!(env!("OUT_DIR"), "/yunq.rs")); diff --git a/yunq/rust/src/codegen.rs b/yunq/rust/src/codegen.rs index 2b2ca34..0051047 100644 --- a/yunq/rust/src/codegen.rs +++ b/yunq/rust/src/codegen.rs @@ -74,7 +74,6 @@ fn generate_interface(interface: &Interface) -> TokenStream { pub fn generate_code(ast: &Vec) -> String { let prelude = quote! { - #![no_std] extern crate alloc;