49 lines
1.3 KiB
C
49 lines
1.3 KiB
C
#include <stdint.h>
|
|
#include <ulib.h>
|
|
|
|
uint64_t PID;
|
|
Dev_t ps2kbdev;
|
|
Dev_t termdev;
|
|
|
|
void tb_runinitscript(void) {
|
|
devctl(&termdev, DEVCTL_GET_HANDLE, (uint8_t *)"termdev", 0, 0);
|
|
|
|
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)(char **)tbargs, ARRLEN(tbargs));
|
|
|
|
processctl(tb, PCTL_RUN, 0, 0, 0);
|
|
|
|
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
|
|
int32_t r;
|
|
|
|
char buf[100];
|
|
string_memset(buf, 0, sizeof(buf));
|
|
r = ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_READ, (uint8_t *)buf, sizeof(buf)-1);
|
|
if (r > 0) {
|
|
devctl(&termdev, DEV_TERMDEV_PUTCH, (uint8_t *)buf, string_len(buf), 0);
|
|
}
|
|
|
|
r = devctl(&ps2kbdev, DEV_PS2KBDEV_READCH, 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 *)"ps2kbdev", 0, 0);
|
|
|
|
Dev_t serialdev;
|
|
int32_t err = devctl(&serialdev, DEVCTL_GET_HANDLE, (uint8_t *)"serialdev", 0, 0);
|
|
uint8_t a = 'A';
|
|
devctl(&serialdev, DEV_SERIALDEV_SENDB, &a, 1, 0);
|
|
|
|
tb_runinitscript();
|
|
|
|
uprintf("Shell exited! Please reboot the system.\n");
|
|
|
|
for(;;);
|
|
}
|