twizzler_driver/
lib.rs

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