Skip to content

Commit

Permalink
syscalls: dispatch mmap()
Browse files Browse the repository at this point in the history
  • Loading branch information
jewelcodes committed Nov 29, 2024
1 parent 1f7adbf commit 3a48766
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion src/syscalls/dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,23 @@ void syscallDispatchSBrk(SyscallRequest *req) {
req->unblock = true;
}

void syscallDispatchMmap(SyscallRequest *req) {
if(syscallVerifyPointer(req, req->params[0], sizeof(struct MmapSyscallParams))) {
req->requestID = syscallID();
struct MmapSyscallParams *p = (struct MmapSyscallParams *) req->params[0];
intptr_t status = (intptr_t) mmap(req->thread, req->requestID, p->addr, p->len,
p->prot, p->flags, p->fd, p->off);
if(status < 0) {
req->ret = status;
req->unblock = true;
} else {
// block until completion
req->external = true;
req->unblock = false;
}
}
}

/* Group 5: Driver I/O Functions */

void syscallDispatchIoperm(SyscallRequest *req) {
Expand Down Expand Up @@ -608,7 +625,7 @@ void (*syscallDispatchTable[])(SyscallRequest *) = {

/* group 4: memory management */
syscallDispatchSBrk, // 50 - sbrk()
NULL, // 51 - mmap()
syscallDispatchMmap, // 51 - mmap()
NULL, // 52 - munmap()

/* group 5: driver I/O functions */
Expand Down

0 comments on commit 3a48766

Please sign in to comment.