Implement user schemes. Example in pcid. Currently deadlocks in UserInner

This commit is contained in:
Jeremy Soller 2016-09-20 08:47:16 -06:00
parent c512d04378
commit 791dbfa7ad
9 changed files with 231 additions and 79 deletions

View file

@ -3,16 +3,19 @@
pub use self::arch::*;
pub use self::error::*;
pub use self::scheme::*;
#[cfg(target_arch = "x86")]
#[path="x86.rs"]
pub mod arch;
mod arch;
#[cfg(target_arch = "x86_64")]
#[path="x86_64.rs"]
pub mod arch;
mod arch;
pub mod error;
mod error;
mod scheme;
pub const SYS_BRK: usize = 45;
pub const SYS_CHDIR: usize = 12;

29
syscall/src/scheme.rs Normal file
View file

@ -0,0 +1,29 @@
use core::ops::{Deref, DerefMut};
use core::{mem, slice};
#[derive(Copy, Clone, Debug, Default)]
#[repr(packed)]
pub struct Packet {
pub id: usize,
pub a: usize,
pub b: usize,
pub c: usize,
pub d: usize
}
impl Deref for Packet {
type Target = [u8];
fn deref(&self) -> &[u8] {
unsafe {
slice::from_raw_parts(self as *const Packet as *const u8, mem::size_of::<Packet>()) as &[u8]
}
}
}
impl DerefMut for Packet {
fn deref_mut(&mut self) -> &mut [u8] {
unsafe {
slice::from_raw_parts_mut(self as *mut Packet as *mut u8, mem::size_of::<Packet>()) as &mut [u8]
}
}
}