Add dev_delhandle() syscall to delete a device handle from process resources
This commit is contained in:
@ -135,3 +135,21 @@ int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1) {
|
|||||||
done:
|
done:
|
||||||
return ret;
|
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;
|
||||||
|
}
|
||||||
|
|||||||
@ -9,5 +9,6 @@ int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1);
|
|||||||
int32_t SYSCALL0(sys_dev_listsize);
|
int32_t SYSCALL0(sys_dev_listsize);
|
||||||
int32_t SYSCALL2(sys_dev_stat, devstat1, idx1);
|
int32_t SYSCALL2(sys_dev_stat, devstat1, idx1);
|
||||||
int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1);
|
int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1);
|
||||||
|
int32_t SYSCALL1(sys_dev_delhandle, dev1);
|
||||||
|
|
||||||
#endif // SYSCALL_DEV_H_
|
#endif // SYSCALL_DEV_H_
|
||||||
|
|||||||
@ -64,6 +64,7 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
|||||||
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
|
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
|
||||||
[SYS_DEV_STAT] = &sys_dev_stat,
|
[SYS_DEV_STAT] = &sys_dev_stat,
|
||||||
[SYS_DEV_CMD] = &sys_dev_cmd,
|
[SYS_DEV_CMD] = &sys_dev_cmd,
|
||||||
|
[SYS_DEV_DELHANDLE] = &sys_dev_delhandle,
|
||||||
|
|
||||||
[SYS_TIME] = &sys_time,
|
[SYS_TIME] = &sys_time,
|
||||||
};
|
};
|
||||||
|
|||||||
@ -37,6 +37,7 @@
|
|||||||
#define SYS_DEV_LISTSIZE 34
|
#define SYS_DEV_LISTSIZE 34
|
||||||
#define SYS_DEV_STAT 35
|
#define SYS_DEV_STAT 35
|
||||||
#define SYS_DEV_CMD 36
|
#define SYS_DEV_CMD 36
|
||||||
|
#define SYS_DEV_DELHANDLE 39
|
||||||
#define SYS_TIME 38
|
#define SYS_TIME 38
|
||||||
|
|
||||||
#endif // SHARE_HDRS_SYSCALL_H_
|
#endif // SHARE_HDRS_SYSCALL_H_
|
||||||
|
|||||||
@ -151,6 +151,10 @@ int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len) {
|
|||||||
return syscall(SYS_DEV_CMD, (uint64_t)dev, (uint64_t)cmd, (uint64_t)buf, (uint64_t)len, 0, 0);
|
return syscall(SYS_DEV_CMD, (uint64_t)dev, (uint64_t)cmd, (uint64_t)buf, (uint64_t)len, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t dev_delhandle(Dev_t *dev) {
|
||||||
|
return syscall(SYS_DEV_DELHANDLE, (uint64_t)dev, 0, 0, 0, 0, 0);
|
||||||
|
}
|
||||||
|
|
||||||
int32_t time(Time *time) {
|
int32_t time(Time *time) {
|
||||||
return syscall(SYS_TIME, (uint64_t)time, 0, 0, 0, 0, 0);
|
return syscall(SYS_TIME, (uint64_t)time, 0, 0, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|||||||
@ -46,6 +46,7 @@ int32_t dev_gethandle(Dev_t *dev, char *name);
|
|||||||
int32_t dev_listsize(void);
|
int32_t dev_listsize(void);
|
||||||
int32_t dev_stat(DevStat *devstatbuf, size_t idx);
|
int32_t dev_stat(DevStat *devstatbuf, size_t idx);
|
||||||
int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len);
|
int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len);
|
||||||
|
int32_t dev_delhandle(Dev_t *dev);
|
||||||
int32_t time(Time *time);
|
int32_t time(Time *time);
|
||||||
|
|
||||||
#endif // ULIB_SYSTEM_SYSTEM_H_
|
#endif // ULIB_SYSTEM_SYSTEM_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user