From da907d78086597656a61099584c4f31afd981a8a Mon Sep 17 00:00:00 2001 From: komrebi32 Date: Fri, 2 Oct 2026 21:35:15 -0400 Subject: [PATCH] refactor(ipc): move the ipc headers to the global include directory - ipc/ipc.h, ipc/message.h and ipc/sync.h move to include/novium/ - the sources and kernel_main() include them as - the headers keep quoting each other, they are in the same directory - changelog: 0.9-dev dated 2026-10-02 --- CHANGELOG.md | 9 +++++---- {ipc => include/novium}/ipc.h | 1 + {ipc => include/novium}/message.h | 0 {ipc => include/novium}/sync.h | 0 init/main.c | 6 +++--- ipc/ipc.c | 2 +- ipc/message.c | 2 +- ipc/sync.c | 2 +- 8 files changed, 12 insertions(+), 10 deletions(-) rename {ipc => include/novium}/ipc.h (99%) rename {ipc => include/novium}/message.h (100%) rename {ipc => include/novium}/sync.h (100%) diff --git a/CHANGELOG.md b/CHANGELOG.md index e9eb3e7..c43490d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,12 +3,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com), Versioning is similar to [semver](https://semver.org) but is more flexible and similar to how linux does it, and uses custom tags (like `-dev` and `-rc`). -## 0.9-dev - 2026-10-2 +## 0.9-dev - 2026-10-02 ### Added - `ipc/` filled in with message passing and synchronisation between kernel tasks, replacing the stubs. -- `IpcPort` in `ipc/message.h`, a FIFO of `IpcPortCapacity` (16) fixed size messages. `IpcSend()` waits while the port is full and `IpcReceive()` waits while it is empty, so two tasks can hand work back and forth without polling. `IpcTrySend()` and `IpcTryReceive()` are the non blocking forms. -- `IpcSemaphore` and `IpcMutex` in `ipc/sync.h`. A semaphore takes a ceiling, so a `Limit` of 1 is a binary semaphore and `SemPost()` past the ceiling reports `IpcErrFull` rather than letting the count run away. +- `IpcPort` in `include/novium/message.h`, a FIFO of `IpcPortCapacity` (16) fixed size messages. `IpcSend()` waits while the port is full and `IpcReceive()` waits while it is empty, so two tasks can hand work back and forth without polling. `IpcTrySend()` and `IpcTryReceive()` are the non blocking forms. +- `IpcSemaphore` and `IpcMutex` in `include/novium/sync.h`. A semaphore takes a ceiling, so a `Limit` of 1 is a binary semaphore and `SemPost()` past the ceiling reports `IpcErrFull` rather than letting the count run away. - `IpcStatus` for every entry point, so a refused call says why instead of failing silently. - A shared wait queue in `ipc/ipc.c`. `IpcPark()` registers the calling task and sleeps as one step under the interrupt lock, so a waker that runs in between either finds the task parked or is seen by the re-check afterwards. A wakeup cannot be lost. - Wait queues keyed by task id rather than `Task *`, and `IpcWaitTakeLive()` drops entries left by a task that was killed, since a dead task can never run again. @@ -16,8 +16,9 @@ Versioning is similar to [semver](https://semver.org) but is more flexible and s - `ipc/` added to the `Makefile` VPATH and its objects to `KERNEL_OBJS`. ### Changed +- The `ipc/` headers moved to the global include directory, so they are `include/novium/ipc.h`, `include/novium/message.h` and `include/novium/sync.h` now. They were left next to the `.c` files while they were stubs, but they describe interfaces the rest of the kernel includes, which is what `include/novium/` is for. Include paths updated accordingly. - `MutexUnlock()` hands ownership straight to the first waiter instead of clearing the owner, so a task that merely happens to be ready cannot take the lock ahead of the task that was woken for it. -- `ipc/message.h` and `ipc/sync.h` are no longer listed as planned interfaces, since their contracts are documented in `Documentation/kernel_api.md` now. +- `include/novium/message.h` and `include/novium/sync.h` are no longer listed as planned interfaces, since their contracts are documented in `Documentation/kernel_api.md` now. ### Known issues - Nothing here is reentrant, so calling into `ipc/` from an interrupt handler is not supported yet. diff --git a/ipc/ipc.h b/include/novium/ipc.h similarity index 99% rename from ipc/ipc.h rename to include/novium/ipc.h index 2bc2d5a..eebb024 100644 --- a/ipc/ipc.h +++ b/include/novium/ipc.h @@ -1,6 +1,7 @@ #ifndef NOVIUM_IPC_H #define NOVIUM_IPC_H +#include "ipc.h" #include #include diff --git a/ipc/message.h b/include/novium/message.h similarity index 100% rename from ipc/message.h rename to include/novium/message.h diff --git a/ipc/sync.h b/include/novium/sync.h similarity index 100% rename from ipc/sync.h rename to include/novium/sync.h diff --git a/init/main.c b/init/main.c index 959bf0a..4f040ed 100644 --- a/init/main.c +++ b/init/main.c @@ -1,15 +1,15 @@ #include #include -#include -#include -#include #include #include #include #include +#include #include +#include #include #include +#include #include #define TASK_STACK_SIZE 4096 diff --git a/ipc/ipc.c b/ipc/ipc.c index 7b62cc8..7b01af1 100644 --- a/ipc/ipc.c +++ b/ipc/ipc.c @@ -1,5 +1,5 @@ -#include "ipc.h" #include +#include u32 IpcSelfId(void) { Task *Self = SchedCurrent(); diff --git a/ipc/message.c b/ipc/message.c index 7bac44e..39000ff 100644 --- a/ipc/message.c +++ b/ipc/message.c @@ -1,5 +1,5 @@ -#include "message.h" #include +#include #define PORT_MAGIC 0x504F5254u /* ASCII "PORT", tells a real port from garbage */ diff --git a/ipc/sync.c b/ipc/sync.c index 0ced247..1df46d6 100644 --- a/ipc/sync.c +++ b/ipc/sync.c @@ -1,5 +1,5 @@ -#include "sync.h" #include +#include /* * Semaphore.