Kinetis Bootloader Host  2.0.0
Host Tools for Kinetis devices
blfwk::SRecordSourceFile Class Reference

Executable file in the Motorola S-record format. More...

#include <SRecordSourceFile.h>

+ Inheritance diagram for blfwk::SRecordSourceFile:
+ Collaboration diagram for blfwk::SRecordSourceFile:

Public Member Functions

 SRecordSourceFile (const std::string &path)
 Default constructor.
 
virtual ~SRecordSourceFile ()
 Destructor.
 
Opening and closing
virtual void open ()
 Opens the file.
 
virtual void close ()
 Closes the file.
 
Format capabilities
virtual bool supportsNamedSections () const
 
virtual bool supportsNamedSymbols () const
 
Data sources
virtual DataSourcecreateDataSource ()
 Returns data source for the entire file. More...
 
Entry point
virtual bool hasEntryPoint ()
 Returns true if an entry point was set in the file. More...
 
virtual uint32_t getEntryPointAddress ()
 Returns the entry point address. More...
 
- Public Member Functions inherited from blfwk::SourceFile
 SourceFile (const std::string &path, source_file_t filetype)
 Default constructor.
 
virtual ~SourceFile ()
 Destructor. More...
 
void setOptions (OptionContext *context)
 Set the option context. More...
 
const OptionContextgetOptions () const
 Return the option context.
 
source_file_t getFileType () const
 Return the file type.
 
const std::string & getPath () const
 Returns the path to the file.
 
unsigned getSize () const
 Get the size in bytes of the file.
 
virtual bool isOpen () const
 Returns whether the file is already open.
 
virtual DataSourcecreateDataSource (StringMatcher &matcher)
 Creates a data source out of one or more sections of the file. More...
 
virtual DataSourcecreateDataSource (const std::string &section)
 Creates a data source out of one section of the file. More...
 
virtual DataTargetcreateDataTargetForSection (const std::string &section)
 
virtual DataTargetcreateDataTargetForSymbol (const std::string &symbol)
 
virtual DataTargetcreateDataTargetForEntryPoint ()
 
virtual bool hasSymbol (const std::string &name)
 Returns whether a symbol exists in the source file.
 
virtual uint32_t getSymbolValue (const std::string &name)
 Returns the value of a symbol.
 
virtual unsigned getSymbolSize (const std::string &name)
 Returns the size of a symbol.
 

Static Public Member Functions

static bool isSRecordFile (std::istream &stream)
 Test whether the stream contains a valid S-record file.
 
- Static Public Member Functions inherited from blfwk::SourceFile
static SourceFileopenFile (const std::string &path)
 

Protected Member Functions

void buildMemoryImage ()
 Build memory image of the S-record file. More...
 
- Protected Member Functions inherited from blfwk::SourceFile
std::ifstream * getStream ()
 Internal access to the input stream object.
 

Protected Attributes

StSRecordFilem_file
 S-record parser instance.
 
StExecutableImagem_image
 Memory image of the S-record file.
 
bool m_hasEntryRecord
 Whether an S7,8,9 record was found.
 
StSRecordFile::SRecord m_entryRecord
 Record for the entry point.
 
- Protected Attributes inherited from blfwk::SourceFile
std::string m_path
 Path to the file.
 
smart_ptr< std::ifstream > m_stream
 File stream, or NULL if file is closed.
 
smart_ptr< OptionContextm_options
 Table of option values.
 
source_file_t m_filetype
 Image file type.
 
unsigned m_size
 The size in bytes of the file.
 

Additional Inherited Members

- Public Types inherited from blfwk::SourceFile
enum  source_file_t {
  kBinarySourceFile,
  kELFSourceFile,
  kIntelHexSourceFile,
  kSBSourceFile,
  kSRecordSourceFile
}
 Set of supported executable image file formats. More...
 

Detailed Description

Executable file in the Motorola S-record format.

Instead of presenting each S-record in the file separately, this class builds up a memory image of all of the records. Records next to each other in memory are coalesced into a single memory region. The data source that is returned from createDataSource() exposes these regions as its segments.

Because the S-record format does not support the concepts, no support is provided for named sections or symbols.

Member Function Documentation

void SRecordSourceFile::buildMemoryImage ( )
protected

Build memory image of the S-record file.

Scans the S-records of the file looking for data records. These are S3, S2, or S1 records. The contents of these records are added to an StExecutableImage object, which coalesces the individual records into contiguous regions of memory.

Also looks for S7, S8, or S9 records that contain the entry point. The first match of one of these records is saved off into the m_entryRecord member.

Precondition
The m_file member must be valid.
The m_image member variable must have been instantiated.
DataSource * SRecordSourceFile::createDataSource ( )
virtual

Returns data source for the entire file.

Precondition
The file must be open before this method can be called.

Implements blfwk::SourceFile.

uint32_t SRecordSourceFile::getEntryPointAddress ( )
virtual

Returns the entry point address.

If no entry point is available then 0 is returned instead. The method scans the records in the file looking for S7, S8, or S9 records. Thus, 16-bit, 24-bit, and 32-bit entry point records are supported.

Returns
Entry point address.
Return values
0No entry point is available.

Reimplemented from blfwk::SourceFile.

bool SRecordSourceFile::hasEntryPoint ( )
virtual

Returns true if an entry point was set in the file.

Return values
trueThe file has an S7, S8, or S9 record.
falseNo entry point is available.

Implements blfwk::SourceFile.


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