Add dev_delhandle() syscall to delete a device handle from process resources

This commit is contained in:
2025-11-08 16:24:04 +01:00
parent 2fa77d073f
commit e0162e9e0b
6 changed files with 26 additions and 0 deletions

View File

@ -135,3 +135,21 @@ int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1) {
done:
return ret;
}
int32_t SYSCALL1(sys_dev_delhandle, dev1) {
uint64_t *devh = (uint64_t *)dev1;
int32_t ret = E_OK;
if (devh == NULL) {
return E_NOMEMORY;
}
spinlock_acquire(&PROCS.spinlock);
Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock);
proc->devs[*devh] = NULL;
return ret;
}

View File

@ -9,5 +9,6 @@ int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1);
int32_t SYSCALL0(sys_dev_listsize);
int32_t SYSCALL2(sys_dev_stat, devstat1, idx1);
int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1);
int32_t SYSCALL1(sys_dev_delhandle, dev1);
#endif // SYSCALL_DEV_H_

View File

@ -64,6 +64,7 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
[SYS_DEV_STAT] = &sys_dev_stat,
[SYS_DEV_CMD] = &sys_dev_cmd,
[SYS_DEV_DELHANDLE] = &sys_dev_delhandle,
[SYS_TIME] = &sys_time,
};