Implement argument_ptr () syscall for handling process arguments
All checks were successful
Build documentation / build-and-deploy (push) Successful in 37s

This commit is contained in:
2026-01-30 14:05:47 +01:00
parent 124aa12f5b
commit 38e26a9c12
10 changed files with 33 additions and 28 deletions

View File

@@ -21,8 +21,8 @@ void* map (uintptr_t vaddr, size_t pages, uint32_t flags) {
int unmap (uintptr_t vaddr, size_t pages) { return do_syscall (SYS_UNMAP, vaddr, pages); }
int clone (uintptr_t vstack_top, void (*entry) (void)) {
return do_syscall (SYS_CLONE, vstack_top, entry);
int clone (uintptr_t vstack_top, void (*entry) (void), void* argument_ptr) {
return do_syscall (SYS_CLONE, vstack_top, entry, argument_ptr);
}
int mutex_create (int mutex_rid) { return do_syscall (SYS_MUTEX_CREATE, mutex_rid); }
@@ -32,3 +32,5 @@ int mutex_delete (int mutex_rid) { return do_syscall (SYS_MUTEX_DELETE, mutex_ri
int mutex_lock (int mutex_rid) { return do_syscall (SYS_MUTEX_LOCK, mutex_rid); }
int mutex_unlock (int mutex_rid) { return do_syscall (SYS_MUTEX_UNLOCK, mutex_rid); }
void* argument_ptr (void) { return (void*)do_syscall (SYS_ARGUMENT_PTR, 0); }

View File

@@ -18,10 +18,11 @@ int test (char c);
int sched (void);
void* map (uintptr_t vaddr, size_t pages, uint32_t flags);
int unmap (uintptr_t vaddr, size_t pages);
int clone (uintptr_t vstack_top, void (*entry) (void));
int clone (uintptr_t vstack_top, void (*entry) (void), void* argument_ptr);
int mutex_create (int mutex_rid);
int mutex_delete (int mutex_rid);
int mutex_lock (int mutex_rid);
int mutex_unlock (int mutex_rid);
void* argument_ptr (void);
#endif // _LIBMSL_M_SYSTEM_H

View File

@@ -5,13 +5,15 @@
#include <stddef.h>
#include <stdint.h>
int process_spawn (process_func_t func) {
int process_spawn (process_func_t func, void* argument_ptr) {
void* stack = malloc (PROC_STACK_SIZE);
if (stack == NULL)
return -ST_OOM_ERROR;
uintptr_t top = (uintptr_t)stack + PROC_STACK_SIZE;
return clone (top, func);
return clone (top, func, argument_ptr);
}
int process_quit (void) { return quit (); }
void* process_argument (void) { return argument_ptr (); }

View File

@@ -7,7 +7,8 @@
typedef void (*process_func_t) (void);
int process_spawn (process_func_t func);
int process_spawn (process_func_t func, void* argument_ptr);
int process_quit (void);
void* process_argument (void);
#endif // _LIBMSL_PROC_PROC_H