twizzler_driver/
controller.rsuse std::sync::Arc;
use twizzler_abi::device::MailboxPriority;
use crate::device::{
events::{DeviceEventStream, InterruptAllocationError, InterruptInfo},
Device,
};
pub struct DeviceController {
device: Arc<Device>,
events: Arc<DeviceEventStream>,
}
impl DeviceController {
pub fn events(&self) -> &DeviceEventStream {
&self.events
}
pub fn device(&self) -> &Device {
&self.device
}
pub fn new_from_device(device: Device) -> Self {
let device = Arc::new(device);
Self {
device: device.clone(),
events: Arc::new(DeviceEventStream::new(device)),
}
}
pub fn allocate_interrupt(&self) -> Result<InterruptInfo, InterruptAllocationError> {
self.events.allocate_interrupt()
}
pub fn check_mailbox(&self, pri: MailboxPriority) -> Option<u64> {
self.events.check_mailbox(pri)
}
pub async fn next_msg(&self, min: MailboxPriority) -> (MailboxPriority, u64) {
self.events.next_msg(min).await
}
}