[Zion] Add a ProcessWait syscall.

This commit is contained in:
Drew Galbraith 2023-12-01 11:36:27 -08:00
parent 642fc4d80d
commit d9a4be6555
8 changed files with 29 additions and 8 deletions

View file

@ -9,7 +9,7 @@
z_err_t ProcessExit(ZProcessExitReq* req) {
auto curr_thread = gScheduler->CurrentThread();
dbgln("Exit code: {}", static_cast<glcr::ErrorCode>(req->code));
curr_thread->process().Exit();
curr_thread->process().Exit(req->code);
panic("Returned from thread exit");
return glcr::UNIMPLEMENTED;
}
@ -39,3 +39,17 @@ z_err_t ProcessSpawn(ZProcessSpawnReq* req) {
return glcr::OK;
}
z_err_t ProcessWait(ZProcessWaitReq* req) {
auto& curr_proc = gScheduler->CurrentProcess();
auto cap = curr_proc.GetCapability(req->proc_cap);
RET_ERR(ValidateCapability<Process>(cap, kZionPerm_Read));
auto proc = cap->obj<Process>();
if (proc->id() == curr_proc.id()) {
return glcr::INVALID_ARGUMENT;
}
proc->GetThread(0)->Wait();
*req->exit_code = proc->exit_code();
return glcr::OK;
}