pub fn sys_ipc_receive(_endpoint: u64, _buf: &mut [u8]) -> SyscallResult<usize>Expand description
Receive a message from an IPC endpoint.
Blocks the calling process until a message is available on the specified
IPC endpoint, then copies the message into the provided buffer. The
endpoint is identified by a capability token that the receiver must
possess with READ rights.
For small messages (64 bytes or fewer), the data is transferred via registers on the fast path. For larger messages, the kernel uses zero-copy page remapping so the receiver sees the sender’s data without any memory copy overhead.
The caller must provide a buffer large enough to hold the incoming
message. If the buffer is too small, the message is truncated and a
BufferTooSmall error is returned (the message remains consumed from
the queue).
§Arguments
endpoint- Capability token identifying the IPC endpoint to receive from. The caller must hold this capability with at leastREADrights.buf- Mutable buffer to receive the message data. Should be at least as large as the expected maximum message size for the endpoint.
§Returns
Ok(bytes_received)- The number of bytes written intobuf.
§Errors
SyscallError::PermissionDenied- The caller does not hold the endpoint capability or lacksREADrights on it.SyscallError::NotFound- The endpoint capability token is invalid or has been revoked.SyscallError::BufferTooSmall- The providedbufis smaller than the incoming message. The message is truncated to fit.SyscallError::WouldBlock- No message is available and non-blocking mode was requested.SyscallError::Timeout- The operation timed out waiting for a message.
§Examples
use veridian_kernel::pkg::sdk::syscall_api::sys_ipc_receive;
let endpoint: u64 = 0x1234; // capability token for the endpoint
let mut buf = [0u8; 4096];
let bytes = sys_ipc_receive(endpoint, &mut buf).expect("ipc receive failed");
let received = &buf[..bytes];
// Process the received message data