This commit is contained in:
2025-09-15 22:35:15 +02:00
parent ce63020b34
commit 0a5523f234
22 changed files with 374 additions and 177 deletions

View File

@ -7,18 +7,37 @@
#include <ansiq/all.h>
#include <string/char.h>
#include <util/util.h>
#include <dlmalloc/malloc.h>
#define SUBPROC_PIPE_OUT 0x1f
uint64_t PID;
void main(void) {
PID = (uint64_t)processctl(-1, PCTL_GETPID, 0, 0, 0);
ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_MAKE, NULL, 0);
char *tbargs[] = { "-m", "runfile", "-f", "base:/scripts/init.tb" };
int32_t tb = processctl(-1, PCTL_SPAWN, (uint64_t)"base:/bin/tb", (uint64_t)&tbargs, ARRLEN(tbargs));
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);
ipcpipe(tb, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)PID, SUBPROC_PIPE_OUT);
ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_MAKE, NULL, 0);
ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_ADD_BCAST, NULL, 1);
processctl(tb, PCTL_RUN, 0, 0, 0);
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 2) {
#define OUTBUF_MAX 1024
char *outbuf = dlmalloc(1024);
while(processctl(tb, PCTL_POLLSTATE, 0, 0, 0) != 4) {
string_memset(outbuf, 0, OUTBUF_MAX);
int32_t nrd = ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_READ, (uint8_t *)outbuf, sizeof(outbuf));
if (nrd > 0) {
uprintf("%s", outbuf);
}
#if 0
int32_t kbchr;
int32_t read = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_READ, (uint8_t *)&kbchr, sizeof(kbchr));
if (read > 0) {
@ -32,6 +51,9 @@ void main(void) {
}
}
}
#endif
}
for(;;);
}