aboutsummaryrefslogtreecommitdiff
path: root/examples/create_process/src
diff options
context:
space:
mode:
Diffstat (limited to 'examples/create_process/src')
-rw-r--r--examples/create_process/src/main.zig39
-rw-r--r--examples/create_process/src/main2.zig22
2 files changed, 14 insertions, 47 deletions
diff --git a/examples/create_process/src/main.zig b/examples/create_process/src/main.zig
index 28fbca7..a18f61b 100644
--- a/examples/create_process/src/main.zig
+++ b/examples/create_process/src/main.zig
@@ -2,37 +2,16 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
-const program2 = @embedFile("program2");
-var buf: [program2.len]u8 = undefined;
-
-export fn _start() void {
- main();
-}
+const srvre_sys = @import("srvre_sys");
+const os = srvre_sys.os;
-pub fn main() void {
- const msg = "Hello from program 1\r\n";
- asm volatile (
- \\ li a7, 100001
- \\ ecall
- :
- : [ptr] "{a0}" (msg.ptr),
- [len] "{a1}" (msg.len),
- : "a7"
- );
+usingnamespace srvre_sys;
- @memcpy(buf[0..], program2);
-
- asm volatile (
- \\ li a7, 100002
- \\ ecall
- :
- : [bytes] "{a0}" (&buf),
- [len] "{a1}" (buf.len),
- : "a7"
- );
+const program2 = @embedFile("program2");
+var buffer: [program2.len]u8 = undefined;
- asm volatile (
- \\ li a7, 100003
- \\ ecall
- ::: "a7");
+pub fn main() void {
+ _ = os.consoleWrite("Hello from program 1\r\n") catch unreachable;
+ @memcpy(buffer[0..], program2);
+ _ = os.launch(@alignCast(buffer[0..])) catch unreachable;
}
diff --git a/examples/create_process/src/main2.zig b/examples/create_process/src/main2.zig
index 89a0255..0099302 100644
--- a/examples/create_process/src/main2.zig
+++ b/examples/create_process/src/main2.zig
@@ -2,23 +2,11 @@
//
// SPDX-License-Identifier: AGPL-3.0-or-later
-export fn _start() void {
- main();
-}
+const srvre_sys = @import("srvre_sys");
+const os = srvre_sys.os;
-pub fn main() void {
- const msg = "Hello from program 2\r\n";
- asm volatile (
- \\ li a7, 100001
- \\ ecall
- :
- : [ptr] "{a0}" (msg.ptr),
- [len] "{a1}" (msg.len),
- : "a7"
- );
+usingnamespace srvre_sys;
- asm volatile (
- \\ li a7, 100003
- \\ ecall
- ::: "a7");
+pub fn main() void {
+ _ = os.consoleWrite("Hello from program 2\r\n") catch unreachable;
}