SongYZZZ/moon-firmware/model does not have a README file

    FirmwareError

    pub(all) suberror FirmwareError {
    FirmwareError(Diagnostic)
    } derive(
    Debug
    )

    Library failures always carry a structured diagnostic.

    AddressRange

    pub struct AddressRange {
    start : Int64
    end : Int64
    } derive(Eq,
    Debug
    )

    Half-open [start, end) interval. End may equal 2^32; start must be smaller.

    AddressRange::contains

    fn AddressRange::contains(self : AddressRange, address : Int64) -> Bool

    Test membership using an exclusive upper bound.

    AddressRange::inclusive

    fn AddressRange::inclusive(start : Int64, last : Int64) -> AddressRange raise FirmwareError

    Convert an inclusive user-facing range to the library's half-open model.

    AddressRange::intersection

    fn AddressRange::intersection(self : AddressRange, other : AddressRange) -> AddressRange?

    A nonempty intersection, or None for disjoint/touching intervals.

    AddressRange::is_empty

    fn AddressRange::is_empty(self : AddressRange) -> Bool

    Empty intervals contain no addresses.

    AddressRange::length

    fn AddressRange::length(self : AddressRange) -> Int64

    Number of addresses in the interval, without narrowing to machine Int.

    AddressRange::new

    fn AddressRange::new(start : Int64, end : Int64) -> AddressRange raise FirmwareError

    Construct a checked interval. Empty intervals are legal.

    AddressRange::render

    fn AddressRange::render(self : AddressRange) -> String

    Display a nonempty interval with inclusive endpoints for firmware tools.

    AddressRange::shift

    fn AddressRange::shift(self : AddressRange, delta : Int64) -> AddressRange raise FirmwareError

    Checked relocation of a range, useful for bootloader image rebasing.

    AddressRange::subtract

    fn AddressRange::subtract(self : AddressRange, other : AddressRange) -> Array[AddressRange]

    Split around an intersection, retaining the two possible outer intervals.

    ChecksumStatus

    pub(all) enum ChecksumStatus {
    Verified
    NotApplicable
    Derived
    } derive(Eq,
    Debug
    )

    Provenance survives decoding. Checksums describe source records, not hashes.

    Diagnostic

    pub(all) struct Diagnostic {
    code : ErrorCode
    format : Format
    line : Int
    column : Int
    record_type : Int?
    address : Int64?
    end_address : Int64?
    message : String
    } derive(Eq,
    Debug
    )

    Diagnostic locations are one-based; zero means not tied to a text line.

    Diagnostic::render

    fn Diagnostic::render(self : Diagnostic) -> String

    Render diagnostic text without losing structured address information.

    EntryPoint

    pub(all) enum EntryPoint {
    Linear(Int64)
    Segment(Int, Int)
    } derive(Eq,
    Debug
    )

    Preserve segmented execution state instead of silently flattening CS:IP.

    EntryPoint::address

    fn EntryPoint::address(self : EntryPoint) -> Int64 raise FirmwareError

    Validated execution address in the same address space as payload.

    ErrorCode

    pub(all) enum ErrorCode {
    InvalidDigit
    InvalidLength
    InvalidRecord
    UnsupportedRecord
    ChecksumMismatch
    MissingTerminator
    AfterTerminator
    DuplicateRecord
    CountMismatch
    AddressOverflow
    InvalidRange
    AddressConflict
    GapRequiresFill
    ResourceLimit
    InvalidOption
    UnknownFormat
    EntryConflict
    Io
    } derive(Eq,
    Debug
    )

    Machine-readable failure categories; messages add context, not identity.

    FirmwareImage

    pub(all) struct FirmwareImage {
    memory : MemoryMap
    entry : EntryPoint?
    metadata : Metadata
    warnings : Array[Diagnostic]
    }

    An owned sparse map, optional entry point, source metadata and warnings.

    FirmwareImage::copy

    Deep-copy mutable state, including metadata counters and diagnostics array.

    FirmwareImage::from_binary

    fn FirmwareImage::from_binary(bytes : Bytes, base_address : Int64) -> FirmwareImage raise FirmwareError

    Construct a raw binary image with explicit placement.

    FirmwareImage::new

    Empty image with unknown origin.

    FirmwareImage::semantic_equal

    fn FirmwareImage::semantic_equal(self : FirmwareImage, other : FirmwareImage) -> Bool

    Compare memory and exact execution state, ignoring serialization metadata.

    Format

    pub(all) enum Format {
    IntelHex
    SRecord
    RawBinary
    Unknown
    } derive(Eq,
    Debug
    )

    The wire format or origin of an image.

    Format::label

    fn Format::label(self : Format) -> String

    Human-readable name independent of enum debugging syntax.

    MemoryMap

    pub struct MemoryMap {
    // private fields
    }

    Sorted, nonempty, disjoint and nonadjacent segments. No allocation for gaps.

    MemoryMap::bounds

    fn MemoryMap::bounds(self : MemoryMap) -> AddressRange?

    Span including internal gaps; empty maps have no bounds.

    MemoryMap::contains

    fn MemoryMap::contains(self : MemoryMap, address : Int64) -> Bool

    True only for occupied addresses; does not treat gaps as zero bytes.

    MemoryMap::copy

    fn MemoryMap::copy(self : MemoryMap) -> MemoryMap

    Independent mutable copy for transactional multi-image operations.

    MemoryMap::gaps

    fn MemoryMap::gaps(self : MemoryMap) -> Array[AddressRange]

    Internal holes only. No leading zero-to-first-address gap is invented.

    MemoryMap::highest_address

    fn MemoryMap::highest_address(self : MemoryMap) -> Int64?

    Highest occupied address (inclusive), or None.

    MemoryMap::holes_in

    fn MemoryMap::holes_in(self : MemoryMap, range : AddressRange) -> Array[AddressRange]

    Holes in an explicit window, including leading and trailing holes.

    MemoryMap::insert

    fn MemoryMap::insert(self : MemoryMap, address : Int64, bytes : Bytes, policy? : OverlapPolicy) -> Unit raise FirmwareError

    Insert data using a checked overlap policy. Limits cap payload at 64 MiB.

    MemoryMap::lowest_address

    fn MemoryMap::lowest_address(self : MemoryMap) -> Int64?

    Lowest occupied address, or None for an empty map.

    MemoryMap::new

    fn MemoryMap::new() -> MemoryMap

    An empty sparse map. Insertions are transactional on validation failure.

    MemoryMap::payload_size

    fn MemoryMap::payload_size(self : MemoryMap) -> Int

    Payload size rather than the address span.

    MemoryMap::read

    fn MemoryMap::read(self : MemoryMap, address : Int64) -> Byte?

    Read an occupied byte; holes and out-of-range addresses return None.

    MemoryMap::same_memory

    fn MemoryMap::same_memory(self : MemoryMap, other : MemoryMap) -> Bool

    Semantic memory equality, independent of source record boundaries.

    MemoryMap::segment_count

    fn MemoryMap::segment_count(self : MemoryMap) -> Int

    Count normalized occupied regions.

    MemoryMap::segments

    fn MemoryMap::segments(self : MemoryMap) -> Array[MemorySegment]

    Return immutable snapshots, never the map's mutable internal buffers.

    MemoryMap::slice

    fn MemoryMap::slice(self : MemoryMap, range : AddressRange) -> MemoryMap raise FirmwareError

    Copy just the occupied intersections with a checked interval.

    MemoryMap::to_binary

    fn MemoryMap::to_binary(self : MemoryMap, range : AddressRange, fill? : Byte, max_size? : Int) -> Bytes raise FirmwareError

    Dense bytes from an explicit interval. Refuse holes unless fill is supplied.

    MemorySegment

    pub struct MemorySegment {
    start : Int64
    data : Bytes
    } derive(Eq,
    Debug
    )

    Immutable snapshot of one contiguous occupied region.

    MemorySegment::new

    fn MemorySegment::new(start : Int64, data : Bytes) -> MemorySegment raise FirmwareError

    Checked segment constructor; bytes are immutable in the public API.

    MemorySegment::range

    Interval occupied by this segment.

    Metadata

    pub(all) struct Metadata {
    source_format : Format
    record_counts : Array[Int]
    header : Bytes?
    checksum_status : ChecksumStatus
    } derive(Eq,
    Debug
    )

    Original record statistics and S0 header bytes, with no lossy text decoding.

    Metadata::new

    fn Metadata::new(format : Format) -> Metadata

    Metadata for an image assembled in memory or transformed after parsing.

    OverlapPolicy

    pub(all) enum OverlapPolicy {
    Reject
    AllowIdentical
    Overwrite
    } derive(Eq,
    Debug
    )

    Reject any overlap, accept byte-identical overlap, or replace existing data.

    ParseMode

    pub(all) enum ParseMode {
    Strict
    Permissive
    } derive(Eq,
    Debug
    )

    Strict structural validation or a small documented set of tolerances.

    ParseOptions

    pub(all) struct ParseOptions {
    mode : ParseMode
    overlap : OverlapPolicy
    max_line_length : Int
    max_records : Int
    max_payload : Int
    max_text_length : Int
    max_warnings : Int
    } derive(Eq,
    Debug
    )

    Resource limits apply before parsing or allocating output buffers.

    ParseOptions::default

    fn ParseOptions::default() -> ParseOptions

    Conservative defaults, independent of the largest address in the input.

    ParseOptions::validate

    fn ParseOptions::validate(self : ParseOptions) -> Unit raise FirmwareError

    Check options once before processing untrusted records.

    data_range

    fn data_range(address : Int64, length : Int) -> AddressRange raise FirmwareError

    Check a start plus byte length without overflow in either integer width.

    diagnostic

    fn diagnostic(code : ErrorCode, message : String, address? : Int64, end_address? : Int64) -> Diagnostic

    Create a diagnostic outside a parser; parser code supplies source fields.

    hex_address

    fn hex_address(address : Int64) -> String

    Stable fixed-width display for firmware addresses and range endpoints.

    Powered by MoonBit

    Site sourceReport issuePackagesBuild queueSkillsStatistics

    © 2026 mooncakes.io