Implement user schemes. Example in pcid. Currently deadlocks in UserInner
This commit is contained in:
parent
c512d04378
commit
791dbfa7ad
9 changed files with 231 additions and 79 deletions
|
@ -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
29
syscall/src/scheme.rs
Normal 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]
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue