Compare commits

...

3 Commits

6 changed files with 40 additions and 19 deletions

View File

@ -1,3 +1,2 @@
@print "this is an init script!" @print "this is an init script!"
base:/bin/pctl ls base:/bin/pctl ls
base:/bin/tb -m interactive

View File

@ -215,6 +215,7 @@ void intr_handleintr(IntrStackFrame *frame) {
break; break;
case INTR_IRQBASE+1: case INTR_IRQBASE+1:
int32_t c = ps2kb_intr(); int32_t c = ps2kb_intr();
intr_eoi(frame->trapnum - INTR_IRQBASE);
if (c >= 0) { if (c >= 0) {
uint8_t *bytes = (uint8_t *)&c; uint8_t *bytes = (uint8_t *)&c;
spinlock_acquire(&PS2KB_BUF.spinlock); spinlock_acquire(&PS2KB_BUF.spinlock);
@ -223,7 +224,6 @@ void intr_handleintr(IntrStackFrame *frame) {
} }
spinlock_release(&PS2KB_BUF.spinlock); spinlock_release(&PS2KB_BUF.spinlock);
} }
intr_eoi(frame->trapnum - INTR_IRQBASE);
break; break;
} }
} else if (frame->trapnum == 0x80) { } else if (frame->trapnum == 0x80) {

View File

@ -61,6 +61,21 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) {
ret = E_OK; ret = E_OK;
} break; } break;
case IPCPIPE_DELETE: {
if (pipenum >= PROC_PIPEHANDLES_MAX) {
ret = E_NOMEMORY;
goto done;
}
spinlock_acquire(&proc->pipes_spinlock);
if (proc->pipes[pipenum] != NULL) {
ipc_pipefree(proc->pipes[pipenum]);
dlfree(proc->pipes[pipenum]);
proc->pipes[pipenum] = NULL;
}
spinlock_release(&proc->pipes_spinlock);
ret = E_OK;
} break;
case IPCPIPE_WRITE: { case IPCPIPE_WRITE: {
if (pipenum >= PROC_PIPEHANDLES_MAX) { if (pipenum >= PROC_PIPEHANDLES_MAX) {
ret = E_INVALIDARGUMENT; ret = E_INVALIDARGUMENT;

View File

@ -9,6 +9,7 @@
#include "path/path.h" #include "path/path.h"
#include "kprintf.h" #include "kprintf.h"
#include "dlmalloc/malloc.h" #include "dlmalloc/malloc.h"
#include "ipc/pipe/pipe.h"
#define PCTL_MP_MAX 0xff #define PCTL_MP_MAX 0xff
#define PCTL_PATH_MAX VFS_PATH_MAX #define PCTL_PATH_MAX VFS_PATH_MAX
@ -66,6 +67,14 @@ int32_t SYSCALL5(sys_processctl, pid1, cmd1, arg1, arg2, arg3) {
PROC_ARG(newproc, (*args)[i]); PROC_ARG(newproc, (*args)[i]);
} }
for (size_t i = 0; i < PROC_PIPEHANDLES_MAX; i++) {
if (newproc->pipes[i] != NULL) {
ipc_pipefree(newproc->pipes[i]);
dlfree(newproc->pipes[i]);
}
newproc->pipes[i] = proc->pipes[i];
}
proc_register(newproc); proc_register(newproc);
ret = newproc->pid; ret = newproc->pid;
} break; } break;

View File

@ -15,6 +15,7 @@ enum {
IPCPIPE_WRITE = 2, IPCPIPE_WRITE = 2,
IPCPIPE_ADD_BCAST = 3, IPCPIPE_ADD_BCAST = 3,
IPCPIPE_REPLACE = 4, IPCPIPE_REPLACE = 4,
IPCPIPE_DELETE = 5,
}; };
#endif // SHARE_SYSDEFS_IPCPIPE_H_ #endif // SHARE_SYSDEFS_IPCPIPE_H_

View File

@ -212,6 +212,7 @@ bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
#define OUTBUF_MAX 1024 #define OUTBUF_MAX 1024
char *outbuf = dlmalloc(OUTBUF_MAX); char *outbuf = dlmalloc(OUTBUF_MAX);
string_memset(outbuf, 0, OUTBUF_MAX);
ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_MAKE, NULL, 0); ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_MAKE, NULL, 0);
@ -219,27 +220,23 @@ bool interp_runstring(const char *string, InterpResult **res, bool logcmds) {
if (app < 0) { if (app < 0) {
usprintf(RES.errmsg, "Could not run %s: %s\n", appname, ERRSTRING(app)); usprintf(RES.errmsg, "Could not run %s: %s\n", appname, ERRSTRING(app));
ok = false; ok = false;
dlfree(outbuf); goto cleanup;
for (size_t j = 0; j < argslen1; j++) {
dlfree(args1[j]);
}
dlfree(args1);
dlfree(appname);
goto done;
} }
ipcpipe(app, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)PID, SUBPROC_PIPE_OUT); ipcpipe(app, IPCPIPE_OUT, IPCPIPE_REPLACE, (uint8_t *)PID, SUBPROC_PIPE_OUT);
ipcpipe(app, IPCPIPE_IN, IPCPIPE_REPLACE, (uint8_t *)PID, IPCPIPE_IN); ipcpipe(app, IPCPIPE_IN, IPCPIPE_REPLACE, (uint8_t *)PID, IPCPIPE_IN);
processctl(app, PCTL_RUN, 0, 0, 0); processctl(app, PCTL_RUN, 0, 0, 0);
while (processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4) { do {
string_memset(outbuf, 0, OUTBUF_MAX); int32_t nrd = ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_READ, (uint8_t *)outbuf, OUTBUF_MAX);
int32_t nrd = ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_READ, (uint8_t *)outbuf, sizeof(outbuf));
if (nrd > 0) { if (nrd > 0) {
uprintf("%s", outbuf); uprintf("%s", outbuf);
string_memset(outbuf, 0, OUTBUF_MAX);
} }
} } while(processctl(app, PCTL_POLLSTATE, 0, 0, 0) != 4);
cleanup:
ipcpipe(PID, SUBPROC_PIPE_OUT, IPCPIPE_DELETE, NULL, 0);
dlfree(outbuf); dlfree(outbuf);
for (size_t j = 0; j < argslen1; j++) { for (size_t j = 0; j < argslen1; j++) {
dlfree(args1[j]); dlfree(args1[j]);