Break ioctl() up into smaller syscalls

This commit is contained in:
2025-10-14 20:05:41 +02:00
parent c34a253d11
commit 406434fed0
21 changed files with 375 additions and 320 deletions

View File

@ -2,7 +2,7 @@
#include <system/system.h>
#include <syscall/syscall.h>
#include <sysdefs/syscall.h>
#include <sysdefs/ioctl.h>
#include <sysdefs/fs.h>
#include <sysdefs/proc.h>
#include <sysdefs/devctl.h>
#include <uprintf.h>
@ -11,10 +11,6 @@ void debugprint(const char *string) {
syscall(SYS_DEBUGPRINT, (uint64_t)string, 0, 0, 0, 0, 0);
}
int32_t ioctl(uint64_t ioh, uint64_t cmd, uint64_t arg1, uint64_t arg2, uint64_t arg3) {
return syscall(SYS_IOCTL, ioh, cmd, arg1, arg2, arg3, 0);
}
int32_t mman_map(uint8_t *addr, size_t size, uint64_t prot, uint64_t flags, uint8_t **out) {
return syscall(SYS_MMAN_MAP, (uint64_t)addr, (uint64_t)size, prot, flags, (uint64_t)out, 0);
}
@ -99,3 +95,30 @@ int32_t proc_stat(size_t idx, ProcStat *pstat) {
return syscall(SYS_PROC_STAT, (uint64_t)idx, (uint64_t)pstat, 0, 0, 0, 0);
}
int32_t fs_openf(char *path, uint64_t flags) {
return syscall(SYS_FS_OPENF, (uint64_t)path, flags, 0, 0, 0, 0);
}
int32_t fs_closef(int32_t fsh) {
return syscall(SYS_FS_CLOSEF, (uint64_t)fsh, 0, 0, 0, 0, 0);
}
int32_t fs_write(int32_t fsh, const uint8_t *buffer, size_t len, size_t off) {
return syscall(SYS_FS_WRITE, (uint64_t)fsh, (uint64_t)buffer, (uint64_t)len, (uint64_t)off, 0, 0);
}
int32_t fs_read(int32_t fsh, uint8_t *const buffer, size_t len, size_t off) {
return syscall(SYS_FS_READ, (uint64_t)fsh, (uint64_t)buffer, (uint64_t)len, (uint64_t)off, 0, 0);
}
int32_t fs_stat(char *path, FsStat *statbuf) {
return syscall(SYS_FS_STAT, (uint64_t)path, (uint64_t)statbuf, 0, 0, 0, 0);
}
int32_t fs_fetchdirent(char *path, FsDirent *direntbuf, size_t idx) {
return syscall(SYS_FS_FETCHDIRENT, (uint64_t)path, (uint64_t)direntbuf, (uint64_t)idx, 0, 0, 0);
}
int32_t fs_mkdir(char *path) {
return syscall(SYS_FS_MKDIR, (uint64_t)path, 0, 0, 0, 0, 0);
}