osiris/
uspace.rs

1//! This module provides access to userspace structures and services.
2
3use crate::{sched, time};
4
5unsafe extern "C" {
6    /// The entry point for the userspace application.
7    fn app_main() -> ();
8}
9
10extern "C" fn app_main_entry() {
11    unsafe { app_main() }
12}
13
14pub fn init_app() {
15    let attrs = sched::thread::Attributes {
16        entry: app_main_entry,
17        fin: None,
18        attrs: None,
19    };
20
21    sched::with(|sched| {
22        if let Ok(uid) = sched.create_thread(Some(sched::task::KERNEL_TASK), &attrs) {
23            if sched.enqueue(time::tick(), uid).is_err() {
24                panic!("failed to enqueue init thread.");
25            }
26        } else {
27            panic!("failed to create init task.");
28        }
29    })
30}