From 038cf5aba13f07f154b0649441b701fca148e5ed Mon Sep 17 00:00:00 2001
From: Jeremy Soller <jackpot51@gmail.com>
Date: Sun, 11 Sep 2016 15:56:48 -0600
Subject: [PATCH] PCI driver WIP

---
 lib.rs             | 2 +-
 scheme/initfs.rs   | 1 +
 syscall/mod.rs     | 4 ++++
 syscall/process.rs | 5 +++++
 4 files changed, 11 insertions(+), 1 deletion(-)

diff --git a/lib.rs b/lib.rs
index e32d0880..c26a057e 100644
--- a/lib.rs
+++ b/lib.rs
@@ -121,7 +121,7 @@ pub extern fn userspace_init() {
     assert_eq!(syscall::open(b"debug:", 0), Ok(1));
     assert_eq!(syscall::open(b"debug:", 0), Ok(2));
 
-    syscall::exec(b"initfs:bin/init", &[]).expect("failed to execute initfs:init");
+    syscall::exec(b"initfs:bin/pcid", &[]).expect("failed to execute initfs:init");
 
     panic!("initfs:init returned")
 }
diff --git a/scheme/initfs.rs b/scheme/initfs.rs
index 38fefc4a..cedca688 100644
--- a/scheme/initfs.rs
+++ b/scheme/initfs.rs
@@ -19,6 +19,7 @@ impl InitFsScheme {
         let mut files: BTreeMap<&'static [u8], &'static [u8]> = BTreeMap::new();
 
         files.insert(b"bin/init", include_bytes!("../../build/userspace/init"));
+        files.insert(b"bin/pcid", include_bytes!("../../build/userspace/pcid"));
         files.insert(b"etc/init.rc", b"echo testing\n");
 
         InitFsScheme {
diff --git a/syscall/mod.rs b/syscall/mod.rs
index 91f43885..7d051492 100644
--- a/syscall/mod.rs
+++ b/syscall/mod.rs
@@ -32,6 +32,8 @@ pub enum Call {
     GetPid = 20,
     /// Set process break
     Brk = 45,
+    /// Set process I/O privilege level
+    Iopl = 110,
     /// Yield to scheduler
     SchedYield = 158
 }
@@ -49,6 +51,7 @@ impl Call {
             11 => Ok(Call::Exec),
             20 => Ok(Call::GetPid),
             45 => Ok(Call::Brk),
+            110 => Ok(Call::Iopl),
             158 => Ok(Call::SchedYield),
             _ => Err(Error::NoCall)
         }
@@ -106,6 +109,7 @@ pub fn handle(a: usize, b: usize, c: usize, d: usize, e: usize, _f: usize) -> Re
         Call::Exec => exec(convert_slice(b as *const u8, c)?, convert_slice(d as *const [usize; 2], e)?),
         Call::GetPid => getpid(),
         Call::Brk => brk(b),
+        Call::Iopl => iopl(b),
         Call::SchedYield => sched_yield()
     }
 }
diff --git a/syscall/process.rs b/syscall/process.rs
index f357d36c..452edc2f 100644
--- a/syscall/process.rs
+++ b/syscall/process.rs
@@ -105,6 +105,11 @@ pub fn getpid() -> Result<usize> {
     Ok(context.id)
 }
 
+pub fn iopl(_level: usize) -> Result<usize> {
+    //TODO
+    Ok(0)
+}
+
 pub fn sched_yield() -> Result<usize> {
     unsafe { context::switch(); }
     Ok(0)
-- 
GitLab