#![feature(const_fn)]
#![no_main]
#![no_std]

extern crate common;
extern crate support;
extern crate hil;
extern crate process;
extern crate platform;

mod sched;

pub mod syscall;

#[allow(improper_ctypes)]
extern {
    static _sapps : usize;
}

#[no_mangle]
pub extern fn main() {
    use process::Process;
    use process::AppId;

    let mut platform = unsafe {
        platform::init()
    };


    let processes = unsafe {
        process::process::PROCS = [Process::create(&_sapps)];
        &mut process::process::PROCS
    };

    loop {
        unsafe {
            platform.service_pending_interrupts();

            for (i, p) in processes.iter_mut().enumerate() {
                p.as_mut().map(|process| {
                    sched::do_process(platform, process, AppId::new(i));
                });
            }

            support::atomic(|| {
                if !platform.has_pending_interrupts() {
                    support::wfi();
                }
            })
        };
    }
}


#![feature(const_fn)]
#![no_main]
#![no_std]

extern crate common;
extern crate support;
extern crate hil;
extern crate process;
extern crate platform;

mod sched;

pub mod syscall;

#[allow(improper_ctypes)]
extern {
    static _sapps : usize;
}

#[no_mangle]
pub extern fn main() {
    use process::Process;
    use process::AppId;

    let processes = unsafe {
        process::process::PROCS = [Process::create(&_sapps)];
        &mut process::process::PROCS
    };

    let mut platform = unsafe {
        platform::init()
    };

    loop {
        unsafe {
            platform.service_pending_interrupts();

            for (i, p) in processes.iter_mut().enumerate() {
                p.as_mut().map(|process| {
                    sched::do_process(platform, process, AppId::new(i));
                });
            }

            support::atomic(|| {
                if !platform.has_pending_interrupts() {
                    support::wfi();
                }
            })
        };
    }
}


--- 
+++ 
@@ -22,13 +22,14 @@
     use process::Process;
     use process::AppId;
 
+    let mut platform = unsafe {
+        platform::init()
+    };
+
+
     let processes = unsafe {
         process::process::PROCS = [Process::create(&_sapps)];
         &mut process::process::PROCS
-    };
-
-    let mut platform = unsafe {
-        platform::init()
     };
 
     loop {
Load the platform before apps

That way, if there is an error loading the apps, the console is already
configured and we can panic with useful output
