Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
elftosb::EncoreBootImage::Section Class Reference

Base class for a section of an Encore boot image. More...

#include <EncoreBootImage.h>

+ Inheritance diagram for elftosb::EncoreBootImage::Section:
+ Collaboration diagram for elftosb::EncoreBootImage::Section:

Public Member Functions

 Section ()
 Default constructor.
 
 Section (uint32_t identifier)
 Constructor taking the unique identifier for this section.
 
Identifier
void setIdentifier (uint32_t identifier)
 
uint32_t getIdentifier () const
 
Header
virtual void setFlags (uint32_t flags)
 Sets explicit flags for this section.
 
virtual uint32_t getFlags () const
 Returns the flags for this section. More...
 
virtual void fillSectionHeader (section_header_t &header)
 Pure virtual method to construct the header for this section. More...
 
Owner image
void setImage (EncoreBootImage *image)
 Called when the section is added to an image.
 
EncoreBootImagegetImage () const
 Returns a pointer to the image that this section belongs to.
 
Alignment
void setAlignment (unsigned alignment)
 Sets the required alignment in the output file for this section. More...
 
unsigned getAlignment () const
 Returns the current alignment, the minimum of which will be 16.
 
unsigned getPadBlockCountForOffset (unsigned offset)
 Computes padding amount for alignment requirement. More...
 
Leave unencrypted flag
void setLeaveUnencrypted (unsigned flag)
 Sets whether the section will be left unencrypted.
 
bool getLeaveUnencrypted () const
 Returns true if the section will remain unencrypted.
 
- Public Member Functions inherited from elftosb::EncoreBootImage::CipherBlockGenerator
virtual void debugPrint () const
 Print out a string representation of the object.
 
virtual unsigned getBlockCount () const
 Returns the total number of cipher blocks. More...
 
virtual unsigned getBlocks (unsigned offset, unsigned maxCount, cipher_block_t *data)
 Returns the contents of up to maxCount cipher blocks. More...
 

Protected Attributes

uint32_t m_identifier
 Unique identifier for this section.
 
EncoreBootImagem_image
 The image to which this section belongs.
 
unsigned m_alignment
 Alignment requirement for the start of this section.
 
uint32_t m_flags
 Section flags set by the user.
 
bool m_leaveUnencrypted
 Set to true to prevent this section from being encrypted.
 

Detailed Description

Base class for a section of an Encore boot image.

Provides methods to manage the unique identifier that all sections have, and to set the boot image object which owns the section. There are also virtual methods to get header flags and fill in the header used in the section table. Subclasses must implement at least fillSectionHeader().

Member Function Documentation

void EncoreBootImage::Section::fillSectionHeader ( section_header_t header)
virtual

Pure virtual method to construct the header for this section.

Only if the section has been assigned a boot image owner object will this method be able to fill in the #section_header_t::m_offset field. If no boot image has been set the offset will be set to 0.

virtual uint32_t elftosb::EncoreBootImage::Section::getFlags ( ) const
inlinevirtual

Returns the flags for this section.

The return value consists of the flags set with setFlags() possibly or-ed with ROM_SECTION_CLEARTEXT if the section has been set to be left unencrypted.

Reimplemented in elftosb::EncoreBootImage::BootSection.

unsigned EncoreBootImage::Section::getPadBlockCountForOffset ( unsigned  offset)

Computes padding amount for alignment requirement.

This method calculates the number of padding blocks that need to be inserted from a given offset for the section to be properly aligned. The value returned is the number of padding blocks that should be inserted starting just after offset to align the first cipher block of the section contents. The section's boot tag is not taken into account by this method, so the caller must deal with that herself.

Parameters
offsetStart offset in cipher blocks (not bytes).
Returns
A number of cipher blocks of padding to insert.
void EncoreBootImage::Section::setAlignment ( unsigned  alignment)

Sets the required alignment in the output file for this section.

The alignment will never be less than 16, since that is the size of the cipher block which is the basic unit of the boot image format. If an alignment less than 16 is set it will be ignored.

Parameters
alignmentAlignment in bytes for this section. Must be a power of two. Ignored if less than 16.

The documentation for this class was generated from the following files: