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 n1;
46pub mod n3;
47pub mod port;
48pub mod quota;
49pub mod reply;
50pub mod semaphore;
51pub mod shared_ring;
52pub mod test;
53pub mod transport;
54
55pub use channel::{
56 channel, create_channel, destroy_channel, get_channel, ChanId, ChannelError, Receiver, Sender,
57 SyncChan,
58};
59pub use lifecycle::{MultiHandleDestroyError, MultiHandleResource};
60pub use lockfree_ring::LockFreeRing;
61pub use mailbox::IntrusiveMailbox;
62pub use message::IpcMessage;
63pub use n3::{
64 allocate_pcid, pcid_available, MigrationFrame, MigrationState, N3MinimalContext, N3Tier,
65 N3Transport, N3_SHARED_FRAME_VA,
66};
67pub use port::{create_port, destroy_port, get_port, IpcError, Port, PortId};
68pub use quota::{IpcQuota, QuotaExceeded};
69pub use semaphore::{
70 create_semaphore, destroy_semaphore, get_semaphore, PosixSemaphore, SemId, SemaphoreError,
71};
72pub use shared_ring::{create_ring, destroy_ring, get_ring, RingError, RingId, SharedRing};
73pub use transport::{
74 IpcConsumer, IpcNotification, IpcProducer, IpcTransport, TransportCapabilities,
75 TransportConfig, TransportCreateResult, TransportEndpoint, TransportId, TransportLevel,
76 TransportManager,
77};