twizzler_driver/
lib.rs

1#![feature(vec_into_raw_parts)]
2#![feature(auto_traits)]
3#![feature(negative_impls)]
4use device::DeviceChildrenIterator;
5use twizzler::object::ObjID;
6use twizzler_abi::kso::{KactionCmd, KactionFlags, KactionGenericCmd};
7
8mod arch;
9pub mod bus;
10mod controller;
11pub mod device;
12pub mod dma;
13pub mod request;
14
15pub use controller::DeviceController;
16
17/// A handle for the root of the bus tree.
18pub struct BusTreeRoot {
19    root_id: ObjID,
20}
21
22impl BusTreeRoot {
23    /// Get the children of the bus tree.
24    pub fn children(&self) -> DeviceChildrenIterator {
25        DeviceChildrenIterator {
26            id: self.root_id,
27            pos: 0,
28        }
29    }
30}
31
32/// Get a handle to the root of the bus tree.
33pub fn get_bustree_root() -> BusTreeRoot {
34    let cmd = KactionCmd::Generic(KactionGenericCmd::GetKsoRoot);
35    let id = twizzler_abi::syscall::sys_kaction(cmd, None, 0, 0, KactionFlags::empty())
36        .expect("failed to get device root")
37        .unwrap_objid();
38    BusTreeRoot { root_id: id }
39}