Skip to content

Commit

Permalink
Syscalls: Add additional system calls for memory management
Browse files Browse the repository at this point in the history
  • Loading branch information
NDRAEY committed Jul 24, 2024
1 parent bc67fe1 commit e28b856
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion kernel/include/sys/syscalls.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

typedef size_t syscall_fn_t (size_t, size_t, size_t);

#define NUM_CALLS 18
#define NUM_CALLS 19

void init_syscalls(void);
extern size_t syscall_entry_call(void* entry_point, void* param1, void* param2, void* param3);
Expand Down
13 changes: 11 additions & 2 deletions kernel/src/sys/syscalls.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,22 @@ size_t syscall_env(struct env* position) {
return 0;
}

size_t syscall_memory_alloc(size_t size, void** out) {
void* allocated = kcalloc(size, 1);
size_t syscall_memory_alloc(size_t size, size_t align, void** out) {
void* allocated = kcalloc(size, align);

*out = allocated;

return 0;
}

size_t syscall_memory_realloc(void* memory, size_t size, void** out) {
void* r = krealloc(memory, size);

*out = r;

return 0;
}

size_t syscall_memory_free(void* memory) {
kfree(memory);

Expand Down Expand Up @@ -150,6 +158,7 @@ void init_syscalls(void){
calls_table[15] = (syscall_fn_t *)syscall_sleep;
calls_table[16] = (syscall_fn_t *)syscall_datetime;
calls_table[17] = (syscall_fn_t *)syscall_exit;
calls_table[18] = (syscall_fn_t)syscall_memory_realloc;

qemu_ok("System calls initialized!");
}
Binary file modified ramdisk/keyboard
Binary file not shown.

0 comments on commit e28b856

Please sign in to comment.