Files
my-os-project2/user/init/main.c
2025-09-28 23:26:07 +02:00

32 lines
795 B
C

#include <stdint.h>
#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));
processctl(tb, PCTL_RUN, 0, 0, 0);
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
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();
uprintf("Shell exited! Please reboot the system.\n");
for(;;);
}