firmware-image-toolkit

    Validated Intel HEX and Motorola S-record firmware image toolkit

    intel-hex
    s-record
    firmware
    embedded
    codec
    Download zip
    Author
    Version
    0.1.0
    License
    Apache-2.0
    Last updated
    2 months ago
    Downloads
    48

    No dependencies

    #Zzqy-yi/firmware-image-toolkit

    Validated Intel HEX and Motorola S-record codecs plus canonical sparse firmware-image operations for MoonBit.

    let parsed = @firmware.parse_firmware_image(
    ":03001000010203E7\n:00000001FF",
    ).unwrap()
    let image = parsed.image()
    println(@firmware.render_statistics_text(@firmware.analyze_image(image)))

    The package validates Intel HEX types 00-05 and S-record types S0, S1, S2, S3, S5, S6, S7, S8 and S9. It supports sparse image conversion, bounded range operations, comparison, manifests, verified patches, memory-map checks, batch processing and deterministic evidence reports.

    The package operates on caller-provided text and bytes. It does not communicate with hardware or parse executable object and vendor container formats. Full usage, commands and boundaries are documented in the repository README.md.

    AddressGap

    pub(all) struct AddressGap {
    start_value : UInt64
    end_exclusive_value : UInt64
    } derive(Eq,
    Debug
    )

    AddressGap::end_exclusive

    fn AddressGap::end_exclusive(self : AddressGap) -> UInt64

    AddressGap::length

    fn AddressGap::length(self : AddressGap) -> UInt64

    AddressGap::start

    fn AddressGap::start(self : AddressGap) -> UInt64

    AuditFinding

    pub struct AuditFinding {
    code_value : String
    severity_value : AuditSeverity
    message_value : String
    address_value : UInt64?
    } derive(Eq,
    Debug
    )

    AuditFinding::address

    fn AuditFinding::address(self : AuditFinding) -> UInt64?

    AuditFinding::code

    fn AuditFinding::code(self : AuditFinding) -> String

    AuditFinding::message

    fn AuditFinding::message(self : AuditFinding) -> String

    AuditFinding::severity

    fn AuditFinding::severity(self : AuditFinding) -> AuditSeverity

    AuditPolicy

    pub struct AuditPolicy {
    max_gap_bytes_value : UInt64?
    allowed_start_value : UInt64?
    allowed_end_exclusive_value : UInt64?
    max_segments_value : Int?
    max_total_bytes_value : Int?
    require_entry_in_data_value : Bool
    } derive(Eq,
    Debug
    )

    AuditPolicy::new

    fn AuditPolicy::new(max_gap_bytes? : UInt64?, allowed_start? : UInt64?, allowed_end_exclusive? : UInt64?, max_segments? : Int?, max_total_bytes? : Int?, require_entry_in_data? : Bool) -> Result[AuditPolicy, FirmwareError]

    AuditPolicy::standard

    fn AuditPolicy::standard() -> AuditPolicy

    AuditSeverity

    pub(all) enum AuditSeverity {
    AuditInfo
    AuditWarning
    AuditError
    } derive(Eq,
    Debug
    )

    ByteDifference

    pub struct ByteDifference {
    address_value : UInt64
    kind_value : ByteDifferenceKind
    left_value : Byte?
    right_value : Byte?
    } derive(Eq,
    Debug
    )

    ByteDifference::address

    fn ByteDifference::address(self : ByteDifference) -> UInt64

    ByteDifference::kind

    ByteDifference::left

    fn ByteDifference::left(self : ByteDifference) -> Byte?

    ByteDifference::right

    fn ByteDifference::right(self : ByteDifference) -> Byte?

    ByteDifferenceKind

    pub(all) enum ByteDifferenceKind {
    ByteAdded
    ByteRemoved
    ByteChanged
    } derive(Eq,
    Debug
    )

    DocumentStatistics

    pub struct DocumentStatistics {
    format_value : FirmwareFormat
    total_records_value : Int
    data_records_value : Int
    metadata_records_value : Int
    data_bytes_value : Int
    largest_data_record_value : Int
    entry_point_value : UInt64?
    has_header_value : Bool
    declared_data_records_value : Int?
    category_values : Array[RecordCategoryStatistics]
    } derive(Eq,
    Debug
    )

    DocumentStatistics::categories

    DocumentStatistics::data_bytes

    fn DocumentStatistics::data_bytes(self : DocumentStatistics) -> Int

    DocumentStatistics::data_records

    fn DocumentStatistics::data_records(self : DocumentStatistics) -> Int

    DocumentStatistics::declared_data_records

    fn DocumentStatistics::declared_data_records(self : DocumentStatistics) -> Int?

    DocumentStatistics::entry_point

    fn DocumentStatistics::entry_point(self : DocumentStatistics) -> UInt64?

    DocumentStatistics::format

    DocumentStatistics::has_header

    fn DocumentStatistics::has_header(self : DocumentStatistics) -> Bool

    DocumentStatistics::largest_data_record

    fn DocumentStatistics::largest_data_record(self : DocumentStatistics) -> Int

    DocumentStatistics::metadata_records

    fn DocumentStatistics::metadata_records(self : DocumentStatistics) -> Int

    DocumentStatistics::total_records

    fn DocumentStatistics::total_records(self : DocumentStatistics) -> Int

    FirmwareBatch

    pub struct FirmwareBatch {
    item_values : Array[FirmwareBatchItem]
    success_count_value : Int
    failure_count_value : Int
    total_bytes_value : Int
    } derive(Eq,
    Debug
    )

    FirmwareBatch::failure_count

    fn FirmwareBatch::failure_count(self : FirmwareBatch) -> Int

    FirmwareBatch::items

    FirmwareBatch::success_count

    fn FirmwareBatch::success_count(self : FirmwareBatch) -> Int

    FirmwareBatch::total_bytes

    fn FirmwareBatch::total_bytes(self : FirmwareBatch) -> Int

    FirmwareBatchItem

    pub struct FirmwareBatchItem {
    label_value : String
    format_value : FirmwareFormat?
    image_value : FirmwareImage?
    error_value : FirmwareError?
    } derive(Eq,
    Debug
    )

    FirmwareBatchItem::error

    FirmwareBatchItem::format

    FirmwareBatchItem::image

    FirmwareBatchItem::label

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

    FirmwareChunk

    pub struct FirmwareChunk {
    address_value : UInt64
    data_value : Bytes
    line_index_value : Int
    } derive(Eq,
    Debug
    )

    A validated contiguous byte range with its source line.

    FirmwareChunk::address

    fn FirmwareChunk::address(self : FirmwareChunk) -> UInt64

    FirmwareChunk::create

    fn FirmwareChunk::create(address : UInt64, data : Bytes, line_index? : Int) -> Result[FirmwareChunk, FirmwareError]

    Create a chunk after checking that its address range is representable.

    FirmwareChunk::data

    fn FirmwareChunk::data(self : FirmwareChunk) -> Bytes

    FirmwareChunk::end_exclusive

    fn FirmwareChunk::end_exclusive(self : FirmwareChunk) -> UInt64

    FirmwareChunk::length

    fn FirmwareChunk::length(self : FirmwareChunk) -> Int

    FirmwareChunk::line_index

    fn FirmwareChunk::line_index(self : FirmwareChunk) -> Int

    FirmwareError

    pub struct FirmwareError {
    code_value : String
    message_value : String
    position_value : SourcePosition
    } derive(Eq,
    Debug
    )

    FirmwareError::code

    fn FirmwareError::code(self : FirmwareError) -> String

    FirmwareError::column_index

    fn FirmwareError::column_index(self : FirmwareError) -> Int?

    FirmwareError::line_index

    fn FirmwareError::line_index(self : FirmwareError) -> Int

    FirmwareError::message

    fn FirmwareError::message(self : FirmwareError) -> String

    FirmwareError::new

    fn FirmwareError::new(code : FirmwareErrorCode, message : String, position : SourcePosition) -> FirmwareError

    FirmwareError::position

    FirmwareErrorCode

    pub(all) enum FirmwareErrorCode {
    HexOddLength
    HexInvalidDigit
    RecordEmpty
    RecordInvalidPrefix
    RecordInvalidType
    RecordLengthMismatch
    RecordTooLong
    ChecksumMismatch
    AddressOutOfRange
    ImageOverlap
    ImageInvalidRange
    IntegrityViolation
    DocumentMissingTerminator
    DocumentRecordAfterTerminator
    DocumentDuplicateMetadata
    } derive(Eq,
    Debug
    )

    FirmwareErrorCode::code

    fn FirmwareErrorCode::code(self : FirmwareErrorCode) -> String

    FirmwareFormat

    pub(all) enum FirmwareFormat {
    IntelHexFormat
    SRecordFormat
    } derive(Eq,
    Debug
    )

    FirmwareImage

    pub struct FirmwareImage {
    segment_values : Array[ImageSegment]
    entry_point_value : UInt64?
    } derive(Eq,
    Debug
    )

    FirmwareImage::byte_at

    fn FirmwareImage::byte_at(self : FirmwareImage, address : UInt64) -> Byte?

    FirmwareImage::coverage

    fn FirmwareImage::coverage(self : FirmwareImage, start : UInt64, end_exclusive : UInt64) -> Result[RangeCoverage, FirmwareError]

    Measure byte coverage within a non-empty half-open address range.

    FirmwareImage::entry_point

    fn FirmwareImage::entry_point(self : FirmwareImage) -> UInt64?

    FirmwareImage::erase

    fn FirmwareImage::erase(self : FirmwareImage, start : UInt64, end_exclusive : UInt64) -> Result[FirmwareImage, FirmwareError]

    Remove bytes in [start, end) and re-canonicalize remaining segments.

    FirmwareImage::fill_gaps

    fn FirmwareImage::fill_gaps(self : FirmwareImage, value : Byte, max_fill_bytes : Int) -> Result[FirmwareImage, FirmwareError]

    Fill only gaps between existing segments, subject to an allocation bound.

    FirmwareImage::from_chunks

    fn FirmwareImage::from_chunks(chunks : Array[FirmwareChunk], policy? : OverlapPolicy, entry_point? : UInt64?) -> Result[FirmwareImage, FirmwareError]

    FirmwareImage::from_intel_document

    fn FirmwareImage::from_intel_document(document : IntelHexDocument, policy? : OverlapPolicy) -> Result[FirmwareImage, FirmwareError]

    FirmwareImage::from_srecord_document

    fn FirmwareImage::from_srecord_document(document : SRecordDocument, policy? : OverlapPolicy) -> Result[FirmwareImage, FirmwareError]

    FirmwareImage::gaps

    FirmwareImage::highest_address

    fn FirmwareImage::highest_address(self : FirmwareImage) -> UInt64?

    FirmwareImage::lowest_address

    fn FirmwareImage::lowest_address(self : FirmwareImage) -> UInt64?

    FirmwareImage::merge

    fn FirmwareImage::merge(self : FirmwareImage, other : FirmwareImage, policy? : OverlapPolicy) -> Result[FirmwareImage, FirmwareError]

    Merge two images while applying an explicit byte-overlap policy.

    FirmwareImage::read_range

    fn FirmwareImage::read_range(self : FirmwareImage, start : UInt64, length : Int, missing : MissingBytePolicy, max_bytes : Int) -> Result[Bytes, FirmwareError]

    Read a bounded contiguous range with an explicit sparse-byte policy.

    FirmwareImage::relocate

    fn FirmwareImage::relocate(self : FirmwareImage, new_base : UInt64) -> Result[FirmwareImage, FirmwareError]

    Move the lowest image address to new_base while preserving distances.

    FirmwareImage::segments

    FirmwareImage::slice

    fn FirmwareImage::slice(self : FirmwareImage, start : UInt64, end_exclusive : UInt64) -> Result[FirmwareImage, FirmwareError]

    Return bytes intersecting the half-open address range [start, end).

    FirmwareImage::to_intel_hex

    fn FirmwareImage::to_intel_hex(self : FirmwareImage, record_bytes? : Int) -> Result[String, FirmwareError]

    Deterministically export an image as 32-bit Intel HEX.

    FirmwareImage::to_srecord

    fn FirmwareImage::to_srecord(self : FirmwareImage, record_bytes? : Int, header? : String) -> Result[String, FirmwareError]

    Deterministically export an image as Motorola S-record text.

    FirmwareImage::total_bytes

    fn FirmwareImage::total_bytes(self : FirmwareImage) -> Int

    FirmwareImage::write

    fn FirmwareImage::write(self : FirmwareImage, address : UInt64, data : Bytes) -> Result[FirmwareImage, FirmwareError]

    Write bytes using replacement semantics while preserving the original image.

    FirmwareInput

    pub struct FirmwareInput {
    label_value : String
    text_value : String
    format_value : FirmwareFormat?
    policy_value : OverlapPolicy
    } derive(Eq,
    Debug
    )

    FirmwareInput::new

    fn FirmwareInput::new(label : String, text : String, format? : FirmwareFormat?, policy? : OverlapPolicy) -> FirmwareInput

    ImageAudit

    pub struct ImageAudit {
    finding_values : Array[AuditFinding]
    segment_count_value : Int
    total_bytes_value : Int
    gap_count_value : Int
    } derive(Eq,
    Debug
    )

    ImageAudit::accepted

    fn ImageAudit::accepted(self : ImageAudit) -> Bool

    ImageAudit::error_count

    fn ImageAudit::error_count(self : ImageAudit) -> Int

    ImageAudit::findings

    fn ImageAudit::findings(self : ImageAudit) -> Array[AuditFinding]

    ImageAudit::gap_count

    fn ImageAudit::gap_count(self : ImageAudit) -> Int

    ImageAudit::segment_count

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

    ImageAudit::total_bytes

    fn ImageAudit::total_bytes(self : ImageAudit) -> Int

    ImageAudit::warning_count

    fn ImageAudit::warning_count(self : ImageAudit) -> Int

    ImageComparison

    pub struct ImageComparison {
    difference_values : Array[ByteDifference]
    added_count_value : Int
    removed_count_value : Int
    changed_count_value : Int
    } derive(Eq,
    Debug
    )

    ImageComparison::added_count

    fn ImageComparison::added_count(self : ImageComparison) -> Int

    ImageComparison::changed_count

    fn ImageComparison::changed_count(self : ImageComparison) -> Int

    ImageComparison::differences

    ImageComparison::identical

    fn ImageComparison::identical(self : ImageComparison) -> Bool

    ImageComparison::removed_count

    fn ImageComparison::removed_count(self : ImageComparison) -> Int

    ImageLayout

    pub struct ImageLayout {
    placement_values : Array[SegmentPlacement]
    mapped_bytes_value : UInt64
    unmapped_bytes_value : UInt64
    fully_mapped_segments_value : Int
    partially_mapped_segments_value : Int
    unmapped_segments_value : Int
    entry_region_value : String?
    entry_was_present_value : Bool
    } derive(Eq,
    Debug
    )

    ImageLayout::accepted

    fn ImageLayout::accepted(self : ImageLayout) -> Bool

    ImageLayout::entry_region

    fn ImageLayout::entry_region(self : ImageLayout) -> String?

    ImageLayout::fully_mapped_segments

    fn ImageLayout::fully_mapped_segments(self : ImageLayout) -> Int

    ImageLayout::mapped_bytes

    fn ImageLayout::mapped_bytes(self : ImageLayout) -> UInt64

    ImageLayout::partially_mapped_segments

    fn ImageLayout::partially_mapped_segments(self : ImageLayout) -> Int

    ImageLayout::placements

    fn ImageLayout::placements(self : ImageLayout) -> Array[SegmentPlacement]

    ImageLayout::segment_count

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

    ImageLayout::unmapped_bytes

    fn ImageLayout::unmapped_bytes(self : ImageLayout) -> UInt64

    ImageLayout::unmapped_segments

    fn ImageLayout::unmapped_segments(self : ImageLayout) -> Int

    ImageManifest

    pub struct ImageManifest {
    segment_digest_values : Array[SegmentDigest]
    total_bytes_value : Int
    entry_point_value : UInt64?
    fingerprint_value : UInt
    } derive(Eq,
    Debug
    )

    ImageManifest::entry_point

    fn ImageManifest::entry_point(self : ImageManifest) -> UInt64?

    ImageManifest::fingerprint

    fn ImageManifest::fingerprint(self : ImageManifest) -> UInt

    ImageManifest::segment_digests

    fn ImageManifest::segment_digests(self : ImageManifest) -> Array[SegmentDigest]

    ImageManifest::total_bytes

    fn ImageManifest::total_bytes(self : ImageManifest) -> Int

    ImagePatch

    pub struct ImagePatch {
    hunk_values : Array[PatchHunk]
    old_entry_value : UInt64?
    new_entry_value : UInt64?
    added_bytes_value : Int
    removed_bytes_value : Int
    changed_bytes_value : Int
    } derive(Eq,
    Debug
    )

    ImagePatch::added_bytes

    fn ImagePatch::added_bytes(self : ImagePatch) -> Int

    ImagePatch::apply

    fn ImagePatch::apply(self : ImagePatch, source : FirmwareImage) -> Result[FirmwareImage, FirmwareError]

    Apply a patch only when all recorded source bytes and entry metadata match.

    ImagePatch::changed_bytes

    fn ImagePatch::changed_bytes(self : ImagePatch) -> Int

    ImagePatch::hunks

    fn ImagePatch::hunks(self : ImagePatch) -> Array[PatchHunk]

    ImagePatch::new_entry

    fn ImagePatch::new_entry(self : ImagePatch) -> UInt64?

    ImagePatch::old_entry

    fn ImagePatch::old_entry(self : ImagePatch) -> UInt64?

    ImagePatch::removed_bytes

    fn ImagePatch::removed_bytes(self : ImagePatch) -> Int

    ImageSegment

    pub struct ImageSegment {
    address_value : UInt64
    data_value : Bytes
    } derive(Eq,
    Debug
    )

    ImageSegment::address

    fn ImageSegment::address(self : ImageSegment) -> UInt64

    ImageSegment::data

    fn ImageSegment::data(self : ImageSegment) -> Bytes

    ImageSegment::end_exclusive

    fn ImageSegment::end_exclusive(self : ImageSegment) -> UInt64

    ImageSegment::length

    fn ImageSegment::length(self : ImageSegment) -> Int

    ImageStatistics

    pub struct ImageStatistics {
    segment_count_value : Int
    occupied_bytes_value : Int
    address_span_value : UInt64
    gap_bytes_value : UInt64
    largest_segment_bytes_value : Int
    largest_gap_bytes_value : UInt64
    lowest_address_value : UInt64?
    highest_address_value : UInt64?
    } derive(Eq,
    Debug
    )

    ImageStatistics::address_span

    fn ImageStatistics::address_span(self : ImageStatistics) -> UInt64

    ImageStatistics::average_segment_bytes

    fn ImageStatistics::average_segment_bytes(self : ImageStatistics) -> Double

    ImageStatistics::density

    fn ImageStatistics::density(self : ImageStatistics) -> Double

    ImageStatistics::gap_bytes

    fn ImageStatistics::gap_bytes(self : ImageStatistics) -> UInt64

    ImageStatistics::highest_address

    fn ImageStatistics::highest_address(self : ImageStatistics) -> UInt64?

    ImageStatistics::largest_gap_bytes

    fn ImageStatistics::largest_gap_bytes(self : ImageStatistics) -> UInt64

    ImageStatistics::largest_segment_bytes

    fn ImageStatistics::largest_segment_bytes(self : ImageStatistics) -> Int

    ImageStatistics::lowest_address

    fn ImageStatistics::lowest_address(self : ImageStatistics) -> UInt64?

    ImageStatistics::occupied_bytes

    fn ImageStatistics::occupied_bytes(self : ImageStatistics) -> Int

    ImageStatistics::segment_count

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

    IntelHexDocument

    pub struct IntelHexDocument {
    record_values : Array[IntelHexRecord]
    chunk_values : Array[FirmwareChunk]
    entry_point_value : UInt64?
    } derive(Eq,
    Debug
    )

    IntelHexDocument::data_chunks

    IntelHexDocument::entry_point

    fn IntelHexDocument::entry_point(self : IntelHexDocument) -> UInt64?

    IntelHexDocument::records

    IntelHexRecord

    pub struct IntelHexRecord {
    record_type_value : IntelRecordType
    address_value : Int
    data_value : Bytes
    checksum_value : Byte
    line_index_value : Int
    } derive(Eq,
    Debug
    )

    IntelHexRecord::address

    fn IntelHexRecord::address(self : IntelHexRecord) -> Int

    IntelHexRecord::byte_count

    fn IntelHexRecord::byte_count(self : IntelHexRecord) -> Int

    IntelHexRecord::checksum

    fn IntelHexRecord::checksum(self : IntelHexRecord) -> Byte

    IntelHexRecord::data

    fn IntelHexRecord::data(self : IntelHexRecord) -> Bytes

    IntelHexRecord::encode

    fn IntelHexRecord::encode(self : IntelHexRecord) -> String

    Encode a validated record using uppercase hexadecimal digits.

    IntelHexRecord::line_index

    fn IntelHexRecord::line_index(self : IntelHexRecord) -> Int

    IntelHexRecord::record_type

    fn IntelHexRecord::record_type(self : IntelHexRecord) -> IntelRecordType

    IntelRecordType

    pub(all) enum IntelRecordType {
    IntelData
    IntelEndOfFile
    IntelExtendedSegmentAddress
    IntelStartSegmentAddress
    IntelExtendedLinearAddress
    IntelStartLinearAddress
    } derive(Eq,
    Debug
    )

    MemoryMap

    pub struct MemoryMap {
    region_values : Array[MemoryRegion]
    } derive(Eq,
    Debug
    )

    MemoryMap::create

    fn MemoryMap::create(regions : Array[MemoryRegion]) -> Result[MemoryMap, FirmwareError]

    MemoryMap::executable_capacity

    fn MemoryMap::executable_capacity(self : MemoryMap) -> UInt64

    MemoryMap::region_at

    fn MemoryMap::region_at(self : MemoryMap, address : UInt64) -> MemoryRegion?

    MemoryMap::region_containing_range

    fn MemoryMap::region_containing_range(self : MemoryMap, start : UInt64, end_exclusive : UInt64) -> MemoryRegion?

    Find one region that completely contains a non-empty half-open range.

    MemoryMap::region_count

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

    MemoryMap::regions

    fn MemoryMap::regions(self : MemoryMap) -> Array[MemoryRegion]

    MemoryMap::total_capacity

    fn MemoryMap::total_capacity(self : MemoryMap) -> UInt64

    MemoryMap::writable_capacity

    fn MemoryMap::writable_capacity(self : MemoryMap) -> UInt64

    MemoryRegion

    pub struct MemoryRegion {
    name_value : String
    start_value : UInt64
    end_exclusive_value : UInt64
    writable_value : Bool
    executable_value : Bool
    } derive(Eq,
    Debug
    )

    MemoryRegion::contains_address

    fn MemoryRegion::contains_address(self : MemoryRegion, address : UInt64) -> Bool

    MemoryRegion::contains_range

    fn MemoryRegion::contains_range(self : MemoryRegion, start : UInt64, end_exclusive : UInt64) -> Bool

    MemoryRegion::create

    fn MemoryRegion::create(name : String, start : UInt64, end_exclusive : UInt64, writable? : Bool, executable? : Bool) -> Result[MemoryRegion, FirmwareError]

    MemoryRegion::end_exclusive

    fn MemoryRegion::end_exclusive(self : MemoryRegion) -> UInt64

    MemoryRegion::executable

    fn MemoryRegion::executable(self : MemoryRegion) -> Bool

    MemoryRegion::length

    fn MemoryRegion::length(self : MemoryRegion) -> UInt64

    MemoryRegion::name

    fn MemoryRegion::name(self : MemoryRegion) -> String

    MemoryRegion::start

    fn MemoryRegion::start(self : MemoryRegion) -> UInt64

    MemoryRegion::writable

    fn MemoryRegion::writable(self : MemoryRegion) -> Bool

    MissingBytePolicy

    pub(all) enum MissingBytePolicy {
    RejectMissing
    FillMissing(Byte)
    } derive(Eq,
    Debug
    )

    OverlapPolicy

    pub(all) enum OverlapPolicy {
    RejectOverlap
    AllowIdentical
    ReplaceExisting
    } derive(Eq,
    Debug
    )

    ParsedFirmware

    pub struct ParsedFirmware {
    format_value : FirmwareFormat
    image_value : FirmwareImage
    record_count_value : Int
    } derive(Eq,
    Debug
    )

    ParsedFirmware::format

    ParsedFirmware::image

    ParsedFirmware::record_count

    fn ParsedFirmware::record_count(self : ParsedFirmware) -> Int

    PatchHunk

    pub struct PatchHunk {
    kind_value : PatchKind
    address_value : UInt64
    before_value : Bytes
    after_value : Bytes
    } derive(Eq,
    Debug
    )

    PatchHunk::address

    fn PatchHunk::address(self : PatchHunk) -> UInt64

    PatchHunk::after

    fn PatchHunk::after(self : PatchHunk) -> Bytes

    PatchHunk::before

    fn PatchHunk::before(self : PatchHunk) -> Bytes

    PatchHunk::kind

    fn PatchHunk::kind(self : PatchHunk) -> PatchKind

    PatchHunk::length

    fn PatchHunk::length(self : PatchHunk) -> Int

    PatchKind

    pub(all) enum PatchKind {
    PatchAdd
    PatchRemove
    PatchReplace
    } derive(Eq,
    Debug
    )

    RangeCoverage

    pub(all) struct RangeCoverage {
    start_value : UInt64
    end_exclusive_value : UInt64
    present_bytes_value : UInt64
    missing_bytes_value : UInt64
    } derive(Eq,
    Debug
    )

    RangeCoverage::complete

    fn RangeCoverage::complete(self : RangeCoverage) -> Bool

    RangeCoverage::end_exclusive

    fn RangeCoverage::end_exclusive(self : RangeCoverage) -> UInt64

    RangeCoverage::missing_bytes

    fn RangeCoverage::missing_bytes(self : RangeCoverage) -> UInt64

    RangeCoverage::present_bytes

    fn RangeCoverage::present_bytes(self : RangeCoverage) -> UInt64

    RangeCoverage::ratio

    fn RangeCoverage::ratio(self : RangeCoverage) -> Double

    RangeCoverage::start

    fn RangeCoverage::start(self : RangeCoverage) -> UInt64

    RecordCategoryStatistics

    pub struct RecordCategoryStatistics {
    name_value : String
    record_count_value : Int
    data_bytes_value : Int
    } derive(Eq,
    Debug
    )

    RecordCategoryStatistics::data_bytes

    RecordCategoryStatistics::name

    RecordCategoryStatistics::record_count

    fn RecordCategoryStatistics::record_count(self : RecordCategoryStatistics) -> Int

    SRecord

    pub struct SRecord {
    record_type_value : SRecordType
    address_value : UInt64
    data_value : Bytes
    checksum_value : Byte
    line_index_value : Int
    } derive(Eq,
    Debug
    )

    SRecord::address

    fn SRecord::address(self : SRecord) -> UInt64

    SRecord::byte_count

    fn SRecord::byte_count(self : SRecord) -> Int

    SRecord::checksum

    fn SRecord::checksum(self : SRecord) -> Byte

    SRecord::data

    fn SRecord::data(self : SRecord) -> Bytes

    SRecord::encode

    fn SRecord::encode(self : SRecord) -> String

    Encode a validated record using uppercase hexadecimal digits.

    SRecord::line_index

    fn SRecord::line_index(self : SRecord) -> Int

    SRecord::record_type

    fn SRecord::record_type(self : SRecord) -> SRecordType

    SRecordDocument

    pub struct SRecordDocument {
    record_values : Array[SRecord]
    header_value : Bytes?
    chunk_values : Array[FirmwareChunk]
    declared_data_count_value : Int?
    entry_point_value : UInt64?
    } derive(Eq,
    Debug
    )

    SRecordDocument::data_chunks

    SRecordDocument::declared_data_count

    fn SRecordDocument::declared_data_count(self : SRecordDocument) -> Int?

    SRecordDocument::entry_point

    fn SRecordDocument::entry_point(self : SRecordDocument) -> UInt64?

    SRecordDocument::header

    fn SRecordDocument::header(self : SRecordDocument) -> Bytes?

    SRecordDocument::records

    SRecordType

    pub(all) enum SRecordType {
    SHeader
    SData16
    SData24
    SData32
    SCount16
    SCount24
    STerminate32
    STerminate24
    STerminate16
    } derive(Eq,
    Debug
    )

    SRecordType::address_bytes

    fn SRecordType::address_bytes(self : SRecordType) -> Int

    SRecordType::is_count

    fn SRecordType::is_count(self : SRecordType) -> Bool

    SRecordType::is_data

    fn SRecordType::is_data(self : SRecordType) -> Bool

    SRecordType::is_termination

    fn SRecordType::is_termination(self : SRecordType) -> Bool

    SegmentDigest

    pub(all) struct SegmentDigest {
    address_value : UInt64
    length_value : Int
    crc32_value : UInt
    crc16_value : Int
    } derive(Eq,
    Debug
    )

    SegmentDigest::address

    fn SegmentDigest::address(self : SegmentDigest) -> UInt64

    SegmentDigest::crc16

    fn SegmentDigest::crc16(self : SegmentDigest) -> Int

    SegmentDigest::crc32

    fn SegmentDigest::crc32(self : SegmentDigest) -> UInt

    SegmentDigest::length

    fn SegmentDigest::length(self : SegmentDigest) -> Int

    SegmentPlacement

    pub struct SegmentPlacement {
    start_value : UInt64
    end_exclusive_value : UInt64
    mapped_bytes_value : UInt64
    unmapped_bytes_value : UInt64
    region_name_values : Array[String]
    } derive(Eq,
    Debug
    )

    SegmentPlacement::end_exclusive

    fn SegmentPlacement::end_exclusive(self : SegmentPlacement) -> UInt64

    SegmentPlacement::mapped_bytes

    fn SegmentPlacement::mapped_bytes(self : SegmentPlacement) -> UInt64

    SegmentPlacement::region_names

    fn SegmentPlacement::region_names(self : SegmentPlacement) -> Array[String]

    SegmentPlacement::start

    fn SegmentPlacement::start(self : SegmentPlacement) -> UInt64

    SegmentPlacement::unmapped_bytes

    fn SegmentPlacement::unmapped_bytes(self : SegmentPlacement) -> UInt64

    SourcePosition

    pub(all) struct SourcePosition {
    line_index_value : Int
    column_index_value : Int?
    } derive(Eq,
    Debug
    )

    SourcePosition::column

    fn SourcePosition::column(line_index : Int, column_index : Int) -> SourcePosition

    SourcePosition::column_index

    fn SourcePosition::column_index(self : SourcePosition) -> Int?

    SourcePosition::line

    fn SourcePosition::line(line_index : Int) -> SourcePosition

    SourcePosition::line_index

    fn SourcePosition::line_index(self : SourcePosition) -> Int

    analyze_image

    fn analyze_image(image : FirmwareImage) -> ImageStatistics

    Calculate sparse-image metrics without materializing missing addresses.

    analyze_image_layout

    fn analyze_image_layout(image : FirmwareImage, map : MemoryMap) -> ImageLayout

    Compare each sparse image segment with a validated non-overlapping map.

    analyze_intel_document

    fn analyze_intel_document(document : IntelHexDocument) -> DocumentStatistics

    analyze_srecord_document

    fn analyze_srecord_document(document : SRecordDocument) -> DocumentStatistics

    audit_image

    fn audit_image(image : FirmwareImage, policy : AuditPolicy) -> ImageAudit

    Evaluate deterministic image acceptance rules without modifying the image.

    build_manifest

    fn build_manifest(image : FirmwareImage) -> ImageManifest

    Build reproducible per-segment checksums and an address-sensitive fingerprint.

    checksum_sum

    fn checksum_sum(bytes : Bytes) -> Int

    Return the low eight bits of the sum of all bytes.

    compare_images

    fn compare_images(left : FirmwareImage, right : FirmwareImage, max_differences? : Int) -> Result[ImageComparison, FirmwareError]

    Compare sparse images without treating absent addresses as zero bytes.

    crc16_ccitt_false

    fn crc16_ccitt_false(data : Bytes) -> Int

    Calculate CRC-16/CCITT-FALSE with initial value 0xFFFF.

    crc32

    fn crc32(data : Bytes) -> UInt

    Calculate the reflected IEEE CRC-32 checksum.

    create_image_patch

    fn create_image_patch(source : FirmwareImage, target : FirmwareImage, max_differences? : Int) -> Result[ImagePatch, FirmwareError]

    Build ordered contiguous patch hunks from exact sparse-byte differences.

    decode_firmware_chunks

    fn decode_firmware_chunks(chunks : Array[Bytes], format? : FirmwareFormat?, policy? : OverlapPolicy, max_line_bytes? : Int) -> Result[ParsedFirmware, FirmwareError]

    Decode caller-provided byte chunks without depending on chunk boundaries. Input must be ASCII and each logical record is bounded independently.

    decode_hex_bytes

    fn decode_hex_bytes(text : String, line_index? : Int) -> Result[Bytes, FirmwareError]

    Decode an even-length hexadecimal string without ignoring whitespace.

    detect_firmware_format

    fn detect_firmware_format(text : String) -> Result[FirmwareFormat, FirmwareError]

    Detect Intel HEX or S-record from the first non-line-ending code unit.

    encode_hex_bytes

    fn encode_hex_bytes(bytes : Bytes) -> String

    Encode bytes using two uppercase hexadecimal digits per byte.

    ones_complement_checksum

    fn ones_complement_checksum(bytes : Bytes) -> Byte

    Calculate the Motorola S-record one's-complement checksum byte.

    ones_complement_valid

    fn ones_complement_valid(bytes : Bytes) -> Bool

    Verify a byte sequence that includes its S-record checksum byte.

    parse_firmware_image

    fn parse_firmware_image(text : String, format? : FirmwareFormat?, policy? : OverlapPolicy) -> Result[ParsedFirmware, FirmwareError]

    Parse either supported format and build a canonical sparse image.

    parse_intel_hex_document

    fn parse_intel_hex_document(text : String) -> Result[IntelHexDocument, FirmwareError]

    Parse a complete Intel HEX document and resolve data addresses.

    parse_intel_hex_record

    fn parse_intel_hex_record(line : String, line_index? : Int) -> Result[IntelHexRecord, FirmwareError]

    Parse and validate one Intel HEX line without accepting surrounding spaces.

    parse_srecord

    fn parse_srecord(line : String, line_index? : Int) -> Result[SRecord, FirmwareError]

    Parse and validate one Motorola S-record line.

    parse_srecord_document

    fn parse_srecord_document(text : String) -> Result[SRecordDocument, FirmwareError]

    Parse a complete S-record document and validate its bookkeeping records.

    process_firmware_batch

    fn process_firmware_batch(inputs : Array[FirmwareInput]) -> FirmwareBatch

    Process inputs independently and retain ordered error evidence.

    render_comparison_json

    fn render_comparison_json(comparison : ImageComparison) -> String

    Render byte-level comparison evidence using the standard JSON type.

    render_document_statistics_json

    fn render_document_statistics_json(statistics : DocumentStatistics) -> String

    render_document_statistics_text

    fn render_document_statistics_text(statistics : DocumentStatistics) -> String

    render_image_json

    fn render_image_json(image : FirmwareImage, audit : ImageAudit) -> String

    Render image structure and audit findings using the standard JSON type.

    render_image_text

    fn render_image_text(image : FirmwareImage, audit : ImageAudit) -> String

    Render a compact deterministic human-readable image audit.

    render_layout_json

    fn render_layout_json(layout : ImageLayout) -> String

    render_layout_text

    fn render_layout_text(layout : ImageLayout) -> String

    render_patch_json

    fn render_patch_json(patch : ImagePatch) -> String

    render_patch_text

    fn render_patch_text(patch : ImagePatch) -> String

    render_statistics_json

    fn render_statistics_json(statistics : ImageStatistics) -> String

    render_statistics_text

    fn render_statistics_text(statistics : ImageStatistics) -> String

    twos_complement_checksum

    fn twos_complement_checksum(bytes : Bytes) -> Byte

    Calculate the Intel HEX two's-complement checksum byte.

    twos_complement_valid

    fn twos_complement_valid(bytes : Bytes) -> Bool

    Verify a byte sequence that includes its Intel HEX checksum byte.