Module host

Module host 

Source
Expand description

Raw host function bindings for FBMU and FBBU.

This module provides the low-level interface between grafos-std and the grafOS runtime. On wasm32 targets, these functions link to real host imports (fabricbios_fbmu_v0 and fabricbios_fbbu_v0 WASM import modules). On native targets, they delegate to mock implementations backed by thread-local storage so unit tests work without a WASM runtime.

All unsafe in the crate is confined to this module. Higher-level code in crate::mem and crate::block wraps these functions with safe Rust APIs.

§Mock configuration (native targets only)

When running on non-WASM targets, the mock state can be configured for testing:

use grafos_std::host;

host::reset_mock();
host::mock_set_fbmu_arena_size(8192);
host::mock_set_fbbu_num_blocks(256);
host::mock_set_unix_time_secs(1_700_000_000);

// Now FabricMem::hello() and FabricBlock::hello() will use these values.

Structs§

FbbuLeaseInfo
Host-side FBBU lease metadata returned by v0 lease lifecycle calls.
FbmuLeaseInfo
Host-side FBMU lease metadata returned by v0 lease lifecycle calls.

Constants§

LEASE_STATUS_ACTIVE
Lease status code: lease is active.
LEASE_STATUS_EXPIRED
Lease status code: lease has expired.
LEASE_STATUS_REVOKED
Lease status code: lease was explicitly revoked/freed.

Functions§

fbbu_alloc
Allocate a block lease from FBBU with the requested minimum capacity and TTL.
fbbu_free
Free/revoke an FBBU lease.
fbbu_get_num_blocks
Query the total number of blocks available on the FBBU device.
fbbu_hello
Perform the FBBU HELLO handshake with the host.
fbbu_query
Query FBBU lease status and geometry metadata.
fbbu_read_block
Read a single 512-byte block at the given logical block address.
fbbu_read_block_lease
Read a 512-byte block via FBBU using an explicit lease id.
fbbu_renew
Renew an FBBU lease and return the updated expiry timestamp.
fbbu_write_block
Write a single 512-byte block at the given logical block address.
fbbu_write_block_lease
Write a 512-byte block via FBBU using an explicit lease id.
fbmu_alloc
Allocate a memory lease from FBMU with the requested minimum capacity and TTL.
fbmu_free
Free/revoke an FBMU lease.
fbmu_get_arena_size
Query the total FBMU arena size in bytes.
fbmu_hello
Perform the FBMU HELLO handshake with the host.
fbmu_query
Query FBMU lease status and capacity metadata.
fbmu_read
Read from the FBMU arena at offset into buf.
fbmu_read_lease
Read from FBMU using an explicit lease id.
fbmu_renew
Renew an FBMU lease and return the updated expiry timestamp.
fbmu_write
Write data to the FBMU arena at the given byte offset.
fbmu_write_lease
Write to FBMU using an explicit lease id.
gpu_lease_alloc
Allocate a GPU lease for the given resource. Returns an opaque lease_id on success.
gpu_lease_free
Free/revoke a GPU lease.
gpu_lease_query
Query the status of a GPU lease. Returns a status code (0=active, 1=expired, 2=revoked, 3=fenced).
gpu_lease_renew
Renew an existing GPU lease.
gpu_session_launch
Launch a kernel within a GPU session.
gpu_session_mem_alloc
Allocate device memory within a GPU session.
gpu_session_mem_free
Free device memory within a GPU session.
gpu_session_mem_read
Read data from device memory within a GPU session.
gpu_session_mem_write
Write data to device memory within a GPU session.
gpu_session_module_load
Load a GPU module within a GPU session.
gpu_session_module_unload
Unload a GPU module within a GPU session (Phase 48.16 SDK polish).
gpu_session_sync
Synchronize a GPU session.
mock_advance_time_secs
Advance the mock unix time by delta_secs.
mock_set_fbbu_hello_error
Inject an error into the mock FBBU HELLO handshake.
mock_set_fbbu_num_blocks
Set the mock FBBU block count.
mock_set_fbmu_arena_size
Set the mock FBMU arena size in bytes.
mock_set_fbmu_hello_error
Inject an error into the mock FBMU HELLO handshake.
mock_set_net_hello_error
Make mock net_hello return an error. Only available on native targets.
mock_set_net_interface
Configure the mock network interface name and bandwidth. Only available on native targets.
mock_set_tasklet_result
Configure the mock tasklet exit code and output. Only available on native targets.
mock_set_tasklet_submit_error
Make mock tasklet_submit return an error. Only available on native targets.
mock_set_unix_time_secs
Set the mock unix time used by lease lifecycle logic.
net_hello
Acquire a network interface with the given minimum bandwidth.
reset_mock
Reset all mock state to defaults.
tasklet_submit
Submit a WASM tasklet for execution on a fabric CPU resource.
unix_time_secs
Return the current unix time in seconds used by lease lifecycle logic.