-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathuspace.rs
More file actions
31 lines (26 loc) · 801 Bytes
/
Copy pathuspace.rs
File metadata and controls
31 lines (26 loc) · 801 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
//! This module provides access to userspace structures and services.
use crate::{sched, time};
unsafe extern "C" {
/// The entry point for the userspace application.
fn app_main() -> ();
}
extern "C" fn app_main_entry(_ctx: *mut core::ffi::c_void) {
unsafe { app_main() }
}
pub fn init_app() {
let attrs = sched::thread::Attributes {
entry: app_main_entry,
ctx: core::ptr::null_mut(),
fin: None,
attrs: None,
};
sched::with(|sched| {
if let Ok(uid) = sched.create_thread(Some(sched::task::KERNEL_TASK), &attrs) {
if sched.enqueue(time::tick(), uid).is_err() {
panic!("failed to enqueue init thread.");
}
} else {
panic!("failed to create init task.");
}
})
}