tb input from ps2kb

This commit is contained in:
2025-09-28 23:26:07 +02:00
parent d7562b98c1
commit 2b93d6d184
4 changed files with 14 additions and 8 deletions

View File

@ -2,22 +2,26 @@
#include <ulib.h>
uint64_t PID;
Dev_t ps2kbdev;
void tb_runinitscript(void) {
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));
ipcpipe(tb, IPCPIPE_IN, IPCPIPE_ADD_BCAST, NULL, 1);
processctl(tb, PCTL_RUN, 0, 0, 0);
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) {
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
devctl(&ps2kbdev, DEVCTL_GET_HANDLE, (uint8_t *)DEV_PS2KBDEV, 0, 0);
tb_runinitscript();

View File

@ -41,7 +41,7 @@ void set_config(void) {
} else if (string_strcmp(CONFIG.modestr, "runfile") == 0) {
CONFIG.mode = MODE_RUNFILE;
} else {
LOG(LOG_ERR, "Unknown mode {s}\n", CONFIG.modestr);
LOG(LOG_ERR, "Unknown mode %s\n", CONFIG.modestr);
}
} else {
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);
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;
}
@ -61,14 +61,14 @@ void do_file(char *filepath) {
ioctl(ioh, IOCTL_STAT, (uint64_t)&statbuf, 0, 0);
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;
}
uint8_t *buf = umalloc(statbuf.size+1);
string_memset(buf, 0, statbuf.size+1);
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;
}
@ -131,7 +131,7 @@ void do_mode_interactive(void) {
uprintf("\n");
InterpResult *res;
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);
}
}
}