Compare commits

...

3 Commits

Author SHA1 Message Date
4452f1b196 Change naming scheme for atasd and ramsd 2025-10-18 22:16:01 +02:00
0e0bff4888 Use implicitly passed _caller_pid in syscalls 2025-10-18 12:20:43 +02:00
a5fe64b253 Pass implicit PID into syscalls 2025-10-18 12:10:59 +02:00
22 changed files with 95 additions and 74 deletions

View File

@ -1,2 +1,2 @@
print 'Mounting filesystems...\n' print 'Mounting filesystems...\n'
$fs mount -mp system -fs LittleFS -dev atasd-mst -fmt no $fs mount -mp system -fs LittleFS -dev atasd-ch0-M -fmt no

View File

@ -8,7 +8,7 @@
struct Dev; struct Dev;
typedef int32_t (*DevFn)(struct Dev *dev, uint8_t *buffer, size_t len, void *extra); typedef int32_t (*DevFn)(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid);
typedef struct Dev { typedef struct Dev {
int _hshtbstate; int _hshtbstate;

View File

@ -10,8 +10,13 @@
#include "bootinfo/bootinfo.h" #include "bootinfo/bootinfo.h"
#include "errors.h" #include "errors.h"
int32_t fbdev_getinfo(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t fbdev_getinfo(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)buffer; (void)len; (void)extra; (void)dev; (void)pid;
if (len != sizeof(FbDevGetInfo)) {
return E_INVALIDARGUMENT;
}
FbDevGetInfo info = { FbDevGetInfo info = {
.w = BOOT_INFO.fb->width, .w = BOOT_INFO.fb->width,
.h = BOOT_INFO.fb->height, .h = BOOT_INFO.fb->height,

View File

@ -163,9 +163,9 @@ struct {
Ps2kbEvConsumer *list; Ps2kbEvConsumer *list;
} PS2KB_CONSUMERS = {0}; } PS2KB_CONSUMERS = {0};
int32_t ps2kbdev_readch(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t ps2kbdev_readch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)len; (void)extra; (void)dev; (void)buffer; (void)len;
uint64_t pid = (uint64_t)buffer;
Proc *consproc = NULL; Proc *consproc = NULL;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc, *proctmp; Proc *proc, *proctmp;
@ -202,9 +202,9 @@ int32_t ps2kbdev_readch(struct Dev *dev, uint8_t *buffer, size_t len, void *extr
#define CONSUMER_RBUF_MAX 0x400 #define CONSUMER_RBUF_MAX 0x400
int32_t ps2kbdev_attchcons(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t ps2kbdev_attchcons(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)len; (void)extra; (void)dev; (void)buffer; (void)len;
uint64_t pid = (uint64_t)buffer;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc, *proctmp; Proc *proc, *proctmp;
LL_FOREACH_SAFE(PROCS.procs, proc, proctmp) { LL_FOREACH_SAFE(PROCS.procs, proc, proctmp) {

View File

@ -48,24 +48,24 @@ void serial_sendb(uint8_t b) {
io_out8(PORT, b); io_out8(PORT, b);
} }
int32_t serialdev_sendb(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t serialdev_sendb(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)len; (void)extra; (void)dev; (void)len;
serial_sendb(buffer[0]); serial_sendb(buffer[0]);
return E_OK; return E_OK;
} }
int32_t serialdev_sendready(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t serialdev_sendready(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)buffer; (void)len; (void) extra; (void)dev; (void)buffer; (void)len;
return serial_sendready(); return serial_sendready();
} }
int32_t serialdev_recvb(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t serialdev_recvb(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)buffer; (void)len; (void)extra; (void)dev; (void)buffer; (void)len;
return serial_recvb(); return serial_recvb();
} }
int32_t serialdev_recvready(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t serialdev_recvready(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)buffer; (void)len; (void)extra; (void)dev; (void)buffer; (void)len;
return serial_recvready(); return serial_recvready();
} }

View File

@ -9,8 +9,8 @@
#include "hshtb.h" #include "hshtb.h"
#include "sysdefs/dev.h" #include "sysdefs/dev.h"
int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) { int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
(void)dev; (void)extra; (void)dev;
kprintf("%.*s", (int)len, (char *)buffer); kprintf("%.*s", (int)len, (char *)buffer);
return E_OK; return E_OK;
} }

View File

@ -193,7 +193,11 @@ void hal_syscalldispatch(IntrStackFrame *frame) {
frame->regs.rax = E_BADSYSCALL; frame->regs.rax = E_BADSYSCALL;
return; return;
} }
int32_t ret = fn(frame, frame->regs.rdi, frame->regs.rsi, frame->regs.rdx, spinlock_acquire(&PROCS.spinlock);
uint64_t calling_proc_pid = PROCS.current->pid;
spinlock_release(&PROCS.spinlock);
hal_intr_enable();
int32_t ret = fn(frame, calling_proc_pid, frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
frame->regs.r10, frame->regs.r8, frame->regs.r9); frame->regs.r10, frame->regs.r8, frame->regs.r9);
if (ret == E_DOSCHEDULING) { if (ret == E_DOSCHEDULING) {

View File

@ -62,7 +62,7 @@
.endm .endm
.macro _vecintr_bodygen .macro _vecintr_bodygen
// cli cli
_push_regs _push_regs
cld cld
movq %rsp, %rdi movq %rsp, %rdi

View File

@ -24,16 +24,15 @@ void storedev_init(void) {
ata_probe(); ata_probe();
} }
size_t ramsd_counter = 0;
void storedev_register_dev_entry(StoreDev *sd, int32_t sdtype) { void storedev_register_dev_entry(StoreDev *sd, int32_t sdtype) {
char key[20]; char key[20];
hal_memset(key, 0, sizeof(key));
if (sdtype == STOREDEV_RAMSD) { if (sdtype == STOREDEV_RAMSD) {
char uniq[5]; ksprintf(key, "ramsd-%zu", ramsd_counter++);
randcrypto_gen_uniqid(uniq, 4);
ksprintf(key, "ramsd-%s", uniq);
} else if (sdtype == STOREDEV_ATASD) { } else if (sdtype == STOREDEV_ATASD) {
ksprintf(key, "atasd-%s", sd->sd.atasd.devno == 0x00 ? "mst" : "slv"); ksprintf(key, "atasd-ch0-%c", sd->sd.atasd.devno == 0x00 ? 'M' : 'S');
} }
spinlock_acquire(&DEVTABLE.spinlock); spinlock_acquire(&DEVTABLE.spinlock);

View File

@ -15,7 +15,8 @@ int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1) {
int32_t ret = E_OK; int32_t ret = E_OK;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
char *ident = (char *)devname1; char *ident = (char *)devname1;
@ -102,13 +103,14 @@ done:
return ret; return ret;
} }
int32_t SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1) { int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1) {
uint64_t *devh = (uint64_t *)dev1; uint64_t *devh = (uint64_t *)dev1;
uint64_t cmd = cmd1; uint64_t cmd = cmd1;
int32_t ret = E_OK; int32_t ret = E_OK;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
if (devh == NULL) { if (devh == NULL) {
@ -127,7 +129,7 @@ int32_t SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1) {
goto done; goto done;
} }
spinlock_acquire(&dev->spinlock); spinlock_acquire(&dev->spinlock);
ret = dev->fns[cmd](dev, (uint8_t *)argbuf1, (size_t)len1, (void *)extra1); ret = dev->fns[cmd](dev, (uint8_t *)argbuf1, (size_t)len1, _caller_pid);
spinlock_release(&dev->spinlock); spinlock_release(&dev->spinlock);
done: done:

View File

@ -8,6 +8,6 @@
int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1); 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 SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1); int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1);
#endif // SYSCALL_DEV_H_ #endif // SYSCALL_DEV_H_

