Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Initialize RngManager #670

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/kernel/src/fs/dev/cdev.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ bitflags! {
#[derive(Debug, Clone, Copy)]
pub struct DriverFlags: u32 {
const D_NEEDMINOR = 0x00800000;
const D_INIT = 0x80000000;
}
}

Expand Down
3 changes: 3 additions & 0 deletions src/kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ use crate::net::NetManager;
use crate::osem::OsemManager;
use crate::process::{VProc, VProcInitError, VThread};
use crate::regmgr::RegMgr;
use crate::rng::RngManager;
use crate::rtld::{LoadFlags, ModuleFlags, RuntimeLinker};
use crate::shm::SharedMemoryManager;
use crate::syscalls::Syscalls;
Expand Down Expand Up @@ -51,6 +52,7 @@ mod net;
mod osem;
mod process;
mod regmgr;
mod rng;
mod rtld;
mod shm;
mod signal;
Expand Down Expand Up @@ -276,6 +278,7 @@ fn run<E: crate::ee::ExecutionEngine>(
TimeManager::new(&mut syscalls);
KernelQueueManager::new(&mut syscalls);
NetManager::new(&mut syscalls);
RngManager::new();

// TODO: Get correct budget name from the PS4.
let budget_id = budget.create(Budget::new("big app", ProcType::BigApp));
Expand Down
37 changes: 37 additions & 0 deletions src/kernel/src/rng/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
use std::sync::Arc;

use crate::{
errno::Errno,
fs::{make_dev, Cdev, CdevSw, DriverFlags, MakeDev, Mode, OpenFlags},
process::VThread,
ucred::{Gid, Uid},
};

pub struct RngManager {}

impl RngManager {
pub fn new() -> () {
let rng_cdevsw = Arc::new(CdevSw::new(DriverFlags::D_INIT, Some(Self::rng_open), None));

let _rng = make_dev(
&rng_cdevsw,
0,
"rng",
Uid::ROOT,
Gid::ROOT,
Mode::new(0o444).unwrap(),
None,
MakeDev::MAKEDEV_ETERNAL,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What I saw on the PS4 is 0 for this one.

);
}

fn rng_open(
_rng: &Arc<Cdev>,
_flags: OpenFlags,
_mode: i32,
_td: Option<&VThread>,
Comment on lines +29 to +32
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better to use _ for all parameters here.

) -> Result<(), Box<dyn Errno>> {
// true to PS4
Ok(())
}
}