pub trait Driver: Send + Sync {
// Required methods
fn name(&self) -> &str;
fn supported_classes(&self) -> Vec<DeviceClass>;
fn supports_device(&self, device: &DeviceInfo) -> bool;
fn probe(&mut self, device: &DeviceInfo) -> Result<(), KernelError>;
fn attach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>;
fn detach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>;
fn suspend(&mut self) -> Result<(), KernelError>;
fn resume(&mut self) -> Result<(), KernelError>;
fn handle_interrupt(&mut self, irq: u8) -> Result<(), KernelError>;
fn read(
&mut self,
offset: u64,
buffer: &mut [u8],
) -> Result<usize, KernelError>;
fn write(&mut self, offset: u64, data: &[u8]) -> Result<usize, KernelError>;
fn ioctl(&mut self, cmd: u32, arg: u64) -> Result<u64, KernelError>;
}Expand description
Driver operations trait
Required Methods§
Sourcefn supported_classes(&self) -> Vec<DeviceClass>
fn supported_classes(&self) -> Vec<DeviceClass>
Get supported device classes
Sourcefn supports_device(&self, device: &DeviceInfo) -> bool
fn supports_device(&self, device: &DeviceInfo) -> bool
Check if driver supports a device
Sourcefn probe(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
fn probe(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
Probe device
Sourcefn attach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
fn attach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
Attach to device
Sourcefn detach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
fn detach(&mut self, device: &DeviceInfo) -> Result<(), KernelError>
Detach from device
Sourcefn suspend(&mut self) -> Result<(), KernelError>
fn suspend(&mut self) -> Result<(), KernelError>
Suspend device
Sourcefn resume(&mut self) -> Result<(), KernelError>
fn resume(&mut self) -> Result<(), KernelError>
Resume device
Sourcefn handle_interrupt(&mut self, irq: u8) -> Result<(), KernelError>
fn handle_interrupt(&mut self, irq: u8) -> Result<(), KernelError>
Handle interrupt
Sourcefn read(&mut self, offset: u64, buffer: &mut [u8]) -> Result<usize, KernelError>
fn read(&mut self, offset: u64, buffer: &mut [u8]) -> Result<usize, KernelError>
Read from device
Sourcefn write(&mut self, offset: u64, data: &[u8]) -> Result<usize, KernelError>
fn write(&mut self, offset: u64, data: &[u8]) -> Result<usize, KernelError>
Write to device
Sourcefn ioctl(&mut self, cmd: u32, arg: u64) -> Result<u64, KernelError>
fn ioctl(&mut self, cmd: u32, arg: u64) -> Result<u64, KernelError>
Device control (ioctl)