kernel/uspace/core.rs
1//! This module provides the core userspace services of the microkernel.
2
3use macros::service;
4
5/// The init service.
6#[service(mem_size = 8192)]
7pub struct Init {}
8
9impl Init {
10 /// The entry point of the init service. TODO: Currently, this is a dummy implementation.
11 pub extern "C" fn main() {
12 loop {
13 hal::asm::syscall!(0, 0, "Hello from Init!".as_bytes().as_ptr(), 16);
14
15 for _ in 0..1_000 {
16 unsafe { core::arch::asm!("nop") }
17 }
18 }
19 }
20}
21
22/// A dummy service. TODO: Currently, this is a dummy implementation.
23#[service(mem_size = 8192)]
24pub struct Dummy {}
25
26impl Dummy {
27 /// The entry point of the dummy service. TODO: Currently, this is a dummy implementation.
28 pub extern "C" fn main() {
29 loop {
30 // The first argument is a pointer to a string.
31 hal::asm::syscall!(0, 0, "Hello from Dummy!".as_bytes().as_ptr(), 17);
32
33 for _ in 0..1_000 {
34 unsafe { core::arch::asm!("nop") }
35 }
36 }
37 }
38}
39
40/// A second dummy service. TODO: Currently, this is a dummy implementation.
41#[service(mem_size = 8192)]
42pub struct Dummy2 {}
43
44impl Dummy2 {
45 /// The entry point of the second dummy service. TODO: Currently, this is a dummy implementation.
46 pub extern "C" fn main() {
47 loop {
48 hal::asm::syscall!(0, 0, "Hello from Dummy2!".as_bytes().as_ptr(), 18);
49
50 for _ in 0..1_000 {
51 unsafe { core::arch::asm!("nop") }
52 }
53 }
54 }
55}