Compare commits
2 Commits
0c3250e8d6
...
1f7f81016e
| Author | SHA1 | Date | |
|---|---|---|---|
| 1f7f81016e | |||
| fa6c194163 |
@ -2,7 +2,7 @@
|
||||
#include <stddef.h>
|
||||
#include "fbdev.h"
|
||||
#include "dev.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "sysdefs/dev.h"
|
||||
#include "hshtb.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "util/util.h"
|
||||
|
||||
@ -8,7 +8,7 @@
|
||||
#include "dlmalloc/malloc.h"
|
||||
#include "util/util.h"
|
||||
#include "hshtb.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "sysdefs/dev.h"
|
||||
#include "proc/proc.h"
|
||||
|
||||
#define KB_CTL_STATUS 0x64
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "errors.h"
|
||||
#include "util/util.h"
|
||||
#include "hshtb.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "sysdefs/dev.h"
|
||||
#include "kprintf.h"
|
||||
#include "hal/hal.h"
|
||||
|
||||
|
||||
@ -7,7 +7,7 @@
|
||||
#include "errors.h"
|
||||
#include "util/util.h"
|
||||
#include "hshtb.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "sysdefs/dev.h"
|
||||
|
||||
int32_t termdev_putch(struct Dev *dev, uint8_t *buffer, size_t len, void *extra) {
|
||||
(void)dev; (void)extra;
|
||||
|
||||
135
kernel/syscall/dev.c
Normal file
135
kernel/syscall/dev.c
Normal file
@ -0,0 +1,135 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "kprintf.h"
|
||||
#include "syscall.h"
|
||||
#include "errors.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "proc/proc.h"
|
||||
#include "sysdefs/dev.h"
|
||||
#include "util/util.h"
|
||||
#include "hshtb.h"
|
||||
#include "dev/dev.h"
|
||||
|
||||
int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1) {
|
||||
uint64_t *devh = (uint64_t *)dev1;
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
char *ident = (char *)devname1;
|
||||
if (ident == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
Dev *founddev;
|
||||
HSHTB_GET(DEVTABLE.devs, ident, ident, founddev);
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
|
||||
if (founddev == NULL) {
|
||||
ret = E_NOENTRY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < PROC_DEVHANDLES_MAX; i++) {
|
||||
if (proc->devs[i] == NULL) {
|
||||
found = true;
|
||||
proc->devs[i] = founddev;
|
||||
*devh = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
ret = E_NOMEMORY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SYSCALL0(sys_dev_listsize) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
size_t n = 0;
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
for (size_t i = 0; i < LEN(DEVTABLE.devs); i++) {
|
||||
if (DEVTABLE.devs[i]._hshtbstate == HSHTB_TAKEN) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
ret = n;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SYSCALL2(sys_dev_stat, devstat1, idx1) {
|
||||
int32_t ret = E_OK;
|
||||
|
||||
DevStat *devstat = (DevStat *)devstat1;
|
||||
size_t idx = (size_t)idx1;
|
||||
|
||||
if (devstat == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
devstat->present = false;
|
||||
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
for (size_t i = 0; i < LEN(DEVTABLE.devs); i++) {
|
||||
if (i == idx && DEVTABLE.devs[i]._hshtbstate == HSHTB_TAKEN) {
|
||||
Dev *dev = &DEVTABLE.devs[i];
|
||||
hal_memcpy(devstat->name, dev->ident, sizeof(dev->ident));
|
||||
for (size_t j = 0; j < DEV_FNS_MAX; j++) {
|
||||
if (dev->fns[j] != NULL) {
|
||||
devstat->nfns++;
|
||||
}
|
||||
}
|
||||
devstat->present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
|
||||
int32_t SYSCALL5(sys_dev_cmd, dev1, cmd1, argbuf1, len1, extra1) {
|
||||
uint64_t *devh = (uint64_t *)dev1;
|
||||
uint64_t cmd = cmd1;
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
if (devh == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (cmd >= DEV_FNS_MAX) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
Dev *dev = proc->devs[*devh];
|
||||
if (dev == NULL) {
|
||||
ret = E_NOENTRY;
|
||||
goto done;
|
||||
}
|
||||
spinlock_acquire(&dev->spinlock);
|
||||
ret = dev->fns[cmd](dev, (uint8_t *)argbuf1, (size_t)len1, (void *)extra1);
|
||||
spinlock_release(&dev->spinlock);
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
13
kernel/syscall/dev.h
Normal file
13
kernel/syscall/dev.h
Normal file
@ -0,0 +1,13 @@
|
||||
#ifndef SYSCALL_DEV_H_
|
||||
#define SYSCALL_DEV_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "syscall.h"
|
||||
|
||||
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);
|
||||
|
||||
#endif // SYSCALL_DEV_H_
|
||||
@ -1,117 +0,0 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "kprintf.h"
|
||||
#include "syscall.h"
|
||||
#include "errors.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "proc/proc.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "util/util.h"
|
||||
#include "hshtb.h"
|
||||
#include "dev/dev.h"
|
||||
|
||||
int32_t SYSCALL5(sys_devctl, devh1, cmd1, buffer1, len1, extra1) {
|
||||
uint64_t *devh = (uint64_t *)devh1;
|
||||
uint64_t cmd = cmd1;
|
||||
int32_t ret = E_OK;
|
||||
|
||||
spinlock_acquire(&PROCS.spinlock);
|
||||
Proc *proc = PROCS.current;
|
||||
spinlock_release(&PROCS.spinlock);
|
||||
|
||||
switch (cmd) {
|
||||
case DEVCTL_GET_HANDLE: {
|
||||
char *ident = (char *)buffer1;
|
||||
if (ident == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
Dev *founddev;
|
||||
HSHTB_GET(DEVTABLE.devs, ident, ident, founddev);
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
|
||||
if (founddev == NULL) {
|
||||
ret = E_NOENTRY;
|
||||
goto done;
|
||||
}
|
||||
|
||||
bool found = false;
|
||||
for (size_t i = 0; i < PROC_DEVHANDLES_MAX; i++) {
|
||||
if (proc->devs[i] == NULL) {
|
||||
found = true;
|
||||
proc->devs[i] = founddev;
|
||||
*devh = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!found) {
|
||||
ret = E_NOMEMORY;
|
||||
goto done;
|
||||
}
|
||||
} break;
|
||||
case DEVCTL_DEVLS_SZ: {
|
||||
size_t n = 0;
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
for (size_t i = 0; i < LEN(DEVTABLE.devs); i++) {
|
||||
if (DEVTABLE.devs[i]._hshtbstate == HSHTB_TAKEN) {
|
||||
n++;
|
||||
}
|
||||
}
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
ret = n;
|
||||
} break;
|
||||
case DEVCTL_DEVLS_STAT: {
|
||||
DevStat *devstat = (DevStat *)buffer1;
|
||||
size_t idx = (size_t)len1;
|
||||
|
||||
if (devstat == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
devstat->present = false;
|
||||
|
||||
spinlock_acquire(&DEVTABLE.spinlock);
|
||||
for (size_t i = 0; i < LEN(DEVTABLE.devs); i++) {
|
||||
if (i == idx && DEVTABLE.devs[i]._hshtbstate == HSHTB_TAKEN) {
|
||||
Dev *dev = &DEVTABLE.devs[i];
|
||||
hal_memcpy(devstat->name, dev->ident, sizeof(dev->ident));
|
||||
for (size_t j = 0; j < DEV_FNS_MAX; j++) {
|
||||
if (dev->fns[j] != NULL) {
|
||||
devstat->nfns++;
|
||||
}
|
||||
}
|
||||
devstat->present = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
spinlock_release(&DEVTABLE.spinlock);
|
||||
} break;
|
||||
default: {
|
||||
if (devh == NULL) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
if (cmd >= DEV_FNS_MAX) {
|
||||
ret = E_INVALIDARGUMENT;
|
||||
goto done;
|
||||
}
|
||||
|
||||
Dev *dev = proc->devs[*devh];
|
||||
if (dev == NULL) {
|
||||
ret = E_NOENTRY;
|
||||
goto done;
|
||||
}
|
||||
spinlock_acquire(&dev->spinlock);
|
||||
ret = dev->fns[cmd](dev, (uint8_t *)buffer1, (size_t)len1, (void *)extra1);
|
||||
spinlock_release(&dev->spinlock);
|
||||
} break;
|
||||
}
|
||||
|
||||
done:
|
||||
return ret;
|
||||
}
|
||||
@ -1,10 +0,0 @@
|
||||
#ifndef SYSCALL_DEVCTL_H_
|
||||
#define SYSCALL_DEVCTL_H_
|
||||
|
||||
#include <stdint.h>
|
||||
#include "syscall.h"
|
||||
#include "dev/dev.h"
|
||||
|
||||
int32_t SYSCALL5(sys_devctl, devh1, cmd1, buffer1, len1, extra1);
|
||||
|
||||
#endif // SYSCALL_DEVCTL_H_
|
||||
@ -6,11 +6,11 @@
|
||||
#include "ipcpipe.h"
|
||||
#include "mman.h"
|
||||
#include "sched.h"
|
||||
#include "devctl.h"
|
||||
#include "randcrypto.h"
|
||||
#include "vfs.h"
|
||||
#include "proc.h"
|
||||
#include "fs.h"
|
||||
#include "dev.h"
|
||||
|
||||
int32_t SYSCALL1(sys_debugprint, string) {
|
||||
char *p = (char *)string;
|
||||
@ -23,7 +23,6 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
||||
[SYS_MMAN_MAP] = &sys_mman_map,
|
||||
[SYS_MMAN_UNMAP] = &sys_mman_unmap,
|
||||
[SYS_SCHEDRELEASE] = &sys_schedrelease,
|
||||
[SYS_DEVCTL] = &sys_devctl,
|
||||
[SYS_RAND] = &sys_rand,
|
||||
[SYS_VFSMOUNT] = &sys_vfsmount,
|
||||
[SYS_VFSUNMOUNT] = &sys_vfsunmount,
|
||||
@ -48,4 +47,8 @@ SyscallFn SYSCALL_TABLE[SYSCALLS_MAX] = {
|
||||
[SYS_FS_STAT] = &sys_fs_stat,
|
||||
[SYS_FS_FETCHDIRENT] = &sys_fs_fetchdirent,
|
||||
[SYS_FS_MKDIR] = &sys_fs_mkdir,
|
||||
[SYS_DEV_GETHANDLE] = &sys_dev_gethandle,
|
||||
[SYS_DEV_LISTSIZE] = &sys_dev_listsize,
|
||||
[SYS_DEV_STAT] = &sys_dev_stat,
|
||||
[SYS_DEV_CMD] = &sys_dev_cmd,
|
||||
};
|
||||
|
||||
@ -5,7 +5,7 @@
|
||||
#include "syscall.h"
|
||||
#include "vfs.h"
|
||||
#include "errors.h"
|
||||
#include "sysdefs/devctl.h"
|
||||
#include "sysdefs/dev.h"
|
||||
#include "vfs/vfs.h"
|
||||
#include "spinlock/spinlock.h"
|
||||
#include "dev/dev.h"
|
||||
|
||||
@ -1,9 +1,5 @@
|
||||
#ifndef SHARE_SYSDEFS_DEVCTL_H_
|
||||
#define SHARE_SYSDEFS_DEVCTL_H_
|
||||
|
||||
#define DEVCTL_GET_HANDLE 100
|
||||
#define DEVCTL_DEVLS_SZ 101
|
||||
#define DEVCTL_DEVLS_STAT 102
|
||||
#ifndef SHARE_SYSDEFS_DEV_H_
|
||||
#define SHARE_SYSDEFS_DEV_H_
|
||||
|
||||
#define DEV_TERMDEV_PUTCH 0
|
||||
|
||||
@ -17,8 +13,6 @@
|
||||
|
||||
#define DEV_FBDEV_GETINFO 0
|
||||
|
||||
#if !defined(__ASSEMBLER__)
|
||||
|
||||
typedef uint64_t Dev_t;
|
||||
|
||||
typedef struct {
|
||||
@ -33,6 +27,4 @@ typedef struct {
|
||||
size_t nfns;
|
||||
} DevStat;
|
||||
|
||||
#endif
|
||||
|
||||
#endif // SHARE_SYSDEFS_DEVCTL_H_
|
||||
#endif // SHARE_SYSDEFS_DEV_H_
|
||||
@ -2,11 +2,9 @@
|
||||
#define SHARE_HDRS_SYSCALL_H_
|
||||
|
||||
#define SYS_DEBUGPRINT 1
|
||||
#define SYS_IOCTL 3
|
||||
#define SYS_MMAN_MAP 5
|
||||
#define SYS_MMAN_UNMAP 6
|
||||
#define SYS_SCHEDRELEASE 7
|
||||
#define SYS_DEVCTL 8
|
||||
#define SYS_RAND 9
|
||||
#define SYS_VFSMOUNT 10
|
||||
#define SYS_VFSUNMOUNT 11
|
||||
@ -31,6 +29,10 @@
|
||||
#define SYS_FS_WRITE 30
|
||||
#define SYS_FS_FETCHDIRENT 31
|
||||
#define SYS_FS_MKDIR 32
|
||||
#define SYS_DEV_GETHANDLE 33
|
||||
#define SYS_DEV_LISTSIZE 34
|
||||
#define SYS_DEV_STAT 35
|
||||
#define SYS_DEV_CMD 36
|
||||
|
||||
|
||||
#endif // SHARE_HDRS_SYSCALL_H_
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <sysdefs/syscall.h>
|
||||
#include <sysdefs/fs.h>
|
||||
#include <sysdefs/proc.h>
|
||||
#include <sysdefs/devctl.h>
|
||||
#include <sysdefs/dev.h>
|
||||
#include <uprintf.h>
|
||||
|
||||
void debugprint(const char *string) {
|
||||
@ -23,10 +23,6 @@ int32_t schedrelease(void) {
|
||||
return syscall(SYS_SCHEDRELEASE, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
int32_t devctl(Dev_t *devh, uint64_t cmd, uint8_t *buffer, size_t len, uint64_t extra) {
|
||||
return syscall(SYS_DEVCTL, (uint64_t)devh, cmd, (uint64_t)buffer, (uint64_t)len, (uint64_t)extra, 0);
|
||||
}
|
||||
|
||||
int32_t rand(void) {
|
||||
return syscall(SYS_RAND, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
@ -122,3 +118,19 @@ int32_t fs_fetchdirent(char *path, FsDirent *direntbuf, size_t idx) {
|
||||
int32_t fs_mkdir(char *path) {
|
||||
return syscall(SYS_FS_MKDIR, (uint64_t)path, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
int32_t dev_gethandle(Dev_t *dev, char *name) {
|
||||
return syscall(SYS_DEV_GETHANDLE, (uint64_t)dev, (uint64_t)name, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
int32_t dev_listsize(void) {
|
||||
return syscall(SYS_DEV_LISTSIZE, 0, 0, 0, 0, 0, 0);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
#include <sysdefs/devctl.h>
|
||||
#include <sysdefs/dev.h>
|
||||
#include <sysdefs/proc.h>
|
||||
#include <sysdefs/fs.h>
|
||||
|
||||
@ -12,7 +12,6 @@ void debugprint(const char *string);
|
||||
int32_t mman_map(uint8_t *addr, size_t size, uint64_t prot, uint64_t flags, uint8_t **out);
|
||||
int32_t mman_unmap(uint8_t *addr);
|
||||
int32_t schedrelease(void);
|
||||
int32_t devctl(Dev_t *devh, uint64_t cmd, uint8_t *buffer, size_t len, uint64_t extra);
|
||||
int32_t rand(void);
|
||||
int32_t vfsmount(char *mountpoint, char *fstype, Dev_t *dev, bool format);
|
||||
int32_t vfsunmount(char *mountpoint);
|
||||
@ -37,5 +36,9 @@ int32_t fs_read(int32_t fsh, uint8_t *const buffer, size_t len, size_t off);
|
||||
int32_t fs_stat(char *path, FsStat *statbuf);
|
||||
int32_t fs_fetchdirent(char *path, FsDirent *direntbuf, size_t idx);
|
||||
int32_t fs_mkdir(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);
|
||||
|
||||
#endif // ULIB_SYSTEM_SYSTEM_H_
|
||||
|
||||
@ -21,6 +21,7 @@
|
||||
|
||||
#include <errors.h>
|
||||
#include <sysdefs/fs.h>
|
||||
#include <sysdefs/dev.h>
|
||||
#include <sysdefs/mman.h>
|
||||
#include <sysdefs/proc.h>
|
||||
#include <sysdefs/sched.h>
|
||||
|
||||
@ -3,14 +3,14 @@
|
||||
#include <ulib.h>
|
||||
|
||||
void dev_ls(void) {
|
||||
size_t ndevs = devctl(NULL, DEVCTL_DEVLS_SZ, NULL, 0, 0);
|
||||
size_t ndevs = dev_listsize();
|
||||
uprintf("TOTAL: %zu\n", ndevs);
|
||||
|
||||
uprintf("%-20s %-10s\n", "DEVICE", "FUNCTIONS");
|
||||
|
||||
for (size_t i = 0; i < 0x100; i++) {
|
||||
DevStat devstat; ZERO(&devstat);
|
||||
devctl(NULL, DEVCTL_DEVLS_STAT, (uint8_t *)&devstat, i, 0);
|
||||
dev_stat(&devstat, i);
|
||||
|
||||
if (!devstat.present)
|
||||
continue;
|
||||
|
||||
@ -40,7 +40,7 @@ void fs_mount(void) {
|
||||
}
|
||||
|
||||
Dev_t dev;
|
||||
ret = devctl(&dev, DEVCTL_GET_HANDLE, (uint8_t *)FS_MOUNT_CONFIG.devname, 0, 0);
|
||||
ret = dev_gethandle(&dev, FS_MOUNT_CONFIG.devname);
|
||||
if (ret != E_OK) {
|
||||
uprintf("fs: device %s not found\n", FS_MOUNT_CONFIG.devname);
|
||||
return;
|
||||
|
||||
@ -6,7 +6,7 @@ Dev_t ps2kbdev;
|
||||
Dev_t termdev;
|
||||
|
||||
void tb_runinitscript(void) {
|
||||
devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)"termdev", 0, 0);
|
||||
dev_gethandle(&termdev, "termdev");
|
||||
|
||||
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb" };
|
||||
int32_t tb = proc_spawn("base:/bin/tb", tbargs, ARRLEN(tbargs));
|
||||
@ -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) {
|
||||
devctl(&termdev, DEV_TERMDEV_PUTCH, (uint8_t *)buf, string_len(buf), 0);
|
||||
dev_cmd(&termdev, DEV_TERMDEV_PUTCH, buf, string_len(buf), NULL);
|
||||
} else {
|
||||
schedrelease();
|
||||
}
|
||||
@ -29,8 +29,8 @@ void tb_runinitscript(void) {
|
||||
|
||||
void main(void) {
|
||||
PID = proc_getpid();
|
||||
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);
|
||||
devctl(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (uint8_t *)PID, 0, 0);
|
||||
dev_gethandle(&ps2kbdev, "ps2kbdev");
|
||||
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (void *)PID, 0, NULL);
|
||||
|
||||
tb_runinitscript();
|
||||
|
||||
|
||||
@ -217,7 +217,7 @@ bool interp_runstring(char *string, InterpResult **res, bool logcmds, bool inter
|
||||
|
||||
while(proc_pollstate(app) != 4) {
|
||||
if (interactive) {
|
||||
int32_t key = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, (uint8_t *)PID, 0, 0);
|
||||
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL);
|
||||
if (key > 0 && (uint8_t)key == C('S')) {
|
||||
proc_kill(app);
|
||||
goto cleanup;
|
||||
|
||||
@ -102,7 +102,7 @@ void do_mode_interactive(void) {
|
||||
|
||||
uint8_t b = 0;
|
||||
for (;;) {
|
||||
int32_t key = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, (uint8_t *)PID, 0, 0);
|
||||
int32_t key = dev_cmd(&ps2kbdev, DEV_PS2KBDEV_READCH, (void *)PID, 0, NULL);
|
||||
if (key > 0) {
|
||||
b = (uint8_t)key;
|
||||
switch (b) {
|
||||
@ -151,8 +151,8 @@ void main(void) {
|
||||
do_file("base:/scripts/rc.tb");
|
||||
|
||||
if (CONFIG.mode == MODE_INTERACTIVE) {
|
||||
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)"ps2kbdev", 0, 0);
|
||||
devctl(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (uint8_t *)PID, 0, 0);
|
||||
dev_gethandle(&ps2kbdev, "ps2kbdev");
|
||||
dev_cmd(&ps2kbdev, DEV_PS2KBDEV_ATTCHCONS, (void *)PID, 0, NULL);
|
||||
do_mode_interactive();
|
||||
} else if (CONFIG.mode == MODE_RUNFILE) {
|
||||
if (CONFIG.filepath == NULL) {
|
||||
|
||||
Reference in New Issue
Block a user