use alloc::sync::Arc;
use libk_util::OneTimeInit;
use object::KObject;

use crate::vfs::NodeRef;

pub mod attribute;
pub mod nodes;
pub mod object;

static ROOT: OneTimeInit<NodeRef> = OneTimeInit::new();

pub fn root() -> &'static NodeRef {
    ROOT.get()
}

pub fn kernel() -> Option<&'static Arc<KObject<()>>> {
    object::KERNEL_OBJECT.try_get()
}

pub fn debug() -> Option<&'static Arc<KObject<()>>> {
    object::DEBUG_OBJECT.try_get()
}

pub fn device() -> Option<&'static Arc<KObject<()>>> {
    object::DEVICE_OBJECT.try_get()
}

pub fn bus() -> Option<&'static Arc<KObject<()>>> {
    object::BUS_OBJECT.try_get()
}

pub fn proc() -> Option<&'static Arc<KObject<()>>> {
    object::PROC_OBJECT.try_get()
}

pub fn init() {
    ROOT.init(object::setup_fixed_objects());
}
