Skip to main content

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(_ctx: *mut core::ffi::c_void) {
11    unsafe { app_main() }
12}
13
14pub fn init_app() {
15    let attrs = sched::thread::Attributes {
16        entry: app_main_entry,
17        ctx: core::ptr::null_mut(),
18        fin: None,
19        attrs: None,
20    };
21
22    sched::with(|sched| {
23        if let Ok(uid) = sched.create_thread(Some(sched::task::KERNEL_TASK), &attrs) {
24            if sched.enqueue(time::tick(), uid).is_err() {
25                panic!("failed to enqueue init thread.");
26            }
27        } else {
28            panic!("failed to create init task.");
29        }
30    })
31}