aboutsummaryrefslogtreecommitdiff
path: root/src/lib/syscall.zig
diff options
context:
space:
mode:
authorHimbeer <himbeer@disroot.org>2024-07-30 17:41:27 +0200
committerHimbeer <himbeer@disroot.org>2024-07-30 17:41:27 +0200
commit48d6fa3e80193a3cc735f5e0b0390a18a7bf5a83 (patch)
tree23468ff08749507d70153e63f91a47cbe8926be2 /src/lib/syscall.zig
parentee824544423fa55884cf0f716a977cd123c6fedf (diff)
channel: Implement joining and leaving
Diffstat (limited to 'src/lib/syscall.zig')
-rw-r--r--src/lib/syscall.zig16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/lib/syscall.zig b/src/lib/syscall.zig
index 03a7979..97dc811 100644
--- a/src/lib/syscall.zig
+++ b/src/lib/syscall.zig
@@ -32,6 +32,8 @@ pub fn handler(proc: *process.Info, trap_frame: *TrapFrame) !void {
100006 => trap_frame.setReturnValue(threadId(proc)),
100007 => trap_frame.setReturnValue(rawUserinit(trap_frame)),
100008 => trap_frame.setReturnValue(devicesByKind(trap_frame)),
+ 100009 => trap_frame.setReturnValue(join(proc, trap_frame)),
+ 100010 => trap_frame.setReturnValue(leave(proc, trap_frame)),
100011 => trap_frame.setReturnValue(pass(trap_frame)),
100012 => trap_frame.setReturnValue(receive(trap_frame)),
else => return HandleError.UnknownSyscall,
@@ -171,6 +173,18 @@ fn devicesByKind(trap_frame: *const TrapFrame) !usize {
return i;
}
+// join(channel_id: usize) !void
+fn join(proc: *process.Info, trap_frame: *const TrapFrame) !void {
+ const id = trap_frame.general_purpose_registers[10];
+ return channel.join(proc.id, id);
+}
+
+// leave(channel_id: usize) void
+fn leave(proc: *process.Info, trap_frame: *const TrapFrame) void {
+ const id = trap_frame.general_purpose_registers[10];
+ channel.leave(proc.id, id);
+}
+
// pass(channel_id: usize, bytes: [*]const u8, len: usize) !void
fn pass(trap_frame: *const TrapFrame) !void {
const id = trap_frame.general_purpose_registers[10];
@@ -178,7 +192,7 @@ fn pass(trap_frame: *const TrapFrame) !void {
const len = trap_frame.general_purpose_registers[12];
const bytes = bytes_ptr[0..len];
- const copy = try channel.messageAllocator().alloc(u8, bytes.len);
+ const copy = try channel.allocator().alloc(u8, bytes.len);
@memcpy(copy, bytes);
try channel.pass(id, copy);
}