Compare commits
3 Commits
d1d777ec75
...
4452f1b196
| Author | SHA1 | Date | |
|---|---|---|---|
| 4452f1b196 | |||
| 0e0bff4888 | |||
| a5fe64b253 |
@ -1,2 +1,2 @@
|
||||
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
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
|
||||
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 {
|
||||
int _hshtbstate;
|
||||
|
||||
@ -10,8 +10,13 @@
|
||||
#include "bootinfo/bootinfo.h"
|
||||
#include "errors.h"
|
||||
|
||||
int32_t fbdev_getinfo(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)buffer; (void)len; (void)extra;
|
||||
int32_t fbdev_getinfo(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
||||
(void)dev; (void)pid;
|
||||
|
||||
if (len != sizeof(FbDevGetInfo)) {
|
||||
return E_INVALIDARGUMENT;
|
||||
}
|
||||
|
||||
FbDevGetInfo info = {
|
||||
.w = BOOT_INFO.fb->width,
|
||||
.h = BOOT_INFO.fb->height,
|
||||
|
||||
@ -163,9 +163,9 @@ struct {
|
||||
Ps2kbEvConsumer *list;
|
||||
} PS2KB_CONSUMERS = {0};
|
||||
|
||||
int32_t ps2kbdev_readch(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)len; (void)extra;
|
||||
uint64_t pid = (uint64_t)buffer;
|
||||
int32_t ps2kbdev_readch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
||||
(void)dev; (void)buffer; (void)len;
|
||||
|
||||
Proc *consproc = NULL;
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
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
|
||||
|
||||
int32_t ps2kbdev_attchcons(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)len; (void)extra;
|
||||
uint64_t pid = (uint64_t)buffer;
|
||||
int32_t ps2kbdev_attchcons(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
||||
(void)dev; (void)buffer; (void)len;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc, *proctmp;
|
||||
LL_FOREACH_SAFE(PROCS.procs, proc, proctmp) {
|
||||
|
||||
@ -48,24 +48,24 @@ void serial_sendb(uint8_t b) {
|
||||
io_out8(PORT, b);
|
||||
}
|
||||
|
||||
int32_t serialdev_sendb(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)len; (void)extra;
|
||||
int32_t serialdev_sendb(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
||||
(void)dev; (void)len;
|
||||
serial_sendb(buffer[0]);
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
int32_t serialdev_sendready(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)buffer; (void)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;
|
||||
return serial_sendready();
|
||||
}
|
||||
|
||||
int32_t serialdev_recvb(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)buffer; (void)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;
|
||||
return serial_recvb();
|
||||
}
|
||||
|
||||
int32_t serialdev_recvready(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)buffer; (void)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;
|
||||
return serial_recvready();
|
||||
}
|
||||
|
||||
|
||||
@ -9,8 +9,8 @@
|
||||
#include "hshtb.h"
|
||||
#include "sysdefs/dev.h"
|
||||
|
||||
int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)extra;
|
||||
int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, uint64_t pid) {
|
||||
(void)dev;
|
||||
kprintf("%.*s", (int)len, (char *)buffer);
|
||||
return E_OK;
|
||||
}
|
||||
|
||||
@ -193,8 +193,12 @@ void hal_syscalldispatch(IntrStackFrame *frame) {
|
||||
frame->regs.rax = E_BADSYSCALL;
|
||||
return;
|
||||
}
|
||||
int32_t ret = fn(frame, frame->regs.rdi, frame->regs.rsi, frame->regs.rdx,
|
||||
frame->regs.r10, frame->regs.r8, frame->regs.r9);
|
||||
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);
|
||||
|
||||
if (ret == E_DOSCHEDULING) {
|
||||
proc_sched((void *)frame);
|
||||
|
||||
@ -62,7 +62,7 @@
|
||||
.endm
|
||||
|
||||
.macro _vecintr_bodygen
|
||||
// cli
|
||||
cli
|
||||
_push_regs
|
||||
cld
|
||||
movq %rsp, %rdi
|
||||
|
||||
@ -24,16 +24,15 @@ void storedev_init(void) {
|
||||
ata_probe();
|
||||
}
|
||||
|
||||
size_t ramsd_counter = 0;
|
||||
|
||||
void storedev_register_dev_entry(StoreDev *sd, int32_t sdtype) {
|
||||
char key[20];
|
||||
hal_memset(key, 0, sizeof(key));
|
||||
|
||||
if (sdtype == STOREDEV_RAMSD) {
|
||||
char uniq[5];
|
||||
randcrypto_gen_uniqid(uniq, 4);
|
||||
ksprintf(key, "ramsd-%s", uniq);
|
||||
ksprintf(key, "ramsd-%zu", ramsd_counter++);
|
||||
} 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);
|
||||
|
||||
@ -15,7 +15,8 @@ int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
char *ident = (char *)devname1;
|
||||
@ -102,13 +103,14 @@ done:
|
||||
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 cmd = cmd1;
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
if (devh == NULL) {
|
||||
@ -127,7 +129,7 @@ int32_t SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1) {
|
||||
goto done;
|
||||
}
|
||||
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);
|
||||
|
||||
done:
|
||||
|
||||
@ -8,6 +8,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 SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1);
|
||||
int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1);
|
||||
|
||||
#endif // SYSCALL_DEV_H_
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
#include "kprintf.h"
|
||||
#include "proc/proc.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "util/util.h"
|
||||
|
||||
#define _MP_MAX 0xff
|
||||
#define _PATH_MAX VFS_PATH_MAX
|
||||
@ -35,7 +36,8 @@ int32_t SYSCALL2(sys_fs_openf, opath1, oflags1) {
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
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);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
VfsObj *vobj = proc->vobjs[fsh];
|
||||
@ -99,7 +102,8 @@ int32_t SYSCALL4(sys_fs_write, fsh1, buffer1, len1, off1) {
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
VfsObj *vobj = proc->vobjs[fsh];
|
||||
@ -134,7 +138,8 @@ int32_t SYSCALL4(sys_fs_read, fsh1, buffer1, len1, off1) {
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
VfsObj *vobj = proc->vobjs[fsh];
|
||||
|
||||
@ -15,9 +15,7 @@ int32_t SYSCALL4(sys_ipc_piperead, pid1, pipenum1, buffer1, len1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
pid = PROCS.current->pid;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
@ -61,9 +59,7 @@ int32_t SYSCALL4(sys_ipc_pipewrite, pid1, pipenum1, buffer1, len1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
pid = PROCS.current->pid;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
@ -106,7 +102,8 @@ int32_t SYSCALL1(sys_ipc_pipemake, pipenum1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
||||
@ -147,7 +144,8 @@ int32_t SYSCALL1(sys_ipc_pipedelete, pipenum1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
||||
@ -174,9 +172,7 @@ int32_t SYSCALL4(sys_ipc_pipeconnect, pid1, pipenum1, pid2, pipenum2) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
pid = PROCS.current->pid;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
|
||||
@ -31,7 +31,8 @@ int32_t SYSCALL5(sys_mman_map, addr1, size1, prot1, flags1, out1) {
|
||||
hal_memset(VIRT(phys), 0, pages * HAL_PAGE_SIZE);
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
uint8_t *virt = NULL;
|
||||
@ -78,7 +79,8 @@ int32_t SYSCALL1(sys_mman_unmap, addr1) {
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
VasRange *tofree = NULL;
|
||||
|
||||
@ -20,7 +20,7 @@ int32_t SYSCALL1(sys_proc_kill, pid1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
pid = PROCS.current->pid;
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
@ -38,7 +38,8 @@ int32_t SYSCALL3(sys_proc_spawn, opath1, args1, argslen1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
const char *opath = (const char *)opath1;
|
||||
@ -87,7 +88,7 @@ int32_t SYSCALL1(sys_proc_pollstate, pid1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
pid = PROCS.current->pid;
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
@ -107,15 +108,7 @@ done:
|
||||
}
|
||||
|
||||
int32_t SYSCALL0(sys_proc_getpid) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
ret = proc->pid;
|
||||
|
||||
return ret;
|
||||
return _caller_pid;
|
||||
}
|
||||
|
||||
int32_t SYSCALL1(sys_proc_run, pid1) {
|
||||
@ -143,7 +136,7 @@ int32_t SYSCALL1(sys_proc_arglen, pid1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
pid = PROCS.current->pid;
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
@ -160,7 +153,7 @@ int32_t SYSCALL4(sys_proc_argv, pid1, argslen1, argbuf1, maxargs1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
if (pid == (uint64_t)-1) {
|
||||
pid = PROCS.current->pid;
|
||||
pid = _caller_pid;
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
|
||||
@ -9,6 +9,7 @@
|
||||
|
||||
#define SYSCALL0(name) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
UNUSED uint64_t _1, \
|
||||
UNUSED uint64_t _2, \
|
||||
UNUSED uint64_t _3, \
|
||||
@ -19,6 +20,7 @@
|
||||
|
||||
#define SYSCALL1(name, arg1) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
UNUSED uint64_t _2, \
|
||||
UNUSED uint64_t _3, \
|
||||
@ -29,6 +31,7 @@
|
||||
|
||||
#define SYSCALL2(name, arg1, arg2) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
uint64_t arg2, \
|
||||
UNUSED uint64_t _3, \
|
||||
@ -39,6 +42,7 @@
|
||||
|
||||
#define SYSCALL3(name, arg1, arg2, arg3) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
uint64_t arg2, \
|
||||
uint64_t arg3, \
|
||||
@ -49,6 +53,7 @@
|
||||
|
||||
#define SYSCALL4(name, arg1, arg2, arg3, arg4) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
uint64_t arg2, \
|
||||
uint64_t arg3, \
|
||||
@ -59,6 +64,7 @@
|
||||
|
||||
#define SYSCALL5(name, arg1, arg2, arg3, arg4, arg5) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
uint64_t arg2, \
|
||||
uint64_t arg3, \
|
||||
@ -69,6 +75,7 @@
|
||||
|
||||
#define SYSCALL6(name, arg1, arg2, arg3, arg4, arg5, arg6) \
|
||||
name(UNUSED IntrStackFrame *frame, \
|
||||
UNUSED uint64_t _caller_pid, \
|
||||
uint64_t arg1, \
|
||||
uint64_t arg2, \
|
||||
uint64_t arg3, \
|
||||
@ -77,7 +84,13 @@
|
||||
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];
|
||||
|
||||
|
||||
@ -11,6 +11,7 @@
|
||||
#include "dev/dev.h"
|
||||
#include "proc/proc.h"
|
||||
#include "storedev/storedev.h"
|
||||
#include "util/util.h"
|
||||
|
||||
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
||||
int32_t ret = E_OK;
|
||||
@ -35,7 +36,8 @@ int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
||||
}
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
Proc *proc = NULL;
|
||||
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
Dev *dp = proc->devs[*dev];
|
||||
|
||||
@ -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);
|
||||
}
|
||||
|
||||
int32_t dev_cmd(Dev_t *dev, uint64_t cmd, void *buf, size_t len, void *extra) {
|
||||
return syscall(SYS_DEV_CMD, (uint64_t)dev, (uint64_t)cmd, (uint64_t)buf, (uint64_t)len, (uint64_t)extra, 0);
|
||||
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);
|
||||
}
|
||||
|
||||
int32_t time(Time *time) {
|
||||
|
||||
@ -41,7 +41,7 @@ int32_t fs_delete(char *path);
|
||||
int32_t dev_gethandle(Dev_t *dev, char *name);
|
||||
int32_t dev_listsize(void);
|
||||
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);
|
||||
|
||||
#endif // ULIB_SYSTEM_SYSTEM_H_
|
||||
|
||||
@ -20,7 +20,7 @@ void tb_runinitscript(void) {
|
||||
string_memset(buf, 0, sizeof(buf));
|
||||
r = ipc_piperead(tb, 0, (uint8_t *const)buf, sizeof(buf)-1);
|
||||
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 {
|
||||
schedrelease();
|
||||
}
|
||||
@ -30,7 +30,7 @@ void tb_runinitscript(void) {
|
||||
void main(void) {
|
||||
PID = proc_getpid();
|
||||
dev_gethandle(&ps2kbdev, "ps2kbdev");
|
||||
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (void *)PID, 0, NULL);
|
||||
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, NULL, 0);
|
||||
|
||||
tb_runinitscript();
|
||||
|
||||
|
||||
@ -240,7 +240,7 @@ bool interp_runstring(char *string, InterpResult **res, bool interactive) {
|
||||
if (wait) {
|
||||
while(proc_pollstate(app) != 4) {
|
||||
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')) {
|
||||
proc_kill(app);
|
||||
goto cleanup;
|
||||
|
||||
@ -90,7 +90,7 @@ void do_mode_interactive(void) {
|
||||
|
||||
uint8_t b = 0;
|
||||
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) {
|
||||
b = (uint8_t)key;
|
||||
switch (b) {
|
||||
@ -140,7 +140,7 @@ void main(void) {
|
||||
|
||||
if (CONFIG.mode == MODE_INTERACTIVE) {
|
||||
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();
|
||||
} else if (CONFIG.mode == MODE_RUNFILE) {
|
||||
if (CONFIG.filepath == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user