strat9_kernel/ipc/mod.rs
1//! Inter-Process Communication (IPC) subsystem.
2//!
3//! See also: [IPC Mechanisms Guide](https://strat9-os.org/strat9-os-docs/ipc-mechanisms.html)
4//! for architecture diagrams and usage patterns.
5//!
6//! Strat9-OS uses two complementary IPC mechanisms:
7//!
8//! ## 1. IPC Ports (synchronous message-passing, service endpoints)
9//!
10//! Each port has a bounded FIFO queue of 64-byte [`IpcMessage`]s.
11//! Senders block when the queue is full; receivers block when empty.
12//! Ports are owned by a single task and accessed via syscalls:
13//! - `SYS_IPC_CREATE_PORT` (200) : create a new port
14//! - `SYS_IPC_SEND` (201) : send a message to a port
15//! - `SYS_IPC_RECV` (202) : receive a message from a port
16//! - `SYS_IPC_CALL` (203) : send and wait for reply
17//! - `SYS_IPC_REPLY` (204) : reply to an IPC call
18//! - `SYS_IPC_BIND_PORT` (205) : bind a port to the namespace
19//! - `SYS_IPC_UNBIND_PORT` (206) : unbind a port
20//!
21//! ## 2. Typed MPMC sync-channels (IPC-02)
22//!
23//! [`channel::channel`]`<T>(capacity)` creates a typed
24//! Multi-Producer/Multi-Consumer channel for kernel-internal use.
25//! [`channel::SyncChan`] provides a symmetric [`IpcMessage`] channel
26//! exposed to userspace silos via:
27//! - `SYS_CHAN_CREATE` (220) : create a channel
28//! - `SYS_CHAN_SEND` (221) : send (blocking)
29//! - `SYS_CHAN_RECV` (222) : receive (blocking)
30//! - `SYS_CHAN_TRY_RECV` (223) : receive (non-blocking)
31//! - `SYS_CHAN_CLOSE` (224) : destroy the channel
32//!
33//! ## 3. Transport layer (N1/N2/N3)
34//!
35//! The [`transport`] module provides a unified trait-based IPC transport
36//! layer with three levels of isolation (TypeSafe, LockFree, MMU).
37//! [`lockfree_ring`] implements the N2 SPSC ring buffer.
38//! [`mailbox`] implements the N1 intrusive mailbox.
39
40pub mod channel;
41pub mod lifecycle;
42pub mod lockfree_ring;
43pub mod mailbox;
44pub mod message;
45pub mod port;
46pub mod reply;
47pub mod semaphore;
48pub mod shared_ring;
49pub mod test;
50pub mod transport;
51
52pub use channel::{
53 channel, create_channel, destroy_channel, get_channel, ChanId, ChannelError, Receiver, Sender,
54 SyncChan,
55};
56pub use lifecycle::{MultiHandleDestroyError, MultiHandleResource};
57pub use lockfree_ring::LockFreeRing;
58pub use mailbox::IntrusiveMailbox;
59pub use message::IpcMessage;
60pub use port::{create_port, destroy_port, get_port, IpcError, Port, PortId};
61pub use semaphore::{
62 create_semaphore, destroy_semaphore, get_semaphore, PosixSemaphore, SemId, SemaphoreError,
63};
64pub use shared_ring::{create_ring, destroy_ring, get_ring, RingError, RingId, SharedRing};
65pub use transport::{
66 IpcConsumer, IpcNotification, IpcProducer, IpcTransport, TransportCapabilities,
67 TransportConfig, TransportCreateResult, TransportEndpoint, TransportId, TransportLevel,
68 TransportManager,
69};