| //! Trivial Shodan elf loader capsule |
| |
| use kernel::{AppId, AppSlice, Callback, Driver, ReturnCode, Shared}; |
| use matcha_hal::dprintf; |
| use matcha_hal::mailbox_hal::MailboxHAL; |
| |
| pub struct ElfLoaderCapsule { |
| mailbox_hal: Option<&'static dyn MailboxHAL>, |
| } |
| |
| impl ElfLoaderCapsule { |
| pub fn new() -> Self { |
| Self { mailbox_hal: None } |
| } |
| |
| pub fn set_mailbox(&mut self, mailbox: &'static dyn MailboxHAL) { |
| self.mailbox_hal = Some(mailbox); |
| } |
| } |
| |
| impl Driver for ElfLoaderCapsule { |
| fn subscribe(&self, _: usize, _: Option<Callback>, _: AppId) -> ReturnCode { |
| return ReturnCode::EINVAL; |
| } |
| |
| fn command(&self, minor_num: usize, _r2: usize, _r3: usize, _app_id: AppId) -> ReturnCode { |
| dprintf!("ElfLoaderCapsule::command()\n"); |
| |
| if minor_num == matcha_config::CMD_ELFLOADER_BOOT_SEL4 { |
| self.mailbox_hal.map(|mb| matcha_utils::load_sel4(mb)); |
| return ReturnCode::SUCCESS; |
| } |
| |
| return ReturnCode::EINVAL; |
| } |
| |
| fn allow(&self, _: AppId, _: usize, _: Option<AppSlice<Shared, u8>>) -> ReturnCode { |
| return ReturnCode::EINVAL; |
| } |
| } |