Expand description
Host implementation of the native application C ABI.
Core’s native ELF handler installs the time manager from its executable
context and discovers the entropy character device at
/devices/random/source before launch. The first successful installation of
each service is retained for the system. Native applications can run
without an entropy device, in which case nonempty random fills return
Status::Unavailable.
A native process is the Core task that runs a native entry on a stackful
coroutine. The XilaStartup.process capability gives it its identity, its
environment (the task’s own), spawn and wait for children, and exit, with
no table of its own: see Process and the crate README.
Structs§
- AnyProcess
Owner - A
ProcessOwnerwith the type of its keep-alive value erased, so that one instantiation ofdrive_ownedserves every owner type instead of duplicatingdrive_processper type. - Child
- A spawned child, owned by the process that spawned it. It holds the child’s
exit status until the owner waits for it, so a child that finished and was not
waited for costs one signal slot and no task.
xila_process_child_closereleases it, waited for or not. - Condition
- Process-local condition variable. Zero initialize or use condition_init. Keep its address fixed from first use through destruction. The fields are private to the host; copying a used condition or sharing it across processes is invalid.
- Directory
- Opaque path capability. Native callers must serialize access and preserve ownership.
- Directory
Iterator - Opaque owned listing with at most one pending VFS entry for buffer retries.
- File
- Opaque owned file. No handle lookup or buffer allocation is required for I/O.
- Heap
- Opaque native heap capability. The process owner drops it after all native execution ends. Keep ownership outside any stack that can be abandoned.
- Home
Grant - A directory capability granted to a child as its home.
- Host
State - Everything the host keeps for one native run: the startup block the entry borrows, the process capability and the resources both point into.
- Mutex
- Process-local mutex. Zero initialize for a plain mutex, or use mutex_init. Keep its address fixed from first use through destruction. The fields are private to the host; copying a used mutex or sharing it across processes is invalid.
- Network
- Host-granted network authority. Future host/port restrictions belong here.
- Network
Address - Fixed-width address. Bytes are in network order; integer fields are host order. IPv4 uses the first four bytes and requires the remaining bytes to be zero. Scope must be zero: Core does not support scoped IPv6 endpoints.
- Poll
Entry - One poll entry. Only IN and OUT are requested. ERR, HUP and NVAL are reported regardless of the request. IGNORE entries always return zero. A null file/directory/socket or unknown kind reports NVAL.
- Process
- Opaque capability of the running process: its identity, environment, children and
exit. The host grants it through
XilaStartup.process; the pointer is borrowed for the entry call and a process must not pass it to another process. - Process
Launch - What a child’s coroutine needs to become a process, carried from the spawn request to the loader that starts its entry.
- Process
Owner - The owner of a leaked
Recordallocation, freeing it on drop. - Spawn
- Arguments of
xila_process_spawn. Setsizetosizeof(XilaSpawn). All pointers are borrowed for the call. - Spawn
Request - What the host needs to start a child: the validated, owned result of
xila_process_spawn’s arguments. The three standard streams are duplicates of the parent’s, owned by the request. - Statistics
- Versioned output: initialize size to sizeof(XilaStatistics) before each call.
- Tcp
- Owned TCP connection. Its creation grants bidirectional I/O authority.
- TcpListener
- One pending connection, with no additional backlog. Accept replenishes the socket.
- Thread
Libc - SDK-reserved coroutine-local libc state. Other applications should use TLS keys.
- Udp
- Owned UDP socket. Sending additionally requires CONNECT on its parent capability.
- XilaApi
- Native application entry points, in slot order. The header precedes slot zero. Networking slots return Unsupported when the runtime omits networking, and so does the graphics slot when it omits graphics.
- Xila
Startup - Host-owned startup data, valid only for the duration of the entry call.
The API is always present. Capability pointers may be null when not granted;
the process capability is null for an application that is not a process, such
as a built-in one linked into the firmware, whose process calls fail with
InvalidArgument. A null argument array has argument_count zero.
Fields are only ever appended: check
sizebefore reading a field that a later Xila version added, such asnetwork. Applications must not close, retain or transfer these objects; closing them is undefined behavior. Objects opened by the application must still be closed. - Xila
String - UTF-8 bytes, not NUL-terminated. A null data pointer is valid only at length zero.
Enums§
- Status
- Native status values mirror the unified error kinds one-to-one. Zero is success.
Constants§
- XILA_
ADDRESS_ IPV4 - XILA_
ADDRESS_ IPV6 - XILA_
CLOCK_ MONOTONIC - Monotonic clock identifier for
xila_time_resolution. - XILA_
CLOCK_ REALTIME - Realtime (Unix UTC) clock identifier for
xila_time_resolution. - XILA_
CONTROL_ BYTES_ AVAILABLE - XILA_
CONTROL_ GET_ FILE_ FLAGS - XILA_
CONTROL_ SET_ FILE_ FLAGS - XILA_
HEAP_ ALIGNMENT - Alignment guaranteed for every allocation, including zero-length requests.
- XILA_
KIND_ BLOCK_ DEVICE - XILA_
KIND_ CHARACTER_ DEVICE - XILA_
KIND_ DIRECTORY - XILA_
KIND_ FILE - XILA_
KIND_ PIPE - XILA_
KIND_ SOCKET - XILA_
KIND_ SYMLINK - XILA_
MUTEX_ RECURSIVE - XILA_
MUTEX_ TRY - XILA_
NETWORK_ CONNECT - XILA_
NETWORK_ LISTEN - XILA_
NETWORK_ RESOLVE - XILA_
OPEN_ APPEND - XILA_
OPEN_ CREATE - XILA_
OPEN_ EXCLUSIVE - XILA_
OPEN_ NON_ BLOCKING - XILA_
OPEN_ READ - XILA_
OPEN_ TRUNCATE - XILA_
OPEN_ WRITE - XILA_
PIPE_ CAPACITY - XILA_
POLL_ DIRECTORY - XILA_
POLL_ ERR - XILA_
POLL_ FILE - XILA_
POLL_ HUP - XILA_
POLL_ IGNORE - XILA_
POLL_ IN - XILA_
POLL_ NVAL - XILA_
POLL_ OUT - XILA_
POLL_ TCP - XILA_
POLL_ TCP_ LISTENER - XILA_
POLL_ UDP - XILA_
REMOVE_ DIRECTORY - Allow removing directories as well as files. Removal never follows the final link.
- XILA_
RIGHT_ READ - XILA_
RIGHT_ WRITE - XILA_
SEEK_ CURRENT - XILA_
SEEK_ END - XILA_
SEEK_ START - XILA_
SHUTDOWN_ WRITE - XILA_
SPAWN_ NETWORK_ CONNECT XilaSpawn.flags: give the child the right to connect (and to send datagrams). The value isXILA_NETWORK_CONNECT’s.- XILA_
SPAWN_ NETWORK_ LISTEN XilaSpawn.flags: give the child the right to listen and bind. The value isXILA_NETWORK_LISTEN’s.- XILA_
SPAWN_ NETWORK_ RESOLVE XilaSpawn.flags: give the child the right to resolve names. The value isXILA_NETWORK_RESOLVE’s.- XILA_
STATISTICS_ NO_ FOLLOW - XILA_
THREAD_ KEYS_ MAX - XILA_
THREAD_ STACK_ MAX - XILA_
THREAD_ STACK_ MIN - XILA_
VERSION_ MAJOR - Major version of the Xila release this ABI belongs to. Native images
record
(XILA_VERSION_MAJOR << 16) | XILA_VERSION_MINORin their ABI note. - XILA_
VERSION_ MINOR - Minor version of the Xila release this ABI belongs to.
- XILA_
WAIT_ NO_ HANG xila_process_waitflag: returnWouldBlockinstead of waiting for a running child.
Statics§
- XILA_
API - Shared API table. Native code receives its address through XilaStartup.
Traits§
- Process
Host - The host services behind a process capability. Core implements them for its
executable context, so a spawned child goes through
executable::execute.
Functions§
- __
xila_ current_ startup - The startup block of the program that the calling coroutine runs, or null.
- drive_
owned - Drive the program’s coroutine to its end, then free what it ran on. The coroutine is
dropped before
owner, on every path, including the future being dropped while the program is suspended: the temporary that holds it is the newest object of this function, so it is the first to be dropped. - drive_
process - Drive the process entry and all its workers on the same executor task. The group and its workers are dropped before this future returns. A suspended coroutine, main or worker, is cancelled: its frames are discarded and its stack freed. What the process owns lives in the host state, which the caller releases afterwards.
- initialize
- Install the runtime’s clock once. The native executable handler calls this before launch. Earlier reads return Unavailable.
- initialize_
random - Install the runtime’s entropy source once if the system VFS has a character
device at
/devices/random/source. The native executable handler calls this before launch. If the device is absent, a later launch can retry. - run_
main ⚠ - Invoke a linked C entry on the calling stack, then close its granted streams. The process owner provides the heap and drops it after all native execution ends.
- start_
process ⚠ - Run
entryas a process on the calling task, as a future that resolves to its exit status, without spawning a task for it. - xila_
condition_ ⚠destroy - Destroy a condition variable, returning ResourceBusy if there are waiters.
- xila_
condition_ ⚠init - Initialize an uninitialized or destroyed condition variable.
- xila_
condition_ ⚠notify - Notify one waiter, or all waiters if all is true.
- xila_
condition_ ⚠wait - Wait for notification or an absolute clock deadline, reacquiring the mutex before returning. The caller must own the mutex with depth exactly one.
- xila_
directory_ ⚠close - Release a directory capability. Null is a no-op.
- xila_
directory_ ⚠create - Create a relative directory with the WRITE right.
- xila_
directory_ ⚠get_ statistics - Read relative path metadata; an empty path means the capability itself.
- xila_
directory_ ⚠iterator_ close - Close and free the iterator even on close error; null succeeds.
- xila_
directory_ ⚠iterator_ next - Copy a name without a trailing NUL, skipping dot entries. End leaves outputs unchanged. BufferTooSmall writes only required name_length and retains the entry.
- xila_
directory_ ⚠iterator_ open - Open a relative directory for listing with READ authority; empty means itself.
- xila_
directory_ ⚠iterator_ rewind - Rewind, discarding a pending entry only on success.
- xila_
directory_ ⚠open - Open a relative directory; requested rights must be a subset of the parent’s.
- xila_
directory_ ⚠remove - Remove a relative entry; XILA_REMOVE_DIRECTORY permits directory removal.
- xila_
directory_ ⚠rename - Rename an entry using two WRITE capabilities with the same VFS and task. Existing destinations follow the underlying filesystem’s replacement semantics.
- xila_
env_ ⚠entry - Copy the zero-based environment entry as
NAME=VALUEwithout a terminator. Output follows the same rules asxila_env_get.NotFoundmarks the end. Indices can change when the environment is mutated. - xila_
env_ ⚠get - Read an environment variable. The value is copied without a terminator; the
length is stored on success and on
BufferTooSmall, which leaves the buffer unchanged. A null buffer is allowed at capacity zero. A missing variable returnsNotFound. - xila_
env_ ⚠remove - Remove an environment variable of this process. A missing variable succeeds.
- xila_
env_ ⚠set - Set an environment variable of this process, replacing any value. Children
spawned afterwards inherit a copy; earlier children and the parent are unaffected.
A name is non-empty UTF-8 without
=or NUL, a value is UTF-8 without NUL and a null value pointer is valid at length zero. - xila_
file_ ⚠close - Close and free the object even if closing fails. Null succeeds.
- xila_
file_ ⚠control - A bounded command with one native-endian uint32_t input or output. BYTES_AVAILABLE returns the queued byte count on either pipe end. GET_FILE_FLAGS returns the access mode and status as XILA_OPEN_* bits. SET_FILE_FLAGS replaces the append and nonblocking bits shared by duplicates.
- xila_
file_ ⚠duplicate - Return an independently closable handle with the same cursor and status flags.
- xila_
file_ ⚠flush - Flush pending writes.
- xila_
file_ ⚠get_ statistics - Read metadata of an opened readable file.
- xila_
file_ ⚠is_ terminal - Report whether this file is an interactive terminal.
- xila_
file_ ⚠open - Open a file relative to a directory with validated XILA_OPEN flags.
- xila_
file_ ⚠read - Read directly into the caller’s buffer; zero size permits a null buffer.
- xila_
file_ ⚠read_ at - Transfer at an explicit offset without changing the shared cursor. Streams return InvalidSeek.
- xila_
file_ ⚠seek - Seek using XILA_SEEK_START, CURRENT or END. Position output is optional.
- xila_
file_ ⚠set_ size - Resize a writable file without changing its cursor.
- xila_
file_ ⚠write - Write directly from the caller’s buffer; zero size permits a null buffer.
- xila_
file_ ⚠write_ at - Transfer at an explicit offset without changing the shared cursor. Streams return InvalidSeek.
- xila_
heap_ ⚠allocate - Allocate uninitialized bytes. A zero-size request reserves one byte.
- xila_
heap_ ⚠free - Free a block owned by this heap. Null succeeds. A pointer that this heap
does not own, an interior pointer or a block that was already freed returns
InvalidArgument. This check reads the block header through the pointer, so the pointer must at least address readable memory (the trusted native contract; seeHeap). - xila_
heap_ ⚠reallocate - Resize a block, preserving its contents up to the smaller of the old and
new sizes. Failure leaves the old allocation and output unchanged. Size
zero frees the block and stores null. A null pointer with nonzero size
allocates a new block. A pointer that this heap does not own, an interior
pointer or a freed block returns
InvalidArgument, with the same trusted native contract asxila_heap_free. - xila_
mutex_ ⚠destroy - Destroy a mutex, returning ResourceBusy while owned or in use by a waiter.
- xila_
mutex_ ⚠init - Initialize an uninitialized or destroyed mutex.
- xila_
mutex_ ⚠lock - Acquire a mutex, suspending on contention unless XILA_MUTEX_TRY is set.
- xila_
mutex_ ⚠unlock - Release one level of the caller’s ownership.
- xila_
network_ ⚠close - Release network authority; existing sockets remain valid. Null succeeds.
- xila_
network_ ⚠resolve - Resolve one address family synchronously. Count is capacity in/results out; capacity zero queries size. Overflow leaves outputs unchanged. DNS allocates inside Core.
- xila_
pipe_ ⚠create - Create an unnamed pipe. Only XILA_OPEN_NON_BLOCKING is accepted in flags.
- xila_
poll_ ⚠wait - Wait for the first ready handle, returning every ready entry in that scan. Timeout is in milliseconds, negative means infinite, and zero is a probe. A blocking wait outside a stackful coroutine returns WouldBlock when no handles are immediately ready.
- xila_
process_ ⚠child_ close - Release a child handle, waited for or not. A running child keeps running and its status is discarded when it ends. Null succeeds.
- xila_
process_ ⚠child_ id - Read the process identifier of a child: the value its own
xila_process_idreports. It stays readable after the child exits or is waited for, until the handle is closed. Core may reuse the identifier once the child’s task is gone. - xila_
process_ ⚠exit - Stop every peer, release the process’s resources, and exit without unwinding. Stopped peers are never resumed: their frames are discarded and their stacks freed when the process’s driver ends, as for a cancelled process. The loader then releases the process heap and image.
- xila_
process_ ⚠id - Read the process’s identifier.
- xila_
process_ ⚠parent_ id - Read the identifier of the process that spawned this one. A process whose parent has exited is adopted by the root task, identifier zero.
- xila_
process_ ⚠spawn - Start an executable as a child of this process and return its handle.
- xila_
process_ ⚠wait - Wait for a child to exit and collect its exit status, which reaps it: a later wait on
the same handle returns
NoChild. Only the process that spawned the child may wait. Inside a coroutine the call suspends until the child exits, so other tasks keep running. WithXILA_WAIT_NO_HANG, or outside a coroutine where nothing can suspend, a running child returnsWouldBlock. The status output is optional and written only on success. - xila_
random_ ⚠fill - Fill the caller’s buffer with random bytes from the host-granted entropy source. Zero size succeeds without touching the buffer or the source, and permits a null buffer. A pending source suspends the caller’s coroutine. On failure the buffer contents are unspecified and must not be used.
- xila_
tcp_ ⚠accept - Wait for a connection and replenish the listener. Run the interface runner independently.
- xila_
tcp_ ⚠close - Abort and release the socket and its buffers. Null succeeds; queued data may be lost.
- xila_
tcp_ ⚠connect - Connect synchronously; timeout zero waits indefinitely, otherwise milliseconds.
- xila_
tcp_ ⚠listen - Bind and start a single-slot TCP listener. Port zero is rejected by Core.
- xila_
tcp_ ⚠listener_ close - Abort and release the socket and its buffers. Null succeeds; queued data may be lost.
- xila_
tcp_ ⚠local_ address - Read the connection endpoint.
- xila_
tcp_ ⚠peer_ address - Read the connection endpoint.
- xila_
tcp_ ⚠receive - Blocking direct-buffer I/O. Zero size permits null; send may be partial; receive zero means EOF.
- xila_
tcp_ ⚠send - Blocking direct-buffer I/O. Zero size permits null; send may be partial; receive zero means EOF.
- xila_
tcp_ ⚠shutdown - Gracefully shut down writing. Only XILA_SHUTDOWN_WRITE is supported; reads remain valid.
- xila_
thread_ ⚠current - Read the calling thread’s process-local identifier.
- xila_
thread_ detach - Detach a worker. Its result is discarded, and it is reaped on return.
- xila_
thread_ ⚠exit - Finish the calling worker with a pointer-sized result. Main must use process exit or return. The worker’s native frames are abandoned.
- xila_
thread_ ⚠has_ workers - Report whether the process still has live workers. Finished workers whose results have not been joined do not count.
- xila_
thread_ ⚠join - Wait for one worker, then reap its result. Joining oneself fails with Deadlock.
- xila_
thread_ ⚠key_ create - Allocate a process-local TLS key. New keys read as null in all threads.
- xila_
thread_ key_ delete - Invalidate a process-local TLS key without calling destructors.
- xila_
thread_ ⚠libc - Read the address of the current coroutine’s libc storage.
- xila_
thread_ ⚠spawn - Start a coroutine on the current process’s executor. Zero stack size uses 4 KiB on bare metal or 64 KiB on Linux.
- xila_
thread_ ⚠stop_ others - Begin terminal process cleanup. Only the calling thread may run after this call, even if cleanup suspends. Spawning new workers is disabled.
- xila_
thread_ ⚠tls_ get - Read a TLS value from the current coroutine.
- xila_
thread_ tls_ set - Write a pointer-sized value in the current coroutine. The host never dereferences or frees it.
- xila_
thread_ yield - Yield once to the other coroutines on the executor.
- xila_
time_ ⚠monotonic - Read monotonic nanoseconds from an arbitrary epoch; may return Overflow.
- xila_
time_ ⚠realtime - Read signed Unix UTC nanoseconds; unsynchronized clocks return Unavailable.
- xila_
time_ ⚠resolution - Read a clock’s nominal quantization in nanoseconds. Actual precision can be coarser. Realtime resolution stays readable while UTC is unsynchronized. An unknown clock identifier returns InvalidArgument; an uninstalled clock returns Unavailable. Outputs change only on success.
- xila_
time_ sleep - Suspend the caller for at least the given nanoseconds on the executor’s clock.
Inside a coroutine this suspends it on the executor’s timer, so other tasks
run meanwhile; zero yields once. Outside a coroutine there is no executor
waker for the timer, so the call polls the clock and zero returns at once.
UTC corrections do not affect the wait, and
u64::MAXwaits practically forever. - xila_
udp_ ⚠bind - Bind a UDP socket. Port zero is rejected by Core; one datagram per direction is buffered.
- xila_
udp_ ⚠close - Release a UDP socket. Null succeeds.
- xila_
udp_ ⚠receive_ from - Nonblocking datagram receive. Overflow preserves the datagram; outputs change only on success.
- xila_
udp_ ⚠send_ to - Nonblocking atomic datagram send, without logging or staging allocation.
Type Aliases§
- Native
Entry - The entry of a native program, as the host calls it.
- Spawn
Future - The result of starting a child: its join handle, which carries its exit status, and its task identifier, which is the child’s process identifier.
- Thread
Entry - A native worker entry. Null is rejected.