Skip to main content

javm_cap/
lib.rs

1#![cfg_attr(not(feature = "std"), no_std)]
2
3//! JAR v3 capability system.
4//!
5//! Defines the four v3 cap kinds (Instance, Image, Data, CNode),
6//! their content-bearing representations, a two-tier cache for
7//! identity-keyed mutable state + content-addressed blobs, and the
8//! primitives (BMT, hash) used by upstream layers.
9//!
10//! `Cap` and its inner storage use the default `Global` allocator (=
11//! std heap on host, talc on guest via `#[global_allocator]`). The
12//! cache layer's outer storage (`HashMap` / `Box` parameters) may still
13//! be parameterised on a custom allocator for shared-memory layouts.
14//!
15//! `Cap` itself is the wire form: it derives
16//! `rkyv::Archive`/`Serialize`/`Deserialize` so callers move caps
17//! across the host/guest boundary by writing
18//! `rkyv::to_bytes(&cap)?` (errors on unsettled `Ref` targets) and
19//! `rkyv::access::<rkyv::Archived<Cap>, _>(bytes)?` for zero-copy
20//! decode. See [`cache::CapHasRefError`] for the encode-time error.
21//!
22//! See `~/jar/website/content/spec/implementation/architecture.md` for
23//! the crate's role in the overall layering.
24
25extern crate alloc;
26
27pub mod abi;
28pub mod cache;
29pub mod cap;
30pub mod error;
31pub mod hash;
32pub mod image;
33pub mod kernel_image;
34pub mod layout;
35pub mod slot;
36pub mod yield_cap;
37
38pub use cache::{CacheDirectory, CacheError, CapHasRefError, CapHashOrRef, CapRef, ResidentCap};
39pub use cap::cnode::CNodeCap;
40pub use cap::data::{DataCap, GROUP_SIZE, PAGE_SIZE, PageResolution, PageSlab};
41pub use cap::image::{
42    EndpointDef, ImageCap, ImageConvertError, ImageSlotEntry, MemoryMapping, image_cap,
43};
44pub use cap::instance::InstanceCap;
45pub use cap::page::{PageBytes, PageRef, PageSlot};
46pub use cap::{Cap, CapHash, MAX_SOURCE_DEPTH, NUM_REGS};
47pub use error::{CapError, OpError};
48pub use hash::{Blake2b256, Hash, Hasher};
49pub use image::{
50    ArenaPageRef, CodeRef, DataDesc, DataDescError, Image, ImageBuilder, InitialDataCap, PinnedCap,
51    chain_extend, chain_genesis, image_content_hash,
52};
53pub use kernel_image::{ALL_KERNEL_IMAGES, KernelImage, kernel_image_hash, recognize_kernel_image};
54pub use slot::{Key, MAX_KEY_LEN, SlotPath, key_from_regs, key_to_regs};
55pub use yield_cap::{
56    gas_handle, gas_meter_key, is_kernel_yield_key, merge_yield_receivers, quota_handle, quota_key,
57    yield_receiver, yield_receiver_keys, yield_sender, yield_sender_key,
58};
59// `CNodeCap::slots` stores `MissingOr<CapHashOrRef>` values; re-export it so
60// cnode-slot walkers (e.g. the recompiler's cnode-inherit loop) don't need a
61// direct `ssz` dependency.
62pub use ssz::MissingOr;