#include #include #include #include #include #include #include #include void main(void) { uprintf(ANSIQ_CUR_SET(0, 0)); uprintf(ANSIQ_SCR_CLR_ALL); int32_t ioh = ioctl(IOCTL_NOHANDLE, IOCTL_OPENF, (uint64_t)"temp:/hello.txt", IOCTL_F_WRITE | IOCTL_F_READ | IOCTL_F_MAKE, 0 ); char *text = "Hello from FS"; ioctl(ioh, IOCTL_WRITE, (uint64_t)text, string_len(text), 0); char buf[0x100] = {0}; ioctl(ioh, IOCTL_READ, (uint64_t)buf, string_len(text), 0); uprintf("file contents: %s\n", buf); ioctl(ioh, IOCTL_CLOSEF, 0, 0, 0); uprintf("Hello world using uprintf\n"); const char *tbargs[] = { "-i" }; int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)tbargs, 1); uint64_t selfpid = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0); ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)selfpid, IPCPIPE_OUT); processctl(tb, PCTL_RUN, 0, 0, 0); while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 2); if (ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_MAKE, NULL, 0) < 0) { uprintf("failed to create 10th pipe\n"); } int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_ADD_BCAST, NULL, 1); uprintf("%d\n", r); while(1) { int32_t kbchr; int32_t read = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_READ, (uint8_t *)&kbchr, sizeof(kbchr)); if (read > 0) { kbchr &= 0xFF; if ((kbchr >= 0x20 && kbchr <= 0x7F) || kbchr == 0xA) { uprintf("%c", kbchr & 0xFF); } } } for(;;); }