aboutsummaryrefslogtreecommitdiff
path: root/examples/create_process/src/main.zig
blob: 5d093dedca313a76e4edad902f08eeec0690c54c (plain) (blame)
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
32
33
34
35
36
37
38
39
// SPDX-FileCopyrightText: 2024 Himbeer <himbeer@disroot.org>
//
// SPDX-License-Identifier: AGPL-3.0-or-later

export fn _start() void {
    main();
}

pub fn main() void {
    const msg = "Hello from program 1\r\n";
    asm volatile (
        \\ li a7, 100000
        \\ ecall
        :
        : [ptr] "{a0}" (msg.ptr),
          [len] "{a1}" (msg.len),
        : "a7"
    );

    const path = "/process/create\x00";
    const program = "/userinit/program2\x00";
    asm volatile (
        \\ li a7, 100001
        \\ ecall
        :
        : [path] "{a0}" (path.ptr),
          [program] "{a1}" (program.ptr),
        : "a7"
    );

    const term_path = "/process/self/terminate\x00";
    asm volatile (
        \\ li a7, 100001
        \\ ecall
        :
        : [path] "{a0}" (term_path.ptr),
        : "a7", "a1"
    );
}