Implement argument_ptr () syscall for handling process arguments
All checks were successful
Build documentation / build-and-deploy (push) Successful in 37s
All checks were successful
Build documentation / build-and-deploy (push) Successful in 37s
This commit is contained in:
@@ -58,7 +58,8 @@ struct proc* proc_from_elf (uint8_t* elf_contents) {
|
||||
return proc;
|
||||
}
|
||||
|
||||
struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t entry) {
|
||||
struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t entry,
|
||||
uintptr_t argument_ptr) {
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
spin_lock_ctx_t ctxprt;
|
||||
|
||||
@@ -88,6 +89,8 @@ struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t ent
|
||||
proc->pdata.regs.cs = GDT_UCODE | 0x03;
|
||||
proc->pdata.regs.rip = (uint64_t)entry;
|
||||
|
||||
proc->uvaddr_argument = argument_ptr;
|
||||
|
||||
proc_init_tls (proc);
|
||||
|
||||
return proc;
|
||||
|
||||
@@ -43,6 +43,7 @@ struct proc {
|
||||
spin_lock_t lock;
|
||||
struct cpu* cpu;
|
||||
atomic_int state;
|
||||
uintptr_t uvaddr_argument;
|
||||
};
|
||||
|
||||
void proc_sched (void);
|
||||
|
||||
@@ -6,7 +6,8 @@
|
||||
struct proc;
|
||||
|
||||
struct proc* proc_from_elf (uint8_t* elf_contents);
|
||||
struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t entry);
|
||||
struct proc* proc_clone (struct proc* proto, uintptr_t vstack_top, uintptr_t entry,
|
||||
uintptr_t argument_ptr);
|
||||
void proc_cleanup (struct proc* proc);
|
||||
void proc_init_tls (struct proc* proc);
|
||||
|
||||
|
||||
@@ -78,12 +78,13 @@ DEFINE_SYSCALL (sys_unmap) {
|
||||
return SYSRESULT (procgroup_unmap (proc->procgroup, vaddr, pages));
|
||||
}
|
||||
|
||||
/* int clone (uintptr_t vstack_top, void* entry) */
|
||||
/* int clone (uintptr_t vstack_top, void* entry, void* argument_ptr) */
|
||||
DEFINE_SYSCALL (sys_clone) {
|
||||
uintptr_t vstack_top = a1;
|
||||
uintptr_t entry = a2;
|
||||
uintptr_t argument_ptr = a3;
|
||||
|
||||
struct proc* new = proc_clone (proc, vstack_top, entry);
|
||||
struct proc* new = proc_clone (proc, vstack_top, entry, argument_ptr);
|
||||
|
||||
if (new == NULL) {
|
||||
return SYSRESULT (-ST_OOM_ERROR);
|
||||
@@ -96,6 +97,9 @@ DEFINE_SYSCALL (sys_clone) {
|
||||
return SYSRESULT (pid);
|
||||
}
|
||||
|
||||
/* void* argument_ptr (void) */
|
||||
DEFINE_SYSCALL (sys_argument_ptr) { return proc->uvaddr_argument; }
|
||||
|
||||
/* int sched (void) */
|
||||
DEFINE_SYSCALL (sys_sched) {
|
||||
proc_sched ();
|
||||
@@ -165,6 +169,7 @@ static syscall_handler_func_t handler_table[] = {
|
||||
[SYS_MAP] = &sys_map,
|
||||
[SYS_UNMAP] = &sys_unmap,
|
||||
[SYS_CLONE] = &sys_clone,
|
||||
[SYS_ARGUMENT_PTR] = &sys_argument_ptr,
|
||||
[SYS_SCHED] = &sys_sched,
|
||||
[SYS_MUTEX_CREATE] = &sys_mutex_create,
|
||||
[SYS_MUTEX_DELETE] = &sys_mutex_delete,
|
||||
|
||||
Reference in New Issue
Block a user