pub struct EcBinary<'a> { /* private fields */ }Expand description
A parsed, read-only view of an Epoch Controller binary container.
Implementations§
Source§impl<'a> EcBinary<'a>
impl<'a> EcBinary<'a>
Sourcepub fn new(binary: &'a [u64]) -> Result<Self, EcError>
pub fn new(binary: &'a [u64]) -> Result<Self, EcError>
Parse an EC binary stored as u64 words (the layout ST Edge AI
generates in <network>_ecblobs.h).
Sourcepub fn from_words(words: &'a [u32]) -> Result<Self, EcError>
pub fn from_words(words: &'a [u32]) -> Result<Self, EcError>
Parse an EC binary from raw u32 words.
Sourcepub fn blob_len(&self) -> Result<usize, EcError>
pub fn blob_len(&self) -> Result<usize, EcError>
Size of the blob in u64 words, including its magic/length header —
i.e. the minimum length of the buffer passed to Self::load_blob.
Sourcepub fn load_blob(&self, dest: &mut [u64]) -> Result<usize, EcError>
pub fn load_blob(&self, dest: &mut [u64]) -> Result<usize, EcError>
Copy the blob (magic + length + instructions) into dest, returning
the number of u64 words used. dest may then be relocated/patched
and handed to Npu::run_epoch_blob.
Sourcepub fn num_relocs(&self) -> usize
pub fn num_relocs(&self) -> usize
Number of relocations described by this binary.
Sourcepub fn reloc_id(&self, idx: usize) -> Option<&'a str>
pub fn reloc_id(&self, idx: usize) -> Option<&'a str>
Identifier of relocation idx (e.g. "_user_io_input_0").
Sourcepub fn reloc(
&self,
blob: &mut [u64],
idx: usize,
base: u32,
prev_base: &mut u32,
) -> Result<(), EcError>
pub fn reloc( &self, blob: &mut [u64], idx: usize, base: u32, prev_base: &mut u32, ) -> Result<(), EcError>
Apply relocation idx to a loaded blob: adds base - *prev_base to
every blob word listed in the relocation, then stores base in
prev_base. Call with *prev_base == 0 the first time; subsequent
calls with an unchanged base are no-ops, matching ST’s ec_reloc.
Sourcepub fn reloc_by_id(
&self,
blob: &mut [u64],
id: &str,
base: u32,
prev_base: &mut u32,
) -> Result<(), EcError>
pub fn reloc_by_id( &self, blob: &mut [u64], id: &str, base: u32, prev_base: &mut u32, ) -> Result<(), EcError>
Apply the relocation with identifier id. See Self::reloc.
Sourcepub fn num_patches(&self) -> usize
pub fn num_patches(&self) -> usize
Number of patches described by this binary.
Sourcepub fn patch(
&self,
blob: &mut [u64],
idx: usize,
value: u64,
) -> Result<(), EcError>
pub fn patch( &self, blob: &mut [u64], idx: usize, value: u64, ) -> Result<(), EcError>
Apply patch idx to a loaded blob: replaces the masked bit-field of
every listed blob word with value (shifted/masked as encoded in the
patch table).
Sourcepub fn patch_by_id(
&self,
blob: &mut [u64],
id: &str,
value: u64,
) -> Result<(), EcError>
pub fn patch_by_id( &self, blob: &mut [u64], id: &str, value: u64, ) -> Result<(), EcError>
Apply the patch with identifier id. See Self::patch.