From 75f137b85a36338eafd27bf290910b102467ba5b Mon Sep 17 00:00:00 2001 From: dzwdz Date: Mon, 25 Sep 2023 00:25:53 +0200 Subject: kernel/procfs: `intrdown` node for sending an interrupt to all children --- src/kernel/vfs/procfs.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/kernel/vfs') diff --git a/src/kernel/vfs/procfs.c b/src/kernel/vfs/procfs.c index 5031840..2e3130d 100644 --- a/src/kernel/vfs/procfs.c +++ b/src/kernel/vfs/procfs.c @@ -11,6 +11,7 @@ enum phandle_type { PhRoot, PhDir, PhIntr, + PhIntrDown, PhMem, }; @@ -55,6 +56,8 @@ openpath(const char *path, size_t len, Proc *root) type = PhDir; } else if (len == 4 && memcmp(path, "intr", 4) == 0) { type = PhIntr; + } else if (len == 8 && memcmp(path, "intrdown", 8) == 0) { + type = PhIntrDown; } else if (len == 3 && memcmp(path, "mem", 3) == 0) { type = PhMem; } else { @@ -145,10 +148,18 @@ procfs_accept(VfsReq *req) req->output.len ); vfsreq_finish_short(req, res); - } else if (req->type == VFSOP_WRITE && h->type == PhIntr) { + } else if (req->type == VFSOP_WRITE && + (h->type == PhIntr || h->type == PhIntrDown)) + { size_t len = min(sizeof buf, req->input.len); len = pcpy_from(req->caller, buf, req->input.buf, len); - proc_intr(p, buf, len); + if (h->type == PhIntr) { + proc_intr(p, buf, len); + } else { + for (Proc *it = p->child; it; it = proc_next(it, p)) { + proc_intr(it, buf, len); + } + } vfsreq_finish_short(req, req->input.len); } else { vfsreq_finish_short(req, -ENOSYS); -- cgit v1.2.3