blob: 1b93b0df7e3c892da565c7575a7ec31c7fbfda0f [file] [log] [blame]
//! Stub Shodan mailbox driver capsule.
use kernel::{AppId, AppSlice, Callback, Driver, Grant, ReturnCode, Shared};
#[derive(Default)]
pub struct AppData {
pub buffer: Option<AppSlice<Shared, u8>>,
}
pub struct MailboxCapsule {
pub app_data_grant: Grant<AppData>,
}
impl Driver for MailboxCapsule {
fn subscribe(&self, _: usize, _: Option<Callback>, _: AppId) -> ReturnCode {
ReturnCode::EINVAL
}
fn command(&self, _minor_num: usize, _r2: usize, _r3: usize, _app_id: AppId) -> ReturnCode {
return ReturnCode::EINVAL;
}
fn allow(&self, app_id: AppId, _: usize, slice: Option<AppSlice<Shared, u8>>) -> ReturnCode {
let _ = self.app_data_grant.enter(app_id, |app_data, _| {
app_data.buffer = slice;
});
return ReturnCode::SUCCESS;
}
}