Skip to content

Commit

Permalink
Implements direct match for RegMgr::decode_key() (#341)
Browse files Browse the repository at this point in the history
  • Loading branch information
ultimaweapon authored Sep 14, 2023
1 parent 56b2bed commit 203b6f9
Show file tree
Hide file tree
Showing 6 changed files with 652 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/kernel/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ mod rtld;
mod signal;
mod syscalls;
mod sysctl;
mod ucred;

fn main() -> ExitCode {
log::init();
Expand Down
3 changes: 2 additions & 1 deletion src/kernel/src/process/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ pub use self::appinfo::*;
pub use self::rlimit::*;
pub use self::thread::*;

use crate::ucred::Ucred;
use gmtx::{GroupMutex, MutexGroup};
use llt::{SpawnError, Thread};
use std::num::NonZeroI32;
Expand Down Expand Up @@ -72,7 +73,7 @@ impl VProc {
// Lock the list before spawn the thread to prevent race condition if the new thread run
// too fast and found out they is not in our list.
let mut threads = self.threads.write();
let td = Arc::new(VThread::new(Self::new_id(), &self.mtxg));
let td = Arc::new(VThread::new(Self::new_id(), Ucred::new(), &self.mtxg));
let active = Box::new(ActiveThread {
proc: self,
id: td.id(),
Expand Down
9 changes: 8 additions & 1 deletion src/kernel/src/process/thread.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use crate::signal::SignalSet;
use crate::ucred::Ucred;
use gmtx::{GroupMutex, GroupMutexWriteGuard, MutexGroup};
use llt::{SpawnError, Thread};
use std::num::NonZeroI32;
Expand All @@ -11,14 +12,16 @@ use tls::{Local, Tls};
#[derive(Debug)]
pub struct VThread {
id: NonZeroI32, // td_tid
cred: Ucred, // td_ucred
sigmask: GroupMutex<SignalSet>, // td_sigmask
}

impl VThread {
pub(super) fn new(id: NonZeroI32, mtxg: &Arc<MutexGroup>) -> Self {
pub(super) fn new(id: NonZeroI32, cred: Ucred, mtxg: &Arc<MutexGroup>) -> Self {
// TODO: Check how the PS4 actually allocate the thread ID.
Self {
id,
cred,
sigmask: mtxg.new_member(SignalSet::default()),
}
}
Expand All @@ -33,6 +36,10 @@ impl VThread {
self.id
}

pub fn cred(&self) -> &Ucred {
&self.cred
}

pub fn sigmask_mut(&self) -> GroupMutexWriteGuard<'_, SignalSet> {
self.sigmask.write()
}
Expand Down
Loading

0 comments on commit 203b6f9

Please sign in to comment.