Skip to content

Commit 4e52697

Browse files
committed
syscalls: exposed sbrk()
1 parent f2b252f commit 4e52697

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

src/include/kernel/syscalls.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <stdbool.h>
1212
#include <kernel/sched.h>
1313

14-
#define MAX_SYSCALL 37 // for now
14+
#define MAX_SYSCALL 43
1515

1616
typedef struct SyscallRequest {
1717
bool busy, queued, unblock;

src/syscalls/dispatch.c

+16
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <kernel/socket.h>
1414
#include <kernel/syscalls.h>
1515
#include <kernel/logger.h>
16+
#include <kernel/memory.h>
1617

1718
/* This is the dispatcher for system calls, many of which need a wrapper for
1819
* their behavior. This ensures the exposed functionality is always as close
@@ -200,6 +201,13 @@ void syscallDispatchSend(SyscallRequest *req) {
200201
}
201202
}
202203

204+
/* Group 4: Memory Management */
205+
206+
void syscallDispatchSBrk(SyscallRequest *req) {
207+
req->ret = (uint64_t) sbrk(req->thread, (intptr_t) req->params[0]);
208+
req->unblock = true;
209+
}
210+
203211
void (*syscallDispatchTable[])(SyscallRequest *) = {
204212
/* group 1: scheduler functions */
205213
syscallDispatchExit, // 0 - exit()
@@ -244,4 +252,12 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {
244252
syscallDispatchAccept, // 35 - accept()
245253
syscallDispatchRecv, // 36 - recv()
246254
syscallDispatchSend, // 37 - send()
255+
NULL, // 38 - kill()
256+
257+
/* group 4: memory management */
258+
syscallDispatchSBrk, // 39 - sbrk()
259+
NULL, // 40 - mmap()
260+
NULL, // 41 - munmap()
261+
NULL, // 42 - mlock()
262+
NULL, // 43 - munlock()
247263
};

0 commit comments

Comments
 (0)