Fix implementation of clone and exec. Now the init process can load and execute the pci driver

This commit is contained in:
Jeremy Soller 2016-09-15 08:35:07 -06:00
parent b01a918556
commit 33e098c124
9 changed files with 233 additions and 78 deletions

View file

@ -100,6 +100,8 @@ extern crate bitflags;
extern crate goblin;
extern crate spin;
use core::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
/// Context management
pub mod context;
@ -117,6 +119,14 @@ pub mod syscall;
#[cfg(test)]
pub mod tests;
#[thread_local]
static CPU_ID: AtomicUsize = ATOMIC_USIZE_INIT;
#[inline(always)]
pub fn cpu_id() -> usize {
CPU_ID.load(Ordering::Relaxed)
}
pub extern fn userspace_init() {
assert_eq!(syscall::open(b"debug:", 0), Ok(0));
assert_eq!(syscall::open(b"debug:", 0), Ok(1));
@ -129,6 +139,8 @@ pub extern fn userspace_init() {
#[no_mangle]
pub extern fn kmain() {
CPU_ID.store(0, Ordering::SeqCst);
context::init();
let pid = syscall::getpid();
@ -144,15 +156,17 @@ pub extern fn kmain() {
}
}
unsafe { context::switch(); }
loop {
unsafe { interrupt::enable_and_halt(); }
unsafe { context::switch(); }
}
}
#[no_mangle]
pub extern fn kmain_ap(id: usize) {
CPU_ID.store(id, Ordering::SeqCst);
context::init();
let pid = syscall::getpid();