View File

@ -8,6 +8,7 @@
#include "kprintf.h" #include "kprintf.h"
#include "proc/proc.h" #include "proc/proc.h"
#include "spinlock/spinlock.h" #include "spinlock/spinlock.h"
#include "util/util.h"
#define _MP_MAX 0xff #define _MP_MAX 0xff
#define _PATH_MAX VFS_PATH_MAX #define _PATH_MAX VFS_PATH_MAX
@ -35,7 +36,8 @@ int32_t SYSCALL2(sys_fs_openf, opath1, oflags1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
for (size_t i = 0; i < PROC_VFSHANDLES_MAX; i++) { for (size_t i = 0; i < PROC_VFSHANDLES_MAX; i++) {
@ -62,7 +64,8 @@ int32_t SYSCALL1(sys_fs_closef, fsh1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
VfsObj *vobj = proc->vobjs[fsh]; VfsObj *vobj = proc->vobjs[fsh];
@ -99,7 +102,8 @@ int32_t SYSCALL4(sys_fs_write, fsh1, buffer1, len1, off1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
VfsObj *vobj = proc->vobjs[fsh]; VfsObj *vobj = proc->vobjs[fsh];
@ -134,7 +138,8 @@ int32_t SYSCALL4(sys_fs_read, fsh1, buffer1, len1, off1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
VfsObj *vobj = proc->vobjs[fsh]; VfsObj *vobj = proc->vobjs[fsh];

View File

@ -15,9 +15,7 @@ int32_t SYSCALL4(sys_ipc_piperead, pid1, pipenum1, buffer1, len1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
spinlock_acquire(&PROCS.spinlock); pid = _caller_pid;
pid = PROCS.current->pid;
spinlock_release(&PROCS.spinlock);
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
@ -61,9 +59,7 @@ int32_t SYSCALL4(sys_ipc_pipewrite, pid1, pipenum1, buffer1, len1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
spinlock_acquire(&PROCS.spinlock); pid = _caller_pid;
pid = PROCS.current->pid;
spinlock_release(&PROCS.spinlock);
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
@ -106,7 +102,8 @@ int32_t SYSCALL1(sys_ipc_pipemake, pipenum1) {
int32_t ret = E_OK; int32_t ret = E_OK;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
if (pipenum >= PROC_PIPEHANDLES_MAX) { if (pipenum >= PROC_PIPEHANDLES_MAX) {
@ -147,7 +144,8 @@ int32_t SYSCALL1(sys_ipc_pipedelete, pipenum1) {
int32_t ret = E_OK; int32_t ret = E_OK;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
if (pipenum >= PROC_PIPEHANDLES_MAX) { if (pipenum >= PROC_PIPEHANDLES_MAX) {
@ -174,9 +172,7 @@ int32_t SYSCALL4(sys_ipc_pipeconnect, pid1, pipenum1, pid2, pipenum2) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
spinlock_acquire(&PROCS.spinlock); pid = _caller_pid;
pid = PROCS.current->pid;
spinlock_release(&PROCS.spinlock);
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);

View File

@ -31,7 +31,8 @@ int32_t SYSCALL5(sys_mman_map, addr1, size1, prot1, flags1, out1) {
hal_memset(VIRT(phys), 0, pages * HAL_PAGE_SIZE); hal_memset(VIRT(phys), 0, pages * HAL_PAGE_SIZE);
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
uint8_t *virt = NULL; uint8_t *virt = NULL;
@ -78,7 +79,8 @@ int32_t SYSCALL1(sys_mman_unmap, addr1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
VasRange *tofree = NULL; VasRange *tofree = NULL;

View File

@ -20,7 +20,7 @@ int32_t SYSCALL1(sys_proc_kill, pid1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
pid = PROCS.current->pid; pid = _caller_pid;
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
@ -38,7 +38,8 @@ int32_t SYSCALL3(sys_proc_spawn, opath1, args1, argslen1) {
int32_t ret = E_OK; int32_t ret = E_OK;
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
const char *opath = (const char *)opath1; const char *opath = (const char *)opath1;
@ -87,7 +88,7 @@ int32_t SYSCALL1(sys_proc_pollstate, pid1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
pid = PROCS.current->pid; pid = _caller_pid;
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
@ -107,15 +108,7 @@ done:
} }
int32_t SYSCALL0(sys_proc_getpid) { int32_t SYSCALL0(sys_proc_getpid) {
int32_t ret = E_OK; return _caller_pid;
spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current;
spinlock_release(&PROCS.spinlock);
ret = proc->pid;
return ret;
} }
int32_t SYSCALL1(sys_proc_run, pid1) { int32_t SYSCALL1(sys_proc_run, pid1) {
@ -143,7 +136,7 @@ int32_t SYSCALL1(sys_proc_arglen, pid1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
pid = PROCS.current->pid; pid = _caller_pid;
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
@ -160,7 +153,7 @@ int32_t SYSCALL4(sys_proc_argv, pid1, argslen1, argbuf1, maxargs1) {
int32_t ret = E_OK; int32_t ret = E_OK;
if (pid == (uint64_t)-1) { if (pid == (uint64_t)-1) {
pid = PROCS.current->pid; pid = _caller_pid;
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);

View File

@ -9,6 +9,7 @@
#define SYSCALL0(name) \ #define SYSCALL0(name) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
UNUSED uint64_t _1, \ UNUSED uint64_t _1, \
UNUSED uint64_t _2, \ UNUSED uint64_t _2, \
UNUSED uint64_t _3, \ UNUSED uint64_t _3, \
@ -19,6 +20,7 @@
#define SYSCALL1(name, arg1) \ #define SYSCALL1(name, arg1) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
UNUSED uint64_t _2, \ UNUSED uint64_t _2, \
UNUSED uint64_t _3, \ UNUSED uint64_t _3, \
@ -29,6 +31,7 @@
#define SYSCALL2(name, arg1, arg2) \ #define SYSCALL2(name, arg1, arg2) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
uint64_t arg2, \ uint64_t arg2, \
UNUSED uint64_t _3, \ UNUSED uint64_t _3, \
@ -39,6 +42,7 @@
#define SYSCALL3(name, arg1, arg2, arg3) \ #define SYSCALL3(name, arg1, arg2, arg3) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
uint64_t arg2, \ uint64_t arg2, \
uint64_t arg3, \ uint64_t arg3, \
@ -49,6 +53,7 @@
#define SYSCALL4(name, arg1, arg2, arg3, arg4) \ #define SYSCALL4(name, arg1, arg2, arg3, arg4) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
uint64_t arg2, \ uint64_t arg2, \
uint64_t arg3, \ uint64_t arg3, \
@ -59,6 +64,7 @@
#define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \ #define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
uint64_t arg2, \ uint64_t arg2, \
uint64_t arg3, \ uint64_t arg3, \
@ -69,6 +75,7 @@
#define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \ #define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
name(UNUSED IntrStackFrame *frame, \ name(UNUSED IntrStackFrame *frame, \
UNUSED uint64_t _caller_pid, \
uint64_t arg1, \ uint64_t arg1, \
uint64_t arg2, \ uint64_t arg2, \
uint64_t arg3, \ uint64_t arg3, \
@ -77,7 +84,13 @@
uint64_t arg6 \ uint64_t arg6 \
) )
typedef int32_t (*SyscallFn)(IntrStackFrame *, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t, uint64_t); typedef int32_t (*SyscallFn)(IntrStackFrame *, uint64_t,
uint64_t,
uint64_t,
uint64_t,
uint64_t,
uint64_t,
uint64_t);
extern SyscallFn SYSCALL_TABLE[SYSCALLS_MAX]; extern SyscallFn SYSCALL_TABLE[SYSCALLS_MAX];

View File

@ -11,6 +11,7 @@
#include "dev/dev.h" #include "dev/dev.h"
#include "proc/proc.h" #include "proc/proc.h"
#include "storedev/storedev.h" #include "storedev/storedev.h"
#include "util/util.h"
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) { int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
int32_t ret = E_OK; int32_t ret = E_OK;
@ -35,7 +36,8 @@ int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
} }
spinlock_acquire(&PROCS.spinlock); spinlock_acquire(&PROCS.spinlock);
Proc *proc = PROCS.current; Proc *proc = NULL;
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
spinlock_release(&PROCS.spinlock); spinlock_release(&PROCS.spinlock);
Dev *dp = proc->devs[*dev]; Dev *dp = proc->devs[*dev];

View File

@ -135,8 +135,8 @@ int32_t dev_stat(DevStat *devstatbuf, size_t idx) {
return syscall(SYS_DEV_STAT, (uint64_t)devstatbuf, (uint64_t)idx, 0, 0, 0, 0); return syscall(SYS_DEV_STAT, (uint64_t)devstatbuf, (uint64_t)idx, 0, 0, 0, 0);
} }
int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len, void *extra) { 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, (uint64_t)extra, 0); return syscall(SYS_DEV_CMD, (uint64_t)dev, (uint64_t)cmd, (uint64_t)buf, (uint64_t)len, 0, 0);
} }
int32_t time(Time *time) { int32_t time(Time *time) {

View File

@ -41,7 +41,7 @@ int32_t fs_delete(char *path);
int32_t dev_gethandle(Dev_t *dev, char *name); 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, void *extra); int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len);
int32_t time(Time *time); int32_t time(Time *time);
#endif // ULIB_SYSTEM_SYSTEM_H_ #endif // ULIB_SYSTEM_SYSTEM_H_

View File

@ -20,7 +20,7 @@ void tb_runinitscript(void) {
string_memset(buf, 0, sizeof(buf)); string_memset(buf, 0, sizeof(buf));
r = ipc_piperead(tb, 0, (uint8_t *const)buf, sizeof(buf)-1); r = ipc_piperead(tb, 0, (uint8_t *const)buf, sizeof(buf)-1);
if (r > 0) { if (r > 0) {
dev_cmd(&termdev, DEV_TERMDEV_PUTCH, buf, string_len(buf), NULL); dev_cmd(&termdev, DEV_TERMDEV_PUTCH, buf, string_len(buf));
} else { } else {
schedrelease(); schedrelease();
} }
@ -30,7 +30,7 @@ void tb_runinitscript(void) {
void main(void) { void main(void) {
PID = proc_getpid(); PID = proc_getpid();
dev_gethandle(&ps2kbdev, "ps2kbdev"); dev_gethandle(&ps2kbdev, "ps2kbdev");
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (void *)PID, 0, NULL); dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, NULL, 0);
tb_runinitscript(); tb_runinitscript();

View File

@ -240,7 +240,7 @@ bool interp_runstring(char *string, InterpResult **res, bool interactive) {
if (wait) { if (wait) {
while(proc_pollstate(app) != 4) { while(proc_pollstate(app) != 4) {
if (interactive) { if (interactive) {
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL); int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, NULL, 0);
if (key > 0 && (uint8_t)key == C('S')) { if (key > 0 && (uint8_t)key == C('S')) {
proc_kill(app); proc_kill(app);
goto cleanup; goto cleanup;

View File

@ -90,7 +90,7 @@ void do_mode_interactive(void) {
uint8_t b = 0; uint8_t b = 0;
for (;;) { for (;;) {
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL); int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, NULL, 0);
if (key > 0) { if (key > 0) {
b = (uint8_t)key; b = (uint8_t)key;
switch (b) { switch (b) {
@ -140,7 +140,7 @@ void main(void) {
if (CONFIG.mode == MODE_INTERACTIVE) { if (CONFIG.mode == MODE_INTERACTIVE) {
dev_gethandle(&ps2kbdev, "ps2kbdev"); dev_gethandle(&ps2kbdev, "ps2kbdev");
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (void *)PID, 0, NULL); dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, NULL, 0);
do_mode_interactive(); do_mode_interactive();
} else if (CONFIG.mode == MODE_RUNFILE) { } else if (CONFIG.mode == MODE_RUNFILE) {
if (CONFIG.filepath == NULL) { if (CONFIG.filepath == NULL) {