Skip to main content

Crate abi_application

Crate abi_application 

Source
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§

AnyProcessOwner
A ProcessOwner with the type of its keep-alive value erased, so that one instantiation of drive_owned serves every owner type instead of duplicating drive_process per 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_close releases 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.
DirectoryIterator
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.
HomeGrant
A directory capability granted to a child as its home.
HostState
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.
NetworkAddress
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.
PollEntry
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.
ProcessLaunch
What a child’s coroutine needs to become a process, carried from the spawn request to the loader that starts its entry.
ProcessOwner
The owner of a leaked Record allocation, freeing it on drop.
Spawn
Arguments of xila_process_spawn. Set size to sizeof(XilaSpawn). All pointers are borrowed for the call.
SpawnRequest
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.
ThreadLibc
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.
XilaStartup
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 size before reading a field that a later Xila version added, such as network. Applications must not close, retain or transfer these objects; closing them is undefined behavior. Objects opened by the application must still be closed.
XilaString
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 is XILA_NETWORK_CONNECT’s.
XILA_SPAWN_NETWORK_LISTEN
XilaSpawn.flags: give the child the right to listen and bind. The value is XILA_NETWORK_LISTEN’s.
XILA_SPAWN_NETWORK_RESOLVE
XilaSpawn.flags: give the child the right to resolve names. The value is XILA_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_MINOR in their ABI note.
XILA_VERSION_MINOR
Minor version of the Xila release this ABI belongs to.
XILA_WAIT_NO_HANG
xila_process_wait flag: return WouldBlock instead of waiting for a running child.

Statics§

XILA_API
Shared API table. Native code receives its address through XilaStartup.

Traits§

ProcessHost
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 entry as 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=VALUE without a terminator. Output follows the same rules as xila_env_get. NotFound marks 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 returns NotFound.
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; see Heap).
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 as xila_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_id reports. 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. With XILA_WAIT_NO_HANG, or outside a coroutine where nothing can suspend, a running child returns WouldBlock. 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::MAX waits 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§

NativeEntry
The entry of a native program, as the host calls it.
SpawnFuture
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.
ThreadEntry
A native worker entry. Null is rejected.