-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
154 additions
and
116 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use crate::{ | ||
errno::EINVAL, | ||
idt::Entry, | ||
info, | ||
process::VProc, | ||
syscalls::{SysErr, SysIn, SysOut, Syscalls}, | ||
}; | ||
use std::sync::Arc; | ||
|
||
pub struct NamedObjManager { | ||
proc: Arc<VProc>, | ||
} | ||
|
||
impl NamedObjManager { | ||
pub fn new(sys: &mut Syscalls, proc: &Arc<VProc>) -> Arc<Self> { | ||
let namedobj = Arc::new(Self { proc: proc.clone() }); | ||
|
||
sys.register(557, &namedobj, Self::sys_namedobj_create); | ||
|
||
namedobj | ||
} | ||
|
||
fn sys_namedobj_create(self: &Arc<Self>, i: &SysIn) -> Result<SysOut, SysErr> { | ||
// Get arguments. | ||
let name = unsafe { i.args[0].to_str(32) }?.ok_or(SysErr::Raw(EINVAL))?; | ||
let data: usize = i.args[1].into(); | ||
let flags: u32 = i.args[2].try_into().unwrap(); | ||
|
||
// Allocate the entry. | ||
let mut table = self.proc.objects_mut(); | ||
|
||
let obj = NamedObj::new(name, data); | ||
|
||
let id = table.alloc_infallible(|_| { | ||
Entry::new( | ||
Some(name.to_owned()), | ||
Arc::new(obj), | ||
(flags as u16) | 0x1000, | ||
) | ||
}); | ||
|
||
info!( | ||
"Named object '{}' (ID = {}) was created with data = {:#x} and flags = {:#x}.", | ||
name, id, data, flags | ||
); | ||
|
||
Ok(id.into()) | ||
} | ||
} | ||
|
||
#[derive(Debug)] | ||
pub struct NamedObj { | ||
name: String, | ||
data: usize, | ||
} | ||
|
||
impl NamedObj { | ||
pub fn new(name: impl Into<String>, data: usize) -> Self { | ||
Self { | ||
name: name.into(), | ||
data, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.