2 * File: SRecordSourceFile.h
4 * Copyright (c) Freescale Semiconductor, Inc. All rights reserved.
5 * See included license file for license details.
7 #if !defined(_SRecordSourceFile_h_)
8 #define _SRecordSourceFile_h_
10 #include "SourceFile.h"
11 #include "StSRecordFile.h"
12 #include "StExecutableImage.h"
18 * \brief Executable file in the Motorola S-record format.
20 * Instead of presenting each S-record in the file separately, this class
21 * builds up a memory image of all of the records. Records next to each other
22 * in memory are coalesced into a single memory region. The data source that
23 * is returned from createDataSource() exposes these regions as its segments.
25 * Because the S-record format does not support the concepts, no support is
26 * provided for named sections or symbols.
28 class SRecordSourceFile : public SourceFile
31 //! \brief Default constructor.
32 SRecordSourceFile(const std::string & path);
34 //! \brief Destructor.
35 virtual ~SRecordSourceFile() {}
37 //! \brief Test whether the \a stream contains a valid S-record file.
38 static bool isSRecordFile(std::istream & stream);
40 //! \name Opening and closing
42 //! \brief Opens the file.
45 //! \brief Closes the file.
49 //! \name Format capabilities
51 virtual bool supportsNamedSections() const { return false; }
52 virtual bool supportsNamedSymbols() const { return false; }
55 //! \name Data sources
57 //! \brief Returns data source for the entire file.
58 virtual DataSource * createDataSource();
63 //! \brief Returns true if an entry point was set in the file.
64 virtual bool hasEntryPoint();
66 //! \brief Returns the entry point address.
67 virtual uint32_t getEntryPointAddress();
71 StSRecordFile * m_file; //!< S-record parser instance.
72 StExecutableImage * m_image; //!< Memory image of the S-record file.
73 bool m_hasEntryRecord; //!< Whether an S7,8,9 record was found.
74 StSRecordFile::SRecord m_entryRecord; //!< Record for the entry point.
77 //! \brief Build memory image of the S-record file.
78 void buildMemoryImage();
81 }; // namespace elftosb
83 #endif // _SRecordSourceFile_h_