diff --git a/kernel/proc/proc.c b/kernel/proc/proc.c index 44278e7..70836aa 100644 --- a/kernel/proc/proc.c +++ b/kernel/proc/proc.c @@ -101,7 +101,7 @@ Proc *proc_spawnkern(void (*ent)(void), char *name) { proc->platformdata.cr3 = hal_vmm_current_cr3(); proc->state = PROC_READY; proc->pid = pids++; - spinlock_init(&proc->eventpipes_spinlock); + spinlock_init(&proc->bcast_pipes.spinlock); return proc; } @@ -167,7 +167,7 @@ Proc *proc_spawnuser(char *mountpoint, char *path) { proc->platformdata.trapframe.rip = aux.entry; proc->state = PROC_READY; proc->pid = pids++; - spinlock_init(&proc->eventpipes_spinlock); + spinlock_init(&proc->bcast_pipes.spinlock); return proc; } diff --git a/kernel/proc/proc.h b/kernel/proc/proc.h index 4664783..f7841be 100644 --- a/kernel/proc/proc.h +++ b/kernel/proc/proc.h @@ -45,10 +45,11 @@ typedef struct Proc { VfsObj *vobjs[PROC_VFSHANDLES_MAX]; uint64_t vobjcnt; - IpcPipe *pipes[PROC_PIPEHANDLES_MAX]; - IpcPipe *eventpipes; - SpinLock eventpipes_spinlock; + struct { + IpcPipe *list; + SpinLock spinlock; + } bcast_pipes; } Proc; typedef struct { diff --git a/kernel/proc/ps2kbproc/ps2kbproc.c b/kernel/proc/ps2kbproc/ps2kbproc.c index bec3f86..9f853be 100644 --- a/kernel/proc/ps2kbproc/ps2kbproc.c +++ b/kernel/proc/ps2kbproc/ps2kbproc.c @@ -13,7 +13,7 @@ Ps2KbFastBuf PS2KB_BUF; void ps2kbproc_init(Proc *proc) { PS2KBPROC = proc; - PS2KBPROC->eventpipes = NULL; + PS2KBPROC->bcast_pipes.list = NULL; PS2KB_BUF.rbuf.buffer = dlmalloc(IPC_PIPE_MAX); PS2KB_BUF.rbuf.cap = IPC_PIPE_MAX; @@ -33,13 +33,13 @@ void ps2kbproc_fn(void) { } spinlock_release(&PS2KB_BUF.spinlock); if (i > 0) { - spinlock_acquire(&PS2KBPROC->eventpipes_spinlock); - IpcPipe *head = PS2KBPROC->eventpipes; + spinlock_acquire(&PS2KBPROC->bcast_pipes.spinlock); + IpcPipe *head = PS2KBPROC->bcast_pipes.list; while (head != NULL) { ipc_pipewrite(head, (uint8_t *)&kbchr, sizeof(kbchr)); head = head->next; } - spinlock_release(&PS2KBPROC->eventpipes_spinlock); + spinlock_release(&PS2KBPROC->bcast_pipes.spinlock); } } } diff --git a/kernel/syscall/ipcpipe.c b/kernel/syscall/ipcpipe.c index 62fe8f9..2e55789 100644 --- a/kernel/syscall/ipcpipe.c +++ b/kernel/syscall/ipcpipe.c @@ -94,7 +94,7 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) { ret = ipc_piperead(pipe, buffer, len1); } break; - case IPCPIPE_REG_EVT_PIPE: { + case IPCPIPE_ADD_BCAST: { if (pipenum >= PROC_PIPEHANDLES_MAX) { ret = E_NOMEMORY; goto done; @@ -119,9 +119,9 @@ int32_t SYSCALL5(sys_ipcpipe, pid1, pipenum1, cmd1, buffer1, len1) { goto done; } - spinlock_acquire(&proc2->eventpipes_spinlock); - LL_APPEND(proc2->eventpipes, pipe); - spinlock_release(&proc2->eventpipes_spinlock); + spinlock_acquire(&proc2->bcast_pipes.spinlock); + LL_APPEND(proc2->bcast_pipes.list, pipe); + spinlock_release(&proc2->bcast_pipes.spinlock); ret = E_OK; } break; diff --git a/share/sysdefs/ipcpipe.h b/share/sysdefs/ipcpipe.h index 358f67e..6042bf4 100644 --- a/share/sysdefs/ipcpipe.h +++ b/share/sysdefs/ipcpipe.h @@ -13,7 +13,7 @@ enum { IPCPIPE_MAKE = 0, IPCPIPE_READ = 1, IPCPIPE_WRITE = 2, - IPCPIPE_REG_EVT_PIPE = 3, + IPCPIPE_ADD_BCAST = 3, }; #endif // SHARE_SYSDEFS_IPCPIPE_H_ diff --git a/user/init/main.c b/user/init/main.c index 9e9b19f..44f82c2 100644 --- a/user/init/main.c +++ b/user/init/main.c @@ -31,7 +31,7 @@ void main(void) { uprintf("failed to create 10th pipe\n"); } - int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_REG_EVT_PIPE, NULL, 1); + int32_t r = ipcpipe(IPCPIPE_SELFPID, 10, IPCPIPE_ADD_BCAST, NULL, 1); uprintf("%d\n", r); while(1) {