1use std::io;
2
3use super::{Config, Driver};
4use crate::backend::Backend;
5use crate::backend::ops::ext::ExtBackend;
6
7pub trait DriverExt: Sized {
8 fn new(cfg: Config) -> io::Result<Self>;
9 fn init_thread(cpu_id: u16) -> io::Result<()>;
10 fn allowed_cpus() -> io::Result<Vec<u16>>;
11}
12
13impl DriverExt for Driver {
14 fn new(cfg: Config) -> io::Result<Self> {
15 cfg.validate()?;
16 let (state, slots) = <Backend as ExtBackend>::create(&cfg)?;
17 Driver::from_state(
18 state,
19 slots,
20 cfg.ready_slots,
21 cfg.timer_slots,
22 cfg.recv.entries as usize,
23 )
24 }
25
26 fn init_thread(cpu_id: u16) -> io::Result<()> {
27 <Backend as ExtBackend>::init_thread(cpu_id)
28 }
29
30 fn allowed_cpus() -> io::Result<Vec<u16>> {
31 <Backend as ExtBackend>::allowed_cpus()
32 }
33}