tb input from ps2kb
This commit is contained in:
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
enum {
|
enum {
|
||||||
DEV_TERMDEV = 0x10,
|
DEV_TERMDEV = 0x10,
|
||||||
|
DEV_PS2KBDEV = 0x11,
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // ULIB_DEVIDS_H_
|
#endif // ULIB_DEVIDS_H_
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <log.h>
|
#include <log.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <umalloc/umalloc.h>
|
#include <umalloc/umalloc.h>
|
||||||
|
#include <devids.h>
|
||||||
|
|
||||||
#include <errors.h>
|
#include <errors.h>
|
||||||
#include <sysdefs/ioctl.h>
|
#include <sysdefs/ioctl.h>
|
||||||
|
@ -2,22 +2,26 @@
|
|||||||
#include <ulib.h>
|
#include <ulib.h>
|
||||||
|
|
||||||
uint64_t PID;
|
uint64_t PID;
|
||||||
|
Dev_t ps2kbdev;
|
||||||
|
|
||||||
void tb_runinitscript(void) {
|
void tb_runinitscript(void) {
|
||||||
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb", "-logcmds", "yes" };
|
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb", "-logcmds", "yes" };
|
||||||
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)&tbargs, ARRLEN(tbargs));
|
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)&tbargs, ARRLEN(tbargs));
|
||||||
|
|
||||||
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_ADD_BCAST, NULL, 1);
|
|
||||||
|
|
||||||
processctl(tb, PCTL_RUN, 0, 0, 0);
|
processctl(tb, PCTL_RUN, 0, 0, 0);
|
||||||
|
|
||||||
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
||||||
schedrelease();
|
int32_t r = devctl(&ps2kbdev, 0x00, NULL, 0, 0);
|
||||||
|
if (r != E_NOTYET) {
|
||||||
|
uint8_t b = r;
|
||||||
|
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_WRITE, &b, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void main(void) {
|
void main(void) {
|
||||||
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
|
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
|
||||||
|
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)DEV_PS2KBDEV, 0, 0);
|
||||||
|
|
||||||
tb_runinitscript();
|
tb_runinitscript();
|
||||||
|
|
||||||
|
@ -41,7 +41,7 @@ void set_config(void) {
|
|||||||
} else if (string_strcmp(CONFIG.modestr, "runfile") == 0) {
|
} else if (string_strcmp(CONFIG.modestr, "runfile") == 0) {
|
||||||
CONFIG.mode = MODE_RUNFILE;
|
CONFIG.mode = MODE_RUNFILE;
|
||||||
} else {
|
} else {
|
||||||
LOG(LOG_ERR, "Unknown mode {s}\n", CONFIG.modestr);
|
LOG(LOG_ERR, "Unknown mode %s\n", CONFIG.modestr);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
CONFIG.mode = MODE_RUNFILE;
|
CONFIG.mode = MODE_RUNFILE;
|
||||||
@ -53,7 +53,7 @@ void do_file(char *filepath) {
|
|||||||
|
|
||||||
int32_t ioh = ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, (uint64_t)filepath, IOCTL_F_READ, 0);
|
int32_t ioh = ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, (uint64_t)filepath, IOCTL_F_READ, 0);
|
||||||
if (ioh < 0) {
|
if (ioh < 0) {
|
||||||
LOG(LOG_ERR, "Could not open {s}: {s}\n", filepath, ERRSTRING(ioh));
|
LOG(LOG_ERR, "Could not open %s: %s\n", filepath, ERRSTRING(ioh));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,14 +61,14 @@ void do_file(char *filepath) {
|
|||||||
|
|
||||||
ioctl(ioh, IOCTL_STAT, (uint64_t)&statbuf, 0, 0);
|
ioctl(ioh, IOCTL_STAT, (uint64_t)&statbuf, 0, 0);
|
||||||
if (statbuf.type != IOCTLSTAT_FILE) {
|
if (statbuf.type != IOCTLSTAT_FILE) {
|
||||||
LOG(LOG_ERR, "{s} is not a file ({d})\n", filepath, statbuf.type);
|
LOG(LOG_ERR, "%s is not a file (%d)\n", filepath, statbuf.type);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
uint8_t *buf = umalloc(statbuf.size+1);
|
uint8_t *buf = umalloc(statbuf.size+1);
|
||||||
string_memset(buf, 0, statbuf.size+1);
|
string_memset(buf, 0, statbuf.size+1);
|
||||||
|
|
||||||
if ((ret = ioctl(ioh, IOCTL_READ, (uint64_t)buf, statbuf.size, 0)) < 0) {
|
if ((ret = ioctl(ioh, IOCTL_READ, (uint64_t)buf, statbuf.size, 0)) < 0) {
|
||||||
LOG(LOG_ERR, "Could not read {s} ({d}): {s}\n", filepath, ioh, ERRSTRING(ioh));
|
LOG(LOG_ERR, "Could not read %s (%d): %s\n", filepath, ioh, ERRSTRING(ioh));
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ void do_mode_interactive(void) {
|
|||||||
uprintf("\n");
|
uprintf("\n");
|
||||||
InterpResult *res;
|
InterpResult *res;
|
||||||
if (!interp_runstring(linebuf, &res, CONFIG.logcmds, CONFIG.mode == MODE_INTERACTIVE)) {
|
if (!interp_runstring(linebuf, &res, CONFIG.logcmds, CONFIG.mode == MODE_INTERACTIVE)) {
|
||||||
LOG(LOG_ERR, "{s}\n", res->errmsg);
|
LOG(LOG_ERR, "%s\n", res->errmsg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user