diff --git a/src/kernel/src/fs/dev/cdev.rs b/src/kernel/src/fs/dev/cdev.rs index f9bad1f8c..2353f2a3f 100644 --- a/src/kernel/src/fs/dev/cdev.rs +++ b/src/kernel/src/fs/dev/cdev.rs @@ -195,6 +195,7 @@ bitflags! { #[derive(Debug, Clone, Copy)] pub struct DriverFlags: u32 { const D_NEEDMINOR = 0x00800000; + const D_INIT = 0x80000000; } } diff --git a/src/kernel/src/fs/mod.rs b/src/kernel/src/fs/mod.rs index a64233928..5c502a0f0 100644 --- a/src/kernel/src/fs/mod.rs +++ b/src/kernel/src/fs/mod.rs @@ -25,7 +25,7 @@ pub use self::perm::*; pub use self::stat::*; pub use self::vnode::*; -mod dev; +pub mod dev; mod dirent; mod file; mod host; diff --git a/src/kernel/src/main.rs b/src/kernel/src/main.rs index 15e50c8da..1f92d2321 100644 --- a/src/kernel/src/main.rs +++ b/src/kernel/src/main.rs @@ -13,6 +13,7 @@ use crate::osem::OsemManager; use crate::process::{VProc, VProcInitError, VThread}; use crate::regmgr::RegMgr; use crate::rtld::{LoadFlags, ModuleFlags, RuntimeLinker}; +use crate::sbl::SblManager; use crate::shm::SharedMemoryManager; use crate::syscalls::Syscalls; use crate::sysctl::Sysctl; @@ -52,6 +53,7 @@ mod osem; mod process; mod regmgr; mod rtld; +mod sbl; mod shm; mod signal; mod syscalls; @@ -276,6 +278,7 @@ fn run( TimeManager::new(&mut syscalls); KernelQueueManager::new(&mut syscalls); NetManager::new(&mut syscalls); + SblManager::new(); // TODO: Get correct budget name from the PS4. let budget_id = budget.create(Budget::new("big app", ProcType::BigApp)); diff --git a/src/kernel/src/sbl/mod.rs b/src/kernel/src/sbl/mod.rs new file mode 100644 index 000000000..0a9f56d4e --- /dev/null +++ b/src/kernel/src/sbl/mod.rs @@ -0,0 +1,45 @@ +use std::sync::Arc; + +use crate::{ + errno::Errno, + fs::{make_dev, Cdev, CdevSw, DriverFlags, MakeDev, Mode, OpenFlags}, + process::VThread, + ucred::{Gid, Uid}, +}; + +#[derive(Debug)] +pub struct SblManager {} + +impl SblManager { + pub fn new() -> Arc { + let sbl = Arc::new(Self {}); + + let sbl_srv_cdevsw = Arc::new(CdevSw::new( + DriverFlags::D_INIT, + Some(Self::sbl_srv_open), + None, + )); + + let _ = make_dev( + &sbl_srv_cdevsw, + 0, + "sbl_srv", + Uid::ROOT, + Gid::ROOT, + Mode::new(0o600).unwrap(), + None, + MakeDev::MAKEDEV_ETERNAL, + ); + + sbl + } + + fn sbl_srv_open( + _: &Arc, + _: OpenFlags, + _: i32, + _: Option<&VThread>, + ) -> Result<(), Box> { + todo!() + } +}